| @@ -0,0 +1,875 @@ | |||
| 1 | + | -- OTX Server database schema. | |
| 2 | + | -- Source: https://github.com/mattyx14/otxserver/blob/main/schema.sql | |
| 3 | + | -- License: GPL-2.0. Covers ZnoteX's TFS_03 engine choice ("TFS 0.3.6+ / 0.4 / OTX"). | |
| 4 | + | ||
| 5 | + | -- Canary - Database (Schema) | |
| 6 | + | ||
| 7 | + | -- Table structure `server_config` | |
| 8 | + | CREATE TABLE IF NOT EXISTS `server_config` ( | |
| 9 | + | `config` varchar(50) NOT NULL, | |
| 10 | + | `value` varchar(256) NOT NULL DEFAULT '', | |
| 11 | + | CONSTRAINT `server_config_pk` PRIMARY KEY (`config`) | |
| 12 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 13 | + | ||
| 14 | + | INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '56'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); | |
| 15 | + | ||
| 16 | + | -- Table structure `accounts` | |
| 17 | + | CREATE TABLE IF NOT EXISTS `accounts` ( | |
| 18 | + | `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 19 | + | `name` varchar(32) NOT NULL, | |
| 20 | + | `password` VARCHAR(255) NOT NULL, | |
| 21 | + | `email` varchar(255) NOT NULL DEFAULT '', | |
| 22 | + | `premdays` int(11) NOT NULL DEFAULT '0', | |
| 23 | + | `premdays_purchased` int(11) NOT NULL DEFAULT '0', | |
| 24 | + | `lastday` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 25 | + | `type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', | |
| 26 | + | `coins` int(12) UNSIGNED NOT NULL DEFAULT '0', | |
| 27 | + | `coins_transferable` int(12) UNSIGNED NOT NULL DEFAULT '0', | |
| 28 | + | `tournament_coins` int(12) UNSIGNED NOT NULL DEFAULT '0', | |
| 29 | + | `creation` int(11) UNSIGNED NOT NULL DEFAULT '0', | |
| 30 | + | `recruiter` INT(6) DEFAULT 0, | |
| 31 | + | `house_bid_id` int(11) NOT NULL DEFAULT '0', | |
| 32 | + | CONSTRAINT `accounts_pk` PRIMARY KEY (`id`), | |
| 33 | + | CONSTRAINT `accounts_unique` UNIQUE (`name`), | |
| 34 | + | INDEX `accounts_email` (`email`), | |
| 35 | + | INDEX `accounts_password` (`password`) | |
| 36 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 37 | + | ||
| 38 | + | -- Table structure `coins_transactions` | |
| 39 | + | CREATE TABLE IF NOT EXISTS `coins_transactions` ( | |
| 40 | + | `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 41 | + | `account_id` int(11) UNSIGNED NOT NULL, | |
| 42 | + | `type` tinyint(1) UNSIGNED NOT NULL, | |
| 43 | + | `coin_type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1', | |
| 44 | + | `amount` int(12) UNSIGNED NOT NULL, | |
| 45 | + | `description` varchar(3500) NOT NULL, | |
| 46 | + | `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP, | |
| 47 | + | INDEX `account_id` (`account_id`), | |
| 48 | + | CONSTRAINT `coins_transactions_pk` PRIMARY KEY (`id`), | |
| 49 | + | CONSTRAINT `coins_transactions_account_fk` | |
| 50 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 51 | + | ON DELETE CASCADE | |
| 52 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 53 | + | ||
| 54 | + | -- Table structure `players` | |
| 55 | + | CREATE TABLE IF NOT EXISTS `players` ( | |
| 56 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 57 | + | `name` varchar(255) NOT NULL, | |
| 58 | + | `group_id` int(11) NOT NULL DEFAULT '1', | |
| 59 | + | `account_id` int(11) UNSIGNED NOT NULL DEFAULT '0', | |
| 60 | + | `level` int(11) NOT NULL DEFAULT '1', | |
| 61 | + | `vocation` int(11) NOT NULL DEFAULT '0', | |
| 62 | + | `health` int(11) NOT NULL DEFAULT '150', | |
| 63 | + | `healthmax` int(11) NOT NULL DEFAULT '150', | |
| 64 | + | `experience` bigint(20) NOT NULL DEFAULT '0', | |
| 65 | + | `lookbody` int(11) NOT NULL DEFAULT '0', | |
| 66 | + | `lookfeet` int(11) NOT NULL DEFAULT '0', | |
| 67 | + | `lookhead` int(11) NOT NULL DEFAULT '0', | |
| 68 | + | `looklegs` int(11) NOT NULL DEFAULT '0', | |
| 69 | + | `looktype` int(11) NOT NULL DEFAULT '136', | |
| 70 | + | `lookaddons` int(11) NOT NULL DEFAULT '0', | |
| 71 | + | `maglevel` int(11) NOT NULL DEFAULT '0', | |
| 72 | + | `mana` int(11) NOT NULL DEFAULT '0', | |
| 73 | + | `manamax` int(11) NOT NULL DEFAULT '0', | |
| 74 | + | `manaspent` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 75 | + | `soul` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 76 | + | `town_id` int(11) NOT NULL DEFAULT '1', | |
| 77 | + | `posx` int(11) NOT NULL DEFAULT '0', | |
| 78 | + | `posy` int(11) NOT NULL DEFAULT '0', | |
| 79 | + | `posz` int(11) NOT NULL DEFAULT '0', | |
| 80 | + | `conditions` mediumblob NOT NULL, | |
| 81 | + | `cap` int(11) NOT NULL DEFAULT '0', | |
| 82 | + | `sex` int(11) NOT NULL DEFAULT '0', | |
| 83 | + | `pronoun` int(11) NOT NULL DEFAULT '0', | |
| 84 | + | `lastlogin` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 85 | + | `lastip` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 86 | + | `save` tinyint(1) NOT NULL DEFAULT '1', | |
| 87 | + | `skull` tinyint(1) NOT NULL DEFAULT '0', | |
| 88 | + | `skulltime` bigint(20) NOT NULL DEFAULT '0', | |
| 89 | + | `lastlogout` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 90 | + | `blessings` tinyint(2) NOT NULL DEFAULT '0', | |
| 91 | + | `blessings1` tinyint(4) NOT NULL DEFAULT '0', | |
| 92 | + | `blessings2` tinyint(4) NOT NULL DEFAULT '0', | |
| 93 | + | `blessings3` tinyint(4) NOT NULL DEFAULT '0', | |
| 94 | + | `blessings4` tinyint(4) NOT NULL DEFAULT '0', | |
| 95 | + | `blessings5` tinyint(4) NOT NULL DEFAULT '0', | |
| 96 | + | `blessings6` tinyint(4) NOT NULL DEFAULT '0', | |
| 97 | + | `blessings7` tinyint(4) NOT NULL DEFAULT '0', | |
| 98 | + | `blessings8` tinyint(4) NOT NULL DEFAULT '0', | |
| 99 | + | `onlinetime` int(11) NOT NULL DEFAULT '0', | |
| 100 | + | `deletion` bigint(15) NOT NULL DEFAULT '0', | |
| 101 | + | `balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 102 | + | `offlinetraining_time` smallint(5) UNSIGNED NOT NULL DEFAULT '43200', | |
| 103 | + | `offlinetraining_skill` tinyint(2) NOT NULL DEFAULT '-1', | |
| 104 | + | `stamina` smallint(5) UNSIGNED NOT NULL DEFAULT '2520', | |
| 105 | + | `skill_fist` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 106 | + | `skill_fist_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 107 | + | `skill_club` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 108 | + | `skill_club_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 109 | + | `skill_sword` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 110 | + | `skill_sword_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 111 | + | `skill_axe` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 112 | + | `skill_axe_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 113 | + | `skill_dist` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 114 | + | `skill_dist_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 115 | + | `skill_shielding` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 116 | + | `skill_shielding_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 117 | + | `skill_fishing` int(10) UNSIGNED NOT NULL DEFAULT '10', | |
| 118 | + | `skill_fishing_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 119 | + | `skill_critical_hit_chance` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 120 | + | `skill_critical_hit_chance_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 121 | + | `skill_critical_hit_damage` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 122 | + | `skill_critical_hit_damage_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 123 | + | `skill_life_leech_chance` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 124 | + | `skill_life_leech_chance_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 125 | + | `skill_life_leech_amount` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 126 | + | `skill_life_leech_amount_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 127 | + | `skill_mana_leech_chance` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 128 | + | `skill_mana_leech_chance_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 129 | + | `skill_mana_leech_amount` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 130 | + | `skill_mana_leech_amount_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 131 | + | `skill_criticalhit_chance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 132 | + | `skill_criticalhit_damage` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 133 | + | `skill_lifeleech_chance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 134 | + | `skill_lifeleech_amount` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 135 | + | `skill_manaleech_chance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 136 | + | `skill_manaleech_amount` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 137 | + | `manashield` INT UNSIGNED NOT NULL DEFAULT '0', | |
| 138 | + | `max_manashield` INT UNSIGNED NOT NULL DEFAULT '0', | |
| 139 | + | `xpboost_stamina` smallint(5) UNSIGNED DEFAULT NULL, | |
| 140 | + | `xpboost_value` tinyint(4) UNSIGNED DEFAULT NULL, | |
| 141 | + | `marriage_status` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 142 | + | `marriage_spouse` int(11) NOT NULL DEFAULT '-1', | |
| 143 | + | `bonus_rerolls` bigint(21) NOT NULL DEFAULT '0', | |
| 144 | + | `prey_wildcard` bigint(21) NOT NULL DEFAULT '0', | |
| 145 | + | `task_points` bigint(21) NOT NULL DEFAULT '0', | |
| 146 | + | `quickloot_fallback` tinyint(1) DEFAULT '0', | |
| 147 | + | `lookmountbody` tinyint(3) unsigned NOT NULL DEFAULT '0', | |
| 148 | + | `lookmountfeet` tinyint(3) unsigned NOT NULL DEFAULT '0', | |
| 149 | + | `lookmounthead` tinyint(3) unsigned NOT NULL DEFAULT '0', | |
| 150 | + | `lookmountlegs` tinyint(3) unsigned NOT NULL DEFAULT '0', | |
| 151 | + | `lookfamiliarstype` int(11) unsigned NOT NULL DEFAULT '0', | |
| 152 | + | `isreward` tinyint(1) NOT NULL DEFAULT '1', | |
| 153 | + | `istutorial` tinyint(1) NOT NULL DEFAULT '0', | |
| 154 | + | `forge_dusts` bigint(21) NOT NULL DEFAULT '0', | |
| 155 | + | `forge_dust_level` bigint(21) NOT NULL DEFAULT '100', | |
| 156 | + | `randomize_mount` tinyint(1) NOT NULL DEFAULT '0', | |
| 157 | + | `boss_points` int NOT NULL DEFAULT '0', | |
| 158 | + | `animus_mastery` mediumblob DEFAULT NULL, | |
| 159 | + | INDEX `account_id` (`account_id`), | |
| 160 | + | INDEX `vocation` (`vocation`), | |
| 161 | + | CONSTRAINT `players_pk` PRIMARY KEY (`id`), | |
| 162 | + | CONSTRAINT `players_unique` UNIQUE (`name`), | |
| 163 | + | CONSTRAINT `players_account_fk` | |
| 164 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 165 | + | ON DELETE CASCADE | |
| 166 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 167 | + | ||
| 168 | + | -- Table structure `account_bans` | |
| 169 | + | CREATE TABLE IF NOT EXISTS `account_bans` ( | |
| 170 | + | `account_id` int(11) UNSIGNED NOT NULL, | |
| 171 | + | `reason` varchar(255) NOT NULL, | |
| 172 | + | `banned_at` bigint(20) NOT NULL, | |
| 173 | + | `expires_at` bigint(20) NOT NULL, | |
| 174 | + | `banned_by` int(11) NOT NULL, | |
| 175 | + | INDEX `banned_by` (`banned_by`), | |
| 176 | + | CONSTRAINT `account_bans_pk` PRIMARY KEY (`account_id`), | |
| 177 | + | CONSTRAINT `account_bans_account_fk` | |
| 178 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 179 | + | ON DELETE CASCADE | |
| 180 | + | ON UPDATE CASCADE, | |
| 181 | + | CONSTRAINT `account_bans_player_fk` | |
| 182 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) | |
| 183 | + | ON DELETE CASCADE | |
| 184 | + | ON UPDATE CASCADE | |
| 185 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 186 | + | ||
| 187 | + | -- Table structure `account_ban_history` | |
| 188 | + | CREATE TABLE IF NOT EXISTS `account_ban_history` ( | |
| 189 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 190 | + | `account_id` int(11) UNSIGNED NOT NULL, | |
| 191 | + | `reason` varchar(255) NOT NULL, | |
| 192 | + | `banned_at` bigint(20) NOT NULL, | |
| 193 | + | `expired_at` bigint(20) NOT NULL, | |
| 194 | + | `banned_by` int(11) NOT NULL, | |
| 195 | + | INDEX `account_id` (`account_id`), | |
| 196 | + | INDEX `banned_by` (`banned_by`), | |
| 197 | + | CONSTRAINT `account_bans_history_account_fk` | |
| 198 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 199 | + | ON DELETE CASCADE | |
| 200 | + | ON UPDATE CASCADE, | |
| 201 | + | CONSTRAINT `account_bans_history_player_fk` | |
| 202 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) | |
| 203 | + | ON DELETE CASCADE | |
| 204 | + | ON UPDATE CASCADE, | |
| 205 | + | CONSTRAINT `account_ban_history_pk` PRIMARY KEY (`id`) | |
| 206 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 207 | + | ||
| 208 | + | -- Table structure `account_viplist` | |
| 209 | + | CREATE TABLE IF NOT EXISTS `account_viplist` ( | |
| 210 | + | `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is', | |
| 211 | + | `player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry', | |
| 212 | + | `description` varchar(128) NOT NULL DEFAULT '', | |
| 213 | + | `icon` tinyint(2) UNSIGNED NOT NULL DEFAULT '0', | |
| 214 | + | `notify` tinyint(1) NOT NULL DEFAULT '0', | |
| 215 | + | INDEX `account_id` (`account_id`), | |
| 216 | + | INDEX `player_id` (`player_id`), | |
| 217 | + | CONSTRAINT `account_viplist_unique` UNIQUE (`account_id`, `player_id`), | |
| 218 | + | CONSTRAINT `account_viplist_account_fk` | |
| 219 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 220 | + | ON DELETE CASCADE, | |
| 221 | + | CONSTRAINT `account_viplist_player_fk` | |
| 222 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 223 | + | ON DELETE CASCADE | |
| 224 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 225 | + | ||
| 226 | + | -- Table structure `account_vipgroup` | |
| 227 | + | CREATE TABLE IF NOT EXISTS `account_vipgroups` ( | |
| 228 | + | `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 229 | + | `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose vip group entry it is', | |
| 230 | + | `name` varchar(128) NOT NULL, | |
| 231 | + | `customizable` BOOLEAN NOT NULL DEFAULT '1', | |
| 232 | + | CONSTRAINT `account_vipgroups_pk` PRIMARY KEY (`id`, `account_id`), | |
| 233 | + | CONSTRAINT `account_vipgroups_accounts_fk` | |
| 234 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 235 | + | ON DELETE CASCADE | |
| 236 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 237 | + | ||
| 238 | + | -- | |
| 239 | + | -- Trigger | |
| 240 | + | -- | |
| 241 | + | DELIMITER // | |
| 242 | + | CREATE TRIGGER `oncreate_accounts` AFTER INSERT ON `accounts` FOR EACH ROW BEGIN | |
| 243 | + | INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Enemies', 0); | |
| 244 | + | INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Friends', 0); | |
| 245 | + | INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Trading Partner', 0); | |
| 246 | + | END | |
| 247 | + | // | |
| 248 | + | DELIMITER ; | |
| 249 | + | ||
| 250 | + | -- Table structure `account_vipgrouplist` | |
| 251 | + | CREATE TABLE IF NOT EXISTS `account_vipgrouplist` ( | |
| 252 | + | `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is', | |
| 253 | + | `player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry', | |
| 254 | + | `vipgroup_id` int(11) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs', | |
| 255 | + | INDEX `account_id` (`account_id`), | |
| 256 | + | INDEX `player_id` (`player_id`), | |
| 257 | + | INDEX `vipgroup_id` (`vipgroup_id`), | |
| 258 | + | CONSTRAINT `account_vipgrouplist_unique` UNIQUE (`account_id`, `player_id`, `vipgroup_id`), | |
| 259 | + | CONSTRAINT `account_vipgrouplist_player_fk` | |
| 260 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 261 | + | ON DELETE CASCADE, | |
| 262 | + | CONSTRAINT `account_vipgrouplist_vipgroup_fk` | |
| 263 | + | FOREIGN KEY (`vipgroup_id`, `account_id`) REFERENCES `account_vipgroups` (`id`, `account_id`) | |
| 264 | + | ON DELETE CASCADE | |
| 265 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 266 | + | ||
| 267 | + | -- Table structure `boosted_boss` | |
| 268 | + | CREATE TABLE IF NOT EXISTS `boosted_boss` ( | |
| 269 | + | `boostname` TEXT, | |
| 270 | + | `date` varchar(250) NOT NULL DEFAULT '', | |
| 271 | + | `raceid` varchar(250) NOT NULL DEFAULT '', | |
| 272 | + | `looktypeEx` int(11) NOT NULL DEFAULT 0, | |
| 273 | + | `looktype` int(11) NOT NULL DEFAULT 136, | |
| 274 | + | `lookfeet` int(11) NOT NULL DEFAULT 0, | |
| 275 | + | `looklegs` int(11) NOT NULL DEFAULT 0, | |
| 276 | + | `lookhead` int(11) NOT NULL DEFAULT 0, | |
| 277 | + | `lookbody` int(11) NOT NULL DEFAULT 0, | |
| 278 | + | `lookaddons` int(11) NOT NULL DEFAULT 0, | |
| 279 | + | `lookmount` int(11) DEFAULT 0, | |
| 280 | + | PRIMARY KEY (`date`) | |
| 281 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 282 | + | ||
| 283 | + | INSERT INTO `boosted_boss` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0); | |
| 284 | + | ||
| 285 | + | -- Table structure `boosted_creature` | |
| 286 | + | CREATE TABLE IF NOT EXISTS `boosted_creature` ( | |
| 287 | + | `boostname` TEXT, | |
| 288 | + | `date` varchar(250) NOT NULL DEFAULT '', | |
| 289 | + | `raceid` varchar(250) NOT NULL DEFAULT '', | |
| 290 | + | `looktype` int(11) NOT NULL DEFAULT 136, | |
| 291 | + | `lookfeet` int(11) NOT NULL DEFAULT 0, | |
| 292 | + | `looklegs` int(11) NOT NULL DEFAULT 0, | |
| 293 | + | `lookhead` int(11) NOT NULL DEFAULT 0, | |
| 294 | + | `lookbody` int(11) NOT NULL DEFAULT 0, | |
| 295 | + | `lookaddons` int(11) NOT NULL DEFAULT 0, | |
| 296 | + | `lookmount` int(11) DEFAULT 0, | |
| 297 | + | PRIMARY KEY (`date`) | |
| 298 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 299 | + | ||
| 300 | + | INSERT INTO `boosted_creature` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0); | |
| 301 | + | ||
| 302 | + | -- Tabble Structure `daily_reward_history` | |
| 303 | + | CREATE TABLE IF NOT EXISTS `daily_reward_history` ( | |
| 304 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 305 | + | `daystreak` smallint(2) NOT NULL DEFAULT 0, | |
| 306 | + | `player_id` int(11) NOT NULL, | |
| 307 | + | `timestamp` int(11) NOT NULL, | |
| 308 | + | `description` varchar(255) DEFAULT NULL, | |
| 309 | + | INDEX `player_id` (`player_id`), | |
| 310 | + | CONSTRAINT `daily_reward_history_pk` PRIMARY KEY (`id`), | |
| 311 | + | CONSTRAINT `daily_reward_history_player_fk` | |
| 312 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 313 | + | ON DELETE CASCADE | |
| 314 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 315 | + | ||
| 316 | + | -- Tabble Structure `forge_history` | |
| 317 | + | CREATE TABLE IF NOT EXISTS `forge_history` ( | |
| 318 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 319 | + | `player_id` int NOT NULL, | |
| 320 | + | `action_type` int NOT NULL DEFAULT '0', | |
| 321 | + | `description` text NOT NULL, | |
| 322 | + | `is_success` tinyint NOT NULL DEFAULT '0', | |
| 323 | + | `bonus` tinyint NOT NULL DEFAULT '0', | |
| 324 | + | `done_at` bigint NOT NULL, | |
| 325 | + | `done_at_date` datetime DEFAULT NOW(), | |
| 326 | + | `cost` bigint UNSIGNED NOT NULL DEFAULT '0', | |
| 327 | + | `gained` bigint UNSIGNED NOT NULL DEFAULT '0', | |
| 328 | + | CONSTRAINT `forge_history_pk` PRIMARY KEY (`id`), | |
| 329 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE, | |
| 330 | + | UNIQUE KEY `unique_player_done_at` (`player_id`, `done_at`) | |
| 331 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 332 | + | ||
| 333 | + | -- Table structure `global_storage` | |
| 334 | + | CREATE TABLE IF NOT EXISTS `global_storage` ( | |
| 335 | + | `key` varchar(32) NOT NULL, | |
| 336 | + | `value` text NOT NULL, | |
| 337 | + | CONSTRAINT `global_storage_unique` UNIQUE (`key`) | |
| 338 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 339 | + | ||
| 340 | + | -- Table structure `guilds` | |
| 341 | + | CREATE TABLE IF NOT EXISTS `guilds` ( | |
| 342 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 343 | + | `level` int(11) NOT NULL DEFAULT '1', | |
| 344 | + | `name` varchar(255) NOT NULL, | |
| 345 | + | `ownerid` int(11) NOT NULL, | |
| 346 | + | `creationdata` int(11) NOT NULL, | |
| 347 | + | `motd` varchar(255) NOT NULL DEFAULT '', | |
| 348 | + | `residence` int(11) NOT NULL DEFAULT '0', | |
| 349 | + | `balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 350 | + | `points` int(11) NOT NULL DEFAULT '0', | |
| 351 | + | CONSTRAINT `guilds_pk` PRIMARY KEY (`id`), | |
| 352 | + | CONSTRAINT `guilds_name_unique` UNIQUE (`name`), | |
| 353 | + | CONSTRAINT `guilds_owner_unique` UNIQUE (`ownerid`), | |
| 354 | + | CONSTRAINT `guilds_ownerid_fk` | |
| 355 | + | FOREIGN KEY (`ownerid`) REFERENCES `players` (`id`) | |
| 356 | + | ON DELETE CASCADE | |
| 357 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 358 | + | ||
| 359 | + | -- Table structure `guild_wars` | |
| 360 | + | CREATE TABLE IF NOT EXISTS `guild_wars` ( | |
| 361 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 362 | + | `guild1` int(11) NOT NULL DEFAULT '0', | |
| 363 | + | `guild2` int(11) NOT NULL DEFAULT '0', | |
| 364 | + | `name1` varchar(255) NOT NULL, | |
| 365 | + | `name2` varchar(255) NOT NULL, | |
| 366 | + | `status` tinyint(2) UNSIGNED NOT NULL DEFAULT '0', | |
| 367 | + | `started` bigint(15) NOT NULL DEFAULT '0', | |
| 368 | + | `ended` bigint(15) NOT NULL DEFAULT '0', | |
| 369 | + | `frags_limit` smallint(4) UNSIGNED NOT NULL DEFAULT '0', | |
| 370 | + | `payment` bigint(13) UNSIGNED NOT NULL DEFAULT '0', | |
| 371 | + | `duration_days` tinyint(3) UNSIGNED NOT NULL DEFAULT '0', | |
| 372 | + | INDEX `guild1` (`guild1`), | |
| 373 | + | INDEX `guild2` (`guild2`), | |
| 374 | + | CONSTRAINT `guild_wars_pk` PRIMARY KEY (`id`) | |
| 375 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 376 | + | ||
| 377 | + | -- Table structure `guildwar_kills` | |
| 378 | + | CREATE TABLE IF NOT EXISTS `guildwar_kills` ( | |
| 379 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 380 | + | `killer` varchar(50) NOT NULL, | |
| 381 | + | `target` varchar(50) NOT NULL, | |
| 382 | + | `killerguild` int(11) NOT NULL DEFAULT '0', | |
| 383 | + | `targetguild` int(11) NOT NULL DEFAULT '0', | |
| 384 | + | `warid` int(11) NOT NULL DEFAULT '0', | |
| 385 | + | `time` bigint(15) NOT NULL, | |
| 386 | + | INDEX `warid` (`warid`), | |
| 387 | + | CONSTRAINT `guildwar_kills_pk` PRIMARY KEY (`id`), | |
| 388 | + | CONSTRAINT `guildwar_kills_warid_fk` | |
| 389 | + | FOREIGN KEY (`warid`) REFERENCES `guild_wars` (`id`) | |
| 390 | + | ON DELETE CASCADE | |
| 391 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 392 | + | ||
| 393 | + | -- Table structure `guild_invites` | |
| 394 | + | CREATE TABLE IF NOT EXISTS `guild_invites` ( | |
| 395 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 396 | + | `guild_id` int(11) NOT NULL DEFAULT '0', | |
| 397 | + | `date` int(11) NOT NULL, | |
| 398 | + | INDEX `guild_id` (`guild_id`), | |
| 399 | + | CONSTRAINT `guild_invites_pk` PRIMARY KEY (`player_id`, `guild_id`), | |
| 400 | + | CONSTRAINT `guild_invites_player_fk` | |
| 401 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 402 | + | ON DELETE CASCADE, | |
| 403 | + | CONSTRAINT `guild_invites_guild_fk` | |
| 404 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) | |
| 405 | + | ON DELETE CASCADE | |
| 406 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 407 | + | ||
| 408 | + | -- Table structure `guild_ranks` | |
| 409 | + | CREATE TABLE IF NOT EXISTS `guild_ranks` ( | |
| 410 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 411 | + | `guild_id` int(11) NOT NULL COMMENT 'guild', | |
| 412 | + | `name` varchar(255) NOT NULL COMMENT 'rank name', | |
| 413 | + | `level` int(11) NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else', | |
| 414 | + | INDEX `guild_id` (`guild_id`), | |
| 415 | + | CONSTRAINT `guild_ranks_pk` PRIMARY KEY (`id`), | |
| 416 | + | CONSTRAINT `guild_ranks_fk` | |
| 417 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) | |
| 418 | + | ON DELETE CASCADE | |
| 419 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 420 | + | ||
| 421 | + | -- | |
| 422 | + | -- Trigger | |
| 423 | + | -- | |
| 424 | + | DELIMITER // | |
| 425 | + | CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds` FOR EACH ROW BEGIN | |
| 426 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('The Leader', 3, NEW.`id`); | |
| 427 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Vice-Leader', 2, NEW.`id`); | |
| 428 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Member', 1, NEW.`id`); | |
| 429 | + | END | |
| 430 | + | // | |
| 431 | + | DELIMITER ; | |
| 432 | + | ||
| 433 | + | -- Table structure `guild_membership` | |
| 434 | + | CREATE TABLE IF NOT EXISTS `guild_membership` ( | |
| 435 | + | `player_id` int(11) NOT NULL, | |
| 436 | + | `guild_id` int(11) NOT NULL, | |
| 437 | + | `rank_id` int(11) NOT NULL, | |
| 438 | + | `nick` varchar(15) NOT NULL DEFAULT '', | |
| 439 | + | INDEX `guild_id` (`guild_id`), | |
| 440 | + | INDEX `rank_id` (`rank_id`), | |
| 441 | + | CONSTRAINT `guild_membership_pk` PRIMARY KEY (`player_id`), | |
| 442 | + | CONSTRAINT `guild_membership_player_fk` | |
| 443 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 444 | + | ON DELETE CASCADE | |
| 445 | + | ON UPDATE CASCADE, | |
| 446 | + | CONSTRAINT `guild_membership_guild_fk` | |
| 447 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) | |
| 448 | + | ON DELETE CASCADE | |
| 449 | + | ON UPDATE CASCADE, | |
| 450 | + | CONSTRAINT `guild_membership_rank_fk` | |
| 451 | + | FOREIGN KEY (`rank_id`) REFERENCES `guild_ranks` (`id`) | |
| 452 | + | ON DELETE CASCADE | |
| 453 | + | ON UPDATE CASCADE | |
| 454 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 455 | + | ||
| 456 | + | -- Table structure `houses` | |
| 457 | + | CREATE TABLE IF NOT EXISTS `houses` ( | |
| 458 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 459 | + | `owner` int(11) NOT NULL, | |
| 460 | + | `new_owner` int(11) NOT NULL DEFAULT '-1', | |
| 461 | + | `paid` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 462 | + | `warnings` int(11) NOT NULL DEFAULT '0', | |
| 463 | + | `name` varchar(255) NOT NULL, | |
| 464 | + | `rent` int(11) NOT NULL DEFAULT '0', | |
| 465 | + | `town_id` int(11) NOT NULL DEFAULT '0', | |
| 466 | + | `size` int(11) NOT NULL DEFAULT '0', | |
| 467 | + | `guildid` int(11), | |
| 468 | + | `beds` int(11) NOT NULL DEFAULT '0', | |
| 469 | + | `bidder` int(11) NOT NULL DEFAULT '0', | |
| 470 | + | `bidder_name` varchar(255) NOT NULL DEFAULT '', | |
| 471 | + | `highest_bid` int(11) NOT NULL DEFAULT '0', | |
| 472 | + | `internal_bid` int(11) NOT NULL DEFAULT '0', | |
| 473 | + | `bid_end_date` int(11) NOT NULL DEFAULT '0', | |
| 474 | + | `state` smallint(5) UNSIGNED NOT NULL DEFAULT '0', | |
| 475 | + | `transfer_status` tinyint(1) DEFAULT '0', | |
| 476 | + | INDEX `owner` (`owner`), | |
| 477 | + | INDEX `town_id` (`town_id`), | |
| 478 | + | CONSTRAINT `houses_pk` PRIMARY KEY (`id`) | |
| 479 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 480 | + | ||
| 481 | + | -- | |
| 482 | + | -- trigger | |
| 483 | + | -- | |
| 484 | + | DELIMITER // | |
| 485 | + | CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players` FOR EACH ROW BEGIN | |
| 486 | + | UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`; | |
| 487 | + | END | |
| 488 | + | // | |
| 489 | + | DELIMITER ; | |
| 490 | + | ||
| 491 | + | -- Table structure `house_lists` | |
| 492 | + | CREATE TABLE IF NOT EXISTS `house_lists` ( | |
| 493 | + | `house_id` int NOT NULL, | |
| 494 | + | `listid` int NOT NULL, | |
| 495 | + | `version` bigint NOT NULL DEFAULT '0', | |
| 496 | + | `list` text NOT NULL, | |
| 497 | + | PRIMARY KEY (`house_id`, `listid`), | |
| 498 | + | KEY `house_id_index` (`house_id`), | |
| 499 | + | KEY `version` (`version`), | |
| 500 | + | CONSTRAINT `houses_list_house_fk` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE | |
| 501 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; | |
| 502 | + | ||
| 503 | + | -- Table structure `ip_bans` | |
| 504 | + | CREATE TABLE IF NOT EXISTS `ip_bans` ( | |
| 505 | + | `ip` int(11) NOT NULL, | |
| 506 | + | `reason` varchar(255) NOT NULL, | |
| 507 | + | `banned_at` bigint(20) NOT NULL, | |
| 508 | + | `expires_at` bigint(20) NOT NULL, | |
| 509 | + | `banned_by` int(11) NOT NULL, | |
| 510 | + | INDEX `banned_by` (`banned_by`), | |
| 511 | + | CONSTRAINT `ip_bans_pk` PRIMARY KEY (`ip`), | |
| 512 | + | CONSTRAINT `ip_bans_players_fk` | |
| 513 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) | |
| 514 | + | ON DELETE CASCADE | |
| 515 | + | ON UPDATE CASCADE | |
| 516 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 517 | + | ||
| 518 | + | -- Table structure `market_history` | |
| 519 | + | CREATE TABLE IF NOT EXISTS `market_history` ( | |
| 520 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 521 | + | `player_id` int(11) NOT NULL, | |
| 522 | + | `sale` tinyint(1) NOT NULL DEFAULT '0', | |
| 523 | + | `itemtype` int(10) UNSIGNED NOT NULL, | |
| 524 | + | `amount` smallint(5) UNSIGNED NOT NULL, | |
| 525 | + | `price` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 526 | + | `expires_at` bigint(20) UNSIGNED NOT NULL, | |
| 527 | + | `inserted` bigint(20) UNSIGNED NOT NULL, | |
| 528 | + | `state` tinyint(1) UNSIGNED NOT NULL, | |
| 529 | + | `tier` tinyint UNSIGNED NOT NULL DEFAULT '0', | |
| 530 | + | INDEX `player_id` (`player_id`,`sale`), | |
| 531 | + | CONSTRAINT `market_history_pk` PRIMARY KEY (`id`), | |
| 532 | + | CONSTRAINT `market_history_players_fk` | |
| 533 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 534 | + | ON DELETE CASCADE | |
| 535 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 536 | + | ||
| 537 | + | -- Table structure `market_offers` | |
| 538 | + | CREATE TABLE IF NOT EXISTS `market_offers` ( | |
| 539 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 540 | + | `player_id` int(11) NOT NULL, | |
| 541 | + | `sale` tinyint(1) NOT NULL DEFAULT '0', | |
| 542 | + | `itemtype` int(10) UNSIGNED NOT NULL, | |
| 543 | + | `amount` smallint(5) UNSIGNED NOT NULL, | |
| 544 | + | `created` bigint(20) UNSIGNED NOT NULL, | |
| 545 | + | `anonymous` tinyint(1) NOT NULL DEFAULT '0', | |
| 546 | + | `price` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 547 | + | `tier` tinyint UNSIGNED NOT NULL DEFAULT '0', | |
| 548 | + | INDEX `sale` (`sale`,`itemtype`), | |
| 549 | + | INDEX `created` (`created`), | |
| 550 | + | INDEX `player_id` (`player_id`), | |
| 551 | + | CONSTRAINT `market_offers_pk` PRIMARY KEY (`id`), | |
| 552 | + | CONSTRAINT `market_offers_players_fk` | |
| 553 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 554 | + | ON DELETE CASCADE | |
| 555 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 556 | + | ||
| 557 | + | -- Table structure `players_online` | |
| 558 | + | CREATE TABLE IF NOT EXISTS `players_online` ( | |
| 559 | + | `player_id` int(11) NOT NULL, | |
| 560 | + | CONSTRAINT `players_online_pk` PRIMARY KEY (`player_id`), | |
| 561 | + | CONSTRAINT `players_online_players_fk` | |
| 562 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 563 | + | ON DELETE CASCADE | |
| 564 | + | ) ENGINE=MEMORY DEFAULT CHARSET=utf8; | |
| 565 | + | ||
| 566 | + | -- Table structure `player_charm` | |
| 567 | + | CREATE TABLE IF NOT EXISTS `player_charms` ( | |
| 568 | + | `player_id` int(11) NOT NULL, | |
| 569 | + | `charm_points` SMALLINT NOT NULL DEFAULT '0', | |
| 570 | + | `minor_charm_echoes` SMALLINT NOT NULL DEFAULT '0', | |
| 571 | + | `max_charm_points` SMALLINT NOT NULL DEFAULT '0', | |
| 572 | + | `max_minor_charm_echoes` SMALLINT NOT NULL DEFAULT '0', | |
| 573 | + | `charm_expansion` BOOLEAN NOT NULL DEFAULT FALSE, | |
| 574 | + | `UsedRunesBit` INT NOT NULL DEFAULT '0', | |
| 575 | + | `UnlockedRunesBit` INT NOT NULL DEFAULT '0', | |
| 576 | + | `charms` BLOB NULL, | |
| 577 | + | `tracker list` BLOB NULL, | |
| 578 | + | CONSTRAINT `player_charms_players_fk` | |
| 579 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 580 | + | ON DELETE CASCADE | |
| 581 | + | ) ENGINE = InnoDB DEFAULT CHARSET=utf8; | |
| 582 | + | ||
| 583 | + | -- Table structure `player_deaths` | |
| 584 | + | CREATE TABLE IF NOT EXISTS `player_deaths` ( | |
| 585 | + | `player_id` int(11) NOT NULL, | |
| 586 | + | `time` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 587 | + | `level` int(11) NOT NULL DEFAULT '1', | |
| 588 | + | `killed_by` varchar(255) NOT NULL, | |
| 589 | + | `is_player` tinyint(1) NOT NULL DEFAULT '1', | |
| 590 | + | `mostdamage_by` varchar(100) NOT NULL, | |
| 591 | + | `mostdamage_is_player` tinyint(1) NOT NULL DEFAULT '0', | |
| 592 | + | `unjustified` tinyint(1) NOT NULL DEFAULT '0', | |
| 593 | + | `mostdamage_unjustified` tinyint(1) NOT NULL DEFAULT '0', | |
| 594 | + | `participants` TEXT NOT NULL, | |
| 595 | + | INDEX `player_id` (`player_id`), | |
| 596 | + | INDEX `killed_by` (`killed_by`), | |
| 597 | + | INDEX `mostdamage_by` (`mostdamage_by`), | |
| 598 | + | CONSTRAINT `player_deaths_players_fk` | |
| 599 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 600 | + | ON DELETE CASCADE | |
| 601 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 602 | + | ||
| 603 | + | -- Table structure `player_depotitems` | |
| 604 | + | CREATE TABLE IF NOT EXISTS `player_depotitems` ( | |
| 605 | + | `player_id` int(11) NOT NULL, | |
| 606 | + | `sid` int(11) NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots', | |
| 607 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 608 | + | `itemtype` int(11) NOT NULL DEFAULT '0', | |
| 609 | + | `count` int(11) NOT NULL DEFAULT '0', | |
| 610 | + | `attributes` blob NOT NULL, | |
| 611 | + | CONSTRAINT `player_depotitems_unique` UNIQUE (`player_id`, `sid`), | |
| 612 | + | CONSTRAINT `player_depotitems_players_fk` | |
| 613 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 614 | + | ON DELETE CASCADE | |
| 615 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 616 | + | ||
| 617 | + | -- Table structure `player_hirelings` | |
| 618 | + | CREATE TABLE IF NOT EXISTS `player_hirelings` ( | |
| 619 | + | `id` INT NOT NULL PRIMARY KEY auto_increment, | |
| 620 | + | `player_id` INT NOT NULL, | |
| 621 | + | `name` varchar(255), | |
| 622 | + | `active` tinyint unsigned NOT NULL DEFAULT '0', | |
| 623 | + | `sex` tinyint unsigned NOT NULL DEFAULT '0', | |
| 624 | + | `posx` int(11) NOT NULL DEFAULT '0', | |
| 625 | + | `posy` int(11) NOT NULL DEFAULT '0', | |
| 626 | + | `posz` int(11) NOT NULL DEFAULT '0', | |
| 627 | + | `lookbody` int(11) NOT NULL DEFAULT '0', | |
| 628 | + | `lookfeet` int(11) NOT NULL DEFAULT '0', | |
| 629 | + | `lookhead` int(11) NOT NULL DEFAULT '0', | |
| 630 | + | `looklegs` int(11) NOT NULL DEFAULT '0', | |
| 631 | + | `looktype` int(11) NOT NULL DEFAULT '136', | |
| 632 | + | FOREIGN KEY(`player_id`) REFERENCES `players`(`id`) | |
| 633 | + | ON DELETE CASCADE | |
| 634 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 635 | + | ||
| 636 | + | -- Table structure `player_inboxitems` | |
| 637 | + | CREATE TABLE IF NOT EXISTS `player_inboxitems` ( | |
| 638 | + | `player_id` int(11) NOT NULL, | |
| 639 | + | `sid` int(11) NOT NULL, | |
| 640 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 641 | + | `itemtype` int(11) NOT NULL DEFAULT '0', | |
| 642 | + | `count` int(11) NOT NULL DEFAULT '0', | |
| 643 | + | `attributes` blob NOT NULL, | |
| 644 | + | CONSTRAINT `player_inboxitems_unique` UNIQUE (`player_id`, `sid`), | |
| 645 | + | CONSTRAINT `player_inboxitems_players_fk` | |
| 646 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 647 | + | ON DELETE CASCADE | |
| 648 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 649 | + | ||
| 650 | + | -- Table structure `player_items` | |
| 651 | + | CREATE TABLE IF NOT EXISTS `player_items` ( | |
| 652 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 653 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 654 | + | `sid` int(11) NOT NULL DEFAULT '0', | |
| 655 | + | `itemtype` int(11) NOT NULL DEFAULT '0', | |
| 656 | + | `count` int(11) NOT NULL DEFAULT '0', | |
| 657 | + | `attributes` blob NOT NULL, | |
| 658 | + | INDEX `player_id` (`player_id`), | |
| 659 | + | INDEX `sid` (`sid`), | |
| 660 | + | CONSTRAINT `player_items_players_fk` | |
| 661 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 662 | + | ON DELETE CASCADE, | |
| 663 | + | CONSTRAINT `player_items_pk` | |
| 664 | + | PRIMARY KEY (`player_id`, `pid`, `sid`) | |
| 665 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 666 | + | ||
| 667 | + | -- Table structure `player_wheeldata` | |
| 668 | + | CREATE TABLE IF NOT EXISTS `player_wheeldata` ( | |
| 669 | + | `player_id` int(11) NOT NULL, | |
| 670 | + | `slot` blob NOT NULL, | |
| 671 | + | INDEX `player_id` (`player_id`), | |
| 672 | + | CONSTRAINT `player_wheeldata_players_fk` | |
| 673 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 674 | + | ON DELETE CASCADE, | |
| 675 | + | CONSTRAINT `player_wheeldata_pk` | |
| 676 | + | PRIMARY KEY (`player_id`) | |
| 677 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 678 | + | ||
| 679 | + | -- Table structure `player_kills` | |
| 680 | + | CREATE TABLE IF NOT EXISTS `player_kills` ( | |
| 681 | + | `player_id` int(11) NOT NULL, | |
| 682 | + | `time` bigint(20) UNSIGNED NOT NULL DEFAULT '0', | |
| 683 | + | `target` int(11) NOT NULL, | |
| 684 | + | `unavenged` tinyint(1) NOT NULL DEFAULT '0', | |
| 685 | + | CONSTRAINT `player_kills_players_fk` | |
| 686 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 687 | + | ON DELETE CASCADE | |
| 688 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 689 | + | ||
| 690 | + | -- Table structure `player_namelocks` | |
| 691 | + | CREATE TABLE IF NOT EXISTS `player_namelocks` ( | |
| 692 | + | `player_id` int(11) NOT NULL, | |
| 693 | + | `reason` varchar(255) NOT NULL, | |
| 694 | + | `namelocked_at` bigint(20) NOT NULL, | |
| 695 | + | `namelocked_by` int(11) NOT NULL, | |
| 696 | + | INDEX `namelocked_by` (`namelocked_by`), | |
| 697 | + | CONSTRAINT `player_namelocks_unique` UNIQUE (`player_id`), | |
| 698 | + | CONSTRAINT `player_namelocks_players_fk` | |
| 699 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 700 | + | ON DELETE CASCADE | |
| 701 | + | ON UPDATE CASCADE, | |
| 702 | + | CONSTRAINT `player_namelocks_players2_fk` | |
| 703 | + | FOREIGN KEY (`namelocked_by`) REFERENCES `players` (`id`) | |
| 704 | + | ON DELETE CASCADE | |
| 705 | + | ON UPDATE CASCADE | |
| 706 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 707 | + | ||
| 708 | + | -- Table structure `player_prey` | |
| 709 | + | CREATE TABLE IF NOT EXISTS `player_prey` ( | |
| 710 | + | `player_id` int(11) NOT NULL, | |
| 711 | + | `slot` tinyint(1) NOT NULL, | |
| 712 | + | `state` tinyint(1) NOT NULL, | |
| 713 | + | `raceid` varchar(250) NOT NULL, | |
| 714 | + | `option` tinyint(1) NOT NULL, | |
| 715 | + | `bonus_type` tinyint(1) NOT NULL, | |
| 716 | + | `bonus_rarity` tinyint(1) NOT NULL, | |
| 717 | + | `bonus_percentage` varchar(250) NOT NULL, | |
| 718 | + | `bonus_time` varchar(250) NOT NULL, | |
| 719 | + | `free_reroll` bigint(20) NOT NULL, | |
| 720 | + | `monster_list` BLOB NULL, | |
| 721 | + | CONSTRAINT `player_prey_pk` PRIMARY KEY (`player_id`, `slot`), | |
| 722 | + | CONSTRAINT `player_prey_players_fk` | |
| 723 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 724 | + | ON DELETE CASCADE | |
| 725 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 726 | + | ||
| 727 | + | -- Table structure `player_taskhunt` | |
| 728 | + | CREATE TABLE IF NOT EXISTS `player_taskhunt` ( | |
| 729 | + | `player_id` int(11) NOT NULL, | |
| 730 | + | `slot` tinyint(1) NOT NULL, | |
| 731 | + | `state` tinyint(1) NOT NULL, | |
| 732 | + | `raceid` varchar(250) NOT NULL, | |
| 733 | + | `upgrade` tinyint(1) NOT NULL, | |
| 734 | + | `rarity` tinyint(1) NOT NULL, | |
| 735 | + | `kills` varchar(250) NOT NULL, | |
| 736 | + | `disabled_time` bigint(20) NOT NULL, | |
| 737 | + | `free_reroll` bigint(20) NOT NULL, | |
| 738 | + | `monster_list` BLOB NULL, | |
| 739 | + | CONSTRAINT `player_taskhunt_pk` PRIMARY KEY (`player_id`, `slot`), | |
| 740 | + | CONSTRAINT `player_taskhunt_players_fk` | |
| 741 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 742 | + | ON DELETE CASCADE | |
| 743 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 744 | + | ||
| 745 | + | -- Table structure `player_bosstiary` | |
| 746 | + | CREATE TABLE IF NOT EXISTS `player_bosstiary` ( | |
| 747 | + | `player_id` int NOT NULL, | |
| 748 | + | `bossIdSlotOne` int NOT NULL DEFAULT 0, | |
| 749 | + | `bossIdSlotTwo` int NOT NULL DEFAULT 0, | |
| 750 | + | `removeTimes` int NOT NULL DEFAULT 1, | |
| 751 | + | `tracker` blob NOT NULL, | |
| 752 | + | CONSTRAINT `player_bosstiary_players_fk` | |
| 753 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 754 | + | ON DELETE CASCADE | |
| 755 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 756 | + | ||
| 757 | + | -- Table structure `player_rewards` | |
| 758 | + | CREATE TABLE IF NOT EXISTS `player_rewards` ( | |
| 759 | + | `player_id` int(11) NOT NULL, | |
| 760 | + | `sid` int(11) NOT NULL, | |
| 761 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 762 | + | `itemtype` int(11) NOT NULL DEFAULT '0', | |
| 763 | + | `count` int(11) NOT NULL DEFAULT '0', | |
| 764 | + | `attributes` blob NOT NULL, | |
| 765 | + | CONSTRAINT `player_rewards_unique` UNIQUE (`player_id`, `sid`), | |
| 766 | + | CONSTRAINT `player_rewards_players_fk` | |
| 767 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 768 | + | ON DELETE CASCADE | |
| 769 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 770 | + | ||
| 771 | + | -- Table structure `player_spells` | |
| 772 | + | CREATE TABLE IF NOT EXISTS `player_spells` ( | |
| 773 | + | `player_id` int(11) NOT NULL, | |
| 774 | + | `name` varchar(255) NOT NULL, | |
| 775 | + | INDEX `player_id` (`player_id`), | |
| 776 | + | CONSTRAINT `player_spells_players_fk` | |
| 777 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 778 | + | ON DELETE CASCADE, | |
| 779 | + | CONSTRAINT `player_spells_pk` PRIMARY KEY (`player_id`, `name`) | |
| 780 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 781 | + | ||
| 782 | + | -- Table structure `player_stash` | |
| 783 | + | CREATE TABLE IF NOT EXISTS `player_stash` ( | |
| 784 | + | `player_id` INT(16) NOT NULL, | |
| 785 | + | `item_id` INT(16) NOT NULL, | |
| 786 | + | `item_count` INT(32) NOT NULL, | |
| 787 | + | CONSTRAINT `player_stash_pk` PRIMARY KEY (`player_id`, `item_id`), | |
| 788 | + | CONSTRAINT `player_stash_players_fk` | |
| 789 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 790 | + | ON DELETE CASCADE | |
| 791 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 792 | + | ||
| 793 | + | -- Table structure `player_storage` | |
| 794 | + | CREATE TABLE IF NOT EXISTS `player_storage` ( | |
| 795 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 796 | + | `key` int(10) UNSIGNED NOT NULL DEFAULT '0', | |
| 797 | + | `value` int(11) NOT NULL DEFAULT '0', | |
| 798 | + | CONSTRAINT `player_storage_pk` PRIMARY KEY (`player_id`, `key`), | |
| 799 | + | CONSTRAINT `player_storage_players_fk` | |
| 800 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) | |
| 801 | + | ON DELETE CASCADE | |
| 802 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 803 | + | ||
| 804 | + | -- Table structure `store_history` | |
| 805 | + | CREATE TABLE IF NOT EXISTS `store_history` ( | |
| 806 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 807 | + | `account_id` int(11) UNSIGNED NOT NULL, | |
| 808 | + | `mode` smallint(2) NOT NULL DEFAULT '0', | |
| 809 | + | `description` varchar(3500) NOT NULL, | |
| 810 | + | `coin_type` tinyint(1) NOT NULL DEFAULT '0', | |
| 811 | + | `coin_amount` int(12) NOT NULL, | |
| 812 | + | `time` bigint(20) UNSIGNED NOT NULL, | |
| 813 | + | `timestamp` int(11) NOT NULL DEFAULT '0', | |
| 814 | + | `coins` int(11) NOT NULL DEFAULT '0', | |
| 815 | + | INDEX `account_id` (`account_id`), | |
| 816 | + | CONSTRAINT `store_history_pk` PRIMARY KEY (`id`), | |
| 817 | + | CONSTRAINT `store_history_account_fk` | |
| 818 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) | |
| 819 | + | ON DELETE CASCADE | |
| 820 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 821 | + | ||
| 822 | + | -- Table structure `tile_store` | |
| 823 | + | CREATE TABLE IF NOT EXISTS `tile_store` ( | |
| 824 | + | `house_id` int(11) NOT NULL, | |
| 825 | + | `data` longblob NOT NULL, | |
| 826 | + | INDEX `house_id` (`house_id`), | |
| 827 | + | CONSTRAINT `tile_store_account_fk` | |
| 828 | + | FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) | |
| 829 | + | ON DELETE CASCADE | |
| 830 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 831 | + | ||
| 832 | + | -- Table structure `towns` | |
| 833 | + | CREATE TABLE IF NOT EXISTS `towns` ( | |
| 834 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 835 | + | `name` varchar(255) NOT NULL, | |
| 836 | + | `posx` int NOT NULL DEFAULT '0', | |
| 837 | + | `posy` int NOT NULL DEFAULT '0', | |
| 838 | + | `posz` int NOT NULL DEFAULT '0', | |
| 839 | + | PRIMARY KEY (`id`), | |
| 840 | + | UNIQUE KEY `name` (`name`) | |
| 841 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 842 | + | ||
| 843 | + | -- Table structure `account_sessions` | |
| 844 | + | CREATE TABLE IF NOT EXISTS `account_sessions` ( | |
| 845 | + | `id` VARCHAR(191) NOT NULL, | |
| 846 | + | `account_id` INTEGER UNSIGNED NOT NULL, | |
| 847 | + | `expires` BIGINT UNSIGNED NOT NULL, | |
| 848 | + | ||
| 849 | + | PRIMARY KEY (`id`) | |
| 850 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 851 | + | ||
| 852 | + | -- Table structure `kv_store` | |
| 853 | + | CREATE TABLE IF NOT EXISTS `kv_store` ( | |
| 854 | + | `key_name` varchar(191) NOT NULL, | |
| 855 | + | `timestamp` bigint NOT NULL, | |
| 856 | + | `value` longblob NOT NULL, | |
| 857 | + | PRIMARY KEY (`key_name`) | |
| 858 | + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 859 | + | ||
| 860 | + | -- Create Account god/god | |
| 861 | + | INSERT INTO `accounts` | |
| 862 | + | (`id`, `name`, `email`, `password`, `type`) VALUES | |
| 863 | + | (1, 'god', '@god', '21298df8a3277357ee55b01df9530b535cf08ec1', 6); | |
| 864 | + | ||
| 865 | + | -- Create player on GOD account | |
| 866 | + | -- Create sample characters | |
| 867 | + | INSERT INTO `players` | |
| 868 | + | (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `town_id`, `conditions`, `cap`, `sex`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`) VALUES | |
| 869 | + | (1, 'Rook Sample', 1, 1, 2, 0, 155, 155, 100, 113, 115, 95, 39, 129, 2, 60, 60, 5936, 1, '', 410, 1, 12, 155, 12, 155, 12, 155, 12, 93), | |
| 870 | + | (2, 'Sorcerer Sample', 1, 1, 8, 1, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0), | |
| 871 | + | (3, 'Druid Sample', 1, 1, 8, 2, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0), | |
| 872 | + | (4, 'Paladin Sample', 1, 1, 8, 3, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0), | |
| 873 | + | (5, 'Knight Sample', 1, 1, 8, 4, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0), | |
| 874 | + | (6, 'Monk Sample', 1, 1, 8, 9, 185, 185, 4200, 113, 115, 95, 39, 129, 0, 90, 90, 0, 8, '', 470, 1, 10, 0, 10, 0, 10, 0, 10, 0), | |
| 875 | + | (7, 'GOD', 6, 1, 2, 0, 155, 155, 100, 113, 115, 95, 39, 75, 0, 60, 60, 0, 8, '', 410, 1, 10, 0, 10, 0, 10, 0, 10, 0); |
| @@ -0,0 +1,352 @@ | |||
| 1 | + | -- The Forgotten Server (TFS) 1.1 database schema. | |
| 2 | + | -- Source: https://github.com/otland/forgottenserver/blob/v1.1/schema.sql | |
| 3 | + | -- License: GPL-2.0. Covers ZnoteX's TFS_10 engine choice ("TFS 1.1 - 1.4.2"). | |
| 4 | + | ||
| 5 | + | CREATE TABLE IF NOT EXISTS `accounts` ( | |
| 6 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 7 | + | `name` varchar(32) NOT NULL, | |
| 8 | + | `password` char(40) NOT NULL, | |
| 9 | + | `type` int(11) NOT NULL DEFAULT '1', | |
| 10 | + | `premdays` int(11) NOT NULL DEFAULT '0', | |
| 11 | + | `lastday` int(10) unsigned NOT NULL DEFAULT '0', | |
| 12 | + | `email` varchar(255) NOT NULL DEFAULT '', | |
| 13 | + | `creation` int(11) NOT NULL DEFAULT '0', | |
| 14 | + | PRIMARY KEY (`id`), | |
| 15 | + | UNIQUE KEY `name` (`name`) | |
| 16 | + | ) ENGINE=InnoDB; | |
| 17 | + | ||
| 18 | + | CREATE TABLE IF NOT EXISTS `players` ( | |
| 19 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 20 | + | `name` varchar(255) NOT NULL, | |
| 21 | + | `group_id` int(11) NOT NULL DEFAULT '1', | |
| 22 | + | `account_id` int(11) NOT NULL DEFAULT '0', | |
| 23 | + | `level` int(11) NOT NULL DEFAULT '1', | |
| 24 | + | `vocation` int(11) NOT NULL DEFAULT '0', | |
| 25 | + | `health` int(11) NOT NULL DEFAULT '150', | |
| 26 | + | `healthmax` int(11) NOT NULL DEFAULT '150', | |
| 27 | + | `experience` bigint(20) NOT NULL DEFAULT '0', | |
| 28 | + | `lookbody` int(11) NOT NULL DEFAULT '0', | |
| 29 | + | `lookfeet` int(11) NOT NULL DEFAULT '0', | |
| 30 | + | `lookhead` int(11) NOT NULL DEFAULT '0', | |
| 31 | + | `looklegs` int(11) NOT NULL DEFAULT '0', | |
| 32 | + | `looktype` int(11) NOT NULL DEFAULT '136', | |
| 33 | + | `lookaddons` int(11) NOT NULL DEFAULT '0', | |
| 34 | + | `maglevel` int(11) NOT NULL DEFAULT '0', | |
| 35 | + | `mana` int(11) NOT NULL DEFAULT '0', | |
| 36 | + | `manamax` int(11) NOT NULL DEFAULT '0', | |
| 37 | + | `manaspent` int(11) unsigned NOT NULL DEFAULT '0', | |
| 38 | + | `soul` int(10) unsigned NOT NULL DEFAULT '0', | |
| 39 | + | `town_id` int(11) NOT NULL DEFAULT '0', | |
| 40 | + | `posx` int(11) NOT NULL DEFAULT '0', | |
| 41 | + | `posy` int(11) NOT NULL DEFAULT '0', | |
| 42 | + | `posz` int(11) NOT NULL DEFAULT '0', | |
| 43 | + | `conditions` blob NOT NULL, | |
| 44 | + | `cap` int(11) NOT NULL DEFAULT '0', | |
| 45 | + | `sex` int(11) NOT NULL DEFAULT '0', | |
| 46 | + | `lastlogin` bigint(20) unsigned NOT NULL DEFAULT '0', | |
| 47 | + | `lastip` int(10) unsigned NOT NULL DEFAULT '0', | |
| 48 | + | `save` tinyint(1) NOT NULL DEFAULT '1', | |
| 49 | + | `skull` tinyint(1) NOT NULL DEFAULT '0', | |
| 50 | + | `skulltime` int(11) NOT NULL DEFAULT '0', | |
| 51 | + | `lastlogout` bigint(20) unsigned NOT NULL DEFAULT '0', | |
| 52 | + | `blessings` tinyint(2) NOT NULL DEFAULT '0', | |
| 53 | + | `onlinetime` int(11) NOT NULL DEFAULT '0', | |
| 54 | + | `deletion` bigint(15) NOT NULL DEFAULT '0', | |
| 55 | + | `balance` bigint(20) unsigned NOT NULL DEFAULT '0', | |
| 56 | + | `offlinetraining_time` smallint(5) unsigned NOT NULL DEFAULT '43200', | |
| 57 | + | `offlinetraining_skill` int(11) NOT NULL DEFAULT '-1', | |
| 58 | + | `stamina` smallint(5) unsigned NOT NULL DEFAULT '2520', | |
| 59 | + | `skill_fist` int(10) unsigned NOT NULL DEFAULT 10, | |
| 60 | + | `skill_fist_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 61 | + | `skill_club` int(10) unsigned NOT NULL DEFAULT 10, | |
| 62 | + | `skill_club_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 63 | + | `skill_sword` int(10) unsigned NOT NULL DEFAULT 10, | |
| 64 | + | `skill_sword_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 65 | + | `skill_axe` int(10) unsigned NOT NULL DEFAULT 10, | |
| 66 | + | `skill_axe_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 67 | + | `skill_dist` int(10) unsigned NOT NULL DEFAULT 10, | |
| 68 | + | `skill_dist_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 69 | + | `skill_shielding` int(10) unsigned NOT NULL DEFAULT 10, | |
| 70 | + | `skill_shielding_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 71 | + | `skill_fishing` int(10) unsigned NOT NULL DEFAULT 10, | |
| 72 | + | `skill_fishing_tries` bigint(20) unsigned NOT NULL DEFAULT 0, | |
| 73 | + | PRIMARY KEY (`id`), | |
| 74 | + | UNIQUE KEY `name` (`name`), | |
| 75 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, | |
| 76 | + | KEY `vocation` (`vocation`) | |
| 77 | + | ) ENGINE=InnoDB; | |
| 78 | + | ||
| 79 | + | CREATE TABLE IF NOT EXISTS `account_bans` ( | |
| 80 | + | `account_id` int(11) NOT NULL, | |
| 81 | + | `reason` varchar(255) NOT NULL, | |
| 82 | + | `banned_at` bigint(20) NOT NULL, | |
| 83 | + | `expires_at` bigint(20) NOT NULL, | |
| 84 | + | `banned_by` int(11) NOT NULL, | |
| 85 | + | PRIMARY KEY (`account_id`), | |
| 86 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 87 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 88 | + | ) ENGINE=InnoDB; | |
| 89 | + | ||
| 90 | + | CREATE TABLE IF NOT EXISTS `account_ban_history` ( | |
| 91 | + | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
| 92 | + | `account_id` int(11) NOT NULL, | |
| 93 | + | `reason` varchar(255) NOT NULL, | |
| 94 | + | `banned_at` bigint(20) NOT NULL, | |
| 95 | + | `expired_at` bigint(20) NOT NULL, | |
| 96 | + | `banned_by` int(11) NOT NULL, | |
| 97 | + | PRIMARY KEY (`id`), | |
| 98 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 99 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 100 | + | ) ENGINE=InnoDB; | |
| 101 | + | ||
| 102 | + | CREATE TABLE IF NOT EXISTS `ip_bans` ( | |
| 103 | + | `ip` int(10) unsigned NOT NULL, | |
| 104 | + | `reason` varchar(255) NOT NULL, | |
| 105 | + | `banned_at` bigint(20) NOT NULL, | |
| 106 | + | `expires_at` bigint(20) NOT NULL, | |
| 107 | + | `banned_by` int(11) NOT NULL, | |
| 108 | + | PRIMARY KEY (`ip`), | |
| 109 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 110 | + | ) ENGINE=InnoDB; | |
| 111 | + | ||
| 112 | + | CREATE TABLE IF NOT EXISTS `player_namelocks` ( | |
| 113 | + | `player_id` int(11) NOT NULL, | |
| 114 | + | `reason` varchar(255) NOT NULL, | |
| 115 | + | `namelocked_at` bigint(20) NOT NULL, | |
| 116 | + | `namelocked_by` int(11) NOT NULL, | |
| 117 | + | PRIMARY KEY (`player_id`), | |
| 118 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 119 | + | FOREIGN KEY (`namelocked_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 120 | + | ) ENGINE=InnoDB; | |
| 121 | + | ||
| 122 | + | CREATE TABLE IF NOT EXISTS `account_viplist` ( | |
| 123 | + | `account_id` int(11) NOT NULL COMMENT 'id of account whose viplist entry it is', | |
| 124 | + | `player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry', | |
| 125 | + | `description` varchar(128) NOT NULL DEFAULT '', | |
| 126 | + | `icon` tinyint(2) unsigned NOT NULL DEFAULT '0', | |
| 127 | + | `notify` tinyint(1) NOT NULL DEFAULT '0', | |
| 128 | + | UNIQUE KEY `account_player_index` (`account_id`,`player_id`), | |
| 129 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, | |
| 130 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE | |
| 131 | + | ) ENGINE=InnoDB; | |
| 132 | + | ||
| 133 | + | CREATE TABLE IF NOT EXISTS `guilds` ( | |
| 134 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 135 | + | `name` varchar(255) NOT NULL, | |
| 136 | + | `ownerid` int(11) NOT NULL, | |
| 137 | + | `creationdata` int(11) NOT NULL, | |
| 138 | + | `motd` varchar(255) NOT NULL DEFAULT '', | |
| 139 | + | PRIMARY KEY (`id`), | |
| 140 | + | UNIQUE KEY (`name`), | |
| 141 | + | UNIQUE KEY (`ownerid`), | |
| 142 | + | FOREIGN KEY (`ownerid`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 143 | + | ) ENGINE=InnoDB; | |
| 144 | + | ||
| 145 | + | CREATE TABLE IF NOT EXISTS `guild_invites` ( | |
| 146 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 147 | + | `guild_id` int(11) NOT NULL DEFAULT '0', | |
| 148 | + | PRIMARY KEY (`player_id`,`guild_id`), | |
| 149 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE, | |
| 150 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE | |
| 151 | + | ) ENGINE=InnoDB; | |
| 152 | + | ||
| 153 | + | CREATE TABLE IF NOT EXISTS `guild_ranks` ( | |
| 154 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 155 | + | `guild_id` int(11) NOT NULL COMMENT 'guild', | |
| 156 | + | `name` varchar(255) NOT NULL COMMENT 'rank name', | |
| 157 | + | `level` int(11) NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else', | |
| 158 | + | PRIMARY KEY (`id`), | |
| 159 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE | |
| 160 | + | ) ENGINE=InnoDB; | |
| 161 | + | ||
| 162 | + | CREATE TABLE IF NOT EXISTS `guild_membership` ( | |
| 163 | + | `player_id` int(11) NOT NULL, | |
| 164 | + | `guild_id` int(11) NOT NULL, | |
| 165 | + | `rank_id` int(11) NOT NULL, | |
| 166 | + | `nick` varchar(15) NOT NULL DEFAULT '', | |
| 167 | + | PRIMARY KEY (`player_id`), | |
| 168 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 169 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 170 | + | FOREIGN KEY (`rank_id`) REFERENCES `guild_ranks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 171 | + | ) ENGINE=InnoDB; | |
| 172 | + | ||
| 173 | + | CREATE TABLE IF NOT EXISTS `guild_wars` ( | |
| 174 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 175 | + | `guild1` int(11) NOT NULL DEFAULT '0', | |
| 176 | + | `guild2` int(11) NOT NULL DEFAULT '0', | |
| 177 | + | `name1` varchar(255) NOT NULL, | |
| 178 | + | `name2` varchar(255) NOT NULL, | |
| 179 | + | `status` tinyint(2) NOT NULL DEFAULT '0', | |
| 180 | + | `started` bigint(15) NOT NULL DEFAULT '0', | |
| 181 | + | `ended` bigint(15) NOT NULL DEFAULT '0', | |
| 182 | + | PRIMARY KEY (`id`), | |
| 183 | + | KEY `guild1` (`guild1`), | |
| 184 | + | KEY `guild2` (`guild2`) | |
| 185 | + | ) ENGINE=InnoDB; | |
| 186 | + | ||
| 187 | + | CREATE TABLE IF NOT EXISTS `guildwar_kills` ( | |
| 188 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 189 | + | `killer` varchar(50) NOT NULL, | |
| 190 | + | `target` varchar(50) NOT NULL, | |
| 191 | + | `killerguild` int(11) NOT NULL DEFAULT '0', | |
| 192 | + | `targetguild` int(11) NOT NULL DEFAULT '0', | |
| 193 | + | `warid` int(11) NOT NULL DEFAULT '0', | |
| 194 | + | `time` bigint(15) NOT NULL, | |
| 195 | + | PRIMARY KEY (`id`), | |
| 196 | + | FOREIGN KEY (`warid`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE | |
| 197 | + | ) ENGINE=InnoDB; | |
| 198 | + | ||
| 199 | + | CREATE TABLE IF NOT EXISTS `houses` ( | |
| 200 | + | `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 201 | + | `owner` int(11) NOT NULL, | |
| 202 | + | `paid` int(10) unsigned NOT NULL DEFAULT '0', | |
| 203 | + | `warnings` int(11) NOT NULL DEFAULT '0', | |
| 204 | + | `name` varchar(255) NOT NULL, | |
| 205 | + | `rent` int(11) NOT NULL DEFAULT '0', | |
| 206 | + | `town_id` int(11) NOT NULL DEFAULT '0', | |
| 207 | + | `bid` int(11) NOT NULL DEFAULT '0', | |
| 208 | + | `bid_end` int(11) NOT NULL DEFAULT '0', | |
| 209 | + | `last_bid` int(11) NOT NULL DEFAULT '0', | |
| 210 | + | `highest_bidder` int(11) NOT NULL DEFAULT '0', | |
| 211 | + | `size` int(11) NOT NULL DEFAULT '0', | |
| 212 | + | `beds` int(11) NOT NULL DEFAULT '0', | |
| 213 | + | PRIMARY KEY (`id`), | |
| 214 | + | KEY `owner` (`owner`), | |
| 215 | + | KEY `town_id` (`town_id`) | |
| 216 | + | ) ENGINE=InnoDB; | |
| 217 | + | ||
| 218 | + | CREATE TABLE IF NOT EXISTS `house_lists` ( | |
| 219 | + | `house_id` int(11) NOT NULL, | |
| 220 | + | `listid` int(11) NOT NULL, | |
| 221 | + | `list` text NOT NULL, | |
| 222 | + | FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE | |
| 223 | + | ) ENGINE=InnoDB; | |
| 224 | + | ||
| 225 | + | CREATE TABLE IF NOT EXISTS `market_history` ( | |
| 226 | + | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
| 227 | + | `player_id` int(11) NOT NULL, | |
| 228 | + | `sale` tinyint(1) NOT NULL DEFAULT '0', | |
| 229 | + | `itemtype` int(10) unsigned NOT NULL, | |
| 230 | + | `amount` smallint(5) unsigned NOT NULL, | |
| 231 | + | `price` int(10) unsigned NOT NULL DEFAULT '0', | |
| 232 | + | `expires_at` bigint(20) unsigned NOT NULL, | |
| 233 | + | `inserted` bigint(20) unsigned NOT NULL, | |
| 234 | + | `state` tinyint(1) unsigned NOT NULL, | |
| 235 | + | PRIMARY KEY (`id`), | |
| 236 | + | KEY `player_id` (`player_id`, `sale`), | |
| 237 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 238 | + | ) ENGINE=InnoDB; | |
| 239 | + | ||
| 240 | + | CREATE TABLE IF NOT EXISTS `market_offers` ( | |
| 241 | + | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
| 242 | + | `player_id` int(11) NOT NULL, | |
| 243 | + | `sale` tinyint(1) NOT NULL DEFAULT '0', | |
| 244 | + | `itemtype` int(10) unsigned NOT NULL, | |
| 245 | + | `amount` smallint(5) unsigned NOT NULL, | |
| 246 | + | `created` bigint(20) unsigned NOT NULL, | |
| 247 | + | `anonymous` tinyint(1) NOT NULL DEFAULT '0', | |
| 248 | + | `price` int(10) unsigned NOT NULL DEFAULT '0', | |
| 249 | + | PRIMARY KEY (`id`), | |
| 250 | + | KEY `sale` (`sale`,`itemtype`), | |
| 251 | + | KEY `created` (`created`), | |
| 252 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 253 | + | ) ENGINE=InnoDB; | |
| 254 | + | ||
| 255 | + | CREATE TABLE IF NOT EXISTS `players_online` ( | |
| 256 | + | `player_id` int(11) NOT NULL, | |
| 257 | + | PRIMARY KEY (`player_id`) | |
| 258 | + | ) ENGINE=MEMORY; | |
| 259 | + | ||
| 260 | + | CREATE TABLE IF NOT EXISTS `player_deaths` ( | |
| 261 | + | `player_id` int(11) NOT NULL, | |
| 262 | + | `time` bigint(20) unsigned NOT NULL DEFAULT '0', | |
| 263 | + | `level` int(11) NOT NULL DEFAULT '1', | |
| 264 | + | `killed_by` varchar(255) NOT NULL, | |
| 265 | + | `is_player` tinyint(1) NOT NULL DEFAULT '1', | |
| 266 | + | `mostdamage_by` varchar(100) NOT NULL, | |
| 267 | + | `mostdamage_is_player` tinyint(1) NOT NULL DEFAULT '0', | |
| 268 | + | `unjustified` tinyint(1) NOT NULL DEFAULT '0', | |
| 269 | + | `mostdamage_unjustified` tinyint(1) NOT NULL DEFAULT '0', | |
| 270 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, | |
| 271 | + | KEY `killed_by` (`killed_by`), | |
| 272 | + | KEY `mostdamage_by` (`mostdamage_by`) | |
| 273 | + | ) ENGINE=InnoDB; | |
| 274 | + | ||
| 275 | + | CREATE TABLE IF NOT EXISTS `player_depotitems` ( | |
| 276 | + | `player_id` int(11) NOT NULL, | |
| 277 | + | `sid` int(11) NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots', | |
| 278 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 279 | + | `itemtype` smallint(6) NOT NULL, | |
| 280 | + | `count` smallint(5) NOT NULL DEFAULT '0', | |
| 281 | + | `attributes` blob NOT NULL, | |
| 282 | + | UNIQUE KEY `player_id_2` (`player_id`, `sid`), | |
| 283 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 284 | + | ) ENGINE=InnoDB; | |
| 285 | + | ||
| 286 | + | CREATE TABLE IF NOT EXISTS `player_inboxitems` ( | |
| 287 | + | `player_id` int(11) NOT NULL, | |
| 288 | + | `sid` int(11) NOT NULL, | |
| 289 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 290 | + | `itemtype` smallint(6) NOT NULL, | |
| 291 | + | `count` smallint(5) NOT NULL DEFAULT '0', | |
| 292 | + | `attributes` blob NOT NULL, | |
| 293 | + | UNIQUE KEY `player_id_2` (`player_id`, `sid`), | |
| 294 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 295 | + | ) ENGINE=InnoDB; | |
| 296 | + | ||
| 297 | + | CREATE TABLE IF NOT EXISTS `player_items` ( | |
| 298 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 299 | + | `pid` int(11) NOT NULL DEFAULT '0', | |
| 300 | + | `sid` int(11) NOT NULL DEFAULT '0', | |
| 301 | + | `itemtype` smallint(6) NOT NULL DEFAULT '0', | |
| 302 | + | `count` smallint(5) NOT NULL DEFAULT '0', | |
| 303 | + | `attributes` blob NOT NULL, | |
| 304 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, | |
| 305 | + | KEY `sid` (`sid`) | |
| 306 | + | ) ENGINE=InnoDB; | |
| 307 | + | ||
| 308 | + | CREATE TABLE IF NOT EXISTS `player_spells` ( | |
| 309 | + | `player_id` int(11) NOT NULL, | |
| 310 | + | `name` varchar(255) NOT NULL, | |
| 311 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 312 | + | ) ENGINE=InnoDB; | |
| 313 | + | ||
| 314 | + | CREATE TABLE IF NOT EXISTS `player_storage` ( | |
| 315 | + | `player_id` int(11) NOT NULL DEFAULT '0', | |
| 316 | + | `key` int(10) unsigned NOT NULL DEFAULT '0', | |
| 317 | + | `value` int(11) NOT NULL DEFAULT '0', | |
| 318 | + | PRIMARY KEY (`player_id`,`key`), | |
| 319 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 320 | + | ) ENGINE=InnoDB; | |
| 321 | + | ||
| 322 | + | CREATE TABLE IF NOT EXISTS `server_config` ( | |
| 323 | + | `config` varchar(50) NOT NULL, | |
| 324 | + | `value` varchar(256) NOT NULL DEFAULT '', | |
| 325 | + | PRIMARY KEY `config` (`config`) | |
| 326 | + | ) ENGINE=InnoDB; | |
| 327 | + | ||
| 328 | + | INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '18'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); | |
| 329 | + | ||
| 330 | + | CREATE TABLE IF NOT EXISTS `tile_store` ( | |
| 331 | + | `house_id` int(11) NOT NULL, | |
| 332 | + | `data` longblob NOT NULL, | |
| 333 | + | FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE | |
| 334 | + | ) ENGINE=InnoDB; | |
| 335 | + | ||
| 336 | + | DROP TRIGGER IF EXISTS `ondelete_players`; | |
| 337 | + | DROP TRIGGER IF EXISTS `oncreate_guilds`; | |
| 338 | + | ||
| 339 | + | DELIMITER // | |
| 340 | + | CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players` | |
| 341 | + | FOR EACH ROW BEGIN | |
| 342 | + | UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`; | |
| 343 | + | END | |
| 344 | + | // | |
| 345 | + | CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds` | |
| 346 | + | FOR EACH ROW BEGIN | |
| 347 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`); | |
| 348 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`); | |
| 349 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`); | |
| 350 | + | END | |
| 351 | + | // | |
| 352 | + | DELIMITER ; |
| @@ -0,0 +1,416 @@ | |||
| 1 | + | -- The Forgotten Server (TFS) 1.6 database schema. | |
| 2 | + | -- Source: https://github.com/otland/forgottenserver/blob/v1.6/schema.sql | |
| 3 | + | -- License: GPL-2.0. Covers ZnoteX's TFS_16 engine choice. | |
| 4 | + | ||
| 5 | + | CREATE TABLE IF NOT EXISTS `accounts` ( | |
| 6 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 7 | + | `name` varchar(32) NOT NULL, | |
| 8 | + | `password` char(40) NOT NULL, | |
| 9 | + | `secret` char(16) DEFAULT NULL, | |
| 10 | + | `type` int NOT NULL DEFAULT '1', | |
| 11 | + | `premium_ends_at` int unsigned NOT NULL DEFAULT '0', | |
| 12 | + | `email` varchar(255) NOT NULL DEFAULT '', | |
| 13 | + | `creation` int NOT NULL DEFAULT '0', | |
| 14 | + | PRIMARY KEY (`id`), | |
| 15 | + | UNIQUE KEY `name` (`name`) | |
| 16 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 17 | + | ||
| 18 | + | CREATE TABLE IF NOT EXISTS `players` ( | |
| 19 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 20 | + | `name` varchar(255) NOT NULL, | |
| 21 | + | `group_id` int NOT NULL DEFAULT '1', | |
| 22 | + | `account_id` int NOT NULL DEFAULT '0', | |
| 23 | + | `level` int NOT NULL DEFAULT '1', | |
| 24 | + | `vocation` int NOT NULL DEFAULT '0', | |
| 25 | + | `health` int NOT NULL DEFAULT '150', | |
| 26 | + | `healthmax` int NOT NULL DEFAULT '150', | |
| 27 | + | `experience` bigint unsigned NOT NULL DEFAULT '0', | |
| 28 | + | `lookbody` int NOT NULL DEFAULT '0', | |
| 29 | + | `lookfeet` int NOT NULL DEFAULT '0', | |
| 30 | + | `lookhead` int NOT NULL DEFAULT '0', | |
| 31 | + | `looklegs` int NOT NULL DEFAULT '0', | |
| 32 | + | `looktype` int NOT NULL DEFAULT '136', | |
| 33 | + | `lookaddons` int NOT NULL DEFAULT '0', | |
| 34 | + | `lookmount` int NOT NULL DEFAULT '0', | |
| 35 | + | `lookmounthead` int NOT NULL DEFAULT '0', | |
| 36 | + | `lookmountbody` int NOT NULL DEFAULT '0', | |
| 37 | + | `lookmountlegs` int NOT NULL DEFAULT '0', | |
| 38 | + | `lookmountfeet` int NOT NULL DEFAULT '0', | |
| 39 | + | `currentmount` smallint unsigned NOT NULL DEFAULT '0', | |
| 40 | + | `randomizemount` tinyint NOT NULL DEFAULT '0', | |
| 41 | + | `direction` tinyint unsigned NOT NULL DEFAULT '2', | |
| 42 | + | `maglevel` int NOT NULL DEFAULT '0', | |
| 43 | + | `mana` int NOT NULL DEFAULT '0', | |
| 44 | + | `manamax` int NOT NULL DEFAULT '0', | |
| 45 | + | `manaspent` bigint unsigned NOT NULL DEFAULT '0', | |
| 46 | + | `soul` int unsigned NOT NULL DEFAULT '0', | |
| 47 | + | `town_id` int NOT NULL DEFAULT '1', | |
| 48 | + | `posx` int NOT NULL DEFAULT '0', | |
| 49 | + | `posy` int NOT NULL DEFAULT '0', | |
| 50 | + | `posz` int NOT NULL DEFAULT '0', | |
| 51 | + | `conditions` blob DEFAULT NULL, | |
| 52 | + | `cap` int NOT NULL DEFAULT '400', | |
| 53 | + | `sex` int NOT NULL DEFAULT '0', | |
| 54 | + | `lastlogin` bigint unsigned NOT NULL DEFAULT '0', | |
| 55 | + | `lastip` varbinary(16) NOT NULL DEFAULT '0', | |
| 56 | + | `save` tinyint NOT NULL DEFAULT '1', | |
| 57 | + | `skull` tinyint NOT NULL DEFAULT '0', | |
| 58 | + | `skulltime` bigint NOT NULL DEFAULT '0', | |
| 59 | + | `lastlogout` bigint unsigned NOT NULL DEFAULT '0', | |
| 60 | + | `blessings` tinyint NOT NULL DEFAULT '0', | |
| 61 | + | `onlinetime` bigint NOT NULL DEFAULT '0', | |
| 62 | + | `deletion` bigint NOT NULL DEFAULT '0', | |
| 63 | + | `balance` bigint unsigned NOT NULL DEFAULT '0', | |
| 64 | + | `offlinetraining_time` smallint unsigned NOT NULL DEFAULT '43200', | |
| 65 | + | `offlinetraining_skill` int NOT NULL DEFAULT '-1', | |
| 66 | + | `stamina` smallint unsigned NOT NULL DEFAULT '2520', | |
| 67 | + | `skill_fist` int unsigned NOT NULL DEFAULT 10, | |
| 68 | + | `skill_fist_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 69 | + | `skill_club` int unsigned NOT NULL DEFAULT 10, | |
| 70 | + | `skill_club_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 71 | + | `skill_sword` int unsigned NOT NULL DEFAULT 10, | |
| 72 | + | `skill_sword_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 73 | + | `skill_axe` int unsigned NOT NULL DEFAULT 10, | |
| 74 | + | `skill_axe_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 75 | + | `skill_dist` int unsigned NOT NULL DEFAULT 10, | |
| 76 | + | `skill_dist_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 77 | + | `skill_shielding` int unsigned NOT NULL DEFAULT 10, | |
| 78 | + | `skill_shielding_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 79 | + | `skill_fishing` int unsigned NOT NULL DEFAULT 10, | |
| 80 | + | `skill_fishing_tries` bigint unsigned NOT NULL DEFAULT 0, | |
| 81 | + | PRIMARY KEY (`id`), | |
| 82 | + | UNIQUE KEY `name` (`name`), | |
| 83 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, | |
| 84 | + | KEY `vocation` (`vocation`) | |
| 85 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 86 | + | ||
| 87 | + | CREATE TABLE IF NOT EXISTS `account_bans` ( | |
| 88 | + | `account_id` int NOT NULL, | |
| 89 | + | `reason` varchar(255) NOT NULL, | |
| 90 | + | `banned_at` bigint NOT NULL, | |
| 91 | + | `expires_at` bigint NOT NULL, | |
| 92 | + | `banned_by` int NOT NULL, | |
| 93 | + | PRIMARY KEY (`account_id`), | |
| 94 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 95 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 96 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 97 | + | ||
| 98 | + | CREATE TABLE IF NOT EXISTS `account_ban_history` ( | |
| 99 | + | `id` int unsigned NOT NULL AUTO_INCREMENT, | |
| 100 | + | `account_id` int NOT NULL, | |
| 101 | + | `reason` varchar(255) NOT NULL, | |
| 102 | + | `banned_at` bigint NOT NULL, | |
| 103 | + | `expired_at` bigint NOT NULL, | |
| 104 | + | `banned_by` int NOT NULL, | |
| 105 | + | PRIMARY KEY (`id`), | |
| 106 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 107 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 108 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 109 | + | ||
| 110 | + | CREATE TABLE IF NOT EXISTS `account_storage` ( | |
| 111 | + | `account_id` int NOT NULL, | |
| 112 | + | `key` int unsigned NOT NULL, | |
| 113 | + | `value` int NOT NULL, | |
| 114 | + | PRIMARY KEY (`account_id`, `key`), | |
| 115 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE | |
| 116 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 117 | + | ||
| 118 | + | CREATE TABLE IF NOT EXISTS `ip_bans` ( | |
| 119 | + | `ip` varbinary(16) NOT NULL, | |
| 120 | + | `reason` varchar(255) NOT NULL, | |
| 121 | + | `banned_at` bigint NOT NULL, | |
| 122 | + | `expires_at` bigint NOT NULL, | |
| 123 | + | `banned_by` int NOT NULL, | |
| 124 | + | PRIMARY KEY (`ip`), | |
| 125 | + | FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 126 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 127 | + | ||
| 128 | + | CREATE TABLE IF NOT EXISTS `player_namelocks` ( | |
| 129 | + | `player_id` int NOT NULL, | |
| 130 | + | `reason` varchar(255) NOT NULL, | |
| 131 | + | `namelocked_at` bigint NOT NULL, | |
| 132 | + | `namelocked_by` int NOT NULL, | |
| 133 | + | PRIMARY KEY (`player_id`), | |
| 134 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 135 | + | FOREIGN KEY (`namelocked_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 136 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 137 | + | ||
| 138 | + | CREATE TABLE IF NOT EXISTS `account_viplist` ( | |
| 139 | + | `account_id` int NOT NULL COMMENT 'id of account whose viplist entry it is', | |
| 140 | + | `player_id` int NOT NULL COMMENT 'id of target player of viplist entry', | |
| 141 | + | `description` varchar(128) NOT NULL DEFAULT '', | |
| 142 | + | `icon` tinyint unsigned NOT NULL DEFAULT '0', | |
| 143 | + | `notify` tinyint NOT NULL DEFAULT '0', | |
| 144 | + | UNIQUE KEY `account_player_index` (`account_id`,`player_id`), | |
| 145 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, | |
| 146 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE | |
| 147 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 148 | + | ||
| 149 | + | CREATE TABLE IF NOT EXISTS `guilds` ( | |
| 150 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 151 | + | `name` varchar(255) NOT NULL, | |
| 152 | + | `ownerid` int NOT NULL, | |
| 153 | + | `creationdata` int NOT NULL, | |
| 154 | + | `motd` varchar(255) NOT NULL DEFAULT '', | |
| 155 | + | PRIMARY KEY (`id`), | |
| 156 | + | UNIQUE KEY (`name`), | |
| 157 | + | UNIQUE KEY (`ownerid`), | |
| 158 | + | FOREIGN KEY (`ownerid`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 159 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 160 | + | ||
| 161 | + | CREATE TABLE IF NOT EXISTS `guild_invites` ( | |
| 162 | + | `player_id` int NOT NULL DEFAULT '0', | |
| 163 | + | `guild_id` int NOT NULL DEFAULT '0', | |
| 164 | + | PRIMARY KEY (`player_id`,`guild_id`), | |
| 165 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE, | |
| 166 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE | |
| 167 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 168 | + | ||
| 169 | + | CREATE TABLE IF NOT EXISTS `guild_ranks` ( | |
| 170 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 171 | + | `guild_id` int NOT NULL COMMENT 'guild', | |
| 172 | + | `name` varchar(255) NOT NULL COMMENT 'rank name', | |
| 173 | + | `level` int NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else', | |
| 174 | + | PRIMARY KEY (`id`), | |
| 175 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE | |
| 176 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 177 | + | ||
| 178 | + | CREATE TABLE IF NOT EXISTS `guild_membership` ( | |
| 179 | + | `player_id` int NOT NULL, | |
| 180 | + | `guild_id` int NOT NULL, | |
| 181 | + | `rank_id` int NOT NULL, | |
| 182 | + | `nick` varchar(15) NOT NULL DEFAULT '', | |
| 183 | + | PRIMARY KEY (`player_id`), | |
| 184 | + | FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 185 | + | FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
| 186 | + | FOREIGN KEY (`rank_id`) REFERENCES `guild_ranks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
| 187 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 188 | + | ||
| 189 | + | CREATE TABLE IF NOT EXISTS `guild_wars` ( | |
| 190 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 191 | + | `guild1` int NOT NULL DEFAULT '0', | |
| 192 | + | `guild2` int NOT NULL DEFAULT '0', | |
| 193 | + | `name1` varchar(255) NOT NULL, | |
| 194 | + | `name2` varchar(255) NOT NULL, | |
| 195 | + | `status` tinyint NOT NULL DEFAULT '0', | |
| 196 | + | `started` bigint NOT NULL DEFAULT '0', | |
| 197 | + | `ended` bigint NOT NULL DEFAULT '0', | |
| 198 | + | PRIMARY KEY (`id`), | |
| 199 | + | KEY `guild1` (`guild1`), | |
| 200 | + | KEY `guild2` (`guild2`) | |
| 201 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 202 | + | ||
| 203 | + | CREATE TABLE IF NOT EXISTS `guildwar_kills` ( | |
| 204 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 205 | + | `killer` varchar(50) NOT NULL, | |
| 206 | + | `target` varchar(50) NOT NULL, | |
| 207 | + | `killerguild` int NOT NULL DEFAULT '0', | |
| 208 | + | `targetguild` int NOT NULL DEFAULT '0', | |
| 209 | + | `warid` int NOT NULL DEFAULT '0', | |
| 210 | + | `time` bigint NOT NULL, | |
| 211 | + | PRIMARY KEY (`id`), | |
| 212 | + | FOREIGN KEY (`warid`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE | |
| 213 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 214 | + | ||
| 215 | + | CREATE TABLE IF NOT EXISTS `houses` ( | |
| 216 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 217 | + | `owner` int NOT NULL, | |
| 218 | + | `paid` int unsigned NOT NULL DEFAULT '0', | |
| 219 | + | `warnings` int NOT NULL DEFAULT '0', | |
| 220 | + | `name` varchar(255) NOT NULL, | |
| 221 | + | `rent` int NOT NULL DEFAULT '0', | |
| 222 | + | `town_id` int NOT NULL DEFAULT '0', | |
| 223 | + | `bid` int NOT NULL DEFAULT '0', | |
| 224 | + | `bid_end` int NOT NULL DEFAULT '0', | |
| 225 | + | `last_bid` int NOT NULL DEFAULT '0', | |
| 226 | + | `highest_bidder` int NOT NULL DEFAULT '0', | |
| 227 | + | `size` int NOT NULL DEFAULT '0', | |
| 228 | + | `beds` int NOT NULL DEFAULT '0', | |
| 229 | + | PRIMARY KEY (`id`), | |
| 230 | + | KEY `owner` (`owner`), | |
| 231 | + | KEY `town_id` (`town_id`) | |
| 232 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 233 | + | ||
| 234 | + | CREATE TABLE IF NOT EXISTS `house_lists` ( | |
| 235 | + | `house_id` int NOT NULL, | |
| 236 | + | `listid` int NOT NULL, | |
| 237 | + | `list` text NOT NULL, | |
| 238 | + | FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE | |
| 239 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 240 | + | ||
| 241 | + | CREATE TABLE IF NOT EXISTS `market_history` ( | |
| 242 | + | `id` int unsigned NOT NULL AUTO_INCREMENT, | |
| 243 | + | `player_id` int NOT NULL, | |
| 244 | + | `sale` tinyint NOT NULL DEFAULT '0', | |
| 245 | + | `itemtype` smallint unsigned NOT NULL, | |
| 246 | + | `amount` smallint unsigned NOT NULL, | |
| 247 | + | `price` bigint unsigned NOT NULL DEFAULT '0', | |
| 248 | + | `expires_at` bigint unsigned NOT NULL, | |
| 249 | + | `inserted` bigint unsigned NOT NULL, | |
| 250 | + | `state` tinyint unsigned NOT NULL, | |
| 251 | + | PRIMARY KEY (`id`), | |
| 252 | + | KEY `player_id` (`player_id`, `sale`), | |
| 253 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 254 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 255 | + | ||
| 256 | + | CREATE TABLE IF NOT EXISTS `market_offers` ( | |
| 257 | + | `id` int unsigned NOT NULL AUTO_INCREMENT, | |
| 258 | + | `player_id` int NOT NULL, | |
| 259 | + | `sale` tinyint NOT NULL DEFAULT '0', | |
| 260 | + | `itemtype` smallint unsigned NOT NULL, | |
| 261 | + | `amount` smallint unsigned NOT NULL, | |
| 262 | + | `created` bigint unsigned NOT NULL, | |
| 263 | + | `anonymous` tinyint NOT NULL DEFAULT '0', | |
| 264 | + | `price` bigint unsigned NOT NULL DEFAULT '0', | |
| 265 | + | PRIMARY KEY (`id`), | |
| 266 | + | KEY `sale` (`sale`,`itemtype`), | |
| 267 | + | KEY `created` (`created`), | |
| 268 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 269 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 270 | + | ||
| 271 | + | CREATE TABLE IF NOT EXISTS `players_online` ( | |
| 272 | + | `player_id` int NOT NULL, | |
| 273 | + | PRIMARY KEY (`player_id`) | |
| 274 | + | ) ENGINE=MEMORY DEFAULT CHARACTER SET=utf8; | |
| 275 | + | ||
| 276 | + | CREATE TABLE IF NOT EXISTS `player_deaths` ( | |
| 277 | + | `player_id` int NOT NULL, | |
| 278 | + | `time` bigint unsigned NOT NULL DEFAULT '0', | |
| 279 | + | `level` int NOT NULL DEFAULT '1', | |
| 280 | + | `killed_by` varchar(255) NOT NULL, | |
| 281 | + | `is_player` tinyint NOT NULL DEFAULT '1', | |
| 282 | + | `mostdamage_by` varchar(100) NOT NULL, | |
| 283 | + | `mostdamage_is_player` tinyint NOT NULL DEFAULT '0', | |
| 284 | + | `unjustified` tinyint NOT NULL DEFAULT '0', | |
| 285 | + | `mostdamage_unjustified` tinyint NOT NULL DEFAULT '0', | |
| 286 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, | |
| 287 | + | KEY `killed_by` (`killed_by`), | |
| 288 | + | KEY `mostdamage_by` (`mostdamage_by`) | |
| 289 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 290 | + | ||
| 291 | + | CREATE TABLE IF NOT EXISTS `player_depotitems` ( | |
| 292 | + | `player_id` int NOT NULL, | |
| 293 | + | `sid` int NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots', | |
| 294 | + | `pid` int NOT NULL DEFAULT '0', | |
| 295 | + | `itemtype` smallint unsigned NOT NULL, | |
| 296 | + | `count` smallint NOT NULL DEFAULT '0', | |
| 297 | + | `attributes` blob NOT NULL, | |
| 298 | + | UNIQUE KEY `player_id_2` (`player_id`, `sid`), | |
| 299 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 300 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 301 | + | ||
| 302 | + | CREATE TABLE IF NOT EXISTS `player_inboxitems` ( | |
| 303 | + | `player_id` int NOT NULL, | |
| 304 | + | `sid` int NOT NULL, | |
| 305 | + | `pid` int NOT NULL DEFAULT '0', | |
| 306 | + | `itemtype` smallint unsigned NOT NULL, | |
| 307 | + | `count` smallint NOT NULL DEFAULT '0', | |
| 308 | + | `attributes` blob NOT NULL, | |
| 309 | + | UNIQUE KEY `player_id_2` (`player_id`, `sid`), | |
| 310 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 311 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 312 | + | ||
| 313 | + | CREATE TABLE IF NOT EXISTS `player_storeinboxitems` ( | |
| 314 | + | `player_id` int NOT NULL, | |
| 315 | + | `sid` int NOT NULL, | |
| 316 | + | `pid` int NOT NULL DEFAULT '0', | |
| 317 | + | `itemtype` smallint unsigned NOT NULL, | |
| 318 | + | `count` smallint NOT NULL DEFAULT '0', | |
| 319 | + | `attributes` blob NOT NULL, | |
| 320 | + | UNIQUE KEY `player_id_2` (`player_id`, `sid`), | |
| 321 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 322 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 323 | + | ||
| 324 | + | CREATE TABLE IF NOT EXISTS `player_items` ( | |
| 325 | + | `player_id` int NOT NULL DEFAULT '0', | |
| 326 | + | `pid` int NOT NULL DEFAULT '0', | |
| 327 | + | `sid` int NOT NULL DEFAULT '0', | |
| 328 | + | `itemtype` smallint unsigned NOT NULL DEFAULT '0', | |
| 329 | + | `count` smallint NOT NULL DEFAULT '0', | |
| 330 | + | `attributes` blob NOT NULL, | |
| 331 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, | |
| 332 | + | KEY `sid` (`sid`) | |
| 333 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 334 | + | ||
| 335 | + | CREATE TABLE IF NOT EXISTS `player_spells` ( | |
| 336 | + | `player_id` int NOT NULL, | |
| 337 | + | `name` varchar(255) NOT NULL, | |
| 338 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 339 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 340 | + | ||
| 341 | + | CREATE TABLE IF NOT EXISTS `player_storage` ( | |
| 342 | + | `player_id` int NOT NULL DEFAULT '0', | |
| 343 | + | `key` int unsigned NOT NULL DEFAULT '0', | |
| 344 | + | `value` int NOT NULL DEFAULT '0', | |
| 345 | + | PRIMARY KEY (`player_id`,`key`), | |
| 346 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 347 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 348 | + | ||
| 349 | + | CREATE TABLE IF NOT EXISTS `player_outfits` ( | |
| 350 | + | `player_id` int NOT NULL DEFAULT '0', | |
| 351 | + | `outfit_id` smallint unsigned NOT NULL DEFAULT '0', | |
| 352 | + | `addons` tinyint unsigned NOT NULL DEFAULT '0', | |
| 353 | + | PRIMARY KEY (`player_id`,`outfit_id`), | |
| 354 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 355 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 356 | + | ||
| 357 | + | CREATE TABLE IF NOT EXISTS `player_mounts` ( | |
| 358 | + | `player_id` int NOT NULL DEFAULT '0', | |
| 359 | + | `mount_id` smallint unsigned NOT NULL DEFAULT '0', | |
| 360 | + | PRIMARY KEY (`player_id`,`mount_id`), | |
| 361 | + | FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | |
| 362 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 363 | + | ||
| 364 | + | CREATE TABLE IF NOT EXISTS `server_config` ( | |
| 365 | + | `config` varchar(50) NOT NULL, | |
| 366 | + | `value` varchar(256) NOT NULL DEFAULT '', | |
| 367 | + | PRIMARY KEY `config` (`config`) | |
| 368 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 369 | + | ||
| 370 | + | CREATE TABLE IF NOT EXISTS `sessions` ( | |
| 371 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 372 | + | `token` binary(16) NOT NULL, | |
| 373 | + | `account_id` int NOT NULL, | |
| 374 | + | `ip` varbinary(16) NOT NULL, | |
| 375 | + | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 376 | + | `expired_at` timestamp, | |
| 377 | + | PRIMARY KEY (`id`), | |
| 378 | + | UNIQUE KEY `token` (`token`), | |
| 379 | + | FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE | |
| 380 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 381 | + | ||
| 382 | + | CREATE TABLE IF NOT EXISTS `tile_store` ( | |
| 383 | + | `house_id` int NOT NULL, | |
| 384 | + | `data` longblob NOT NULL, | |
| 385 | + | FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE | |
| 386 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 387 | + | ||
| 388 | + | CREATE TABLE IF NOT EXISTS `towns` ( | |
| 389 | + | `id` int NOT NULL AUTO_INCREMENT, | |
| 390 | + | `name` varchar(255) NOT NULL, | |
| 391 | + | `posx` int NOT NULL DEFAULT '0', | |
| 392 | + | `posy` int NOT NULL DEFAULT '0', | |
| 393 | + | `posz` int NOT NULL DEFAULT '0', | |
| 394 | + | PRIMARY KEY (`id`), | |
| 395 | + | UNIQUE KEY `name` (`name`) | |
| 396 | + | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | |
| 397 | + | ||
| 398 | + | INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '37'), ('players_record', '0'); | |
| 399 | + | ||
| 400 | + | DROP TRIGGER IF EXISTS `ondelete_players`; | |
| 401 | + | DROP TRIGGER IF EXISTS `oncreate_guilds`; | |
| 402 | + | ||
| 403 | + | DELIMITER // | |
| 404 | + | CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players` | |
| 405 | + | FOR EACH ROW BEGIN | |
| 406 | + | UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`; | |
| 407 | + | END | |
| 408 | + | // | |
| 409 | + | CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds` | |
| 410 | + | FOR EACH ROW BEGIN | |
| 411 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`); | |
| 412 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`); | |
| 413 | + | INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`); | |
| 414 | + | END | |
| 415 | + | // | |
| 416 | + | DELIMITER ; |
| @@ -0,0 +1,16 @@ | |||
| 1 | + | memory_limit = 256M | |
| 2 | + | upload_max_filesize = 20M | |
| 3 | + | post_max_size = 20M | |
| 4 | + | max_execution_time = 60 | |
| 5 | + | date.timezone = UTC | |
| 6 | + | ||
| 7 | + | display_errors = Off | |
| 8 | + | log_errors = On | |
| 9 | + | error_log = /dev/stderr | |
| 10 | + | ||
| 11 | + | opcache.enable = 1 | |
| 12 | + | opcache.memory_consumption = 128 | |
| 13 | + | opcache.validate_timestamps = 1 | |
| 14 | + | opcache.revalidate_freq = 1 | |
| 15 | + | ||
| 16 | + | apc.enable_cli = 0 |
| @@ -0,0 +1,36 @@ | |||
| 1 | + | FROM php:8.5-apache | |
| 2 | + | ||
| 3 | + | RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| 4 | + | libzip-dev \ | |
| 5 | + | libpng-dev \ | |
| 6 | + | libjpeg62-turbo-dev \ | |
| 7 | + | libfreetype6-dev \ | |
| 8 | + | libcurl4-openssl-dev \ | |
| 9 | + | libonig-dev \ | |
| 10 | + | unzip \ | |
| 11 | + | git \ | |
| 12 | + | && docker-php-ext-configure gd --with-jpeg --with-freetype \ | |
| 13 | + | && docker-php-ext-install mysqli pdo_mysql zip gd curl \ | |
| 14 | + | && pecl install apcu \ | |
| 15 | + | && docker-php-ext-enable apcu \ | |
| 16 | + | && a2enmod rewrite \ | |
| 17 | + | && apt-get purge -y --auto-remove git \ | |
| 18 | + | && rm -rf /var/lib/apt/lists/* | |
| 19 | + | ||
| 20 | + | COPY docker/php.ini /usr/local/etc/php/conf.d/znotex.ini | |
| 21 | + | COPY docker/apache-htaccess.conf /etc/apache2/conf-enabled/z-znotex.conf | |
| 22 | + | ||
| 23 | + | COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | |
| 24 | + | ||
| 25 | + | WORKDIR /var/www/html | |
| 26 | + | ||
| 27 | + | COPY . . | |
| 28 | + | RUN composer install --no-dev --no-interaction --no-scripts --optimize-autoloader \ | |
| 29 | + | && chown -R www-data:www-data /var/www/html \ | |
| 30 | + | && chmod -R u+rwX,g+rX engine/cache engine/img/theme 2>/dev/null || true | |
| 31 | + | ||
| 32 | + | COPY docker/entrypoint.sh /usr/local/bin/znotex-entrypoint.sh | |
| 33 | + | RUN chmod +x /usr/local/bin/znotex-entrypoint.sh | |
| 34 | + | ||
| 35 | + | ENTRYPOINT ["/usr/local/bin/znotex-entrypoint.sh"] | |
| 36 | + | CMD ["apache2-foreground"] |
| @@ -0,0 +1,5 @@ | |||
| 1 | + | <?php require_once 'engine/init.php'; theme_open(); | |
| 2 | + | ||
| 3 | + | view('downloads'); | |
| 4 | + | ||
| 5 | + | theme_close(); |
| @@ -0,0 +1,40 @@ | |||
| 1 | + | <?php | |
| 2 | + | /** | |
| 3 | + | * BlackTek (https://github.com/Black-Tek/BlackTek-Server): a TFS fork whose | |
| 4 | + | * schema.sql - checked against its `master` branch - matches TFS_10 in every | |
| 5 | + | * way that matters here: `accounts` has `name` and a `secret` char(16) column, | |
| 6 | + | * `players_online` exists, `houses` uses the TFS column names (not Canary's | |
| 7 | + | * renamed internal_bid/bid_end_date/...), and both `guild_membership` and | |
| 8 | + | * `guild_ranks` exist. So it is normalised to TFS_10 for querying (see | |
| 9 | + | * engine/init.php) and the legacy accounts.secret 2FA flow works unmodified. | |
| 10 | + | */ | |
| 11 | + | final class BlackTekAdapter implements ServerAdapterInterface | |
| 12 | + | { | |
| 13 | + | public function key(): string { | |
| 14 | + | return 'BLACKTEK'; | |
| 15 | + | } | |
| 16 | + | ||
| 17 | + | public function login(string $username, string $password): int|false { | |
| 18 | + | return user_login($username, $password); | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | public function accountIdentityColumn(): string { | |
| 22 | + | return 'name'; | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | public function accountDisplayColumn(): string { | |
| 26 | + | return '`a`.`name`'; | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | public function supportsLegacyTwoFactor(): bool { | |
| 30 | + | return true; | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | public function onlineCount(): int { | |
| 34 | + | return znote_sql_count("SELECT COUNT(*) AS `c` FROM `players_online`;"); | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | public function normalizedEngine(): string { | |
| 38 | + | return 'TFS_10'; | |
| 39 | + | } | |
| 40 | + | } |
| @@ -0,0 +1,36 @@ | |||
| 1 | + | <?php | |
| 2 | + | /** | |
| 3 | + | * Canary. Normalised to the TFS_10 schema for querying (see engine/init.php), | |
| 4 | + | * but it is not TFS: the legacy accounts.secret 2FA flow does not apply, which | |
| 5 | + | * is why engine/init.php also forces twoFactorAuthenticator off for it. | |
| 6 | + | */ | |
| 7 | + | final class CanaryAdapter implements ServerAdapterInterface | |
| 8 | + | { | |
| 9 | + | public function key(): string { | |
| 10 | + | return 'CANARY'; | |
| 11 | + | } | |
| 12 | + | ||
| 13 | + | public function login(string $username, string $password): int|false { | |
| 14 | + | return user_login($username, $password); | |
| 15 | + | } | |
| 16 | + | ||
| 17 | + | public function accountIdentityColumn(): string { | |
| 18 | + | return 'name'; | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | public function accountDisplayColumn(): string { | |
| 22 | + | return '`a`.`name`'; | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | public function supportsLegacyTwoFactor(): bool { | |
| 26 | + | return false; | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | public function onlineCount(): int { | |
| 30 | + | return znote_sql_count("SELECT COUNT(*) AS `c` FROM `players_online`;"); | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | public function normalizedEngine(): string { | |
| 34 | + | return 'TFS_10'; | |
| 35 | + | } | |
| 36 | + | } |
| @@ -0,0 +1,21 @@ | |||
| 1 | + | <?php | |
| 2 | + | ||
| 3 | + | function znote_server_adapter(?string $engine = null): ServerAdapterInterface { | |
| 4 | + | static $cache = array(); | |
| 5 | + | ||
| 6 | + | global $config; | |
| 7 | + | $engine = $engine ?? (string)($config['ServerEngineReal'] ?? $config['ServerEngine'] ?? 'TFS_10'); | |
| 8 | + | ||
| 9 | + | if (isset($cache[$engine])) { | |
| 10 | + | return $cache[$engine]; | |
| 11 | + | } | |
| 12 | + | ||
| 13 | + | $adapter = match ($engine) { | |
| 14 | + | 'OTHIRE' => new OtHireAdapter(), | |
| 15 | + | 'CANARY' => new CanaryAdapter(), | |
| 16 | + | 'BLACKTEK' => new BlackTekAdapter(), | |
| 17 | + | default => new TFSAdapter($engine), // TFS_02, TFS_03, TFS_10, TFS_16 | |
| 18 | + | }; | |
| 19 | + | ||
| 20 | + | return $cache[$engine] = $adapter; | |
| 21 | + | } |
| @@ -0,0 +1,35 @@ | |||
| 1 | + | <?php | |
| 2 | + | /** | |
| 3 | + | * otHire: accounts have no `name` column, an account is identified by its | |
| 4 | + | * numeric id everywhere a TFS-based engine would use a name. | |
| 5 | + | */ | |
| 6 | + | final class OtHireAdapter implements ServerAdapterInterface | |
| 7 | + | { | |
| 8 | + | public function key(): string { | |
| 9 | + | return 'OTHIRE'; | |
| 10 | + | } | |
| 11 | + | ||
| 12 | + | public function login(string $username, string $password): int|false { | |
| 13 | + | return user_login($username, $password); | |
| 14 | + | } | |
| 15 | + | ||
| 16 | + | public function accountIdentityColumn(): string { | |
| 17 | + | return 'id'; | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | public function accountDisplayColumn(): string { | |
| 21 | + | return '`a`.`id`'; | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | public function supportsLegacyTwoFactor(): bool { | |
| 25 | + | return false; | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | public function onlineCount(): int { | |
| 29 | + | return znote_sql_count("SELECT COUNT(*) AS `c` FROM `players` WHERE `online` > 0;"); | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | public function normalizedEngine(): string { | |
| 33 | + | return 'OTHIRE'; | |
| 34 | + | } | |
| 35 | + | } |
| @@ -0,0 +1,58 @@ | |||
| 1 | + | <?php | |
| 2 | + | /** | |
| 3 | + | * Server Adapter. | |
| 4 | + | * | |
| 5 | + | * Every place that used to branch on $config['ServerEngine'] directly is a | |
| 6 | + | * place that has to be found and re-checked whenever a new engine shows up. | |
| 7 | + | * This interface collects the differences that actually matter to the | |
| 8 | + | * website - how an account logs in, how it is identified, whether the legacy | |
| 9 | + | * in-game 2FA exists, how "online" is counted - behind one call: | |
| 10 | + | * znote_server_adapter(). | |
| 11 | + | * | |
| 12 | + | * This does not replace every scattered ServerEngine check in one pass - that | |
| 13 | + | * would be the highest-risk change in the codebase, done all at once, with no | |
| 14 | + | * way to review it in reviewable pieces. It gives new code, and code being | |
| 15 | + | * touched anyway, somewhere better to live. login.php and the admin | |
| 16 | + | * dashboard/analytics modules are wired to it as the first, carefully tested | |
| 17 | + | * examples; the rest can move over one file at a time. | |
| 18 | + | */ | |
| 19 | + | ||
| 20 | + | /** COUNT(*) helper shared by the adapters - 0 for a table this engine does not have. */ | |
| 21 | + | function znote_sql_count(string $sql, array $params = array()): int { | |
| 22 | + | $row = db()->fetchOne($sql, $params); | |
| 23 | + | return is_array($row) && $row ? (int)reset($row) : 0; | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | interface ServerAdapterInterface | |
| 27 | + | { | |
| 28 | + | /** The ServerEngineReal value this adapter was built for. */ | |
| 29 | + | public function key(): string; | |
| 30 | + | ||
| 31 | + | /** | |
| 32 | + | * Authenticates a username/password pair against `accounts`. | |
| 33 | + | * Returns the account id, or false. | |
| 34 | + | */ | |
| 35 | + | public function login(string $username, string $password): int|false; | |
| 36 | + | ||
| 37 | + | /** The `accounts` column identity is checked against - 'name' everywhere except otHire. */ | |
| 38 | + | public function accountIdentityColumn(): string; | |
| 39 | + | ||
| 40 | + | /** SQL fragment for a human-readable account label in a query - `a`.`name` or `a`.`id`. */ | |
| 41 | + | public function accountDisplayColumn(): string; | |
| 42 | + | ||
| 43 | + | /** Whether the legacy, engine-tied 2FA (accounts.secret, twofa.php) can work here. */ | |
| 44 | + | public function supportsLegacyTwoFactor(): bool; | |
| 45 | + | ||
| 46 | + | /** How many characters are online right now. */ | |
| 47 | + | public function onlineCount(): int; | |
| 48 | + | ||
| 49 | + | /** | |
| 50 | + | * The engine value the rest of the codebase should dispatch on for schema | |
| 51 | + | * differences: one of 'TFS_02', 'TFS_03', 'TFS_10' or 'OTHIRE'. Canary, | |
| 52 | + | * TFS_16 and BlackTek all report 'TFS_10' here - they already run that | |
| 53 | + | * schema, which is exactly what $config['ServerEngine'] was normalised to | |
| 54 | + | * in engine/init.php. This is the single place that mapping lives now, | |
| 55 | + | * instead of every file re-deriving it. | |
| 56 | + | */ | |
| 57 | + | public function normalizedEngine(): string; | |
| 58 | + | } |
| @@ -0,0 +1,46 @@ | |||
| 1 | + | <?php | |
| 2 | + | /** | |
| 3 | + | * TFS_02, TFS_03, TFS_10 and TFS_16 (TFS_16 already runs the TFS_10 schema, | |
| 4 | + | * normalised in engine/init.php). TFS_03's salted password scheme is the one | |
| 5 | + | * real behavioural difference among them. | |
| 6 | + | */ | |
| 7 | + | final class TFSAdapter implements ServerAdapterInterface | |
| 8 | + | { | |
| 9 | + | public function __construct(private string $realEngine) { | |
| 10 | + | } | |
| 11 | + | ||
| 12 | + | public function key(): string { | |
| 13 | + | return $this->realEngine; | |
| 14 | + | } | |
| 15 | + | ||
| 16 | + | public function login(string $username, string $password): int|false { | |
| 17 | + | if ($this->realEngine === 'TFS_03') { | |
| 18 | + | return user_login_03($username, $password); | |
| 19 | + | } | |
| 20 | + | return user_login($username, $password); | |
| 21 | + | } | |
| 22 | + | ||
| 23 | + | public function accountIdentityColumn(): string { | |
| 24 | + | return 'name'; | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | public function accountDisplayColumn(): string { | |
| 28 | + | return '`a`.`name`'; | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | public function supportsLegacyTwoFactor(): bool { | |
| 32 | + | // accounts.secret and the QR-code flow in twofa.php only exist from TFS 1.2. | |
| 33 | + | return $this->realEngine === 'TFS_10'; | |
| 34 | + | } | |
| 35 | + | ||
| 36 | + | public function onlineCount(): int { | |
| 37 | + | return $this->realEngine === 'TFS_10' | |
| 38 | + | ? znote_sql_count("SELECT COUNT(*) AS `c` FROM `players_online`;") | |
| 39 | + | : znote_sql_count("SELECT COUNT(*) AS `c` FROM `players` WHERE `online` > 0;"); | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | public function normalizedEngine(): string { | |
| 43 | + | // TFS_16 already runs the TFS_10 schema (normalised in engine/init.php). | |
| 44 | + | return $this->realEngine === 'TFS_16' ? 'TFS_10' : $this->realEngine; | |
| 45 | + | } | |
| 46 | + | } |