This commit is contained in:
Arthur Ice
2013-03-10 16:15:43 -07:00
13 changed files with 576 additions and 533 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ DATLoader::~DATLoader()
this->Close();
}
int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) {
int DATLoader::Open(char *base_path, const char *zone_name, Archive *archive) {
#ifdef DEBUGDAT
printf("DATLoader::Open %s, [%s]\n", base_path, zone_name);
+1 -1
View File
@@ -54,7 +54,7 @@ class DATLoader : public FileLoader {
public:
DATLoader();
~DATLoader();
virtual int Open(char *base_path, char *zone_name, Archive *archive);
virtual int Open(char *base_path, const char *zone_name, Archive *archive);
virtual int Close();
};
+1 -1
View File
@@ -9,7 +9,7 @@ public:
FileLoader() {}
virtual ~FileLoader() {}
virtual int Open(char *base_path, char *zone_name, Archive *archive) = 0;
virtual int Open(char *base_path, const char *zone_name, Archive *archive) = 0;
virtual int Close() = 0;
Content_3D model_data;
+1 -1
View File
@@ -20,7 +20,7 @@ TERLoader::~TERLoader() {
this->Close();
}
int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
int TERLoader::Open(char *base_path, const char *zone_name, Archive *archive) {
#ifdef DEBUGTER
printf("TERLoader::Open %s, [%s]\n", base_path, zone_name);
+1 -1
View File
@@ -55,7 +55,7 @@ class TERLoader : public FileLoader {
public:
TERLoader();
~TERLoader();
virtual int Open(char *base_path, char *zone_name, Archive *archive);
virtual int Open(char *base_path, const char *zone_name, Archive *archive);
virtual int Close();
};
+1 -1
View File
@@ -461,7 +461,7 @@ WLDLoader::~WLDLoader() {
this->Close();
}
int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
int WLDLoader::Open(char *base_path, const char *zone_name, Archive *archive) {
uchar *buffer;
int buf_len;
int i, j, vc, pc, bc, mlen, *pmap;
+1 -1
View File
@@ -34,7 +34,7 @@ public:
WLDLoader();
~WLDLoader();
virtual int Open(char *base_path, char *zone_name, Archive *archive);
virtual int Open(char *base_path, const char *zone_name, Archive *archive);
virtual int Close();
int fragcount;
+1 -1
View File
@@ -22,7 +22,7 @@ ZonLoader::~ZonLoader() {
this->Close();
}
int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
int ZonLoader::Open(char *base_path, const char *zone_name, Archive *archive) {
uchar *buffer, *orig_buffer;
int buf_len;
+1 -1
View File
@@ -36,7 +36,7 @@ public:
ZonLoader();
~ZonLoader();
virtual int Open(char *base_path, char *zone_name, Archive *archive);
virtual int Open(char *base_path, const char *zone_name, Archive *archive);
virtual int Close();
private:
+1 -1
View File
@@ -24,7 +24,7 @@ Zonv4Loader::~Zonv4Loader()
this->Close();
}
int Zonv4Loader::Open(char *base_path, char *zone_name, Archive *archive)
int Zonv4Loader::Open(char *base_path, const char *zone_name, Archive *archive)
{
uchar *buffer;
+1 -1
View File
@@ -32,7 +32,7 @@ public:
Zonv4Loader();
~Zonv4Loader();
virtual int Open(char *base_path, char *zone_name, Archive *archive);
virtual int Open(char *base_path, const char *zone_name, Archive *archive);
virtual int Close();
private:
+164 -128
View File
@@ -368,48 +368,13 @@ void Client::SendPostEnterWorld() {
safe_delete(outapp);
}
bool Client::HandlePacket(const EQApplicationPacket *app) {
const WorldConfig *Config=WorldConfig::get();
EmuOpcode opcode = app->GetOpcode();
clog(WORLD__CLIENT_TRACE,"Recevied EQApplicationPacket");
_pkt(WORLD__CLIENT_TRACE,app);
bool ret = true;
if (!eqs->CheckState(ESTABLISHED)) {
clog(WORLD__CLIENT,"Client disconnected (net inactive on send)");
return false;
}
// Voidd: Anti-GM Account hack, Checks source ip against valid GM Account IP Addresses
if (RuleB(World, GMAccountIPList) && this->GetAdmin() >= (RuleI(World, MinGMAntiHackStatus))) {
if(!database.CheckGMIPs(long2ip(this->GetIP()).c_str(), this->GetAccountID())) {
clog(WORLD__CLIENT,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID());
eqs->Close();
}
}
if (GetAccountID() == 0 && opcode != OP_SendLoginInfo) {
// Got a packet other than OP_SendLoginInfo when not logged in
clog(WORLD__CLIENT_ERR,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
return false;
}
else if (opcode == OP_AckPacket) {
return true;
}
switch(opcode)
{
case OP_CrashDump:
break;
case OP_SendLoginInfo:
{
bool Client::HandleLoginInfoPacket(const EQApplicationPacket *app)
{
if (app->size != sizeof(LoginInfo_Struct)) {
ret = false;
break;
return false;
}
const WorldConfig *Config=WorldConfig::get();
LoginInfo_Struct *li=(LoginInfo_Struct *)app->pBuffer;
// Quagmire - max len for name is 18, pass 15
@@ -421,8 +386,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
if (strlen(password) <= 1) {
// TODO: Find out how to tell the client wrong username/password
clog(WORLD__CLIENT_ERR,"Login without a password");
ret = false;
break;
return false;
}
pZoning=(li->zoning==1);
@@ -433,7 +397,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
#endif
uint32 id=0;
bool minilogin = loginserverlist.MiniLogin();
if(minilogin){
if(minilogin) {
struct in_addr miniip;
miniip.s_addr = ip;
id = database.GetMiniLoginAccount(inet_ntoa(miniip));
@@ -442,13 +406,13 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
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.");
ret = false;
break;
return false;
}
if ((minilogin && (cle = client_list.CheckAuth(id,password,ip))) || (cle = client_list.CheckAuth(id, password)))
#endif
@@ -459,12 +423,10 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
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.");
ret = false;
break;
return false;
}
cle->SetOnline();
clog(WORLD__CLIENT,"Logged in. Mode=%s",pZoning ? "(Zoning)" : "(CharSel)");
if(minilogin){
@@ -474,7 +436,8 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
else {
clog(WORLD__CLIENT,"LS Account #%d",cle->LSID());
}
if(Config->UpdateStats){
if(Config->UpdateStats) {
ServerPacket* pack = new ServerPacket;
pack->opcode = ServerOP_LSPlayerJoinWorld;
pack->size = sizeof(ServerLSPlayerJoinWorld_Struct);
@@ -503,22 +466,24 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
else {
// TODO: Find out how to tell the client wrong username/password
clog(WORLD__CLIENT_ERR,"Bad/Expired session key '%s'",name);
ret = false;
break;
return false;
}
if (!cle)
break;
return false;
cle->SetIP(GetIP());
break;
}
case OP_ApproveName: //Name approval
{
return true;
}
bool Client::HandleApproveNamePacket(const EQApplicationPacket *app)
{
if (GetAccountID() == 0) {
clog(WORLD__CLIENT_ERR,"Name approval request with no logged in account");
ret = false;
break;
return false;
}
snprintf(char_name, 64, "%s", (char*)app->pBuffer);
uchar race = app->pBuffer[64];
uchar clas = app->pBuffer[68];
@@ -530,7 +495,9 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
outapp->SetOpcode(OP_ApproveName);
outapp->pBuffer = new uchar[1];
outapp->size = 1;
bool valid;
if(!database.CheckNameFilter(char_name)) {
valid = false;
}
@@ -544,18 +511,21 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
else {
valid = false;
}
outapp->pBuffer[0] = valid? 1 : 0;
QueuePacket(outapp);
safe_delete(outapp);
if(!valid) {
memset(char_name, 0, sizeof(char_name));
return false;
}
break;
}
case OP_RandomNameGenerator:
{
return true;
}
bool Client::HandleRandomNameGeneratorPacket(const EQApplicationPacket *app)
{
// creates up to a 10 char name
char vowels[18]="aeiouyaeiouaeioe";
char cons[48]="bcdfghjklmnpqrstvwxzybcdgklmnprstvwbcdgkpstrkd";
@@ -565,59 +535,64 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
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
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)
{
else if (rndnum>16) {
rndnum-=17;
rndname[0]=cons[rndnum];
}
else
{
else {
rndname[0]=vowels[rndnum];
vwl=true;
}
int namlen=MakeRandomInt(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
if (vwl) {
//last char was a vowel
// so pick a cons or cons pair
rndnum=MakeRandomInt(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"
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=MakeRandomInt(0, 7)*2;
}
else
{ // pick any from the set
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
else {
// select a single cons
rndname[i]=cons[rndnum];
}
}
else
{ // select a vowel
else {
// select a vowel
rndname[i]=vowels[MakeRandomInt(0, 16)];
}
vwl=!vwl;
if (!dbl && !dlc)
{ // one chance at double letters in name
if (!MakeRandomInt(0, i+9)) // chances decrease towards end of name
{
// one chance at double letters in name
if (!MakeRandomInt(0, i+9)) {
// chances decrease towards end of name
rndname[i+1]=rndname[i];
dbl=true;
i+=1;
@@ -630,16 +605,12 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
memset(ngs->name,0,64);
strcpy(ngs->name,rndname);
// char names[8][64] = { "How", "About", "You", "Think", "Of", "Your", "Own", "Name" };
// //Could have parts of the random name in this struct and they compile together
// NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer;
// strncpy(ngs->name,"Notcreated",64);
QueuePacket(app);
break;
return true;
}
}
case OP_CharacterCreateRequest: {
bool Client::HandleCharacterCreateRequestPacket(const EQApplicationPacket *app)
{
// New OpCode in SoF
uint32 allocs = character_create_allocations.size();
uint32 combos = character_create_race_class_combos.size();
@@ -665,6 +636,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
alc->BaseStats[j] = character_create_allocations[i].BaseStats[j];
alc->DefaultPointAllocation[j] = character_create_allocations[i].DefaultPointAllocation[j];
}
ptr += sizeof(RaceClassAllocation);
}
@@ -683,22 +655,21 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
QueuePacket(outapp);
safe_delete(outapp);
break;
}
return true;
}
case OP_CharacterCreate: //Char create
{
bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app)
{
if (GetAccountID() == 0)
{
clog(WORLD__CLIENT_ERR,"Account ID not set; unable to create character.");
ret = false;
break;
return false;
}
else if (app->size != sizeof(CharCreate_Struct))
{
clog(WORLD__CLIENT_ERR,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct));
DumpPacket(app);
break;
return false;
}
CharCreate_Struct *cc = (CharCreate_Struct*)app->pBuffer;
@@ -709,27 +680,32 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
outapp->pBuffer[0] = 0;
QueuePacket(outapp);
safe_delete(outapp);
return false;
}
else
SendCharInfo();
break;
}
case OP_EnterWorld: // Enter world
{
return true;
}
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app)
{
const WorldConfig *Config=WorldConfig::get();
if (GetAccountID() == 0) {
clog(WORLD__CLIENT_ERR,"Enter world with no logged in account");
eqs->Close();
break;
return false;
}
if(GetAdmin() < 0)
{
clog(WORLD__CLIENT,"Account banned or suspended.");
eqs->Close();
break;
return false;
}
if (RuleI(World, MaxClientsPerIP) >= 0) {
client_list.GetCLEIP(this->GetIP()); //Check current CLE Entry IPs against incoming connection
//Check current CLE Entry IPs against incoming connection
client_list.GetCLEIP(this->GetIP());
}
EnterWorld_Struct *ew=(EnterWorld_Struct *)app->pBuffer;
@@ -738,17 +714,18 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
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();
break;
return false;
}
// 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();
break;
return false;
}
if(!pZoning && ew->return_home)
@@ -780,7 +757,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
clog(WORLD__CLIENT_ERR,"'%s' is trying to go home before they're able...",char_name);
database.SetHackerFlag(GetAccountName(), char_name, "MQGoHome: player tried to go home before they were able.");
eqs->Close();
break;
return false;
}
}
@@ -813,7 +790,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
clog(WORLD__CLIENT_ERR,"'%s' is trying to go to tutorial but are not allowed...",char_name);
database.SetHackerFlag(GetAccountName(), char_name, "MQTutorial: player tried to enter the tutorial without having tutorial enabled for this character.");
eqs->Close();
break;
return false;
}
}
@@ -868,8 +845,8 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
outapp->pBuffer = new uchar[outapp->size];
memset(outapp->pBuffer,0,outapp->size);
strcpy((char*)outapp->pBuffer, tmp);
} else {
}
else {
// Null Message of the Day. :)
outapp->size = 1;
outapp->pBuffer = new uchar[outapp->size];
@@ -893,12 +870,14 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
EQApplicationPacket *outapp2 = new EQApplicationPacket(OP_SetChatServer);
char buffer[112];
sprintf(buffer,"%s,%i,%s.%s,%c%08X",
sprintf(buffer,
"%s,%i,%s.%s,%c%08X",
Config->ChatHost.c_str(),
Config->ChatPort,
Config->ShortName.c_str(),
this->GetCharName(), ConnectionType, MailKey
);
this->GetCharName(),
ConnectionType,
MailKey);
outapp2->size=strlen(buffer)+1;
outapp2->pBuffer = new uchar[outapp2->size];
memcpy(outapp2->pBuffer,buffer,outapp2->size);
@@ -914,8 +893,10 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
Config->MailHost.c_str(),
Config->MailPort,
Config->ShortName.c_str(),
this->GetCharName(), ConnectionType, MailKey
);
this->GetCharName(),
ConnectionType,
MailKey);
outapp2->size=strlen(buffer)+1;
outapp2->pBuffer = new uchar[outapp2->size];
memcpy(outapp2->pBuffer,buffer,outapp2->size);
@@ -923,10 +904,68 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
safe_delete(outapp2);
EnterWorld();
return true;
}
bool Client::HandlePacket(const EQApplicationPacket *app) {
const WorldConfig *Config=WorldConfig::get();
EmuOpcode opcode = app->GetOpcode();
clog(WORLD__CLIENT_TRACE,"Recevied EQApplicationPacket");
_pkt(WORLD__CLIENT_TRACE,app);
if (!eqs->CheckState(ESTABLISHED)) {
clog(WORLD__CLIENT,"Client disconnected (net inactive on send)");
return false;
}
// Voidd: Anti-GM Account hack, Checks source ip against valid GM Account IP Addresses
if (RuleB(World, GMAccountIPList) && this->GetAdmin() >= (RuleI(World, MinGMAntiHackStatus))) {
if(!database.CheckGMIPs(long2ip(this->GetIP()).c_str(), this->GetAccountID())) {
clog(WORLD__CLIENT,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID());
eqs->Close();
}
}
if (GetAccountID() == 0 && opcode != OP_SendLoginInfo) {
// Got a packet other than OP_SendLoginInfo when not logged in
clog(WORLD__CLIENT_ERR,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
return false;
}
else if (opcode == OP_AckPacket) {
return true;
}
switch(opcode)
{
case OP_CrashDump:
break;
case OP_SendLoginInfo:
{
return HandleLoginInfoPacket(app);
}
case OP_ApproveName: //Name approval
{
return HandleApproveNamePacket(app);
}
case OP_RandomNameGenerator:
{
return HandleRandomNameGeneratorPacket(app);
}
case OP_CharacterCreateRequest:
{
return HandleCharacterCreateRequestPacket(app);
}
case OP_CharacterCreate: //Char create
{
return HandleCharacterCreatePacket(app);
}
case OP_EnterWorld: // Enter world
{
return HandleEnterWorldPacket(app);
}
case OP_LoginComplete:{
break;
return true;
}
case OP_DeleteCharacter: {
uint32 char_acct_id = database.GetAccountIDByChar((char*)app->pBuffer);
@@ -936,14 +975,14 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
database.DeleteCharacter((char *)app->pBuffer);
SendCharInfo();
}
break;
return true;
}
case OP_ApproveWorld:
{
break;
return true;
}
case OP_WorldClientReady:{
break;
return true;
}
case OP_World_Client_CRC1:
case OP_World_Client_CRC2: {
@@ -952,18 +991,18 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
// before OP_World_Client_CRC1. Therefore, if we receive OP_World_Client_CRC1 before OP_EnterWorld,
// then 'Start Tutorial' was not chosen.
StartInTutorial = false;
break;
return true;
}
case OP_WearChange: { // User has selected a different character
break;
return true;
}
case OP_WorldComplete: {
eqs->Close();
break;
return true;
}
case OP_LoginUnknown1:
case OP_LoginUnknown2:
break;
return true;
case OP_ZoneChange:
// HoT sends this to world while zoning and wants it echoed back.
@@ -971,16 +1010,13 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
{
QueuePacket(app);
}
break;
return true;
default: {
clog(WORLD__CLIENT_ERR,"Received unknown EQApplicationPacket");
_pkt(WORLD__CLIENT_ERR,app);
break;
return true;
}
}
return ret;
}
bool Client::Process() {
+7
View File
@@ -91,6 +91,13 @@ private:
void SetRaceStartingSkills( PlayerProfile_Struct *pp );
void SetRacialLanguages( PlayerProfile_Struct *pp );
bool HandleLoginInfoPacket(const EQApplicationPacket *app);
bool HandleApproveNamePacket(const EQApplicationPacket *app);
bool HandleRandomNameGeneratorPacket(const EQApplicationPacket *app);
bool HandleCharacterCreateRequestPacket(const EQApplicationPacket *app);
bool HandleCharacterCreatePacket(const EQApplicationPacket *app);
bool HandleEnterWorldPacket(const EQApplicationPacket *app);
ClientListEntry* cle;
Timer CLE_keepalive_timer;
Timer connect;