Reduce compiler warnings in login server

This commit is contained in:
Patrick Boyd 2020-09-03 14:43:40 -05:00
parent 5b717c408a
commit 3078e12938
8 changed files with 33 additions and 28 deletions

View file

@ -396,8 +396,8 @@ bool LWorld::Process() {
if (pack->size != sizeof(ServerLSInfo_Struct)) {
this->Kick(ERROR_BADVERSION);
ret = false;
struct in_addr in;
in.s_addr = GetIP();
//struct in_addr in;
//in.s_addr = GetIP();
}
else {
ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*) pack->pBuffer;
@ -406,14 +406,14 @@ bool LWorld::Process() {
cout << "To allow all world server versions to login, run query on your login database (alternatively replacing * with the database version if preferred): insert into login_versions set version = '*';" << endl;
this->Kick(ERROR_BADVERSION);
ret = false;
struct in_addr in;
in.s_addr = GetIP();
//struct in_addr in;
//in.s_addr = GetIP();
}
else if (!SetupWorld(lsi->name, lsi->address, lsi->account, lsi->password, lsi->serverversion)) {
this->Kick(ERROR_BADPASSWORD);
ret = false;
struct in_addr in;
in.s_addr = GetIP();
//struct in_addr in;
//in.s_addr = GetIP();
}
else{
isAuthenticated = true;
@ -461,8 +461,8 @@ bool LWorld::Process() {
}
ServerSyncWorldList_Struct* sswls = (ServerSyncWorldList_Struct*) pack->pBuffer;
if (!CheckServerName(sswls->name)) {
struct in_addr in;
in.s_addr = sswls->ip;
//struct in_addr in;
//in.s_addr = sswls->ip;
break; // Someone needs to tell the other login server to update it's exe!
}
LWorld* world = world_list.FindByLink(this->Link, sswls->RemoteID);
@ -621,7 +621,7 @@ void LWorld::SendPacket(ServerPacket* pack) {
}
}
void LWorld::Message(char* to, char* message, ...) {
void LWorld::Message(const char* to, const char* message, ...) {
va_list argptr;
char buffer[256];
@ -637,7 +637,7 @@ void LWorld::Message(char* to, char* message, ...) {
delete pack;
}
void LWorld::Kick(char* message, bool iSetKickedFlag) {
void LWorld::Kick(const char* message, bool iSetKickedFlag) {
if (iSetKickedFlag)
kicked = true;
if (message) {
@ -649,10 +649,10 @@ void LWorld::Kick(char* message, bool iSetKickedFlag) {
if (Link && GetRemoteID() == 0)
Link->Disconnect();
}
bool LWorld::CheckServerName(char* name) {
bool LWorld::CheckServerName(const char* name) {
if (strlen(name) < 10)
return false;
for (int i=0; i<strlen(name); i++) {
for (size_t i=0; i<strlen(name); i++) {
if (!((name[i] >= 'a' && name[i] <= 'z') || (name[i] >= 'A' && name[i] <= 'Z') || (name[i] >= '0' && name[i] <= '9') || name[i] == ' ' || name[i] == '\'' || name[i] == '-' || name[i] == '(' || name[i] == ')' || name[i] == '[' || name[i] == ']' || name[i] == '/' || name[i] == '.' || name[i] == ',' || name[i] == '_' || name[i] == '+' || name[i] == '=' || name[i] == ':' || name[i] == '~'))
return false;
}
@ -819,6 +819,7 @@ void LWorldList::KickGhostIP(int32 ip, LWorld* NotMe, int16 iClientPort) {
in.s_addr = world->GetIP();
// cout << "Removing GhostIP LWorld(" << world->GetID() << ") from ip: " << inet_ntoa(in) << " port: " << (int16)(world->GetPort());
if (!world->Connected())
{
// cout << " (it wasnt connected)";
// cout << endl;
if (NotMe) {
@ -826,6 +827,7 @@ void LWorldList::KickGhostIP(int32 ip, LWorld* NotMe, int16 iClientPort) {
cout << "NotMe(" << NotMe->GetID() << ") = " << inet_ntoa(in) << ":" << NotMe->GetPort() << " (" << NotMe->GetClientPort() << ")" << endl;
}
world->Kick("Ghost IP kick");
}
}
}
}
@ -839,8 +841,8 @@ void LWorldList::KickGhost(ConType in_type, int32 in_accountid, LWorld* ButNotMe
LWorld* world = map_list->second;
if (!world->IsKicked() && world->GetType() == in_type && world != ButNotMe && (in_accountid == 0 || world->GetAccountID() == in_accountid)) {
if (world->GetIP() != 0) {
struct in_addr in;
in.s_addr = world->GetIP();
//struct in_addr in;
//in.s_addr = world->GetIP();
// cout << "Removing GhostAcc LWorld(" << world->GetID() << ") from ip: " << inet_ntoa(in) << " port: " << (int16)(world->GetPort()) << endl;
}
if (world->GetType() == Login && world->IsOutgoingUplink()) {
@ -915,8 +917,8 @@ void LWorldList::Process() {
continue;
}
else if (!world->Process()) {
struct in_addr in;
in.s_addr = world->GetIP();
//struct in_addr in;
//in.s_addr = world->GetIP();
if (world->GetAccountID() == 0 || !(world->ShowDown()) || world->GetType() == Chat) {
map_list++;
worldmap.erase ( account_id );
@ -1120,8 +1122,7 @@ EQ2Packet* LWorldList::MakeServerListPacket(int8 lsadmin, int16 version) {
return ServerListData[version];
}
LWorld* world = 0;
uchar num_servers[2];
//LWorld* world = 0;
int32 ServerNum = 0;
/* while(iterator.MoreElements()){
world = iterator.GetData();
@ -1191,8 +1192,11 @@ EQ2Packet* LWorldList::MakeServerListPacket(int8 lsadmin, int16 version) {
}
EQ2Packet* pack = packet->serialize();
#ifdef DEBUG
//Only dump these for people trying to debug this...
printf("WorldList:\n");
DumpPacket(pack->pBuffer, pack->size);
#endif
if (ServerListData.count(version))
{
map<int32, EQ2Packet*>::iterator it = ServerListData.find(version);

View file

@ -50,11 +50,11 @@ public:
LWorld(TCPConnection* in_RemoteLink, int32 in_ip, int32 in_RemoteID, int32 in_accountid, char* in_accountname, char* in_worldname, char* in_address, sint32 in_status, int32 in_adminid, bool in_showdown, int8 in_authlevel, bool in_placeholder, int32 iLinkWorldID);
~LWorld();
static bool CheckServerName(char* name);
static bool CheckServerName(const char* name);
bool Process();
void SendPacket(ServerPacket* pack);
void Message(char* to, char* message, ...);
void Message(const char* to, const char* message, ...);
bool SetupWorld(char* in_worldname, char* in_worldaddress, char* in_account, char* in_password, char* in_version);
void UpdateStatus(sint32 in_status, sint32 in_players, sint32 in_zones) {
@ -91,7 +91,7 @@ public:
int8 GetWorldStatus();
void ChangeToPlaceholder();
void Kick(char* message = ERROR_GHOST, bool iSetKickedFlag = true);
void Kick(const char* message = ERROR_GHOST, bool iSetKickedFlag = true);
inline bool IsKicked() { return kicked; }
inline bool IsNeverKick() { return pNeverKick; }
inline ConType GetType() { return ptype; }

View file

@ -229,7 +229,7 @@ void LoginDatabase::LoadCharacters(LoginAccount* acct, int16 version){
player->packet->setColorByName("unknown14", 0xFF, 0xFF, 0xFF);
uchar tmp[] = {0xFF, 0xFF, 0xFF, 0x61, 0x00, 0x2C, 0x04, 0xA5, 0x09, 0x02, 0x0F, 0x00, 0x00};
for(int y=0;y<sizeof(tmp);y++)
for(size_t y=0;y<sizeof(tmp);y++)
player->packet->setDataByName("unknown11", tmp[y], y);
MYSQL_RES* result3 = query2.RunQuery2(Q_SELECT, "SELECT slot, equip_type, red, green, blue, highlight_red, highlight_green, highlight_blue from login_equipment where login_characters_id=%i order by slot",id);
@ -623,7 +623,7 @@ void LoginDatabase::GetServerAccounts(vector<LWorld*>* server_list){
server_list->push_back(world);
}
}
void LoginDatabase::SaveClientLog(char* type, char* message, char* player_name, int16 version){
void LoginDatabase::SaveClientLog(const char* type, const char* message, const char* player_name, int16 version){
Query query;
query.escaped_data1 = getEscapeString(message);
query.escaped_name = getEscapeString(player_name);

View file

@ -61,7 +61,7 @@ public:
int32 GetRaceID(char* name);
void UpdateRaceID(char* name);
bool DeleteCharacter(int32 account_id, int32 character_id, int32 server_id);
void SaveClientLog(char* type, char* message, char* player_name, int16 version);
void SaveClientLog(const char* type, const char* message, const char* player_name, int16 version);
bool CheckVersion(char* version);
void GetLatestTableVersions(LatestTableVersions* table_versions);
TableQuery* GetLatestTableQuery(int32 server_ip, char* name, int16 version);

View file

@ -49,7 +49,7 @@ public:
int32 GetIP() { return ip; }
int16 GetPort() { return port; }
int32 GetAccountID() { return account_id; }
char* GetAccountName(){ return (char*)account_name.c_str(); }
const char* GetAccountName(){ return (char*)account_name.c_str(); }
void SetAccountName(const char* name){ account_name = string(name); }
void ProcessLogin(char* name, char* pass,int seq=0);
void QueuePacket(EQ2Packet* app);

View file

@ -86,6 +86,7 @@ public:
MobListMutex.writelock();
RunningCommandProcess = status;
MobListMutex.releasewritelock();
return true;
}
private:
MobMovementManager(const MobMovementManager&);

View file

@ -212,9 +212,9 @@ void ConfigReader::loadDataStruct(PacketStruct* packet, XMLNode parentNode, bool
vector<DataStruct*>* structs = substruct_packet->getStructs();
DataStruct* ds = 0;
int i = 0;
char tmp[10] = {0};
char tmp[12] = {0};
for(i=0;i<num_size;i++){
sprintf(tmp,"%i",i);
snprintf(tmp, sizeof(tmp)-1, "%i", i);
for(itr=structs->begin();itr!=structs->end();itr++) {
ds = *itr;
string new_name;

View file

@ -637,7 +637,7 @@ struct ZoneUpdate_Struct{
};
struct ZoneUpdateList_Struct{
sint16 total_updates;
uint16 total_updates;
char data[0];
};