Jump to content

Recommended Posts

Posted

Habe den jail.patch latzte Woche angepasst für Mangos

die aktuelle Ver. findet ihr in SVN under http://svn.assembla.com/svn/jail

wichtig ist nur das ihn die characters_jail.sql neu ein patchen soldetet da sich einiges an der DB geentert hat

bei prolemen benützt bitte diesen Tatet http://getmangos.eu/community/viewtopic.php?id=281 hir in Forum da schaue ich imer wieder rein auch wen ich nicht viel schreibe.

translate mit google

Have the jail.patch latzte weeks adapted for mangoes

the current Ver. finds her in SVN underhttp://svn.assembla.com/svn/jail'> http://svn.assembla.com/svn/jail

important is it only the characters_jail.sql re soldetet patch because some of the DB has geentert

prolemen used to ask these did http://getmangos.eu/community/viewtopic.php?id=281 hir forum because I always look back here even if I do not write much.

  • 38 years later...
Posted

I have made one (called simple jail) but I havent pushed it to my mangos fork at github yet. I don't know if custom stuff is allowed on the network graph or just patches that is useful for the main repo. I can push it and see if the developers want me to take it away and then make a patch for it instead.

Anyway, it's just a simple jail patch, no advanced stuff like auto-unjail etc, so no SQL is needed. If you want one with auto-unjail you can try to update the old jail patch. This one just has two simple commands (.jail and .unjail). I started on it a bit this morning and have only made two commits but I'll continue and complete it now and then push it to github. Try it if you want.

Posted

old jail patch tred to add manually but failed

 
Index: src/game/Chat.cpp
===================================================================
--- src/game/Chat.cpp (Revision 6767)
+++ src/game/Chat.cpp (Arbeitskopie)
@@ -401,6 +401,12 @@
{ "instance", SEC_ADMINISTRATOR, NULL, "", instanceCommandTable },
{ "server", SEC_ADMINISTRATOR, NULL, "", serverCommandTable },

+ // Jail by WarHead
+ { "jail", SEC_MODERATOR, &ChatHandler::HandleJailCommand, "", NULL },
+ { "jailinfo", SEC_PLAYER, &ChatHandler::HandleJailInfoCommand, "", NULL },
+ { "unjail", SEC_MODERATOR, &ChatHandler::HandleUnJailCommand, "", NULL },
+ { "jailreload", SEC_ADMINISTRATOR, &ChatHandler::HandleJailReloadCommand, "", NULL },
+
{ "aura", SEC_ADMINISTRATOR, &ChatHandler::HandleAuraCommand, "", NULL },
{ "unaura", SEC_ADMINISTRATOR, &ChatHandler::HandleUnAuraCommand, "", NULL },
{ "acct", SEC_PLAYER, &ChatHandler::HandleAcctCommand, "", NULL },
Index: src/game/Chat.h
===================================================================
--- src/game/Chat.h (Revision 6767)
+++ src/game/Chat.h (Arbeitskopie)
@@ -376,6 +376,12 @@
bool HandleComeToMeCommand(const char *args);
bool HandleCombatStopCommand(const char *args);

+ // Jail by WarHead
+ bool HandleJailCommand(const char* args);
+ bool HandleJailInfoCommand(const char* args);
+ bool HandleUnJailCommand(const char* args);
+ bool HandleJailReloadCommand(const char* args);
+
//! Development Commands
bool HandleSetValue(const char* args);
bool HandleGetValue(const char* args);
Index: src/game/Language.h
===================================================================
--- src/game/Language.h (Revision 6767)
+++ src/game/Language.h (Arbeitskopie)
@@ -21,6 +21,41 @@

