bool Client::GenPassKey(char* key) { char* passKey=nullptr; *passKey += ((char)('A'+((int)emu_random.Int(0, 25)))); *passKey += ((char)('A'+((int)emu_random.Int(0, 25)))); memcpy(key, passKey, strlen(passKey)); return true; }
void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skipid, uint32 zoneid){ // get random zone LinkedListIterator<ZoneServer*> iterator(list); uint32 x = 0; iterator.Reset(); while(iterator.MoreElements()) { x++; iterator.Advance(); } if (x == 0) return; auto tmp = new ZoneServer *[x]; uint32 y = 0; iterator.Reset(); while(iterator.MoreElements()) { if (!strcmp(iterator.GetData()->GetCAddress(),ip2) && !iterator.GetData()->IsBootingUp() && iterator.GetData()->GetID() != skipid) { tmp[y++] = iterator.GetData(); } iterator.Advance(); } if (y == 0) { safe_delete(tmp); return; } uint32 z = emu_random.Int(0, y-1); auto pack = new ServerPacket(ServerOP_ZoneReboot, sizeof(ServerZoneReboot_Struct)); ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*) pack->pBuffer; // strcpy(s->ip1,ip1); strcpy(s->ip2,ip2); s->port = port; s->zoneid = zoneid; if(zoneid != 0) Log.Out(Logs::Detail, Logs::World_Server,"Rebooting static zone with the ID of: %i",zoneid); tmp[z]->SendPacket(pack); delete pack; safe_delete_array(tmp); }
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Enter world with no logged in account"); eqs->Close(); return true; } if(GetAdmin() < 0) { clog(WORLD__CLIENT,"Account banned or suspended."); eqs->Close(); return true; } if (RuleI(World, MaxClientsPerIP) >= 0) { client_list.GetCLEIP(this->GetIP()); //Check current CLE Entry IPs against incoming connection } EnterWorld_Struct *ew=(EnterWorld_Struct *)app->pBuffer; strn0cpy(char_name, ew->name, 64); EQApplicationPacket *outapp; uint32 tmpaccid = 0; charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID, &instanceID); if (charid == 0 || tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"Could not get CharInfo for '%s'",char_name); eqs->Close(); return true; } // Make sure this account owns this character if (tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"This account does not own the character named '%s'",char_name); eqs->Close(); return true; } if (zoneID == 0 || !database.GetZoneName(zoneID)) { // This is to save people in an invalid zone, once it's removed from the DB database.MoveCharacterToZone(charid, "arena"); clog(WORLD__CLIENT_ERR, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zoneID, char_name); } if(instanceID > 0) { if(!database.VerifyInstanceAlive(instanceID, GetCharID())) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } else { if(!database.VerifyZoneInstance(zoneID, instanceID)) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } } } if(!pZoning) { database.SetGroupID(char_name, 0, charid); database.SetFirstLogon(charid, 1); } else{ uint32 groupid = database.GetGroupID(char_name); if(groupid > 0){ char* leader = 0; char leaderbuf[64] = {0}; if((leader = database.GetGroupLeaderForLogin(char_name, leaderbuf)) && strlen(leader)>1){ EQApplicationPacket* outapp3 = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gj=(GroupJoin_Struct*)outapp3->pBuffer; gj->action=8; strcpy(gj->yourname, char_name); strcpy(gj->membername, leader); QueuePacket(outapp3); safe_delete(outapp3); } } } outapp = new EQApplicationPacket(OP_MOTD); char tmp[500] = {0}; if (database.GetVariable("MOTD", tmp, 500)) { outapp->size = strlen(tmp)+1; outapp->pBuffer = new uchar[outapp->size]; memset(outapp->pBuffer,0,outapp->size); strcpy((char*)outapp->pBuffer, tmp); } else { // Null Message of the Day. :) outapp->size = 1; outapp->pBuffer = new uchar[outapp->size]; outapp->pBuffer[0] = 0; } QueuePacket(outapp); safe_delete(outapp); int MailKey = emu_random.Int(1, INT_MAX); database.SetMailKey(charid, GetIP(), MailKey); char ConnectionType; ConnectionType = 'C'; EQApplicationPacket *outapp2 = new EQApplicationPacket(OP_SetChatServer); char buffer[112]; const WorldConfig *Config = WorldConfig::get(); sprintf(buffer,"%s,%i,%s.%s,%c%08X", Config->ChatHost.c_str(), Config->ChatPort, Config->ShortName.c_str(), this->GetCharName(), ConnectionType, MailKey ); outapp2->size=strlen(buffer)+1; outapp2->pBuffer = new uchar[outapp2->size]; memcpy(outapp2->pBuffer,buffer,outapp2->size); QueuePacket(outapp2); safe_delete(outapp2); EnterWorld(); return true; }
bool Client::HandleGenerateRandomNamePacket(const EQApplicationPacket *app) { // creates up to a 10 char name char vowels[18]="aeiouyaeiouaeioe"; char cons[48]="bcdfghjklmnpqrstvwxzybcdgklmnprstvwbcdgkpstrkd"; char rndname[17]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; char paircons[33]="ngrkndstshthphsktrdrbrgrfrclcr"; int rndnum=emu_random.Int(0, 75),n=1; bool dlc=false; bool vwl=false; bool dbl=false; if (rndnum>63) { // rndnum is 0 - 75 where 64-75 is cons pair, 17-63 is cons, 0-16 is vowel rndnum=(rndnum-61)*2; // name can't start with "ng" "nd" or "rk" rndname[0]=paircons[rndnum]; rndname[1]=paircons[rndnum+1]; n=2; } else if (rndnum>16) { rndnum-=17; rndname[0]=cons[rndnum]; } else { rndname[0]=vowels[rndnum]; vwl=true; } int namlen=emu_random.Int(5, 10); for (int i=n;i<namlen;i++) { dlc=false; if (vwl) //last char was a vowel { // so pick a cons or cons pair rndnum=emu_random.Int(0, 62); if (rndnum>46) { // pick a cons pair if (i>namlen-3) // last 2 chars in name? { // name can only end in cons pair "rk" "st" "sh" "th" "ph" "sk" "nd" or "ng" rndnum=emu_random.Int(0, 7)*2; } else { // pick any from the set rndnum=(rndnum-47)*2; } rndname[i]=paircons[rndnum]; rndname[i+1]=paircons[rndnum+1]; dlc=true; // flag keeps second letter from being doubled below i+=1; } else { // select a single cons rndname[i]=cons[rndnum]; } } else { // select a vowel rndname[i]=vowels[emu_random.Int(0, 16)]; } vwl=!vwl; if (!dbl && !dlc) { // one chance at double letters in name if (!emu_random.Int(0, i+9)) // chances decrease towards end of name { rndname[i+1]=rndname[i]; dbl=true; i+=1; } } } rndname[0]=toupper(rndname[0]); NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer; memset(ngs->name,0,64); strcpy(ngs->name,rndname); QueuePacket(app); return true; }