diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 14:03:04 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 14:03:04 +0000 |
commit | 806dd2ec3cdb39c8ae528b65f93984ed66496709 (patch) | |
tree | 6f654774ee4e0e6275f5904093dea0147ead9edf /src | |
parent | aa42c03c8a6b10d4fac03143f06811d94a253270 (diff) | |
download | mana-806dd2ec3cdb39c8ae528b65f93984ed66496709.tar.gz mana-806dd2ec3cdb39c8ae528b65f93984ed66496709.tar.bz2 mana-806dd2ec3cdb39c8ae528b65f93984ed66496709.tar.xz mana-806dd2ec3cdb39c8ae528b65f93984ed66496709.zip |
Fixing crash on death. Death handling could still be improved though.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 82 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 6 | ||||
-rw-r--r-- | src/gui/skill.cpp | 9 | ||||
-rw-r--r-- | src/net/protocol.cpp | 3 |
4 files changed, 57 insertions, 43 deletions
diff --git a/src/game.cpp b/src/game.cpp index eb94541a..8df4aca5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -53,9 +53,20 @@ extern unsigned char screen_mode; int fps = 0, frame = 0; Setup *setup = NULL; +OkDialog *deathNotice = NULL; #define MAX_TIME 10000 +class DeatchNoticeListener : public gcn::ActionListener { + public: + void action(const std::string &eventId) { + WFIFOW(0) = net_w_value(0x00b2); + WFIFOB(2) = 0; + WFIFOSET(3); + deathNotice = NULL; + } +} deathNoticeListener; + /** * Finite states machine to keep track of player walking status (2 steps * linear prediction) @@ -634,20 +645,17 @@ void do_parse() { case 0x0037: char_info->job_lv = RFIFOW(4); break; - // try to get the stats point to attribute... - // FIXME : Wrong or misplaced... - //case 0x0009: - // char_info->statsPointsToAttribute = RFIFOW(4); - //break; + //case 0x0009: + // try to get the stats point to attribute... + // FIXME : Wrong or misplaced... + //char_info->statsPointsToAttribute = RFIFOW(4); + //break; } statusWindow->update(); - if (char_info->hp == 0) { - //OkDialog *death = new OkDialog("Message", - // "You're now dead, press ok to restart"); - //alert("","","","","",0,0); - WFIFOW(0) = net_w_value(0x00b2); - WFIFOB(2) = 0; - WFIFOSET(3); + if (char_info->hp == 0 && deathNotice == NULL) { + deathNotice = new OkDialog("Message", + "You're now dead, press ok to restart", + &deathNoticeListener); } break; // Stop walking @@ -665,11 +673,11 @@ void do_parse() { //break; // Damage, sit, stand up case 0x008a: - switch(RFIFOB(26)) { + switch (RFIFOB(26)) { case 0: // Damage node = find_node(RFIFOL(6)); - if(node!=NULL) { - if(node->speech!=NULL) { + if (node != NULL) { + if (node->speech != NULL) { free(node->speech); node->speech = NULL; //node->speech_time = SPEECH_TIME; @@ -681,16 +689,23 @@ void do_parse() { node->speech_color = makecol(255, 255, 0); } else { sprintf(node->speech, "%i", RFIFOW(22)); - if(node->id!=player_node->id)node->speech_color = makecol(0, 0, 255); - else node->speech_color = makecol(255, 0, 0); + if (node->id != player_node->id) { + node->speech_color = makecol(0,0,255); + } + else { + node->speech_color = makecol(255,0,0); + } } node->speech_time = SPEECH_TIME; - if(RFIFOL(2)!=player_node->id) { // buggy + if (RFIFOL(2) != player_node->id) { // buggy node = find_node(RFIFOL(2)); - if(node!=NULL) { - if(node->job<10) + if (node != NULL) { + if (node->job<10) { node->action = ATTACK; - else node->action = MONSTER_ATTACK; + } + else { + node->action = MONSTER_ATTACK; + } node->frame = 0; } } @@ -699,15 +714,15 @@ void do_parse() { case 2: // Sit case 3: // Stand up node = find_node(RFIFOL(2)); - if(node!=NULL) { + if (node != NULL) { node->frame = 0; - if(RFIFOB(26)==2) { + if (RFIFOB(26) == 2) { node->action = SIT; - //alert("","","","","",0,0); walk_status = 0; } - else if(RFIFOB(26)==3) + else if (RFIFOB(26) == 3) { node->action = STAND; + } } break; } @@ -724,21 +739,20 @@ void do_parse() { case 20: char_info->gp = RFIFOL(4); break; - // case 16 and 17 missing - - case 0x0016: - char_info->xpForNextLevel = RFIFOL(4); - break; - case 0x0017: - char_info->jobXpForNextLevel = RFIFOL(4); - break; + case 0x0016: + char_info->xpForNextLevel = RFIFOL(4); + break; + case 0x0017: + char_info->jobXpForNextLevel = RFIFOL(4); + break; } break; // Level up case 0x019b: if (RFIFOL(2) == player_node->id) { #ifndef WIN32 - SOUND_SID sound_id = sound.loadItem("./data/sound/wavs/level.ogg"); + SOUND_SID sound_id = sound.loadItem( + "./data/sound/wavs/level.ogg"); sound.startItem(sound_id, 64); sound.clearCache(); #endif /* not WIN32 */ diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 1759f72a..1e40c845 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -256,11 +256,11 @@ void GraphicEngine::refresh() { unsigned short tile0 = get_tile(i + camera_x, j + camera_y, 0); unsigned short tile1 = get_tile(i + camera_x, j + camera_y, 1); - if (tile0 < 600) { + if (tile0 < tileset->spriteset.size()) { tileset->spriteset[tile0]->draw(buffer, i * 32 - offset_x, j * 32 - offset_y); } - if (tile1 > 0) { //&& tile1 < 600 + if (tile1 > 0 && tile1 < tileset->spriteset.size()) { tileset->spriteset[tile1]->draw(buffer, i * 32 - offset_x, j * 32 - offset_y); } @@ -418,7 +418,7 @@ void GraphicEngine::refresh() { for (int i = 0; i < 26; i++) { unsigned short tile = get_tile(i + camera_x, j + camera_y, 2); - if (tile > 0 && tile < 600) { + if (tile > 0 && tile < tileset->spriteset.size()) { tileset->spriteset[tile]->draw( buffer, i * 32 - offset_x, j * 32 - offset_y); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 88e16047..65214e4a 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -107,11 +107,12 @@ void SkillListModel::addSkill(int id, int lv, int sp) void SkillListModel::setSkill(int id, int lv, int sp) { - if (!hasSkill(id)) { - return; + for (unsigned int i = 0; i < skillList.size(); i++) { + if (skillList[i]->id == id) { + skillList[i]->lv = lv; + skillList[i]->sp = sp; + } } - skillList[id]->lv = lv; - skillList[id]->sp = sp; } diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index b9a9c938..6a519a0f 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -114,9 +114,8 @@ unsigned short get_x(const char *data) { unsigned short get_y(const char *data) { short temp; - if(!data)error("Corrupted data"); + if (!data) throw "Corrupted data"; temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f); - if(!temp)error("Corrupted data"); temp >>= 4; return temp; } |