- Fix #533 - Group support for DoF, fixed /acceptinvite and group member display

- Fix #541 - Support for world server to use non-3306 port for mysql by using port=3307 in world_db.ini
- Fix #540 - Added GetDifficulty(Spawn) command.  No longer do spawns have a "encounter_level" all translated to "difficulty"
- HateList now no longer allows negative hate from deaggro
- more protection on player_quests to avoid crash
This commit is contained in:
Emagi 2023-09-23 16:12:04 -04:00
parent a793c71f51
commit 523e98c2c5
24 changed files with 89 additions and 65 deletions

View file

@ -434,7 +434,7 @@ void Commands::Command_Bot_Create(Client* client, Seperator* sep) {
bot->SetAdventureClass(advClass);
bot->SetLevel(client->GetPlayer()->GetLevel());
bot->SetName(name.c_str());
bot->SetEncounterLevel(6);
bot->SetDifficulty(6);
bot->size = 32;
if (bot->GetTotalHP() == 0) {
bot->SetTotalHP(25 * bot->GetLevel() + 1);
@ -541,7 +541,7 @@ void Commands::Command_Bot_Spawn(Client* client, Seperator* sep) {
bot->SetLocation(client->GetPlayer()->GetLocation());
bot->SetInitialState(16512);
bot->SetLevel(client->GetPlayer()->GetLevel());
bot->SetEncounterLevel(6);
bot->SetDifficulty(6);
bot->size = 32;
if (bot->GetTotalHP() == 0) {
bot->SetTotalHP(25 * bot->GetLevel() + 1);

View file

@ -332,8 +332,8 @@ bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const c
break;
}
case SPAWN_SET_VALUE_DIFFICULTY:{
sprintf(tmp, "%i", target->GetEncounterLevel());
target->SetEncounterLevel(val, send_update);
sprintf(tmp, "%i", target->GetDifficulty());
target->SetDifficulty(val, send_update);
break;
}
case SPAWN_SET_VALUE_MODEL_TYPE:{
@ -1007,7 +1007,7 @@ bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const c
break;
}
case SPAWN_SET_VALUE_DIFFICULTY:{
target->SetEncounterLevel(val, send_update);
target->SetDifficulty(val, send_update);
break;
}
case SPAWN_SET_VALUE_MODEL_TYPE:{
@ -3359,7 +3359,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
break;
}
case COMMAND_GROUP_ACCEPT_INVITE: {
if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
if (result == 0)
@ -4519,7 +4519,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
spawn->SetTotalHP(0);
spawn->SetPower(0);
spawn->SetTotalPower(0);
spawn->SetEncounterLevel(0);
spawn->SetDifficulty(0);
spawn->SetTargetable(0);
spawn->SetSogaModelType(0);
spawn->SetCollisionRadius(19);
@ -4539,7 +4539,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
spawn->SetLevel(atoi(sep->arg[3]));
spawn->SetName(sep->arg[4]);
if(sep->arg[5][0] && sep->IsNumber(5))
spawn->SetEncounterLevel(atoi(sep->arg[5]));
spawn->SetDifficulty(atoi(sep->arg[5]));
if(sep->arg[6][0] && sep->IsNumber(6))
spawn->size = atoi(sep->arg[6]);
if(spawn->GetTotalHP() == 0){
@ -4715,7 +4715,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
client->Message(CHANNEL_COLOR_YELLOW, "Respawn Time: %u (sec), X: %f, Y: %f, Z: %f Heading: %f", spawn->GetRespawnTime(), spawn->GetX(), spawn->GetY(), spawn->GetZ(), spawn->GetHeading());
client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
if (spawn->IsEntity()) {
@ -4753,7 +4753,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
details += "Level: " + to_string(spawn->GetLevel()) + "\n";
details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";

View file

@ -29,7 +29,7 @@ extern World world;
GroundSpawn::GroundSpawn(){
packet_num = 0;
appearance.encounter_level = 0;
appearance.difficulty = 0;
spawn_type = 2;
appearance.pos.state = 129;
number_harvests = 0;

View file

@ -3145,6 +3145,15 @@ int EQ2Emu_lua_GetLevel(lua_State* state) {
return 0;
}
int EQ2Emu_lua_GetDifficulty(lua_State* state) {
Spawn* spawn = lua_interface->GetSpawn(state);
if (spawn) {
lua_interface->SetInt32Value(state, spawn->GetDifficulty());
return 1;
}
return 0;
}
int EQ2Emu_lua_GetCurrentPower(lua_State* state) {
if (!lua_interface)
return 0;

View file

@ -79,6 +79,7 @@ int EQ2Emu_lua_SetQuestYellow(lua_State* state);
//Gets
int EQ2Emu_lua_GetLevel(lua_State* state);
int EQ2Emu_lua_GetDifficulty(lua_State* state);
int EQ2Emu_lua_GetCurrentHP(lua_State* state);
int EQ2Emu_lua_GetMaxHP(lua_State* state);
int EQ2Emu_lua_GetMaxHPBase(lua_State* state);

View file

@ -942,6 +942,7 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
lua_register(state, "GetDistance", EQ2Emu_lua_GetDistance);
lua_register(state, "GetHeading", EQ2Emu_lua_GetHeading);
lua_register(state, "GetLevel", EQ2Emu_lua_GetLevel);
lua_register(state, "GetDifficulty", EQ2Emu_lua_GetDifficulty);
lua_register(state, "GetHP", EQ2Emu_lua_GetCurrentHP);
lua_register(state, "GetMaxHP", EQ2Emu_lua_GetMaxHP);
lua_register(state, "GetMaxHPBase", EQ2Emu_lua_GetMaxHPBase);

View file

@ -234,8 +234,13 @@ void Brain::AddHate(Entity* entity, sint32 hate) {
// Lock the hate list, we are altering the list so use write lock
MHateList.writelock(__FUNCTION__, __LINE__);
if (m_hatelist.count(entity->GetID()) > 0)
if (m_hatelist.count(entity->GetID()) > 0) {
m_hatelist[entity->GetID()] += hate;
// take into consideration that 0 or negative hate is not valid, we need to properly reset the value
if(m_hatelist[entity->GetID()] < 1) {
m_hatelist[entity->GetID()] = 1;
}
}
else
m_hatelist.insert(std::pair<int32, sint32>(entity->GetID(), hate));

View file

@ -31,7 +31,7 @@ Object::Object(){
packet_num = 0;
appearance.activity_status = 64;
appearance.pos.state = 1;
appearance.encounter_level = 0;
appearance.difficulty = 0;
spawn_type = 2;
m_deviceID = 0;
}

View file

@ -3892,12 +3892,12 @@ float Player::CalculateXP(Spawn* victim){
float total = multiplier * 8;
LogWrite(PLAYER__DEBUG, 5, "XP", "Multiplier * 8 = %.2f", total);
if(victim->GetEncounterLevel() > 6) { // no need to multiply by 1 if this is a normal mob
total *= (victim->GetEncounterLevel() - 5);
if(victim->GetDifficulty() > 6) { // no need to multiply by 1 if this is a normal mob
total *= (victim->GetDifficulty() - 5);
LogWrite(PLAYER__DEBUG, 5, "XP", "Encounter > 6, total = %.2f", total);
}
else if(victim->GetEncounterLevel() <= 5) {
total /= (7 - victim->GetEncounterLevel()); //1 down mobs are worth half credit, 2 down worth .25, etc
else if(victim->GetDifficulty() <= 5) {
total /= (7 - victim->GetDifficulty()); //1 down mobs are worth half credit, 2 down worth .25, etc
LogWrite(PLAYER__DEBUG, 5, "XP", "Encounter <= 5, total = %.2f", total);
}
@ -5500,7 +5500,6 @@ void Player::SetGroupInformation(PacketStruct* packet){
member = info->member;
if (member && member->GetZone() == GetZone()) {
packet->setSubstructDataByName("group_members", "unknown3", 1, x);
packet->setSubstructDataByName("group_members", "spawn_id", GetIDWithPlayerSpawn(member), x);
if (member->HasPet()) {
@ -5547,11 +5546,13 @@ void Player::SetGroupInformation(PacketStruct* packet){
det_count = 255;
}
packet->setSubstructDataByName("group_members", "curse_count", det_count, x);
packet->setSubstructDataByName("group_members", "zone_status", 1, x);
}
else {
packet->setSubstructDataByName("group_members", "unknown3", 2, x);
packet->setSubstructDataByName("group_members", "pet_id", 0xFFFFFFFF, x);
//packet->setSubstructDataByName("group_members", "unknown5", 1, x, 1); // unknown5 > 1 = name is blue
packet->setSubstructDataByName("group_members", "zone_status", 2, x);
}
packet->setSubstructDataByName("group_members", "name", info->name.c_str(), x);

View file

@ -36,7 +36,7 @@ Sign::Sign(){
widget_y = 0;
widget_z = 0;
appearance.pos.state = 1;
appearance.encounter_level = 0;
appearance.difficulty = 0;
spawn_type = 2;
appearance.activity_status = 64;
sign_type = 0;

View file

@ -58,7 +58,7 @@ Spawn::Spawn(){
memset(&appearance, 0, sizeof(AppearanceData));
memset(&basic_info, 0, sizeof(BasicInfoStruct));
appearance.pos.state = 0x4080;
appearance.encounter_level =6;
appearance.difficulty = 6;
size = 32;
appearance.pos.collision_radius = 32;
id = Spawn::NextID();
@ -2375,7 +2375,7 @@ void Spawn::InitializeInfoPacketData(Player* spawn, PacketStruct* packet) {
packet->setDataByName("effective_level", IsEntity() && ((Entity*)this)->GetInfoStruct()->get_effective_level() != 0 ? (int8)((Entity*)this)->GetInfoStruct()->get_effective_level() : (int8)GetLevel());
packet->setDataByName("level", (int8)GetLevel());
packet->setDataByName("unknown4", (int8)GetLevel());
packet->setDataByName("difficulty", appearance.encounter_level); //6);
packet->setDataByName("difficulty", GetDifficulty()); //6);
packet->setDataByName("unknown6", 1);
packet->setDataByName("heroic_flag", appearance.heroic_flag);
packet->setDataByName("class", appearance.adventure_class);
@ -2609,7 +2609,7 @@ void Spawn::InitializeInfoPacketData(Player* spawn, PacketStruct* packet) {
if (appearance.icon == 0) {
if (appearance.attackable == 1)
appearance.icon = 0;
else if (appearance.encounter_level > 0)
else if (GetDifficulty() > 0)
appearance.icon = 4;
else
appearance.icon = 6;

View file

@ -486,8 +486,8 @@ public:
void SetID(int32 in_id){
Set(&id, in_id);
}
void SetEncounterLevel(int8 enc_level, bool setUpdateFlags = true){
SetInfo(&appearance.encounter_level, enc_level, setUpdateFlags);
void SetDifficulty(int8 difficulty, bool setUpdateFlags = true){
SetInfo(&appearance.difficulty, difficulty, setUpdateFlags);
}
virtual void SetLevel(int16 level, bool setUpdateFlags = true){
SetInfo(&appearance.level, level, setUpdateFlags);
@ -673,8 +673,8 @@ public:
float GetDistance(Spawn* spawn, float x1, float y1, float z1, bool includeRadius=true);
float CalculateRadius(Spawn* target);
int8 GetEncounterLevel(){
return appearance.encounter_level;
int8 GetDifficulty(){
return appearance.difficulty;
}
sint32 GetTotalPower();
sint32 GetPower();

View file

@ -505,8 +505,14 @@ void ClientPacketFunctions::SendItemCreationUI(Client* client, Recipe* recipe) {
packet->setArrayDataByName("item_name", item->name.c_str(), i);
packet->setArrayDataByName("item_icon", item->details.icon, i);
if(client->GetVersion() < 860)
packet->setItemArrayDataByName("item", item, client->GetPlayer(), i, 0, -1);
if(client->GetVersion() < 860) {
char item_slot_name[64];
snprintf(item_slot_name,64,"item_%u",i);
packet->setItemByName(item_slot_name, item, client->GetPlayer(), 0, 5, true, true);
//packet->setItemArrayDataByName("item", item, client->GetPlayer(), i, 0, -1);
}
else if (client->GetVersion() < 1193)
packet->setItemArrayDataByName("item", item, client->GetPlayer(), i);
else
@ -577,9 +583,9 @@ void ClientPacketFunctions::SendItemCreationUI(Client* client, Recipe* recipe) {
}
//packet->PrintPacket();
packet->PrintPacket();
EQ2Packet* outapp = packet->serialize();
//DumpPacket(outapp);
DumpPacket(outapp);
client->QueuePacket(outapp);
safe_delete(packet);
}

View file

@ -41,7 +41,7 @@ Widget::Widget(){
linked_spawn = 0;
linked_spawn_id = 0;
appearance.pos.state = 1;
appearance.encounter_level = 0;
appearance.difficulty = 0;
spawn_type = 2;
appearance.activity_status = 64;
include_location = true;

View file

@ -980,7 +980,7 @@ void WorldDatabase::LoadNPCs(ZoneServer* zone){
npc->appearance.min_level = atoi(row[2]);
npc->appearance.max_level = atoi(row[3]);
npc->appearance.level = atoi(row[2]);
npc->appearance.encounter_level = atoi(row[4]);
npc->appearance.difficulty = atoi(row[4]);
npc->appearance.race = atoi(row[5]);
npc->appearance.model_type = atoi(row[6]);
npc->appearance.soga_model_type = atoi(row[62]);
@ -3478,7 +3478,7 @@ bool WorldDatabase::SaveSpawnInfo(Spawn* spawn){
if(spawn->IsNPC()){
query.RunQuery2(Q_INSERT, "insert into spawn_npcs (spawn_id, min_level, max_level, enc_level, class_, gender, min_group_size, max_group_size, hair_type_id, facial_hair_type_id, wing_type_id, chest_type_id, legs_type_id, soga_hair_type_id, soga_facial_hair_type_id, soga_model_type, heroic_flag, action_state, mood_state, initial_state, activity_status, hide_hood, emote_state) values(%u, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)",
spawn->GetDatabaseID(), spawn->GetLevel(), spawn->GetLevel(), spawn->appearance.encounter_level, spawn->GetAdventureClass(), spawn->GetGender(), 0, 0, ((NPC*)spawn)->features.hair_type, ((NPC*)spawn)->features.hair_face_type,
spawn->GetDatabaseID(), spawn->GetLevel(), spawn->GetLevel(), spawn->GetDifficulty(), spawn->GetAdventureClass(), spawn->GetGender(), 0, 0, ((NPC*)spawn)->features.hair_type, ((NPC*)spawn)->features.hair_face_type,
((NPC*)spawn)->features.wing_type, ((NPC*)spawn)->features.chest_type, ((NPC*)spawn)->features.legs_type, ((NPC*)spawn)->features.soga_hair_type, ((NPC*)spawn)->features.soga_hair_face_type, spawn->appearance.soga_model_type, spawn->appearance.heroic_flag, spawn->GetActionState(), spawn->GetMoodState(), spawn->GetInitialState(), spawn->GetActivityStatus(), spawn->appearance.hide_hood, spawn->appearance.emote_state);
}
else if(spawn->IsObject()){
@ -3499,7 +3499,7 @@ bool WorldDatabase::SaveSpawnInfo(Spawn* spawn){
else{
if(spawn->IsNPC()){
query.RunQuery2(Q_UPDATE, "update spawn_npcs, spawn set name='%s', min_level=%i, max_level=%i, enc_level=%i, race=%i, model_type=%i, class_=%i, gender=%i, show_name=%i, attackable=%i, show_level=%i, targetable=%i, show_command_icon=%i, display_hand_icon=%i, hair_type_id=%i, facial_hair_type_id=%i, wing_type_id=%i, chest_type_id=%i, legs_type_id=%i, soga_hair_type_id=%i, soga_facial_hair_type_id=%i, soga_model_type=%i, size=%i, hp=%u, heroic_flag=%i, power=%u, collision_radius=%i, command_primary=%u, command_secondary=%u, visual_state=%i, action_state=%i, mood_state=%i, initial_state=%i, activity_status=%i, alignment=%i, faction_id=%u, hide_hood=%i, emote_state=%i, suffix ='%s', prefix='%s', last_name='%s', merchant_min_level = %u, merchant_max_level = %u where spawn_npcs.spawn_id = spawn.id and spawn.id = %u",
name.c_str(), spawn->GetLevel(), spawn->GetLevel(), spawn->appearance.encounter_level, spawn->GetRace(), spawn->GetModelType(),
name.c_str(), spawn->GetLevel(), spawn->GetLevel(), spawn->GetDifficulty(), spawn->GetRace(), spawn->GetModelType(),
spawn->GetAdventureClass(), spawn->GetGender(), spawn->appearance.display_name, spawn->appearance.attackable, spawn->appearance.show_level, spawn->appearance.targetable, spawn->appearance.show_command_icon, spawn->appearance.display_hand_icon, ((NPC*)spawn)->features.hair_type,
((NPC*)spawn)->features.hair_face_type, ((NPC*)spawn)->features.wing_type, ((NPC*)spawn)->features.chest_type, ((NPC*)spawn)->features.legs_type, ((NPC*)spawn)->features.soga_hair_type, ((NPC*)spawn)->features.soga_hair_face_type, spawn->appearance.soga_model_type, spawn->GetSize(),
spawn->GetTotalHP(), spawn->appearance.heroic_flag, spawn->GetTotalPower(), spawn->GetCollisionRadius(), spawn->GetPrimaryCommandListID(),
@ -6781,7 +6781,7 @@ bool WorldDatabase::LoadNPC(ZoneServer* zone, int32 spawn_id) {
npc->appearance.min_level = result.GetInt8(2);
npc->appearance.max_level = result.GetInt8(3);
npc->appearance.level = result.GetInt8(2);
npc->appearance.encounter_level = result.GetInt8(4);
npc->appearance.difficulty = result.GetInt8(4);
npc->appearance.race = result.GetInt8(5);
npc->appearance.model_type = result.GetInt16(6);
npc->appearance.soga_model_type = result.GetInt16(62);

View file

@ -2439,7 +2439,7 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
LogWrite(CCLIENT__DEBUG, 5, "Client", "quest_id = %u", id);
bool tracked = packet->getType_int8_ByName("quest_tracked_0", i) == 1 ? true : false;
GetPlayer()->MPlayerQuests.writelock(__FUNCTION__, __LINE__);
if (player->player_quests.count(id) > 0) {
if (player->player_quests.count(id) > 0 && player->player_quests[id]) {
player->player_quests[id]->SetTracked(tracked);
player->player_quests[id]->SetSaveNeeded(true);
}
@ -6190,7 +6190,7 @@ void Client::SetPlayerQuest(Quest* quest, map<int32, int32>* progress) {
void Client::AddPlayerQuest(Quest* quest, bool call_accepted, bool send_packets) {
bool lockCleared = false;
GetPlayer()->MPlayerQuests.writelock(__FUNCTION__, __LINE__);
if (player->player_quests.count(quest->GetQuestID()) > 0) {
if (player->player_quests.count(quest->GetQuestID()) > 0 && player->player_quests[quest->GetQuestID()]) {
if (player->player_quests[quest->GetQuestID()]->GetQuestFlags() > 0)
quest->SetQuestFlags(player->player_quests[quest->GetQuestID()]->GetQuestFlags());
int32 questID = quest->GetQuestID();
@ -6234,7 +6234,7 @@ void Client::RemovePlayerQuest(int32 id, bool send_update, bool delete_quest) {
if (current_quest_id == id)
current_quest_id = 0;
GetPlayer()->MPlayerQuests.writelock(__FUNCTION__, __LINE__);
if (player->player_quests.count(id) > 0) {
if (player->player_quests.count(id) > 0 && player->player_quests[id]) {
if (delete_quest) {
player->player_quests[id]->SetDeleted(true);
database.DeleteCharacterQuest(id, GetCharacterID(), player->GetCompletedPlayerQuests()->count(id) > 0);

View file

@ -2765,7 +2765,7 @@ NPC* ZoneServer::AddNPCSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentr
info->set_poison(spawnentry->poison_override);
}
if(spawnentry->difficulty_override > 0){
npc->SetEncounterLevel(spawnentry->difficulty_override, 1);
npc->SetDifficulty(spawnentry->difficulty_override, 1);
}
if (spawnentry->expire_time > 0)
AddSpawnExpireTimer(npc, spawnentry->expire_time, spawnentry->expire_offset);
@ -4805,7 +4805,7 @@ void ZoneServer::KillSpawn(bool spawnListLocked, Spawn* dead, Spawn* killer, boo
((Player*)spawn)->UpdatePlayerStatistic(STAT_PLAYER_TOTAL_NPC_KILLS, 1);
// If this was an epic mob kill send the announcement for this player
if (dead->GetEncounterLevel() >= 10)
if (dead->GetDifficulty() >= 10)
SendEpicMobDeathToGuild((Player*)spawn, dead);
// Clear hostile spells from the players spell queue

View file

@ -54,7 +54,7 @@ DatabaseNew::~DatabaseNew() {
bool DatabaseNew::Connect() {
char line[256], *key, *val;
char host[256], user[64], password[64], database[64];
char host[256], user[64], password[64], database[64], port[64];
bool found_section = false;
FILE *f;
@ -67,6 +67,7 @@ bool DatabaseNew::Connect() {
memset(user, 0, sizeof(user));
memset(password, 0, sizeof(password));
memset(database, 0, sizeof(database));
memset(port, 0, sizeof(port));
while (fgets(line, sizeof(line), f) != NULL) {
if (line[0] == '#' || line[0] == '\n' || line[0] == '\r')
@ -87,6 +88,8 @@ bool DatabaseNew::Connect() {
strncpy(password, val, sizeof(password) - 1);
else if (strncasecmp(line, "database", 8) == 0)
strncpy(database, val, sizeof(database) - 1);
else if (strncasecmp(line, "port", 4) == 0)
strncpy(port, val, sizeof(port) - 1);
}
}
}
@ -111,11 +114,8 @@ bool DatabaseNew::Connect() {
return false;
}
return Connect(host, user, password, database);
}
bool DatabaseNew::Connect(const char *host, const char *user, const char *password, const char *database) {
return Connect(host, user, password, database, 3306);
unsigned int portnum = atoul(port);
return Connect(host, user, password, database, portnum);
}
bool DatabaseNew::Connect(const char *host, const char *user, const char *password, const char *database, unsigned int port) {

View file

@ -15,8 +15,7 @@ public:
const char * GetErrorMsg() {return mysql_error(&mysql);}
bool Connect();
bool Connect(const char *host, const char *user, const char *password, const char *database);
bool Connect(const char *host, const char *user, const char *password, const char *database, unsigned int port);
bool Connect(const char *host, const char *user, const char *password, const char *database, unsigned int port = 3306);
bool Query(const char *query, ...);
bool Select(DatabaseResult *result, const char *query, ...);

View file

@ -216,7 +216,7 @@ struct AppearanceData {
int8 tradeskill_level;
int8 min_level;
int8 max_level;
int8 encounter_level;
int8 difficulty;
int16 visible; // 02 = normal, 15 = shadow
char name[128]; //size around here somewhere
char last_name[64];

View file

@ -87,12 +87,12 @@ Database::Database()
bool Database::Init(bool silentLoad) {
char host[200], user[200], passwd[200], database[200];
int32 port=0;
unsigned int port=0;
bool compression = false;
bool items[6] = {false, false, false, false, false, false};
const char* exampleIni[] = { "[Database]", "host = localhost", "user = root", "password = pass", "database = dbname", "### --- Assure each parameter is on a new line!" };
if(!ReadDBINI(host, user, passwd, database, port, compression, items)) {
if(!ReadDBINI(host, user, passwd, database, &port, &compression, items)) {
//exit(1);
return false;
}

View file

@ -75,7 +75,7 @@ DBcore::~DBcore() {
}
bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, int32& port, bool& compress, bool* items) {
bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, unsigned int* port, bool* compress, bool* items) {
char line[256], * key, * val;
bool on_database_section = false;
FILE* f;
@ -133,15 +133,17 @@ bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, int
strcpy(database, val);
items[3] = true;
}
else if (strcasecmp(key, "port") == 0) {
port = atoi(val);
else if (strcasecmp(key, "port") == 0 && port) {
*port = atoul(val);
items[4] = true;
}
else if (strcasecmp(key, "compression") == 0) {
if (strcasecmp(val, "on") == 0) {
compress = true;
items[5] = true;
LogWrite(DATABASE__INFO, 0, "DBCore", "DB Compression on.");
if(compress) {
*compress = true;
items[5] = true;
LogWrite(DATABASE__INFO, 0, "DBCore", "DB Compression on.");
}
}
}
}

View file

@ -59,7 +59,7 @@ public:
protected:
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, int32 iPort, int32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
bool ReadDBINI(char *host, char *user, char *pass, char *db, int32 &port, bool &compress, bool *items);
bool ReadDBINI(char *host, char *user, char *pass, char *db, unsigned int* port, bool* compress, bool *items);
private:
bool Open(int32* errnum = 0, char* errbuf = 0);

View file

@ -1502,7 +1502,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />
@ -1525,7 +1525,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />
@ -1549,7 +1549,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />
@ -1575,7 +1575,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />
@ -1599,7 +1599,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />
@ -1623,7 +1623,7 @@ to zero and treated like placeholders." />
<Data ElementName="name" Type="char" Size="41" />
<Data ElementName="zone" Type="char" Size="60" />
<Data ElementName="instance" Type="int8" Size="1" />
<Data ElementName="unknown3" Type="int8" Size="1" />
<Data ElementName="zone_status" Type="int8" Size="1" />
<Data ElementName="unknown4" Type="int16" Size="1" />
<Data ElementName="race_id" Type="int8" Size="1" />
<Data ElementName="class_id" Type="int8" Size="1" />