mojo_client/src/Client/Realm/RealmListHandler.cpp_
False.Genesis 58872f1f39 initial release.
still a lot of stuff to fix before everything works as it should.
compilation works, linking produces errors.
most code cleanups done.
2007-01-05 18:30:22 +00:00

62 lines
2.2 KiB
Plaintext

#include "basics.h"
#include "PseuWoW.h"
#include "Auth/ByteBuffer.h"
#include "RealmListHandler.h"
#include "realmfunc.h"
// process a given realmlist packet
struct SRealmInfo
{
uint32 icon; // icon near realm
uint8 color; // color of record
std::string name; // Text zero terminated name of Realm
std::string addr_port; // Text zero terminated address of Realm ("ip:port")
float population; // 1.6 -> population value. lower == lower population and vice versa
uint8 chars_here; // number of characters on this server
uint8 timezone; // timezone
uint8 unknown; //
} * realms;
bool HandleRealmList(ByteBuffer pkt){
uint8 PosOfRealm=0;
bool FoundRealm=false;
uint32 i=0,pktpos=0, unk1=0;
uint16 datalen;
uint8 count, trash;
pkt >> trash >> datalen >> unk1 >> count;
DEBUG3(printf("Length of realm data: %d\n",datalen);)
DEBUG1(printf("Realms in List: %d\n",count););
if(count==0)
something_went_wrong=true;
realms=new SRealmInfo[count];
for(i=0;i<count;i++){
pkt >> realms[i].icon >> realms[i].color >> realms[i].name >> realms[i].addr_port >> realms[i].population >> realms[i].chars_here >> realms[i].timezone >> realms[i].unknown;
if(stricmp(realmname,realms[i].name.c_str())==0){PosOfRealm=i;FoundRealm=true;}
printf("Realm: %s (%s)",realms[i].name.c_str(),realms[i].addr_port.c_str());
DEBUG1(printf("[chars:%d][population:%f][timezone:%d]",realms[i].chars_here,realms[i].population,realms[i].timezone););
printf("\n");
}
// the rest of the packet is not interesting
// now setup where the woldserver is and how to login there
if(!FoundRealm){
printf("Realm \"%s\" was not found on the realmlist!\n",realmname);
something_went_wrong=true;
realmCon.Close();
return false;
}
// transform "hostname:port" into something useful
// -> convert the worldserver port from string to int
// -> and remove it from the hostname, then write the remains into worldhost
uint16 colonpos=realms[PosOfRealm].addr_port.find(":");
worldhost=realms[PosOfRealm].addr_port.substr(0,colonpos);
ws_port=atoi(realms[PosOfRealm].addr_port.substr(colonpos+1,realms[PosOfRealm].addr_port.length()-colonpos-1).c_str());
return true;
}