While investigating issue http://rathena.org/b...e-data-loading/ I analyzed guild castle code thoroughly, and started to wonder about reasons why every map-server keeps a local copy of all castles. It's counterintuitive, since every castle is tied to a map, and every map is tied to a map-server. So it is not possible to have the same castle on more than one map-server.
Unless I'm wrong there are just two ways of modifying guild castle data:
with a script command SetCastleData
breaking a guild that owns the castle, which abandons the castle
Guild breaking can happen on another map-server, and this scenario is already covered:
Map-server requests guild break from char-server.
Char-server deletes the guild and notifies all map-servers.
Map-servers performs ::OnGuildBreak NPC events, reset castle owners and request char-server to save castle data.
Manipulating castle data on one map-server with a script that is on another map-server doesn't make sense to me. This could be disallowed without any harm to usability IMO.
The only piece of information about castles on other map-servers that could be used, is number of castles owned by each guild (required in guild info window and guild_max_castles battle conf). This is however guild's attribute and could be stored in guild struct.
So it looks to me that we could safely remove non-local guild castles from map-server.
Another question that arises immediately is: is it char-server or map-server that should declare/define castle maps? Currently char-server knows nothing about castle maps, unless map-server requests data for it (based on db/castle_db.txt and WoE scripts). Char-server does no checks whatsoever, assuming that if castle is not in SQL, but has been requested by map-server, then it must be an empty castle.
It is possible to have 2 castles with same castle ID on different map-servers as long as map names are different as well. It would make more sense if castle was identified by mapindex.