int n;
void charcreate( UOXSOCKET s ) // All the character creation stuff{	int n;	unsigned int i ;	signed int ii ;	int totalstats,totalskills;	unsigned int c;	c=Npcs->MemCharFree();	P_CHAR pc = MAKE_CHARREF_LR(c);	pc->Init();	for (i=0;i<=strlen((char*)&buffer[s][10]);i++) pc->name[i]=buffer[s][10+i];	pc->account = acctno[s];	//	Code to support the new GuildType, and GuildTraitor members of the	//	character strcture.	pc->GuildType=-1;				//	Default to no guild	pc->GuildTraitor=false;	//	Also defauot to non trator, or no guild	pc->race=0; // Default human race	if (buffer[s][0x46]!='\x00')	{		pc->id2=0x91;		pc->xid2=0x91;	}	pc->skin = (buffer[s][0x50]|0x80 << 8) + buffer[s][0x51];	if ( pc->skin < 0x83EA || pc->skin>0x8422 )	{		pc->skin = 0x83EA;	}	pc->xskin = pc->skin;	pc->setPriv(defaultpriv1);	pc->priv2=defaultpriv2;	if (acctno[s]==0)	{		pc->setPriv(0xE7);		pc->priv3[0]=0xFFFFFFFF; // lb, meta gm		pc->priv3[1]=0xFFFFFFFF;		pc->priv3[2]=0xFFFFFFFF;		pc->priv3[3]=0xFFFFFFFF;		pc->priv3[4]=0xFFFFFFFF;		pc->priv3[5]=0xFFFFFFFF;		pc->priv3[6]=0xFFFFFFFF;		pc->menupriv=-1; // lb, menu priv	}	pc->MoveTo(str2num(start[buffer[s][0x5B]][2]), str2num(start[buffer[s][0x5B]][3]), str2num(start[buffer[s][0x5B]][4]));	pc->dir=4;	pc->hp=pc->st=buffer[s][0x47];	if (pc->st>45) pc->st=45;		// fix for hack exploit	if (pc->st<10) pc->st=10;	totalstats=pc->st;	short d=buffer[s][0x48];	if (d>45) d=45;		// fix for hack exploit	if (d<10) d=10;	if (d+totalstats>65) d=65-totalstats;	totalstats+=d;	pc->setDex(d);	pc->stm=d;	pc->mn=pc->in=buffer[s][0x49];	if (pc->in>45) pc->in=45;		// fix for hack exploit	if (pc->in<10) pc->in=10;	if (pc->in+totalstats>65) pc->in=65-totalstats;	if (buffer[s][0x4b]>50) buffer[s][0x4b]=50; // fixes for hack exploit	totalskills=buffer[s][0x4b];	if (buffer[s][0x4d]>50) buffer[s][0x4d]=50;	if (buffer[s][0x4d]+totalskills>100) buffer[s][0x4d]=100-totalskills;	totalskills+=buffer[s][0x4d];	if (buffer[s][0x4f]>50) buffer[s][0x4f]=50;	if (buffer[s][0x4f]+totalskills>100) buffer[s][0x4f]=100-totalskills;	for (ii=0;ii<TRUESKILLS;ii++)	{		pc->baseskill[ii]=0;		if (ii==buffer[s][0x4a]) pc->baseskill[buffer[s][0x4a]]=buffer[s][0x4b]*10;		if (ii==buffer[s][0x4c]) pc->baseskill[buffer[s][0x4c]]=buffer[s][0x4d]*10;		if (ii==buffer[s][0x4e]) pc->baseskill[buffer[s][0x4e]]=buffer[s][0x4f]*10;		Skills->updateSkillLevel(DEREF_P_CHAR(pc), i);	}	if (validhair(buffer[s][0x52],buffer[s][0x53]))	{		const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1, "#", 0, buffer[s][0x52], buffer[s][0x53], buffer[s][0x54], buffer[s][0x55],0,0);		if(pi == NULL) return;		if ((((pi->color1<<8)+pi->color2)<0x044E) ||			(((pi->color1<<8)+pi->color2)>0x04AD) )		{			pi->color1=0x04;			pi->color2=0x4E;		}		pi->SetContSerial(pc->serial);		pi->layer=0x0B;	}	if ( (validbeard(buffer[s][0x56],buffer[s][0x57])) && (pc->id2==0x90) )	{		const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1, "#", 0, buffer[s][0x56], buffer[s][0x57], buffer[s][0x58], buffer[s][0x59],0,0);		if(pi == NULL) return;//AntiChrist to preview crashes		if ((((pi->color1<<8)+pi->color2)<0x044E) ||			(((pi->color1<<8)+pi->color2)>0x04AD) )		{			pi->color1=0x04;			pi->color2=0x4E;		}		pi->SetContSerial(pc->serial);		pi->layer=0x10;	}	{	// just to limit the scope of pi	// - create the backpack	P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1, "#", 0, 0x0E, 0x75, 0, 0,0,0);	if (pi == NULL)		return;	pc->packitem = pi->serial;	pi->SetContSerial(pc->serial);	pi->layer=0x15;	pi->type=1;	pi->dye=1;	}	{	// limit the scope of pi	const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1,"#",0,0x09,0x15,0,0,0,0);	if(pi == NULL) return;//AntiChrist to preview crashes	switch (RandomNum(0, 1))	{	case 0:		if ((pc->id2==(unsigned char)'\x90') && (pc->xid2==(unsigned char)'\x90'))		{			pi->setId(0x1539);			pi->layer=0x04; // pant		} else		{			pi->setId(0x1516);			pi->layer=23; //skirt		}		break;	case 1:		if ((pc->id2==(unsigned char)'\x90') && (pc->xid2==(unsigned char)'\x90'))		{			pi->setId(0x152E);			pi->layer=0x04;		} else		{			pi->setId(0x1537);			pi->layer=23;		}		break;	}	// pant/skirt color -> old client code, random color	pi->color1=buffer[s][102];	pi->color2=buffer[s][103];	pi->SetContSerial(pc->serial);	pi->type=0;	pi->dye=1;	pi->hp=10;	pi->priv |= 0x02; // Mark as a newbie item	}	{	// limit the scope of pi	const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1,"#",0,0x09,0x15,0,0,0,0); // spawn pants	if(pi == NULL) return;//AntiChrist to preview crashes	if (!(rand()%2))	{		pi->setId(0x1EFD);	}	else	{		pi->setId(0x1517);	}	pi->color1=buffer[s][100];	pi->color2=buffer[s][101];	pi->SetContSerial(pc->serial);	pi->layer=0x05;	pi->dye=1;	pi->hp=10;	pi->def=1;	pi->priv |= 0x02; // Mark as a newbie item	}	{	// limit the scope of pi	const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1,"#",0,0x17,0x0F,0x02,0x87,0,0); // shoes	if(pi == NULL) return;//AntiChrist to preview crashes	pi->SetContSerial(pc->serial);	pi->layer=0x03;	pi->dye=1;	pi->hp=10;	pi->def=1;	pi->priv |= 0x02; // Mark as a newbie item	}	{	// limit the scope of pi	const P_ITEM pi = Items->SpawnItem(s,DEREF_P_CHAR(pc),1,"#",0,0x0F,0x51,0,0,0,0); // dagger	if(pi == NULL) return;	pi->SetContSerial(pc->serial);	pi->layer=0x01;	//pi->att=5;	pi->hp=10;	pi->spd=50;	pi->lodamage=3;	pi->hidamage=15;	pi->itmhand=1;	pi->priv |= 0x02; // Mark as a newbie item	}#ifdef SPECIAL	{	// limit the scope of pi	n=Items->SpawnItem(s,1,"#",0,0x09,0x15,0,0,0,0);	if(n==-1) return;//AntiChrist to preview crashes	const P_ITEM pi=MAKE_ITEMREF_LR(n);	// on error return	switch (RandomNum(0, 6))	{	case 0:	pi->id1=0x15; pi->id2=0x4b; break;	case 1:	pi->id1=0x15; pi->id2=0x45; break;	case 2:	pi->id1=0x15; pi->id2=0x47; break;	case 3:	pi->id1=0x15; pi->id2=0x49; break;	case 4:	pi->id1=0x17; pi->id2=0x1c; break;	case 5:	pi->id1=0x1f; pi->id2=0x0b; break;	case 6:	pi->id1=0x14; pi->id2=0x51; break;	}	pi->SetContSerial(pc->serial);	pi->layer=0x06;	}#endif	currchar[s]=DEREF_P_CHAR(pc);	newbieitems(DEREF_P_CHAR(pc));	perm[s]=1;	if(pc->st<10)		pc->st=10;	if(pc->in<10)		pc->in=10;	if(pc->effDex()<10)		pc->setDex(10);	Network->startchar(s);}