enum MangosStrings
{
+ // Added by WarHead for the Jail
+ LANG_JAIL_YOURE_JAILED = 950, // "You are jailed by %s for %u hour(s)!"
+ LANG_JAIL_REASON = 951, // "%s wrote this as reason: %s"
+ LANG_JAIL_WAS_JAILED = 952, // "%s was jailed by you for %u hour(s)!"
+ LANG_JAIL_YOURE_UNJAILED = 953, // "You was released out of the jail by %s."
+ LANG_JAIL_WAS_UNJAILED = 954, // "You have released %s out of the jail."
+ LANG_JAIL_NOREASON = 955, // "No reason given or reason is < %u chars!"
+ LANG_JAIL_NONAME = 956, // "No name given!"
+ LANG_JAIL_NOTIME = 957, // "No time given!"
+ LANG_JAIL_VALUE = 958, // "The jailtime must be between 1 and %u hours!"
+ LANG_JAIL_CHAR_NOTJAILED = 959, // "The character (%s) is not jailed!"
+ LANG_JAIL_DENIED = 960, // "Command forbidden for jailed characters!"
+ LANG_JAIL_JAILED_H_INFO = 961, // "You have %u hour(s) left in the jail."
+ LANG_JAIL_JAILED_M_INFO = 962, // "You have %u minute(s) left in the jail."
+ LANG_JAIL_NOTJAILED_INFO = 963, // "You're a free woman / man. ;-)"
+ LANG_JAIL_GM_INFO = 964, // "%s was %u times jailed and has %u minute(s) left. Last time jailed by %s. Last reason was: '%s'"
+ LANG_JAIL_GM_NOINFO = 965, // "%s was never jailed."
+ LANG_JAIL_NO_JAIL = 966, // "You can't jail yourself!"
+ LANG_JAIL_NO_UNJAIL = 967, // "You can't unjail yourself!"
+ LANG_JAIL_WARNING = 968, // "Be carefull! Only one more jailtime and your current character will be deleted!"
+ LANG_JAIL_ANNOUNCE1 = 969, // "The character '"
+ LANG_JAIL_ANNOUNCE2 = 970, // "' was jailed for "
+ LANG_JAIL_ANNOUNCE3 = 971, // " hour(s) by the GM character '"
+ LANG_JAIL_ANNOUNCE4 = 972, // "'. The reason is: "
+ LANG_JAIL_RELOAD = 973, // "The jail configuration was reloaded."
+ LANG_JAIL_CONF_LOADED = 974, // ">> Jail config loaded."
+ LANG_JAIL_CONF_ERR1 = 975, // "Can't load jail config! Table empty or missed! Use jail_conf.sql!"
+ LANG_JAIL_CONF_ERR2 = 976, // "Set all jail config settings to default..."
+ LANG_JAIL_CHAR_TELE = 977, // "The Character '%s' (GUID %u) is jailed and teleportet into the jail."
+ LANG_JAIL_CHAR_FREE = 978, // "The Character '%s' (GUID %u) was released out of the jail."
+ LANG_JAIL_WRONG_NAME = 979, // "A character with this name doesn't exists!"
+ LANG_JAIL_WARNING_BAN = 980, // "Be carefull! Only one more jailtime and your account will be banned!"
+ LANG_JAIL_BAN_REASON = 981, // "Max. jailtimes reached!"
+ LANG_JAIL_BAN_BY = 982, // "Robotron"
+
// for chat commands
LANG_SELECT_CHAR_OR_CREATURE = 1,
LANG_SELECT_CREATURE = 2,
Index: src/game/Level0.cpp
===================================================================
--- src/game/Level0.cpp (Revision 6767)
+++ src/game/Level0.cpp (Arbeitskopie)
@@ -30,7 +30,9 @@
#include "AccountMgr.h"
#include "SystemConfig.h"
#include "Util.h"
+#include "math.h"

+
bool ChatHandler::HandleHelpCommand(const char* args)
{
if(!*args)
@@ -60,7 +62,13 @@
}

bool ChatHandler::HandleStartCommand(const char* /*args*/)
-{
+{ // Jail by WarHead
+ if (m_session->GetPlayer()->m_jail_isjailed)
+ {
+ SendSysMessage(LANG_JAIL_DENIED);
+ return true;
+ }
+
Player *chr = m_session->GetPlayer();

if(chr->isInFlight())
@@ -123,6 +131,13 @@
{
Player *player=m_session->GetPlayer();

+ // Jail by WarHead
+ if (player->m_jail_isjailed)
+ {
+ SendSysMessage(LANG_JAIL_DENIED);
+ return true;
+ }
+
// save GM account without delay and output message (testing, etc)
if(m_session->GetSecurity())
{
@@ -205,6 +220,40 @@
return true;
}

+bool ChatHandler::HandleJailInfoCommand(const char* args)
+{
+ time_t localtime;
+ localtime = time(NULL);
+ Player *chr = m_session->GetPlayer();
+
+ if (chr->m_jail_release > 0)
+ {
+ uint32 min_left = (uint32)floor(float(chr->m_jail_release - localtime) / 60);
+
+ if (min_left <= 0)
+ {
+ chr->m_jail_release = 0;
+ chr->_SaveJail();
+ SendSysMessage(LANG_JAIL_NOTJAILED_INFO);
+ return true;
+ }
+ else
+ {
+ if (min_left >= 60) PSendSysMessage(LANG_JAIL_JAILED_H_INFO, (uint32)floor(float(chr->m_jail_release - localtime) / 60 / 60));
+ else PSendSysMessage(LANG_JAIL_JAILED_M_INFO, min_left);
+ PSendSysMessage(LANG_JAIL_REASON, chr->m_jail_gmchar.c_str(), chr->m_jail_reason.c_str());
+
+ return true;
+ }
+ }
+ else
+ {
+ SendSysMessage(LANG_JAIL_NOTJAILED_INFO);
+ return true;
+ }
+ return false;
+}
+
bool ChatHandler::HandleLockAccountCommand(const char* args)
{
if (!*args)

Posted
 
Index: src/game/Level1.cpp
===================================================================
--- src/game/Level1.cpp (Revision 6767)
+++ src/game/Level1.cpp (Arbeitskopie)
@@ -1818,6 +1818,300 @@
return true;
}

+// Jail by WarHead
+bool ChatHandler::HandleJailCommand(const char *args)
+{
+ std::string cname, announce, ban_reason, ban_by;
+ time_t localtime;
+ localtime = time(NULL);
+
+ char *charname = strtok((char*)args, " ");
+ if (charname == NULL)
+ {
+ SendSysMessage(LANG_JAIL_NONAME);
+ return true;
+ } else cname = charname;
+
+ char *timetojail = strtok(NULL, " ");
+ if (timetojail == NULL)
+ {
+ SendSysMessage(LANG_JAIL_NOTIME);
+ return true;
+ }
+
+ uint32 jailtime = (uint32) atoi((char*)timetojail);
+ if (jailtime < 1 || jailtime > objmgr.m_jailconf_max_duration)
+ {
+ PSendSysMessage(LANG_JAIL_VALUE, objmgr.m_jailconf_max_duration);
+ return true;
+ }
+
+ char *reason = strtok(NULL, "\\0");
+ std::string jailreason;
+ if (reason == NULL || strlen((const char*)reason) < objmgr.m_jailconf_min_reason)
+ {
+ PSendSysMessage(LANG_JAIL_NOREASON, objmgr.m_jailconf_min_reason);
+ return true;
+ } else jailreason = reason;
+
+ uint64 GUID = objmgr.GetPlayerGUIDByName(cname.c_str());
+ if (GUID == 0)
+ {
+ SendSysMessage(LANG_JAIL_WRONG_NAME);
+ return true;
+ }
+
+ Player *chr = objmgr.GetPlayer(GUID);
+ if (!chr)
+ {
+ uint32 jail_guid = GUID_LOPART(GUID);
+ std::string jail_char = cname;
+ bool jail_isjailed = true;
+ uint32 jail_release = localtime + (jailtime * 60 * 60);
+ std::string jail_reason = jailreason;
+ uint32 jail_times = 0;
+
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `jail` WHERE `guid`='%u' LIMIT 1", jail_guid);
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ jail_times = 1;
+ }
+ else
+ {
+ Field *fields = result->Fetch();
+ jail_times = fields[4].GetUInt32()+1;
+ }
+
+ uint32 jail_gmacc = m_session->GetAccountId();
+ std::string jail_gmchar = m_session->GetPlayerName();
+
+ CharacterDatabase.BeginTransaction();
+ if (!result) CharacterDatabase.PExecute("INSERT INTO `jail` VALUES
('%u','%s','%u','%s','%u','%u','%s',CURRENT_TIMESTAMP,'%u')", jail_guid, jail_char.c_str(), jail_release, jail_reason.c_str(), jail_times, jail_gmacc, jail_gmchar.c_str(), jailtime);
+ else CharacterDatabase.PExecute("UPDATE `jail` SET `release`='%u',`reason`='%s',`times`='%u',`gmacc`='%u',`gmchar`='%s',`duration`='%u' WHERE `guid`='%u' LIMIT 1", jail_release, jail_reason.c_str(), jail_times, jail_gmacc, jail_gmchar.c_str(), jailtime, jail_guid);
+ CharacterDatabase.CommitTransaction();
+
+ PSendSysMessage(LANG_JAIL_WAS_JAILED, cname.c_str(), jailtime);
+
+ announce = GetMangosString(LANG_JAIL_ANNOUNCE1);
+ announce += cname;
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE2);
+ announce += timetojail;
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE3);
+ announce += m_session->GetPlayerName();
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE4);
+ announce += jail_reason;
+
+ HandleAnnounceCommand(announce.c_str());
+
+ if (result) delete result;
+
+ if ((objmgr.m_jailconf_max_jails == jail_times) && !objmgr.m_jailconf_ban)
+ {
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `characters` WHERE `guid`='%u' LIMIT 1", GUID_LOPART(GUID));
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ PSendSysMessage(LANG_NO_PLAYER, cname.c_str());
+ return true;
+ }
+
+ Field *fields = result->Fetch();
+
+ Player::DeleteFromDB(GUID, fields[1].GetUInt32());
+
+ delete result;
+ }
+ else if ((objmgr.m_jailconf_max_jails == jail_times) && objmgr.m_jailconf_ban)
+ {
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `characters` WHERE `guid`='%u' LIMIT 1", GUID_LOPART(GUID));
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ PSendSysMessage(LANG_NO_PLAYER, cname.c_str());
+ return true;
+ }
+ Field *fields = result->Fetch();
+ uint32 acc_id = fields[1].GetUInt32();
+
+ loginDatabase.BeginTransaction();
+ result = loginDatabase.PQuery("SELECT * FROM `account` WHERE `id`='%u' LIMIT 1", acc_id);
+ loginDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ PSendSysMessage(LANG_NO_PLAYER, cname.c_str());
+ return true;
+ }
+ ban_reason = GetMangosString(LANG_JAIL_BAN_REASON);
+ ban_by = GetMangosString(LANG_JAIL_BAN_BY);
+
+ loginDatabase.BeginTransaction();
+ loginDatabase.PExecute("INSERT IGNORE INTO `account_banned` (`id`,`bandate`,`bannedby`,`banreason`) VALUES
('%u',UNIX_TIMESTAMP,'%s','%s')", acc_id, ban_by.c_str(), ban_reason.c_str());
+ loginDatabase.CommitTransaction();
+
+ delete result;
+ }
+ return true;
+ }
+
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `characters` WHERE `guid`='%u' LIMIT 1", chr->GetGUIDLow());
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ PSendSysMessage(LANG_NO_PLAYER, cname.c_str());
+ return true;
+ }
+
+ Field *fields = result->Fetch();
+
+ if(chr->GetName() == m_session->GetPlayerName())
+ {
+ SendSysMessage(LANG_JAIL_NO_JAIL);
+ delete result;
+ return true;
+ }
+
+ chr->SaveToDB();
+
+ chr->m_jail_guid = fields[0].GetUInt32();
+ chr->m_jail_char = fields[3].GetCppString();
+ chr->m_jail_isjailed = true;
+ chr->m_jail_release = localtime + (jailtime * 60 * 60);
+ chr->m_jail_reason = jailreason;
+ chr->m_jail_times = chr->m_jail_times+1;
+ chr->m_jail_gmacc = m_session->GetAccountId();
+ chr->m_jail_gmchar = m_session->GetPlayerName();
+ chr->m_jail_duration = jailtime;
+
+ chr->_SaveJail();
+
+ PSendSysMessage(LANG_JAIL_WAS_JAILED, fields[3].GetCppString().c_str(), jailtime);
+ ChatHandler(chr).PSendSysMessage(LANG_JAIL_YOURE_JAILED, m_session->GetPlayerName(), jailtime);
+ ChatHandler(chr).PSendSysMessage(LANG_JAIL_REASON, m_session->GetPlayerName(), jailreason.c_str());
+
+ announce = GetMangosString(LANG_JAIL_ANNOUNCE1);
+ announce += fields[3].GetCppString();
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE2);
+ announce += timetojail;
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE3);
+ announce += m_session->GetPlayerName();
+ announce += GetMangosString(LANG_JAIL_ANNOUNCE4);
+ announce += chr->m_jail_reason;
+
+ HandleAnnounceCommand(announce.c_str());
+
+ if (objmgr.m_jailconf_max_jails == chr->m_jail_times)
+ {
+ chr->GetSession()->KickPlayer();
+ chr->DeleteFromDB(fields[0].GetUInt64(), fields[1].GetUInt32());
+ }
+ else if ((objmgr.m_jailconf_max_jails == chr->m_jail_times) && objmgr.m_jailconf_ban)
+ {
+ uint32 acc_id = chr->GetSession()->GetAccountId();
+ ban_reason = GetMangosString(LANG_JAIL_BAN_REASON);
+ ban_by = GetMangosString(LANG_JAIL_BAN_BY);
+
+ loginDatabase.BeginTransaction();
+ loginDatabase.PExecute("INSERT IGNORE INTO `account_banned` (`id`,`bandate`,`bannedby`,`banreason`) VALUES
('%u',UNIX_TIMESTAMP,'%s','%s')", acc_id, ban_by.c_str(), ban_reason.c_str());
+ loginDatabase.CommitTransaction();
+
+ chr->GetSession()->LogoutPlayer(false);
+ }
+ else chr->GetSession()->LogoutPlayer(false);
+
+ delete result;
+ return true;
+}
+
+bool ChatHandler::HandleUnJailCommand(const char *args)
+{
+ char *charname = strtok((char*)args, " ");
+ std::string cname;
+
+ if (charname == NULL) return false;
+ else cname = charname;
+
+ uint64 GUID = objmgr.GetPlayerGUIDByName(cname.c_str());
+ Player *chr = objmgr.GetPlayer(GUID);
+
+ if (chr)
+ {
+ if (chr->GetName() == m_session->GetPlayerName())
+ {
+ SendSysMessage(LANG_JAIL_NO_UNJAIL);
+ return true;
+ }
+
+ if (chr->m_jail_isjailed)
+ {
+ chr->m_jail_isjailed = false;
+ chr->m_jail_release = 0;
+ chr->m_jail_times = chr->m_jail_times-1;
+
+ chr->_SaveJail();
+
+ if (chr->m_jail_times == 0)
+ {
+ CharacterDatabase.BeginTransaction();
+ CharacterDatabase.PQuery("DELETE FROM `jail` WHERE `guid`='%u' LIMIT 1", chr->GetGUIDLow());
+ CharacterDatabase.CommitTransaction();
+ }
+
+ PSendSysMessage(LANG_JAIL_WAS_UNJAILED, cname.c_str());
+ ChatHandler(chr).PSendSysMessage(LANG_JAIL_YOURE_UNJAILED, m_session->GetPlayerName()); 
+ chr->CastSpell(chr,8690,false);
+ //chr->GetSession()->LogoutPlayer(false);
+ } else PSendSysMessage(LANG_JAIL_CHAR_NOTJAILED, cname.c_str());
+ return true;
+ }
+ else
+ {
+ CharacterDatabase.BeginTransaction();
+ QueryResult *jresult = CharacterDatabase.PQuery("SELECT * FROM `jail` WHERE `guid`='%u' LIMIT 1", GUID_LOPART(GUID));
+ CharacterDatabase.CommitTransaction();
+
+ if (!jresult)
+ {
+ PSendSysMessage(LANG_JAIL_CHAR_NOTJAILED, cname.c_str());
+ return true;
+ }
+ else
+ {
+ Field *fields = jresult->Fetch();
+ uint32 jail_times = fields[4].GetUInt32()-1;
+
+ if (jail_times == 0)
+ {
+ CharacterDatabase.BeginTransaction();
+ CharacterDatabase.PQuery("DELETE FROM `jail` WHERE `guid`='%u' LIMIT 1", fields[0].GetUInt32());
+ CharacterDatabase.CommitTransaction();
+ }
+ else
+ {
+ CharacterDatabase.BeginTransaction();
+ CharacterDatabase.PQuery("UPDATE `jail` SET `release`='0',`times`='%u' WHERE `guid`='%u' LIMIT 1", jail_times, fields[0].GetUInt32());
+ CharacterDatabase.CommitTransaction();
+ }
+
+ PSendSysMessage(LANG_JAIL_WAS_UNJAILED, cname.c_str());
+
+ delete jresult;
+ return true;
+ }
+
+ }
+ return true;
+}
+
//Send mail by command
bool ChatHandler::HandleSendMailCommand(const char* args)
{

Posted
 
Index: src/game/Level2.cpp
===================================================================
--- src/game/Level2.cpp (Revision 6767)
+++ src/game/Level2.cpp (Arbeitskopie)
@@ -31,6 +31,8 @@
#include "MapManager.h"
#include "Language.h"
#include "World.h"
+#include "math.h"
+#include "WaypointMovementGenerator.h"
#include "GameEvent.h"
#include "SpellMgr.h"
#include "AccountMgr.h"
@@ -1867,6 +1869,42 @@
SendSysMessage(ss.str().c_str());
}
}
+
+ if (py && strncmp(py, "jail", 4) == 0)
+ {
+ if (target->m_jail_times > 0)
+ {
+ if(target->m_jail_release > 0)
+ {
+ time_t localtime;
+ localtime = time(NULL);
+ uint32 min_left = (uint32)floor(float(target->m_jail_release - localtime) / 60);
+
+ if (min_left <= 0)
+ {
+ target->m_jail_release = 0;
+ target->_SaveJail();
+ PSendSysMessage(LANG_JAIL_GM_INFO, target->m_jail_char.c_str(), target->m_jail_times, 0, target->m_jail_gmchar.c_str(), target->m_jail_reason.c_str());
+ return true;
+ }
+ else
+ {
+ PSendSysMessage(LANG_JAIL_GM_INFO, target->m_jail_char.c_str(), target->m_jail_times, min_left, target->m_jail_gmchar.c_str(), target->m_jail_reason.c_str());
+ return true;
+ }
+ }
+ else
+ {
+ PSendSysMessage(LANG_JAIL_GM_INFO, target->m_jail_char.c_str(), target->m_jail_times, 0, target->m_jail_gmchar.c_str(), target->m_jail_reason.c_str());
+ return true;
+ }
+ }
+ else
+ {
+ PSendSysMessage(LANG_JAIL_GM_NOINFO, target->GetName());
+ return true;
+ }
+ }
return true;
}

