From ebfe2715e0e4ab5a901a33bc017a702d27e669c1 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Wed, 20 Mar 2019 19:56:30 +0100 Subject: [PATCH] Fixes compile error and some graphical issues - Keys and artifacts should render on to of other items - Locked doors will impact surrounding wall layouts --- data/layoutparser.lua | 8 +++++--- src/doorlocktype.h | 25 +++++++++++++++++++++++++ src/map.h | 7 +------ src/monster.c | 14 +++++++------- src/monster.h | 2 +- 5 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 src/doorlocktype.h diff --git a/data/layoutparser.lua b/data/layoutparser.lua index d10315c..efadd8c 100644 --- a/data/layoutparser.lua +++ b/data/layoutparser.lua @@ -325,17 +325,19 @@ function createJumbleLayout(matrix) end function draw_layout_to_room(room, matrix, roomx, roomy) + local wallTypes = {"#", "\"", "/", "d", "g", "S", "G"} + for i=2,13 do for j=2,10 do if matrix[i][j] == "p" then setPitTile(room, matrix, i, j); elseif matrix[i][j] == "#" then - setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) + setBlockTile(room, matrix, i, j, walls, wallTypes, false) elseif matrix[i][j] == "\"" then - setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) + setBlockTile(room, matrix, i, j, walls, wallTypes, false) room.decor[i][j] = lights.candle1 elseif matrix[i][j] == "/" then - setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) + setBlockTile(room, matrix, i, j, walls, wallTypes, false) if random(2) == 1 then room.decor[i][j] = lights.candle1 else diff --git a/src/doorlocktype.h b/src/doorlocktype.h new file mode 100644 index 0000000..a3a26f4 --- /dev/null +++ b/src/doorlocktype.h @@ -0,0 +1,25 @@ +/* + * BreakHack - A dungeone crawler RPG + * Copyright (C) 2018 Linus Probert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +typedef enum DoorLockType { + LOCK_NONE, + LOCK_SILVER, + LOCK_GOLD +} DoorLockType; diff --git a/src/map.h b/src/map.h index 6b712d2..5ae1cbc 100644 --- a/src/map.h +++ b/src/map.h @@ -32,16 +32,11 @@ #include "player.h" #include "map_room_modifiers.h" #include "object.h" +#include "doorlocktype.h" typedef struct UpdateData UpdateData; typedef struct Trap Trap; -typedef enum DoorLockType { - LOCK_NONE, - LOCK_SILVER, - LOCK_GOLD -} DoorLockType; - typedef struct MapTile_t { Sprite *sprite; bool collider; diff --git a/src/monster.c b/src/monster.c index e0fef76..bd04e52 100644 --- a/src/monster.c +++ b/src/monster.c @@ -690,25 +690,25 @@ monster_drop_loot(Monster *monster, Map *map, Player *player) linkedlist_append(&map->artifacts, a); Item *treasure = item_builder_build_item(TREASURE, map->level*2); treasure->sprite->pos = monsterTilePos; - linkedlist_push(&map->items, treasure); + linkedlist_append(&map->items, treasure); } if (monster->items.keyType != LOCK_NONE) { Item *key = item_builder_build_key(monster->items.keyType); key->sprite->pos = monsterTilePos; - linkedlist_push(&map->items, key); + linkedlist_append(&map->items, key); } if (strcmp(monster->label, "The Trader") == 0) { Item *treasure = item_builder_build_treasure(PLATINUM, 10 * monster->stats.lvl); treasure->sprite->pos = monsterTilePos; - linkedlist_push(&map->items, treasure); + linkedlist_append(&map->items, treasure); } if (strcmp(monster->label, "A Fairy") == 0) { Item *treasure = item_builder_build_treasure(PLATINUM, 3 * monster->stats.lvl); treasure->sprite->pos = monsterTilePos; - linkedlist_push(&map->items, treasure); + linkedlist_append(&map->items, treasure); } if (monster->stats.lvl > 2 && get_random(29) == 0) { @@ -744,15 +744,15 @@ monster_drop_loot(Monster *monster, Map *map, Player *player) gui_log("%s dropped something", monster->label); if (item_count == 1) { - linkedlist_append(&map->items, items[0]); + linkedlist_push(&map->items, items[0]); } else { Item *container = item_builder_build_sack(); container->sprite->pos = monsterTilePos; unsigned int i; for (i = 0; i < item_count; ++i) { - linkedlist_append(&container->items, items[i]); + linkedlist_push(&container->items, items[i]); } - linkedlist_append(&map->items, container); + linkedlist_push(&map->items, container); } } diff --git a/src/monster.h b/src/monster.h index 9910f42..38f555c 100644 --- a/src/monster.h +++ b/src/monster.h @@ -25,9 +25,9 @@ #include "actiontext.h" #include "player.h" #include "linkedlist.h" +#include "doorlocktype.h" struct UpdateData; -enum DoorLockType; typedef enum { PACIFIST,