cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
180 stars 47 forks source link

[CLASSIC] Incorrect table format creature_respawn? #1346

Closed virusav closed 7 years ago

virusav commented 7 years ago

/sql/base/characters.sql:

DROP TABLE IF EXISTS `creature_respawn`;
CREATE TABLE `creature_respawn` (
  `guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
  `respawntime` bigint(20) unsigned NOT NULL DEFAULT '0',
  `instance` mediumint(8) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`guid`,`instance`),
  KEY `instance` (`instance`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System';

Core:

QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id");
...
        uint32 loguid               = fields[0].GetUInt32();
        uint64 respawn_time         = fields[1].GetUInt64();
        uint32 mapId                = fields[2].GetUInt32();
        uint32 instanceId           = fields[3].GetUInt32();
        time_t resetTime            = (time_t)fields[4].GetUInt64();
        uint32 completedEncounters  = fields[5].GetUInt32();

The result is errors in the log.

The table does not have enough fields? Or the code was taken from another version and was not fixed under the structure of the table?

henrikssonkevin commented 7 years ago

Check your DBErrors.log for encountersMask. I get this error using TBCDB:

2017-03-30 10:40:19 SQL: SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id
2017-03-30 10:40:19 query ERROR: Unknown column 'encountersMask' in 'field list'

Probably forgot deleting encountersMask when backporting from WOTLK or Cata.

virusav commented 7 years ago

I checked the 4 versions: Classic, TBC, Wotlk, Cata. Everywhere in the structure of the table has only 3 fields, but at the core is extracted and processing of 6-7 fields.

virusav commented 7 years ago

Column encountersMask is only in Wotlk and Cata.

Generally it is strange that in a cross-queries the kernel developers do not indicate the names of the tables in front of the fields, as this may cause errors when samples if fields in different tables have the same name.