Index: src/game/Level3.cpp
===================================================================
--- src/game/Level3.cpp (Revision 6767)
+++ src/game/Level3.cpp (Arbeitskopie)
@@ -58,6 +58,13 @@
return false;
}

+bool ChatHandler::HandleJailReloadCommand(const char* arg)
+{
+ objmgr.LoadJailConf();
+ SendSysMessage(LANG_JAIL_RELOAD);
+ return true;
+}
+
bool ChatHandler::HandleReloadAllCommand(const char*)
{
HandleReloadAreaTriggerTeleportCommand("");
Index: src/game/ObjectAccessor.cpp
===================================================================
--- src/game/ObjectAccessor.cpp (Revision 6767)
+++ src/game/ObjectAccessor.cpp (Arbeitskopie)
@@ -241,8 +241,11 @@
Guard guard(*HashMapHolder<Player*>::GetLock());
HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
HashMapHolder<Player>::MapType::iterator itr = m.begin();
- for(; itr != m.end(); ++itr)
+ for (; itr != m.end(); ++itr)
+ {
+ if (itr->second->m_jail_isjailed) continue; // Prevent jailed players to be saved
itr->second->SaveToDB();
+ }
}

void
Index: src/game/ObjectMgr.cpp
===================================================================
--- src/game/ObjectMgr.cpp (Revision 6767)
+++ src/game/ObjectMgr.cpp (Arbeitskopie)
@@ -5521,6 +5521,70 @@
return ++m_hiPetNumber;
}

