From 1c43b2cdee5a5508a6e771b477100517deae07e7 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Tue, 26 Jul 2005 20:07:20 +0000 Subject: Added Being::Type enumeration and type-aware findNode(). Fixed font not being reset after drawing speech. Target marker drawing moved into engine. --- src/game.cpp | 119 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 50 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 16addcd4..df5033be 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -536,39 +536,47 @@ void do_input() if (target) { - // NPC default: talk - if ((target->isNpc()) && (current_npc == 0)) + switch (target->getType()) { - WFIFOW(0) = net_w_value(0x0090); - WFIFOL(2) = net_l_value(target->getId()); - WFIFOB(6) = 0; - WFIFOSET(7); - current_npc = target->getId(); - } - // Monster default: attack - else if (target->isMonster()) - { - /** - * TODO: Move player to mouse click position before - * attack the monster (maybe using follow mode). - */ - if (target->action != MONSTER_DEAD && - player_node->action==STAND) - { - attack(target); - // Autotarget by default with mouse - //if (keys[SDLK_LSHIFT]) - //{ + // Player default: trade + case Being::PLAYER: + WFIFOW(0) = net_w_value(0x00e4); + WFIFOL(2) = net_l_value(target->getId()); + WFIFOSET(6); + break; + + // NPC default: talk + case Being::NPC: + if (!current_npc) + { + WFIFOW(0) = net_w_value(0x0090); + WFIFOL(2) = net_l_value(target->getId()); + WFIFOB(6) = 0; + WFIFOSET(7); + current_npc = target->getId(); + } + break; + + // Monster default: attack + case Being::MONSTER: + /** + * TODO: Move player to mouse click position before + * attack the monster (maybe using follow mode). + */ + if (target->action != MONSTER_DEAD && + player_node->action==STAND) + { + attack(target); + // Autotarget by default with mouse + //if (keys[SDLK_LSHIFT]) + //{ autoTarget = target; - //} - } - } - // Player default: trade - else if (target->isPlayer()) - { - WFIFOW(0) = net_w_value(0x00e4); - WFIFOL(2) = net_l_value(target->getId()); - WFIFOSET(6); + //} + } + break; + + default: + break; } } // Check for default action to items on the floor @@ -947,19 +955,26 @@ void do_parse() { if (RFIFOB(6) == 1) { // Death - if (being->isMonster()) - { - being->action = MONSTER_DEAD; - being->frame = 0; - being->walk_time = tick_time; - } - else + switch (being->getType()) { - being->action = DEAD; + case Being::MONSTER: + being->action = MONSTER_DEAD; + being->frame = 0; + being->walk_time = tick_time; + break; + + default: + being->action = DEAD; + break; } //remove_node(RFIFOL(2)); } - else remove_node(RFIFOL(2)); + else { + remove_node(RFIFOL(2)); + if (being == autoTarget) { + autoTarget = NULL; + } + } } break; @@ -1354,16 +1369,20 @@ void do_parse() if (RFIFOL(2) != player_node->getId()) { // buggy being = findNode(RFIFOL(2)); - if (being != NULL) { - if (being->isPlayer()) { - being->action = ATTACK; - being->frame = 0; - being->walk_time = tick_time; - } - else { - being->action = MONSTER_ATTACK; - being->frame = 0; - being->walk_time = tick_time; + if (being) { + switch (being->getType()) + { + case Being::PLAYER: + being->action = ATTACK; + being->frame = 0; + being->walk_time = tick_time; + break; + + default: + being->action = MONSTER_ATTACK; + being->frame = 0; + being->walk_time = tick_time; + break; } being->frame = 0; } -- cgit v1.2.3-70-g09d2