diff --git a/src/map/guild.cpp b/src/map/guild.cpp index 14a94a569f..cd85673b16 100644 --- a/src/map/guild.cpp +++ b/src/map/guild.cpp @@ -165,12 +165,16 @@ int guild_check_skill_require(struct guild *g,int id) { static bool guild_read_castledb(char* str[], int columns, int current) {// ,,,[,] struct guild_castle *gc; int mapindex = mapindex_name2id(str[1]); - + const int castle_id = atoi(str[0]); + if (map_mapindex2mapid(mapindex) < 0) // Map not found or on another map-server return false; - CREATE(gc, struct guild_castle, 1); - gc->castle_id = atoi(str[0]); + if ((gc = static_cast(idb_get(castle_db, castle_id))) == nullptr) { + CREATE(gc, struct guild_castle, 1); + } + + gc->castle_id = castle_id; gc->mapindex = mapindex; safestrncpy(gc->castle_name, trim(str[2]), sizeof(gc->castle_name)); safestrncpy(gc->castle_event, trim(str[3]), sizeof(gc->castle_event));