+// Loads the jail conf out of the database
+void ObjectMgr::LoadJailConf(void)
+{
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `jail_conf`");
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ sLog.outError(GetMangosStringForDBCLocale(LANG_JAIL_CONF_ERR1));
+ sLog.outError(GetMangosStringForDBCLocale(LANG_JAIL_CONF_ERR2));
+
+ m_jailconf_max_jails = 3;
+ m_jailconf_max_duration = 672;
+ m_jailconf_min_reason = 25;
+ m_jailconf_warn_player = 1;
+
+ m_jailconf_ally_x = -8673.43;
+ m_jailconf_ally_y = 631.795;
+ m_jailconf_ally_z = 96.9406;
+ m_jailconf_ally_o = 2.1785;
+ m_jailconf_ally_m = 0;
+
+ m_jailconf_horde_x = 2179.85;
+ m_jailconf_horde_y = -4763.96;
+ m_jailconf_horde_z = 54.911;
+ m_jailconf_horde_o = 4.44216;
+ m_jailconf_horde_m = 1;
+
+ m_jailconf_ban = 0;
+ m_jailconf_radius = 10;
+
+ return;
+ }
+
+ Field *fields = result->Fetch();
+
+ m_jailconf_max_jails = fields[0].GetUInt32();
+ m_jailconf_max_duration = fields[1].GetUInt32();
+ m_jailconf_min_reason = fields[2].GetUInt32();
+ m_jailconf_warn_player = fields[3].GetUInt32();
+
+ m_jailconf_ally_x = fields[4].GetFloat();
+ m_jailconf_ally_y = fields[5].GetFloat();
+ m_jailconf_ally_z = fields[6].GetFloat();
+ m_jailconf_ally_o = fields[7].GetFloat();
+ m_jailconf_ally_m = fields[8].GetUInt32();
+
+ m_jailconf_horde_x = fields[9].GetFloat();
+ m_jailconf_horde_y = fields[10].GetFloat();
+ m_jailconf_horde_z = fields[11].GetFloat();
+ m_jailconf_horde_o = fields[12].GetFloat();
+ m_jailconf_horde_m = fields[13].GetUInt32();
+
+ m_jailconf_ban = fields[14].GetUInt32();
+ m_jailconf_radius = fields[15].GetUInt32();
+
+ delete result;
+
+ sLog.outString("");
+ sLog.outString(GetMangosStringForDBCLocale(LANG_JAIL_CONF_LOADED));
+ sLog.outString("");
+}
+
void ObjectMgr::LoadCorpses()
{
uint32 count = 0;
Index: src/game/ObjectMgr.h
===================================================================
--- src/game/ObjectMgr.h (Revision 6767)
+++ src/game/ObjectMgr.h (Arbeitskopie)
@@ -543,11 +543,32 @@

void LoadWeatherZoneChances();
void LoadGameTele();
-
- void LoadNpcTextId();
+ void LoadNpcTextId();
void LoadVendors();
void LoadTrainerSpell();

+ // Loads the jail conf out of the database
+ void LoadJailConf(void);
+
+ // Jail Config...
+ uint32 m_jailconf_max_jails; // Jail times when the char will be deleted
+ uint32 m_jailconf_max_duration; // Max. jail duration in hours
+ uint32 m_jailconf_min_reason; // Min. char length of the reason
+ uint32 m_jailconf_warn_player; // Warn player every login if max_jails is nearly reached?
+ float m_jailconf_ally_x; // Coords of the jail for the allies
+ float m_jailconf_ally_y;
+ float m_jailconf_ally_z;
+ float m_jailconf_ally_o;
+ uint32 m_jailconf_ally_m;
+ float m_jailconf_horde_x; // Coords of the jail for the horde
+ float m_jailconf_horde_y;
+ float m_jailconf_horde_z;
+ float m_jailconf_horde_o;
+ uint32 m_jailconf_horde_m;
+ uint32 m_jailconf_ban; // Ban acc if max. jailtimes is reached?
+ uint32 m_jailconf_radius; // Radius in which a jailed char can walk
+
+ 
std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint32 level);

