bool Client::Process() { bool ret = true; //bool sendguilds = true; sockaddr_in to; memset((char *) &to, 0, sizeof(to)); to.sin_family = AF_INET; to.sin_port = port; to.sin_addr.s_addr = ip; if (autobootup_timeout.Check()) { clog(WORLD__CLIENT_ERR, "Zone bootup timer expired, bootup failed or too slow."); ZoneUnavail(); } if(connect.Check()){ SendGuildList();// Send OPCode: OP_GuildsList SendApproveWorld(); connect.Disable(); } if (CLE_keepalive_timer.Check()) { if (cle) cle->KeepAlive(); } /************ Get all packets from packet manager out queue and process them ************/ EQApplicationPacket *app = 0; while(ret && (app = (EQApplicationPacket *)eqs->PopPacket())) { ret = HandlePacket(app); delete app; } if (!eqs->CheckState(ESTABLISHED)) { if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSPlayerLeftWorld; pack->size = sizeof(ServerLSPlayerLeftWorld_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ServerLSPlayerLeftWorld_Struct* logout =(ServerLSPlayerLeftWorld_Struct*)pack->pBuffer; strcpy(logout->key,GetLSKey()); logout->lsaccount_id = GetLSID(); loginserverlist.SendPacket(pack); safe_delete(pack); } clog(WORLD__CLIENT,"Client disconnected (not active in process)"); return false; } return ret; }
void ZoneServer::LSSleepUpdate(uint32 zoneid){ if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSZoneSleep; pack->size = sizeof(ServerLSZoneSleep_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ServerLSZoneSleep_Struct* sleep =(ServerLSZoneSleep_Struct*)pack->pBuffer; sleep->zone = zoneid; sleep->zone_wid = GetID(); loginserverlist.SendPacket(pack); safe_delete(pack); } }
void ClientListEntry::LSZoneChange(ZoneToZone_Struct* ztz){ if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSPlayerZoneChange; pack->size = sizeof(ServerLSPlayerZoneChange_Struct); pack->pBuffer = new uchar[pack->size]; ServerLSPlayerZoneChange_Struct* zonechange =(ServerLSPlayerZoneChange_Struct*)pack->pBuffer; zonechange->lsaccount_id = LSID(); zonechange->from = ztz->current_zone_id; zonechange->to = ztz->requested_zone_id; loginserverlist.SendPacket(pack); safe_delete(pack); } }
void ClientListEntry::LSUpdate(ZoneServer* iZS){ if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSZoneInfo; pack->size = sizeof(ZoneInfo_Struct); pack->pBuffer = new uchar[pack->size]; ZoneInfo_Struct* zone =(ZoneInfo_Struct*)pack->pBuffer; zone->count=iZS->NumPlayers(); zone->zone = iZS->GetZoneID(); zone->zone_wid = iZS->GetID(); loginserverlist.SendPacket(pack); safe_delete(pack); } }
void ZoneServer::LSShutDownUpdate(uint32 zoneid){ if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSZoneShutdown; pack->size = sizeof(ZoneShutdown_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ZoneShutdown_Struct* zsd =(ZoneShutdown_Struct*)pack->pBuffer; if(zoneid==0) zsd->zone = GetPrevZoneID(); else zsd->zone = zoneid; zsd->zone_wid = GetID(); loginserverlist.SendPacket(pack); safe_delete(pack); } }
void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup){ if(WorldConfig::get()->UpdateStats){ ServerPacket* pack = new ServerPacket; if(startup) pack->opcode = ServerOP_LSZoneStart; else pack->opcode = ServerOP_LSZoneBoot; pack->size = sizeof(ZoneBoot_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ZoneBoot_Struct* bootup =(ZoneBoot_Struct*)pack->pBuffer; if(startup) strcpy(bootup->compile_time,GetCompileTime()); bootup->zone = zoneid; bootup->zone_wid = GetID(); bootup->instance = instanceid; loginserverlist.SendPacket(pack); safe_delete(pack); } }
bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { if (app->size != sizeof(LoginInfo_Struct)) { return false; } LoginInfo_Struct *li=(LoginInfo_Struct *)app->pBuffer; // Quagmire - max len for name is 18, pass 15 char name[19] = {0}; char password[16] = {0}; strn0cpy(name, (char*)li->login_info,18); strn0cpy(password, (char*)&(li->login_info[strlen(name)+1]), 15); if (strlen(password) <= 1) { // TODO: Find out how to tell the client wrong username/password clog(WORLD__CLIENT_ERR,"Login without a password"); return false; } pZoning=(li->zoning==1); #ifdef IPBASED_AUTH_HACK struct in_addr tmpip; tmpip.s_addr = ip; #endif uint32 id=0; bool minilogin = loginserverlist.MiniLogin(); if(minilogin){ struct in_addr miniip; miniip.s_addr = ip; id = database.GetMiniLoginAccount(inet_ntoa(miniip)); } else if(strncasecmp(name, "LS#", 3) == 0) id=atoi(&name[3]); else id=atoi(name); #ifdef IPBASED_AUTH_HACK if ((cle = zoneserver_list.CheckAuth(inet_ntoa(tmpip), password))) #else if (loginserverlist.Connected() == false && !pZoning) { clog(WORLD__CLIENT_ERR,"Error: Login server login while not connected to login server."); return false; } if(minilogin) client_list.CLEAdd(id, name, password, 0, ip, true); if ((minilogin && (cle = client_list.CheckAuth(id,password,ip))) || (cle = client_list.CheckAuth(id, password))) #endif { if (cle->AccountID() == 0 || (!minilogin && cle->LSID()==0)) { clog(WORLD__CLIENT_ERR,"ID is 0. Is this server connected to minilogin?"); if(!minilogin) clog(WORLD__CLIENT_ERR,"If so you forget the minilogin variable..."); else clog(WORLD__CLIENT_ERR,"Could not find a minilogin account, verify ip address logging into minilogin is the same that is in your account table."); return false; } cle->SetOnline(); clog(WORLD__CLIENT,"Logged in. Mode=%s",pZoning ? "(Zoning)" : "(CharSel)"); if(minilogin){ WorldConfig::DisableStats(); clog(WORLD__CLIENT,"MiniLogin Account #%d",cle->AccountID()); } else { clog(WORLD__CLIENT,"LS Account #%d",cle->LSID()); } const WorldConfig *Config=WorldConfig::get(); if(Config->UpdateStats){ ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_LSPlayerJoinWorld; pack->size = sizeof(ServerLSPlayerJoinWorld_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer,0,pack->size); ServerLSPlayerJoinWorld_Struct* join =(ServerLSPlayerJoinWorld_Struct*)pack->pBuffer; strcpy(join->key,GetLSKey()); join->lsaccount_id = GetLSID(); loginserverlist.SendPacket(pack); safe_delete(pack); } expansion = database.GetExpansion(cle->AccountID()); if(ClientVersionBit == 1) { SendApproveWorld(); SendEnterWorld(cle->name()); SendExpansionInfo(); SendCharInfo(); } else { if (!pZoning && ClientVersionBit != 0) SendGuildList(); SendLogServer(); SendApproveWorld(); SendEnterWorld(cle->name()); if (!pZoning) { SendExpansionInfo(); SendCharInfo(); database.LoginIP(cle->AccountID(), long2ip(GetIP()).c_str()); } } } else { // TODO: Find out how to tell the client wrong username/password clog(WORLD__CLIENT_ERR,"Bad/Expired session key '%s'",name); return false; } if (!cle) return true; cle->SetIP(GetIP()); return true; }