Added ability to disable gate from specific zones. Update SQL.

This commit is contained in:
Devn00b 2022-06-16 17:50:39 -07:00
parent 352024d59a
commit 6484e62cfb
6 changed files with 22 additions and 10 deletions

View file

@ -0,0 +1 @@
ALTER TABLE `zones` ADD COLUMN `can_gate` INT(11) NULL DEFAULT '1' AFTER `can_bind`;

View file

@ -11044,7 +11044,6 @@ int EQ2Emu_lua_GetZoneHolidayFlag(lua_State* state) {
return 0;
}
//devn00b test
int EQ2Emu_lua_SetCanBind(lua_State* state) {
if (!lua_interface)
return 0;
@ -11062,7 +11061,6 @@ int EQ2Emu_lua_GetCanBind(lua_State* state) {
Spawn* player = lua_interface->GetSpawn(state);
ZoneServer* zone = player->GetZone();
if (zone) {
cout << "\n\n-----dev---- We Got zone!\n\n";
lua_interface->SetInt32Value(state, zone->GetCanBind());
return 1;
}

View file

@ -2698,7 +2698,7 @@ void WorldDatabase::LoadZoneInfo(ZoneServer* zone){
Query query;
int32 ruleset_id;
char* escaped = getEscapeString(zone->GetZoneName());
MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, file, description, underworld, safe_x, safe_y, safe_z, min_status, min_level, max_level, instance_type+0, shutdown_timer, zone_motd, default_reenter_time, default_reset_time, default_lockout_time, force_group_to_zone, safe_heading, xp_modifier, ruleset_id, expansion_id, weather_allowed, sky_file, can_bind FROM zones where name='%s'",escaped);
MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, file, description, underworld, safe_x, safe_y, safe_z, min_status, min_level, max_level, instance_type+0, shutdown_timer, zone_motd, default_reenter_time, default_reset_time, default_lockout_time, force_group_to_zone, safe_heading, xp_modifier, ruleset_id, expansion_id, weather_allowed, sky_file, can_bind, can_gate FROM zones where name='%s'",escaped);
if(result && mysql_num_rows(result) > 0) {
MYSQL_ROW row;
row = mysql_fetch_row(result);
@ -2745,6 +2745,7 @@ void WorldDatabase::LoadZoneInfo(ZoneServer* zone){
zone->SetupInstance(zone->GetInstanceID());
}
zone->SetCanBind(atoul(row[23]));
zone->SetCanGate(atoul(row[24]));
}
safe_delete_array(escaped);
}

View file

@ -8347,12 +8347,12 @@ void Client::ResetSendMail(bool cancel, bool needslock) {
}
bool Client::GateAllowed() {
ZoneServer* zone = zone_list.Get(player->GetPlayerInfo()->GetBindZoneID());
ZoneServer* zone = GetCurrentZone();
LogWrite(MISC__TODO, 1, "TODO", "possibly add a check here to see if a player is allowed to gate from this spot, allow for now\nfile: %s, func: %s, line: %i", __FILE__, __FUNCTION__, __LINE__);
if (zone)
return true;
if (zone){
return cangate;
}
return false;
}
@ -8367,6 +8367,7 @@ bool Client::Bind() {
int canbind = BindAllowed();
if(canbind == 0) {
return false;
}
player->GetPlayerInfo()->SetBindZone(GetCurrentZone()->GetZoneID());
@ -8384,6 +8385,11 @@ bool Client::Gate(bool is_spell) {
ZoneServer* zone = zone_list.Get(player->GetPlayerInfo()->GetBindZoneID());
if (zone) {
int cangate = GateAllowed();
if(cangate == 0) {
SimpleMessage(CHANNEL_NARRATIVE, "You cant cast recall spells in this zone.");
return false;
}
player->SetX(player->GetPlayerInfo()->GetBindZoneX());
player->SetY(player->GetPlayerInfo()->GetBindZoneY());
player->SetZ(player->GetPlayerInfo()->GetBindZoneZ());

View file

@ -160,7 +160,8 @@ ZoneServer::ZoneServer(const char* name, bool incoming_clients) {
reloading_spellprocess = false;
expansion_flag = 0;
holiday_flag = 0;
can_bind = 1;
can_bind = 1;
can_gate = 1;
MMasterZoneLock = new CriticalSection(MUTEX_ATTRIBUTE_RECURSIVE);
pathing = nullptr;

View file

@ -592,10 +592,13 @@ public:
int32 GetHolidayFlag() { return holiday_flag; }
void SetHolidayFlag(int32 val) { holiday_flag = val; }
//devn00b test
int32 GetCanBind() { return can_bind; }
void SetCanBind(int32 val) { can_bind = val; }
bool GetCanGate() { return can_gate; }
void SetCanGate(int32 val) { can_gate = val; }
void RemoveClientImmediately(Client* client);
void ClearHate(Entity* entity);
@ -910,6 +913,8 @@ private:
int32 holiday_flag;
//devn00b:test
int can_bind;
bool can_gate;
map<int16, PacketStruct*> versioned_pos_structs;
map<int16, PacketStruct*> versioned_info_structs;
map<int16, PacketStruct*> versioned_vis_structs;