Posted
 
Index: src/game/Player.cpp
===================================================================
--- src/game/Player.cpp (Revision 6767)
+++ src/game/Player.cpp (Arbeitskopie)
@@ -247,6 +247,20 @@

Player::Player (WorldSession *session): Unit()
{
+ // Jail by WarHead
+ m_jail_guid = 0;
+ m_jail_char = "";
+ m_jail_warning = false;
+ m_jail_isjailed = false;
+ m_jail_release = 0;
+ m_jail_times = 0;
+ m_jail_reason = "";
+ m_jail_gmacc = 0;
+ m_jail_gmchar = "";
+ m_jail_lasttime = "";
+ m_jail_duration = 0;
+ // Jail end
+
m_transport = 0;

m_speakTime = 0;
@@ -928,6 +942,66 @@

Unit::Update( p_time );

+ if (m_jail_isjailed)
+ {
+ time_t localtime;
+ localtime = time(NULL);
+ 
+ if (m_jail_release <= localtime)
+ {
+ m_jail_isjailed = false;
+ m_jail_release = 0;
+
+ _SaveJail();
+ 
+ sWorld.SendWorldText(LANG_JAIL_CHAR_FREE, GetName());
+ 
+ CastSpell(this,8690,false);
+
+ return;
+ }
+
+ if (m_team == ALLIANCE)
+ {
+ if (GetDistance(objmgr.m_jailconf_ally_x, objmgr.m_jailconf_ally_y, objmgr.m_jailconf_ally_z) > objmgr.m_jailconf_radius)
+ {
+ TeleportTo(objmgr.m_jailconf_ally_m, objmgr.m_jailconf_ally_x,
+ objmgr.m_jailconf_ally_y, objmgr.m_jailconf_ally_z, objmgr.m_jailconf_ally_o);
+ return;
+ }
+ }
+ else
+ {
+ if (GetDistance(objmgr.m_jailconf_horde_x, objmgr.m_jailconf_horde_y, objmgr.m_jailconf_horde_z) > objmgr.m_jailconf_radius)
+ {
+ TeleportTo(objmgr.m_jailconf_horde_m, objmgr.m_jailconf_horde_x,
+ objmgr.m_jailconf_horde_y, objmgr.m_jailconf_horde_z, objmgr.m_jailconf_horde_o);
+ return;
+ }
+ 
+ }
+ }
+ 
+ if(m_jail_warning == true)
+ {
+ m_jail_warning = false;
+ 
+ if(objmgr.m_jailconf_warn_player == m_jail_times || objmgr.m_jailconf_warn_player <= m_jail_times)
+ {
+ if ((objmgr.m_jailconf_max_jails-1 == m_jail_times-1) && objmgr.m_jailconf_ban-1)
+ {
+ ChatHandler(this).PSendSysMessage(LANG_JAIL_WARNING_BAN, m_jail_times , objmgr.m_jailconf_max_jails-1);
+ }
+ else
+ {
+ ChatHandler(this).PSendSysMessage(LANG_JAIL_WARNING, m_jail_times , objmgr.m_jailconf_max_jails);
+ }
+ 
+ }
+ return;
+ }
+ 
+
// update player only attacks
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
{
@@ -1116,11 +1190,16 @@
}

if (m_deathState == JUST_DIED)
- {
- KillPlayer();
+ { // Prevent death of jailed players
+ if (!m_jail_isjailed) KillPlayer();
+ else
+ {
+ m_deathState = ALIVE;
+ RegenerateAll();
+ }
}

- if(m_nextSave > 0)
+ if(m_nextSave > 0 && !m_jail_isjailed)
{
if(p_time >= m_nextSave)
{
@@ -3558,6 +3637,8 @@
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE receiver = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",guid);
+ CharacterDatabase.PExecute("DELETE FROM `jail` WHERE `guid` = '%u'",guid);
+
CharacterDatabase.CommitTransaction();

//loginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = %d AND realmid = %d", accountId, realmID);
@@ -13788,9 +13869,82 @@
}
}

- _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
+ _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
+ // Loads the jail datas and if jailed it corrects the position to the corresponding jail
+ _LoadJail();
+ 
+return true;
+}

- return true;
+// Loads the jail datas (added by WarHead).
+void Player::_LoadJail(void)
+{
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM `jail` WHERE `guid`='%u' LIMIT 1", GetGUIDLow());
+ CharacterDatabase.CommitTransaction();
+
+ if (!result)
+ {
+ m_jail_isjailed = false;
+ return;
+ }
+
+ Field *fields = result->Fetch();
+ m_jail_warning = true;
+ m_jail_isjailed = true;
+ m_jail_guid = fields[0].GetUInt32();
+ m_jail_char = fields[1].GetString();
+ m_jail_release = fields[2].GetUInt32();
+ m_jail_reason = fields[3].GetString();
+ m_jail_times = fields[4].GetUInt32();
+ m_jail_gmacc = fields[5].GetUInt32();
+ m_jail_gmchar = fields[6].GetString();
+ m_jail_lasttime = fields[7].GetString();
+ m_jail_duration = fields[8].GetUInt32();
+
+ if (m_jail_release == 0)
+ {
+ m_jail_isjailed = false;
+ delete result;
+ return;
+ }
+
+ time_t localtime;
+ localtime = time(NULL);
+
+ if (m_jail_release <= localtime)
+ {
+ m_jail_isjailed = false;
+ m_jail_release = 0;
+
+ _SaveJail();
+
+ sWorld.SendWorldText(LANG_JAIL_CHAR_FREE, GetName());
+
+ CastSpell(this,8690,false);
+
+ delete result;
+ return;
+ }
+
+ if (m_jail_isjailed)
+ {
+ if (m_team == ALLIANCE)
+ {
+ TeleportTo(objmgr.m_jailconf_ally_m, objmgr.m_jailconf_ally_x,
+ objmgr.m_jailconf_ally_y, objmgr.m_jailconf_ally_z, objmgr.m_jailconf_ally_o);
+ }
+ else
+ {
+ TeleportTo(objmgr.m_jailconf_horde_m, objmgr.m_jailconf_horde_x,
+ objmgr.m_jailconf_horde_y, objmgr.m_jailconf_horde_z, objmgr.m_jailconf_horde_o);
+ }
+ 
+ sWorld.SendWorldText(LANG_JAIL_CHAR_TELE, GetName() );
+ }
+ 
+ delete result;
+ 
}

bool Player::isAllowedToLoot(Creature* creature)
@@ -14721,8 +14875,23 @@
/*** SAVE SYSTEM ***/
/*********************************************************/

+// Saves the jail datas (added by WarHead).
+void Player::_SaveJail(void)
+{
+ CharacterDatabase.BeginTransaction();
+ QueryResult *result = CharacterDatabase.PQuery("SELECT `guid` FROM `jail` WHERE `guid`='%u' LIMIT 1", m_jail_guid);
+ if (!result) CharacterDatabase.PExecute("INSERT INTO `jail` VALUES
('%u','%s','%u','%s','%u','%u','%s',CURRENT_TIMESTAMP,'%u')", m_jail_guid, m_jail_char.c_str(), m_jail_release, m_jail_reason.c_str(), m_jail_times, m_jail_gmacc, m_jail_gmchar.c_str(), m_jail_duration);
+ else CharacterDatabase.PExecute("UPDATE `jail` SET `release`='%u',`reason`='%s',`times`='%u',`gmacc`='%u',`gmchar`='%s',`duration`='%u' WHERE `guid`='%u' LIMIT 1", m_jail_release, m_jail_reason.c_str(), m_jail_times, m_jail_gmacc, m_jail_gmchar.c_str(), m_jail_duration, m_jail_guid);
+ CharacterDatabase.CommitTransaction();
+
+ if (result) delete result;
+}
+
void Player::SaveToDB()
{
+ // Jail: Prevent saving of jailed players
+ if (m_jail_isjailed) return;
+
// delay auto save at any saves (manual, in code, or autosave)
m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE);

@@ -15693,7 +15862,7 @@
SetAcceptWhispers(true);
ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON);
}
-
+ 
// announce to player that player he is whispering to is afk
if(rPlayer->isAFK())
ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str());
Index: src/game/Player.h
===================================================================
--- src/game/Player.h (Revision 6767)
+++ src/game/Player.h (Arbeitskopie)
@@ -1899,6 +1899,24 @@

