Merge branch 'RunQueryToDatabaseQuery_database' of https://github.com/addtheice/Server into DBQuery

This commit is contained in:
KimLS
2014-08-10 13:23:09 -07:00
12 changed files with 2639 additions and 2054 deletions
+2 -4
View File
@@ -916,8 +916,7 @@ void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
if (!inst || !inst->GetItem())
continue;
std::string slot;
StringFormat(slot, "Slot %d: %s (%d)", it->first, it->second->GetItem()->Name, (inst->GetCharges() <= 0) ? 1 : inst->GetCharges());
std::string slot = StringFormat("Slot %d: %s (%d)", it->first, it->second->GetItem()->Name, (inst->GetCharges() <= 0) ? 1 : inst->GetCharges());
std::cout << slot << std::endl;
dumpBagContents(inst, &it);
@@ -936,8 +935,7 @@ void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
if (!baginst || !baginst->GetItem())
continue;
std::string subSlot;
StringFormat(subSlot, " Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
std::string subSlot = StringFormat(" Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
+26 -19
View File
@@ -38,8 +38,9 @@
// original source:
// https://github.com/facebook/folly/blob/master/folly/String.cpp
//
void vStringFormat(std::string& output, const char* format, va_list args)
const std::string vStringFormat(const char* format, va_list args)
{
std::string output;
va_list tmpargs;
va_copy(tmpargs,args);
@@ -48,11 +49,8 @@ void vStringFormat(std::string& output, const char* format, va_list args)
if (characters_used < 0) {
// Looks like we have an invalid format string.
// error out.
std::string errorMessage("Invalid format string; snprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
// return empty string.
return "";
}
else if ((unsigned int)characters_used > output.capacity()) {
output.resize(characters_used+1);
@@ -62,12 +60,10 @@ void vStringFormat(std::string& output, const char* format, va_list args)
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. Still, error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
// could have by this point. Still, return empty string;
return "";
}
return std::move(output);
}
else {
output.resize(characters_used + 1);
@@ -78,24 +74,23 @@ void vStringFormat(std::string& output, const char* format, va_list args)
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. still error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
// could have by this point. Still, return empty string;
return "";
}
return std::move(output);
}
}
void StringFormat(std::string& output, const char* format, ...)
const std::string StringFormat(const char* format, ...)
{
va_list args;
va_start(args, format);
vStringFormat(output,format,args);
std::string output = vStringFormat(format,args);
va_end(args);
return std::move(output);
}
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
@@ -384,3 +379,15 @@ std::string EscapeString(const std::string &s) {
return ret;
}
bool isAlphaNumeric(const char *text)
{
for (unsigned int charIndex=0; charIndex<strlen(text); charIndex++) {
if ((text[charIndex] < 'a' || text[charIndex] > 'z') &&
(text[charIndex] < 'A' || text[charIndex] > 'Z') &&
(text[charIndex] < '0' || text[charIndex] > '9'))
return false;
}
return true;
}
+5 -2
View File
@@ -19,11 +19,12 @@
#include <sstream>
#include <vector>
#include <cstdarg>
#include <string.h>
#include "types.h"
void vStringFormat(std::string& output, const char* format, va_list args);
void StringFormat(std::string& output, const char* format, ...);
const std::string vStringFormat(const char* format, va_list args);
const std::string StringFormat(const char* format, ...);
std::string EscapeString(const std::string &s);
const char *MakeLowerString(const char *source);
@@ -51,4 +52,6 @@ char *RemoveApostrophes(const char *s);
std::vector<std::string> SplitString(const std::string &s, char delim);
bool isAlphaNumeric(const char *text);
#endif
+1381 -2000
View File
File diff suppressed because it is too large Load Diff
+17 -3
View File
@@ -130,7 +130,7 @@ public:
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
uint32 GetAccountIDByChar(uint32 char_id);
uint32 GetAccountIDByName(const char* accname, int16* status = 0, uint32* lsid = 0);
uint32 GetGuildDBIDByCharID(uint32 char_id);
uint32 GetGuildIDByCharID(uint32 char_id);
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
void GetCharName(uint32 char_id, char* name);
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0,float* oX = 0, float* oY = 0, float* oZ = 0);
@@ -207,6 +207,7 @@ public:
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
GroupLeadershipAA_Struct* GLAA = nullptr);
void ClearGroupLeader(uint32 gid = 0);
/*
* Raids
@@ -223,7 +224,7 @@ public:
bool SetVariable(const char* varname, const char* varvalue);
bool LoadVariables();
uint32 LoadVariables_MQ(char** query);
bool LoadVariables_result(MYSQL_RES* result);
bool LoadVariables_result(MySQLRequestResult results);
/*
* General Queries
@@ -262,7 +263,20 @@ private:
uint32 varcache_max;
VarCache_Struct** varcache_array;
uint32 varcache_lastupdate;
/*
* Groups, utility methods.
*/
void ClearAllGroupLeaders();
void ClearAllGroups();
/*
* Raid, utility methods.
*/
void ClearAllRaids();
void ClearAllRaidDetails();
};
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap);
#endif
+14 -14
View File
@@ -237,7 +237,7 @@ std::string EmuConstants::InventorySubName(int16 sub) {
return "Unknown Sub";
std::string ret_str;
StringFormat(ret_str, "Container %i", (sub + 1)); // zero-based index..but, count starts at one
ret_str = StringFormat("Container %i", (sub + 1)); // zero-based index..but, count starts at one
return ret_str;
}
@@ -250,7 +250,7 @@ std::string EmuConstants::InventoryAugName(int16 aug) {
return "Unknown Aug";
std::string ret_str;
StringFormat(ret_str, "Augment %i", (aug + 1)); // zero-based index..but, count starts at one
ret_str = StringFormat("Augment %i", (aug + 1)); // zero-based index..but, count starts at one
return ret_str;
}
@@ -929,7 +929,7 @@ uint64 EQLimits::PossessionsBitmask(uint32 version) {
/*Underfoot*/ 0x000000027FFFFFFF,
/*RoF*/ 0x00000003FFFFFFFF,
/*RoF2*/ 0,
/*NPC*/ 0,
/*Merc*/ 0,
/*Bot*/ 0,
@@ -950,7 +950,7 @@ uint64 EQLimits::EquipmentBitmask(uint32 version) {
/*Underfoot*/ 0x00000000007FFFFF,
/*RoF*/ 0x00000000007FFFFF,
/*RoF2*/ 0,
/*NPC*/ 0,
/*Merc*/ 0,
/*Bot*/ 0,
@@ -971,7 +971,7 @@ uint64 EQLimits::GeneralBitmask(uint32 version) {
/*Underfoot*/ 0x000000007F800000,
/*RoF*/ 0x00000001FF800000,
/*RoF2*/ 0,
/*NPC*/ 0,
/*Merc*/ 0,
/*Bot*/ 0,
@@ -992,7 +992,7 @@ uint64 EQLimits::CursorBitmask(uint32 version) {
/*Underfoot*/ 0x0000000200000000,
/*RoF*/ 0x0000000200000000,
/*RoF2*/ 0,
/*NPC*/ 0,
/*Merc*/ 0,
/*Bot*/ 0,
@@ -1013,13 +1013,13 @@ bool EQLimits::AllowsEmptyBagInBag(uint32 version) {
/*Underfoot*/ Underfoot::limits::ALLOWS_EMPTY_BAG_IN_BAG,
/*RoF*/ RoF::limits::ALLOWS_EMPTY_BAG_IN_BAG,
/*RoF2*/ false,
/*NPC*/ false,
/*Merc*/ false,
/*Bot*/ false,
/*Pet*/ false
};
return false; // not implemented
//return local[ValidateMobVersion(version)];
}
@@ -1035,7 +1035,7 @@ uint16 EQLimits::ItemCommonSize(uint32 version) {
/*Underfoot*/ EmuConstants::ITEM_COMMON_SIZE,
/*RoF*/ EmuConstants::ITEM_COMMON_SIZE,
/*RoF2*/ 0,
/*NPC*/ EmuConstants::ITEM_COMMON_SIZE,
/*Merc*/ EmuConstants::ITEM_COMMON_SIZE,
/*Bot*/ EmuConstants::ITEM_COMMON_SIZE,
@@ -1055,7 +1055,7 @@ uint16 EQLimits::ItemContainerSize(uint32 version) {
/*Underfoot*/ EmuConstants::ITEM_CONTAINER_SIZE,
/*RoF*/ EmuConstants::ITEM_CONTAINER_SIZE,
/*RoF2*/ 0,
/*NPC*/ EmuConstants::ITEM_CONTAINER_SIZE,
/*Merc*/ EmuConstants::ITEM_CONTAINER_SIZE,
/*Bot*/ EmuConstants::ITEM_CONTAINER_SIZE,
@@ -1075,7 +1075,7 @@ bool EQLimits::CoinHasWeight(uint32 version) {
/*Underfoot*/ Underfoot::limits::COIN_HAS_WEIGHT,
/*RoF*/ RoF::limits::COIN_HAS_WEIGHT,
/*RoF2*/ true,
/*NPC*/ true,
/*Merc*/ true,
/*Bot*/ true,
@@ -1095,7 +1095,7 @@ uint32 EQLimits::BandoliersCount(uint32 version) {
/*Underfoot*/ EmuConstants::BANDOLIERS_COUNT,
/*RoF*/ EmuConstants::BANDOLIERS_COUNT,
/*RoF2*/ 0,
/*NPC*/ NOT_USED,
/*Merc*/ NOT_USED,
/*Bot*/ NOT_USED,
@@ -1115,7 +1115,7 @@ uint32 EQLimits::BandolierSize(uint32 version) {
/*Underfoot*/ EmuConstants::BANDOLIER_SIZE,
/*RoF*/ EmuConstants::BANDOLIER_SIZE,
/*RoF2*/ 0,
/*NPC*/ NOT_USED,
/*Merc*/ NOT_USED,
/*Bot*/ NOT_USED,
@@ -1135,7 +1135,7 @@ uint32 EQLimits::PotionBeltSize(uint32 version) {
/*Underfoot*/ EmuConstants::POTION_BELT_SIZE,
/*RoF*/ EmuConstants::POTION_BELT_SIZE,
/*RoF2*/ 0,
/*NPC*/ NOT_USED,
/*Merc*/ NOT_USED,
/*Bot*/ NOT_USED,
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -33,9 +33,7 @@ void log_message(LogType type, const char *fmt, ...) {
}
void log_messageVA(LogType type, const char *fmt, va_list args) {
std::string prefix_buffer;
StringFormat(prefix_buffer, "[%s] ", log_type_info[type].name);
std::string prefix_buffer = StringFormat("[%s] ", log_type_info[type].name);
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args);
}