PageRenderTime 366ms CodeModel.GetById 141ms app.highlight 81ms RepoModel.GetById 140ms app.codeStats 1ms

/AE_GameServer/src/com/aionemu/gameserver/network/aion/PlayerInfo.java

https://github.com/weachina/aion-emu-backup
Java | 312 lines | 252 code | 34 blank | 26 comment | 15 complexity | e59e033f4a5f195a051d0b1ecca60d78 MD5 | raw file
  1/**
  2 * This file is part of aion-emu <aion-emu.com>.
  3 *
  4 *  aion-emu is free software: you can redistribute it and/or modify
  5 *  it under the terms of the GNU General Public License as published by
  6 *  the Free Software Foundation, either version 3 of the License, or
  7 *  (at your option) any later version.
  8 *
  9 *  aion-emu is distributed in the hope that it will be useful,
 10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *  GNU General Public License for more details.
 13 *
 14 *  You should have received a copy of the GNU General Public License
 15 *  along with aion-emu.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17package com.aionemu.gameserver.network.aion;
 18
 19import java.nio.ByteBuffer;
 20
 21import org.apache.log4j.Logger;
 22
 23import com.aionemu.gameserver.model.account.PlayerAccountData;
 24import com.aionemu.gameserver.model.gameobjects.player.PlayerAppearance;
 25import com.aionemu.gameserver.model.gameobjects.player.PlayerCommonData;
 26import com.aionemu.gameserver.model.gameobjects.player.PlayerItems;
 27
 28/**
 29 * 
 30 * @author AEJTester
 31 * @author Nemesiss
 32 * @author Niato
 33 */
 34public abstract class PlayerInfo extends AionServerPacket
 35{
 36	private static Logger log= Logger.getLogger(PlayerInfo.class);
 37
 38	protected PlayerInfo()
 39	{
 40		
 41	}
 42
 43
 44	protected void writePlayerInfo(ByteBuffer buf, PlayerAccountData accPlData, PlayerItems playerItems)
 45	{
 46		PlayerCommonData pbd = accPlData.getPlayerCommonData();
 47		final int raceId = pbd.getRace().getRaceId();
 48		final int genderId = pbd.getGender().getGenderId();
 49		final PlayerAppearance playerAppearance = accPlData.getAppereance();
 50		writeD(buf, pbd.getPlayerObjId());
 51		writeS(buf, pbd.getName());
 52		/**
 53		 * Stupid NC...
 54		 */
 55		int size = 44 - (pbd.getName().length() * 2 + 2);
 56		byte[] stupidNc = new byte[size];
 57		writeB(buf, stupidNc);
 58		writeD(buf, genderId);
 59		writeD(buf, raceId);
 60		writeD(buf, pbd.getPlayerClass().getClassId());
 61		writeD(buf, playerAppearance.getVoice());
 62		writeD(buf, playerAppearance.getSkinRGB());
 63		writeD(buf, playerAppearance.getHairRGB());
 64		writeD(buf, playerAppearance.getEyeRGB());
 65		writeD(buf, playerAppearance.getLipRGB());
 66		writeC(buf, playerAppearance.getFace());
 67		writeC(buf, playerAppearance.getHair());
 68		writeC(buf, playerAppearance.getDeco());
 69		writeC(buf, playerAppearance.getTattoo());
 70		writeC(buf, 4);// always 4 o0
 71		writeC(buf, playerAppearance.getFaceShape());
 72		writeC(buf, playerAppearance.getForehead());
 73		writeC(buf, playerAppearance.getEyeHeight());
 74		writeC(buf, playerAppearance.getEyeSpace());
 75		writeC(buf, playerAppearance.getEyeWidth());
 76		writeC(buf, playerAppearance.getEyeSize());
 77		writeC(buf, playerAppearance.getEyeShape());
 78		writeC(buf, playerAppearance.getEyeAngle());
 79		writeC(buf, playerAppearance.getBrowHeight());
 80		writeC(buf, playerAppearance.getBrowAngle());
 81		writeC(buf, playerAppearance.getBrowShape());
 82		writeC(buf, playerAppearance.getNose());
 83		writeC(buf, playerAppearance.getNoseBridge());
 84		writeC(buf, playerAppearance.getNoseWidth());
 85		writeC(buf, playerAppearance.getNoseTip());
 86		writeC(buf, playerAppearance.getCheek());
 87		writeC(buf, playerAppearance.getLipHeight());
 88		writeC(buf, playerAppearance.getMouthSize());
 89		writeC(buf, playerAppearance.getLipSize());
 90		writeC(buf, playerAppearance.getSmile());
 91		writeC(buf, playerAppearance.getLipShape());
 92		writeC(buf, playerAppearance.getJawHeigh());
 93		writeC(buf, playerAppearance.getChinJut());
 94		writeC(buf, playerAppearance.getEarShape());
 95		writeC(buf, playerAppearance.getHeadSize());
 96		// 1.5.x 0x00, shoulderSize, armLength, legLength (BYTE) after HeadSize
 97		writeC(buf, 0x00); // 0x00
 98		writeC(buf, 0x01); // shoulderSize
 99		writeC(buf, 0x01); // armLength
100		writeC(buf, 0x01); // legLength
101		writeC(buf, playerAppearance.getNeck());
102		writeC(buf, playerAppearance.getNeckLength());
103		writeC(buf, playerAppearance.getShoulders());
104		writeC(buf, playerAppearance.getTorso());
105		writeC(buf, playerAppearance.getChest());
106		writeC(buf, playerAppearance.getWaist());
107		writeC(buf, playerAppearance.getHips());
108		writeC(buf, playerAppearance.getArmThickness());
109		writeC(buf, playerAppearance.getHandSize());
110		writeC(buf, playerAppearance.getLegThicnkess());
111		writeC(buf, playerAppearance.getFootSize());
112		writeC(buf, playerAppearance.getFacialRate());
113		writeC(buf, 0x00); // always 0 may be acessLevel
114		writeC(buf, 0x00); // always 0 - unk
115		writeF(buf, playerAppearance.getHeight());
116		int raceSex = 100000 + raceId * 2 + genderId;
117		writeD(buf, raceSex);
118		writeD(buf, pbd.getPosition().getMapId());//mapid for preloading map
119		writeF(buf, pbd.getPosition().getX());
120		writeF(buf, pbd.getPosition().getY());
121		writeF(buf, pbd.getPosition().getZ());
122		writeD(buf, 0);// unk 0x6f
123		writeD(buf, pbd.getLevel());// lvl confirmed
124		writeD(buf, -1);// unk -1 -1 = played 0 = neverplayed
125		writeD(buf, 0);// unk 0
126		writeD(buf, 0);// unk 41549824 can be 0
127		writeD(buf, 0);// unk 1 can be 0
128		writeD(buf, 0);// unk 25118405 elyos : 25642769
129		writeD(buf, 0);// unk 1
130		writeD(buf, 0);// unk 0
131		writeD(buf, 0);// unk 2 can be 0
132		writeD(buf, 0);// unk 0
133		writeD(buf, 0);// unk 0
134		writeD(buf, 0);// unk 1242826833
135		writeD(buf, 0);// unk 0
136		writeD(buf, 0);// unk 0
137		writeD(buf, 0);// unk 0
138		writeD(buf, 0);// unk 73138176
139		writeD(buf, 0);// unk 0
140		writeD(buf, 0);// unk 73182320
141		writeD(buf, 0);// unk 0
142		writeD(buf, 0);// unk 50379392
143		writeD(buf, 0);// unk 1242638636
144
145		int itemsSize = 0;
146		int i=0;
147		
148		if (playerItems.getWarmer()!=0)
149		{
150			 writeC(buf, i);
151		     writeD(buf, playerItems.getWarmer());
152		     writeD(buf, 0);
153		     writeD(buf, 0);
154		     i++;
155		     itemsSize = itemsSize + 13;
156		}
157    
158		if (playerItems.getShield()!=0)
159		{
160			 writeC(buf, i);
161		     writeD(buf, playerItems.getShield());
162		     writeD(buf, 0);
163		     writeD(buf, 0);
164		     i++;
165		     itemsSize = itemsSize + 13;
166		}
167
168	    
169		if (playerItems.getHelmet()!=0)
170		{
171			  writeC(buf, i);
172			  writeD(buf, playerItems.getHelmet());
173			  writeD(buf, 0);
174			  writeD(buf, 0);
175			  i++;
176			  itemsSize = itemsSize + 13;
177		}
178
179		if (playerItems.getArmor()!=0)
180		{
181			writeC(buf, i);
182		    writeD(buf, playerItems.getArmor());
183		    writeD(buf, 0);
184		    writeD(buf, 0);
185		    i++;
186		    itemsSize = itemsSize + 13;
187		}
188
189		if (playerItems.getBoots()!=0)
190		{
191			  writeC(buf, i);
192			  writeD(buf, playerItems.getBoots());
193			  writeD(buf, 0);
194			  writeD(buf, 0);
195			  i++;
196			  itemsSize = itemsSize + 13;
197		}
198
199		if (playerItems.getLearrings()!=0)
200		{
201			 writeC(buf, i);
202		     writeD(buf, playerItems.getLearrings());
203		     writeD(buf, 0);
204		     writeD(buf, 0);
205		     i++;
206		     itemsSize = itemsSize + 13;
207		}
208
209		
210		if (playerItems.getRearrings()!=0)
211		{
212			 writeC(buf, i);
213		     writeD(buf, playerItems.getRearrings());
214		     writeD(buf, 0);
215		     writeD(buf, 0);
216		     i++;
217		     itemsSize = itemsSize + 13;
218		}
219
220		
221		if (playerItems.getLring()!=0)
222		{
223			 writeC(buf, i);
224		     writeD(buf, playerItems.getLring());
225		     writeD(buf, 0);
226		     writeD(buf, 0);
227		     i++;
228		     itemsSize = itemsSize + 13;
229		}
230
231		
232		
233		if (playerItems.getRring()!=0)
234		{
235			 writeC(buf, i);
236		     writeD(buf, playerItems.getRring());
237		     writeD(buf, 0);
238		     writeD(buf, 0);
239		     i++;
240		     itemsSize = itemsSize + 13;
241		}
242
243	    
244		if (playerItems.getNecklace()!=0)
245		{
246			 writeC(buf, i);
247			 writeD(buf, playerItems.getNecklace());
248		     writeD(buf, 0);
249		     writeD(buf, 0);
250		     i++;
251		     itemsSize = itemsSize + 13;
252		}
253
254		
255		if (playerItems.getPauldron()!=0)
256		{
257			  writeC(buf, i);
258			  writeD(buf, playerItems.getPauldron());
259			  writeD(buf, 0);
260			  writeD(buf, 0);
261			  i++;
262			  itemsSize = itemsSize + 13;
263		}
264
265		if (playerItems.getPants()!=0)
266		{
267			 writeC(buf, i);
268		     writeD(buf, playerItems.getPants());
269		     writeD(buf, 0);
270		     writeD(buf, 0);
271		     i++;
272		     itemsSize = itemsSize + 13;
273		}
274
275		if (playerItems.getRshard()!=0)
276		{
277			 writeC(buf, i);
278			 writeD(buf, playerItems.getRshard());
279			 writeD(buf, 0);
280			 writeD(buf, 0);
281			 i++;
282			 itemsSize = itemsSize + 13;
283		}
284
285		if (playerItems.getLshard()!=0)
286		{
287			 writeC(buf, i);
288		     writeD(buf, playerItems.getLshard());
289		     writeD(buf, 0);
290		     writeD(buf, 0);
291		     i++;
292			 itemsSize = itemsSize + 13;
293		}
294
295		if (playerItems.getWing()!=0)
296		{
297			 writeC(buf, i);
298		     writeD(buf, playerItems.getWing());
299		     writeD(buf, 0);
300		     writeD(buf, 0);
301		     i++;
302			 itemsSize = itemsSize + 13;
303		}
304
305		
306		stupidNc = new byte[208-itemsSize];
307		writeB(buf, stupidNc);
308		writeD(buf, accPlData.getDeletionTimeInSeconds());
309		writeD(buf, 0x00);// unk
310		
311	}
312}