void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage);

+ // Jail by WarHead
+ // ---------------
+ // Char datas...
+ bool m_jail_warning;
+ bool m_jail_isjailed; // Is this player jailed?
+ std::string m_jail_char; // Name of jailed char
+ uint32 m_jail_guid; // guid of the jailed char
+ uint32 m_jail_release; // When is the player a free man/woman?
+ std::string m_jail_reason; // Why was the char jailed?
+ uint32 m_jail_times; // How often was the player jailed?
+ uint32 m_jail_gmacc; // Used GM acc
+ std::string m_jail_gmchar; // Used GM char
+ std::string m_jail_lasttime; // Last jail time
+ uint32 m_jail_duration; // Duration of the jail
+ // Load / save functions...
+ void _LoadJail(void); // Loads the jail datas
+ void _SaveJail(void); // Saves the jail datas
+
/*********************************************************/
/*** FLOOD FILTER SYSTEM ***/
/*********************************************************/
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp (Revision 6767)
+++ src/game/World.cpp (Arbeitskopie)
@@ -1124,6 +1124,9 @@
sLog.outString( "Returning old mails..." );
objmgr.ReturnOrDeleteOldMails(false);

+ // Loads the jail conf out of the database
+ objmgr.LoadJailConf();
+
///- Load and initialize scripts
sLog.outString( "Loading Scripts..." );
objmgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate

Posted

hmm oke got it in but now i got

 
4> Creating library .\\mangosd__Win32_Release\\mangosd.lib and object .\\mangosd__Win32_Release\\mangosd.exp
4>game.lib(World.obj) : error LNK2019: unresolved external symbol "public: void __thiscall ObjectMgr::LoadJailConf(void)" (?LoadJailConf@ObjectMgr@@QAEXXZ) referenced in function "public: void __thiscall World::SetInitialWorldSettings(void)" (?SetInitialWorldSettings@World@@QAEXXZ)
4>game.lib(Level3.obj) : error LNK2001: unresolved external symbol "public: void __thiscall ObjectMgr::LoadJailConf(void)" ([email="?LoadJailConf@ObjectMgr@@QAEXXZ"]?LoadJailConf@ObjectMgr@@QAEXXZ[/email])

something changed?in latest cores?

if i remove lines wrom world.cpp and level3.cpp then it wont load the conf sttings from database

can anyone help me fix it?

  • 2 months later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use