Page 1 of 1

(solved)Releasing keep is not updating guilds keep count

PostPosted: Sun Feb 26, 2017 8:18 pm
by ontheDOL
hi guys,
using latest revision, guild claim limit set to 1.

I can claim a keep, guards will reset with my guild name etc, which is all good.

then when you release the keep, the guards reset back to no guild, which is all good.

In the database, the keep table for "ClaimedKeepName" updates fine (adds name when claimed, removes name when released)

The problem after releasing is, /gc info shows that the guild still has control of the keep, and if you try to reclaim the keep, it says "your guild already owns a keep"


here in abstractgamekeep.cs it has the line this.Guild.ClaimedKeeps.Remove(this); but it doesnt seem to be working
Code: Select all
public virtual void Release() { this.Guild.ClaimedKeeps.Remove(this); PlayerMgr.BroadcastRelease(this); this.m_guild = null; StopDeductionTimer(); StopChangeLevelTimer(); ChangeLevel((byte)ServerProperties.Properties.STARTING_KEEP_LEVEL); foreach (GameKeepGuard guard in Guards.Values) { guard.ChangeGuild(); } foreach (GameKeepBanner banner in Banners.Values) { banner.ChangeGuild(); } this.SaveIntoDatabase(); }
Tested in new frontiers on Caer Renaris with Normal ruleset, and on pvp ruleset, both with same result.
has anyone got some insight on this?
thanks

Re: Releasing keep is not updating guilds keep count

PostPosted: Sun Feb 26, 2017 11:19 pm
by PlanarChaosRvrtwo
Did you released the keep with the Lord menu or with the /gc release command couse i think it could be handled diffrent but allready to tired to relook that.

Re: Releasing keep is not updating guilds keep count

PostPosted: Mon Feb 27, 2017 12:11 am
by ontheDOL
tested with both methods , lord menu and the /gc commands.

i think the issue is when you claim, the claimedkeep is being added to the list twice. that is to say,
If i claim a keep, and then type /gc info , it tells me the keep i claimed twice.
ie;
your guild has currently claimed caer renaris
your guild has currently claimed caer renaris

when you release the keep, it only removes only one of these records.
so i think i need to find out why its added it twice when claimed

Re: Releasing keep is not updating guilds keep count

PostPosted: Mon Feb 27, 2017 12:57 am
by PlanarChaosRvrtwo
Hmm could be possible for some reason 2 scripts is handling it like keepmanager and playercommandmanager (just an idea)

Re: Releasing keep is not updating guilds keep count

PostPosted: Mon Feb 27, 2017 12:58 am
by ontheDOL
ok i think i fixed it
Code: Select all
public virtual void Claim(GamePlayer player) { this.m_guild = player.Guild; player.Guild.ClaimedKeeps.Add(this); if (ServerProperties.Properties.GUILDS_CLAIM_LIMIT > 1) player.Guild.SendMessageToGuildMembers("Your guild has currently claimed " + player.Guild.ClaimedKeeps.Count + " keeps of a maximum of " + ServerProperties.Properties.GUILDS_CLAIM_LIMIT, eChatType.CT_Guild, eChatLoc.CL_ChatWindow); ChangeLevel((byte)ServerProperties.Properties.STARTING_KEEP_CLAIM_LEVEL); PlayerMgr.BroadcastClaim(this); foreach (GameKeepGuard guard in Guards.Values) { guard.ChangeGuild(); } foreach (GameKeepBanner banner in Banners.Values) { banner.ChangeGuild(); } this.SaveIntoDatabase(); LoadFromDatabase(DBKeep); StartDeductionTimer(); GameEventMgr.Notify(KeepEvent.KeepClaimed, this, new KeepEventArgs(this)); }
player.Guild.ClaimedKeeps.Add(this); adds the keep to the guilds claimed list, then at the bottom is calls LoadFromDatabase(DBKeep);

in the LoadFromDatabase method
Code: Select all
public virtual void LoadFromDatabase(DataObject keep) { m_dbkeep = keep as DBKeep; InternalID = keep.ObjectId; m_difficultyLevel[0] = m_dbkeep.AlbionDifficultyLevel; m_difficultyLevel[1] = m_dbkeep.MidgardDifficultyLevel; m_difficultyLevel[2] = m_dbkeep.HiberniaDifficultyLevel; if (m_dbkeep.ClaimedGuildName != null && m_dbkeep.ClaimedGuildName != "") { Guild myguild = GuildMgr.GetGuildByName(m_dbkeep.ClaimedGuildName); if (myguild != null) { this.m_guild = myguild; this.m_guild.ClaimedKeeps.Add(this); StartDeductionTimer(); } }
it adds the keep again " this.m_guild.ClaimedKeeps.Add(this);"
so i removed the player.Guild.ClaimedKeeps.Add(this); from the Claim method , and now it works. It will save the guild in the DB and put the keep in the guilds keep list to prevent from multiple keeps captures
i tested claiming and releasing claiming releasing and it works fine.

when you reboot server, the loadfromdatabase happens again so it retains the guilds keep count.

Re: (solved)Releasing keep is not updating guilds keep count

PostPosted: Mon Feb 27, 2017 2:38 am
by PlanarChaosRvrtwo
you should maybe merge it with current revision on github

Re: (solved)Releasing keep is not updating guilds keep count

PostPosted: Fri Mar 03, 2017 1:00 pm
by Leodagan
This code is really not optimal ;)

I merged your fix for the moment, but ideally an in-game object should not interact this directly with database...

For a simple player command we have multiple direct database query (update/create and select), I think game status should be flawless and on specific timer or event : dump changed state to the DB (preferably from another thread than a player command handler or region event handler)

Thanks for your great pull request ;)