mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-09 21:42:27 +00:00
Merge pull request #1283 from EQEmu/cleanup/Wformat-overflow
[Cleanup] Make code -Wformat-overflow safe
This commit is contained in:
commit
d635e69ee3
@ -45,24 +45,6 @@ namespace EQ
|
|||||||
class InventoryProfile;
|
class InventoryProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EventLogDetails_Struct {
|
|
||||||
uint32 id;
|
|
||||||
char accountname[64];
|
|
||||||
uint32 account_id;
|
|
||||||
int16 status;
|
|
||||||
char charactername[64];
|
|
||||||
char targetname[64];
|
|
||||||
char timestamp[64];
|
|
||||||
char descriptiontype[64];
|
|
||||||
char details[128];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CharacterEventLog_Struct {
|
|
||||||
uint32 count;
|
|
||||||
uint8 eventid;
|
|
||||||
EventLogDetails_Struct eld[255];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct npcDecayTimes_Struct {
|
struct npcDecayTimes_Struct {
|
||||||
uint16 minlvl;
|
uint16 minlvl;
|
||||||
uint16 maxlvl;
|
uint16 maxlvl;
|
||||||
|
|||||||
@ -4791,7 +4791,12 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
|
|||||||
tmpsize = c->GetMercInfo().MercSize;
|
tmpsize = c->GetMercInfo().MercSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(npc_type->lastname, "%s's Mercenary", c->GetName());
|
std::string tmp_lastname = c->GetName();
|
||||||
|
tmp_lastname += "'s Mercenary";
|
||||||
|
|
||||||
|
// not sure what to do if too long
|
||||||
|
if (tmp_lastname.length() < sizeof(npc_type->lastname))
|
||||||
|
strn0cpy(npc_type->lastname, tmp_lastname.c_str(), sizeof(npc_type->lastname));
|
||||||
npc_type->gender = tmpgender;
|
npc_type->gender = tmpgender;
|
||||||
npc_type->size = tmpsize;
|
npc_type->size = tmpsize;
|
||||||
npc_type->loottable_id = 0; // Loottable has to be 0, otherwise we'll be leavin' some corpses!
|
npc_type->loottable_id = 0; // Loottable has to be 0, otherwise we'll be leavin' some corpses!
|
||||||
|
|||||||
13
zone/npc.cpp
13
zone/npc.cpp
@ -2254,8 +2254,12 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
|
|||||||
if (RuleB(Pets, UnTargetableSwarmPet))
|
if (RuleB(Pets, UnTargetableSwarmPet))
|
||||||
{
|
{
|
||||||
ns->spawn.bodytype = 11;
|
ns->spawn.bodytype = 11;
|
||||||
if(!IsCharmed() && swarmOwner->IsClient())
|
if(!IsCharmed() && swarmOwner->IsClient()) {
|
||||||
sprintf(ns->spawn.lastName, "%s's Pet", swarmOwner->GetName());
|
std::string tmp_lastname = swarmOwner->GetName();
|
||||||
|
tmp_lastname += "'s Pet";
|
||||||
|
if (tmp_lastname.size() < sizeof(ns->spawn.lastName))
|
||||||
|
strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GetOwnerID())
|
else if(GetOwnerID())
|
||||||
@ -2267,7 +2271,10 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
|
|||||||
if(client)
|
if(client)
|
||||||
{
|
{
|
||||||
SetPetOwnerClient(true);
|
SetPetOwnerClient(true);
|
||||||
sprintf(ns->spawn.lastName, "%s's Pet", client->GetName());
|
std::string tmp_lastname = swarmOwner->GetName();
|
||||||
|
tmp_lastname += "'s Pet";
|
||||||
|
if (tmp_lastname.size() < sizeof(ns->spawn.lastName))
|
||||||
|
strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -473,20 +473,16 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_Motd: {
|
case ServerOP_Motd: {
|
||||||
ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer;
|
if (pack->size != sizeof(ServerMotd_Struct))
|
||||||
EQApplicationPacket *outapp;
|
break;
|
||||||
outapp = new EQApplicationPacket(OP_MOTD);
|
|
||||||
char tmp[500] = { 0 };
|
|
||||||
sprintf(tmp, "%s", smotd->motd);
|
|
||||||
|
|
||||||
outapp->size = strlen(tmp) + 1;
|
ServerMotd_Struct *smotd = (ServerMotd_Struct *)pack->pBuffer;
|
||||||
outapp->pBuffer = new uchar[outapp->size];
|
SerializeBuffer buf(100);
|
||||||
memset(outapp->pBuffer, 0, outapp->size);
|
buf.WriteString(smotd->motd);
|
||||||
strcpy((char*)outapp->pBuffer, tmp);
|
|
||||||
|
|
||||||
entity_list.QueueClients(0, outapp);
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_MOTD, buf);
|
||||||
safe_delete(outapp);
|
|
||||||
|
|
||||||
|
entity_list.QueueClients(0, outapp.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_ShutdownAll: {
|
case ServerOP_ShutdownAll: {
|
||||||
|
|||||||
@ -639,53 +639,6 @@ void ZoneDatabase::SetDoorPlace(uint8 value,uint8 door_id,const char* zone_name)
|
|||||||
door_isopen_array[door_id] = value;
|
door_isopen_array[door_id] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id,uint8 eventid,char* detail,char* timestamp, CharacterEventLog_Struct* cel)
|
|
||||||
{
|
|
||||||
char modifications[200];
|
|
||||||
if(strlen(name) != 0)
|
|
||||||
sprintf(modifications,"charname=\'%s\'",name);
|
|
||||||
else if(account_id != 0)
|
|
||||||
sprintf(modifications,"accountid=%i",account_id);
|
|
||||||
|
|
||||||
if(strlen(target) != 0)
|
|
||||||
sprintf(modifications,"%s AND target LIKE \'%%%s%%\'",modifications,target);
|
|
||||||
|
|
||||||
if(strlen(detail) != 0)
|
|
||||||
sprintf(modifications,"%s AND description LIKE \'%%%s%%\'",modifications,detail);
|
|
||||||
|
|
||||||
if(strlen(timestamp) != 0)
|
|
||||||
sprintf(modifications,"%s AND time LIKE \'%%%s%%\'",modifications,timestamp);
|
|
||||||
|
|
||||||
if(eventid == 0)
|
|
||||||
eventid =1;
|
|
||||||
sprintf(modifications,"%s AND event_nid=%i",modifications,eventid);
|
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT id, accountname, accountid, status, charname, target, "
|
|
||||||
"time, descriptiontype, description FROM eventlog WHERE %s", modifications);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
if (!results.Success())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row, ++index) {
|
|
||||||
if(index == 255)
|
|
||||||
break;
|
|
||||||
|
|
||||||
cel->eld[index].id = atoi(row[0]);
|
|
||||||
strn0cpy(cel->eld[index].accountname,row[1],64);
|
|
||||||
cel->eld[index].account_id = atoi(row[2]);
|
|
||||||
cel->eld[index].status = atoi(row[3]);
|
|
||||||
strn0cpy(cel->eld[index].charactername,row[4],64);
|
|
||||||
strn0cpy(cel->eld[index].targetname,row[5],64);
|
|
||||||
sprintf(cel->eld[index].timestamp,"%s",row[6]);
|
|
||||||
strn0cpy(cel->eld[index].descriptiontype,row[7],64);
|
|
||||||
strn0cpy(cel->eld[index].details,row[8],128);
|
|
||||||
cel->eventid = eventid;
|
|
||||||
cel->count = index + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load child objects for a world container (i.e., forge, bag dropped to ground, etc)
|
// Load child objects for a world container (i.e., forge, bag dropped to ground, etc)
|
||||||
void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQ::ItemInstance* container)
|
void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQ::ItemInstance* container)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,7 +23,6 @@ class Petition;
|
|||||||
class Spawn2;
|
class Spawn2;
|
||||||
class SpawnGroupList;
|
class SpawnGroupList;
|
||||||
class Trap;
|
class Trap;
|
||||||
struct CharacterEventLog_Struct;
|
|
||||||
struct Door;
|
struct Door;
|
||||||
struct ExtendedProfile_Struct;
|
struct ExtendedProfile_Struct;
|
||||||
struct NPCType;
|
struct NPCType;
|
||||||
@ -551,7 +550,6 @@ public:
|
|||||||
* REALLY HAS NO BETTER SECTION
|
* REALLY HAS NO BETTER SECTION
|
||||||
*/
|
*/
|
||||||
bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
|
bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
|
||||||
void GetEventLogs(const char* name,char* target,uint32 account_id=0,uint8 eventid=0,char* detail=0,char* timestamp=0, CharacterEventLog_Struct* cel=0);
|
|
||||||
uint32 GetKarma(uint32 acct_id);
|
uint32 GetKarma(uint32 acct_id);
|
||||||
void UpdateKarma(uint32 acct_id, uint32 amount);
|
void UpdateKarma(uint32 acct_id, uint32 amount);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user