Don't allocate space for new castle data if castle with the same ID already exists. Fixed #2793.

Thanks to @Daegaladh
This commit is contained in:
Jittapan Pluemsumran
2018-01-09 19:33:17 +07:00
parent 6ed40baad1
commit 48d79cef43

View File

@@ -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) {// <castle id>,<map name>,<castle name>,<castle event>[,<reserved/unused switch flag>]
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<guild_castle*>(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));