summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-01-15 14:15:50 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-01-15 14:15:50 +0000
commit9171b9739dfb8a1ca0bf963c5041d0a801e4aa90 (patch)
treea7e4514fb14b0c166ec052df1887b4963c51574b
parent806dd2ec3cdb39c8ae528b65f93984ed66496709 (diff)
downloadmana-client-9171b9739dfb8a1ca0bf963c5041d0a801e4aa90.tar.gz
mana-client-9171b9739dfb8a1ca0bf963c5041d0a801e4aa90.tar.bz2
mana-client-9171b9739dfb8a1ca0bf963c5041d0a801e4aa90.tar.xz
mana-client-9171b9739dfb8a1ca0bf963c5041d0a801e4aa90.zip
Being struct/class switch
-rw-r--r--The Mana World.dev8
-rw-r--r--src/being.cpp63
-rw-r--r--src/being.h41
-rw-r--r--src/game.cpp314
-rw-r--r--src/graphic/graphic.cpp189
-rw-r--r--src/map.cpp6
6 files changed, 309 insertions, 312 deletions
diff --git a/The Mana World.dev b/The Mana World.dev
index 9c7bb352..3dbc30c1 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -11,7 +11,7 @@ PrivateResource=The_Mana_World_private.rc
ResourceIncludes=
MakeIncludes=
Compiler=
-CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@_-D__DEBUG_@@_
+CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@_
Linker=-lguichan_@@_-lguichan_allegro_@@_-lalleg_@@_-lwsock32_@@_-lSDL_mixer_@@_-lSDL_@@_
IsCpp=1
Icon=The Mana World.ico
@@ -33,7 +33,11 @@ CompilerSettings=0010001001001000001101
Major=0
Minor=0
Release=8
-Build=833
+<<<<<<< The Mana World.dev
+Build=809
+=======
+Build=851
+>>>>>>> 1.76
LanguageID=1033
CharsetID=1252
CompanyName=The Mana World Development Team
diff --git a/src/being.cpp b/src/being.cpp
index 41fa46fe..268f5e23 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -24,11 +24,11 @@
#include <stdio.h>
#include "astar.h"
-#include "being.h"
+#include "Being.h"
-NODE *player_node = NULL;
+Being *player_node = NULL;
-std::list<NODE*> beings;
+std::list<Being *> beings;
PATH_NODE::PATH_NODE(unsigned short x, unsigned short y):
@@ -45,7 +45,7 @@ PATH_NODE *calculate_path(
return find_path(1, src_x, src_y, dest_x, dest_y);
}
-NODE::NODE():
+/*Being::Being():
id(0), job(0),
action(0), frame(0),
path(NULL),
@@ -58,22 +58,22 @@ NODE::NODE():
{
memset(coordinates, 0, 3);
speech_color = makecol(0, 0, 0);
-}
+}*/
void empty() {
- std::list<NODE*>::iterator i;
+ std::list<Being *>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
delete (*i);
}
beings.clear();
}
-void add_node(NODE *node) {
- beings.push_back(node);
+void add_node(Being *Being) {
+ beings.push_back(Being);
}
void remove_node(unsigned int id) {
- std::list<NODE*>::iterator i;
+ std::list<Being *>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
if ((*i)->id == id) {
delete (*i);
@@ -84,41 +84,40 @@ void remove_node(unsigned int id) {
}
unsigned int find_npc(unsigned short x, unsigned short y) {
- std::list<NODE*>::iterator i;
+ std::list<Being *>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
- NODE *node = (*i);
+ Being *being = (*i);
// Check if is a NPC (only low job ids)
- if (node->job >= 46 && node->job <= 125 &&
- get_x(node->coordinates) == x &&
- get_y(node->coordinates) == y)
+ if (being->job >= 46 && being->job <= 125 &&
+ being->x == x && being->y == y)
{
- return node->id;
+ return being->id;
}
}
return 0;
}
unsigned int find_monster(unsigned short x, unsigned short y) {
- std::list<NODE*>::iterator i;
+ std::list<Being*>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
- NODE *node = (*i);
+ Being *being = (*i);
// Check if is a MONSTER
- if (node->job > 200 &&
- get_x(node->coordinates) == x &&
- get_y(node->coordinates) == y)
+ if (being->job > 200 &&
+ being->x == x &&
+ being->y == y)
{
- return node->id;
+ return being->id;
}
}
return 0;
}
-NODE *find_node(unsigned int id) {
- std::list<NODE*>::iterator i;
+Being *find_node(unsigned int id) {
+ std::list<Being*>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
- NODE *node = (*i);
- if (node->id == id) {
- return node;
+ Being *Being = (*i);
+ if (Being->id == id) {
+ return Being;
}
}
return NULL;
@@ -126,8 +125,8 @@ NODE *find_node(unsigned int id) {
class NODE_Compare {
public:
- bool operator() (const NODE *a, const NODE *b) const {
- return get_y(a->coordinates) < get_y(b->coordinates);
+ bool operator() (const Being *a, const Being *b) const {
+ return a->y < b->y;
}
};
@@ -135,16 +134,16 @@ void sort() {
beings.sort(NODE_Compare());
}
-void empty_path(NODE *node) {
- if (node) {
- PATH_NODE *temp = node->path;
+void empty_path(Being *Being) {
+ if (Being) {
+ PATH_NODE *temp = Being->path;
PATH_NODE *next;
while (temp) {
next = temp->next;
delete temp;
temp = next;
}
- node->path = NULL;
+ Being->path = NULL;
}
}
diff --git a/src/being.h b/src/being.h
index cc7b3973..ec58b986 100644
--- a/src/being.h
+++ b/src/being.h
@@ -67,41 +67,16 @@ class Being {
Being::~Being();
};
-struct NODE {
- /**
- * Constructor.
- */
- NODE();
-
- unsigned int id;
- short job;
- char coordinates[3];
- unsigned char type;
- unsigned char action;
- unsigned char frame;
- PATH_NODE *path;
- char *speech;
- unsigned char speech_time;
- int speech_color;
- short tick_time;
- short speed;
- unsigned char emotion;
- unsigned char emotion_time;
- int text_x, text_y; // temp solution to fix speech position
- short hair_style, hair_color;
- short weapon;
-};
-
/** Removes all beings from the list */
void empty();
-/** Add a node to the list */
-void add_node(NODE *node);
+/** Add a Being to the list */
+void add_node(Being *Being);
-/** Return a specific id node */
-NODE *find_node(unsigned int id);
+/** Return a specific id Being */
+Being *find_node(unsigned int id);
-/** Remove a node */
+/** Remove a Being */
void remove_node(unsigned int id);
PATH_NODE *calculate_path(
@@ -118,10 +93,10 @@ unsigned int find_monster(unsigned short x, unsigned short y);
void sort();
/** Remove all path nodes from a being */
-void empty_path(NODE *node);
+void empty_path(Being *Being);
-extern NODE *player_node;
+extern Being *player_node;
-extern std::list<NODE*> beings;
+extern std::list<Being*> beings;
#endif
diff --git a/src/game.cpp b/src/game.cpp
index 8df4aca5..aa5f401a 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -172,10 +172,12 @@ void do_init() {
// Initialize beings
empty();
- player_node = new NODE();
+ player_node = new Being();
player_node->id = account_ID;
player_node->type = ACTION_NODE;
- set_coordinates(player_node->coordinates, x, y, 0);
+ player_node->x = x;
+ player_node->y = y;
+ //set_coordinates(player_node->coordinates, x, y, 0);
player_node->speed = 150;
player_node->hair_color = char_info->hair_color;
player_node->hair_style = char_info->hair_style;
@@ -193,8 +195,8 @@ void do_exit() {
void do_input() {
if (walk_status == 0) {
- int x = get_x(player_node->coordinates);
- int y = get_y(player_node->coordinates);
+ int x = player_node->x;
+ int y = player_node->y;
if (key[KEY_8_PAD] || key[KEY_UP]) {
if (get_walk(x, y - 1) != 0) {
@@ -204,8 +206,9 @@ void do_input() {
src_y = y;
player_node->action = WALK;
player_node->tick_time = tick_time;
- set_coordinates(player_node->coordinates, x, y - 1, NORTH);
- } else set_coordinates(player_node->coordinates, x, y, NORTH);
+ player_node->y = y - 1;
+ player_node->direction = NORTH;
+ } else player_node->direction = NORTH;
} else if (key[KEY_2_PAD] || key[KEY_DOWN]) {
if(get_walk(x, y + 1) != 0) {
walk(x, y + 1, SOUTH);
@@ -214,8 +217,9 @@ void do_input() {
src_y = y;
player_node->action = WALK;
player_node->tick_time = tick_time;
- set_coordinates(player_node->coordinates, x, y + 1, SOUTH);
- } else set_coordinates(player_node->coordinates, x, y, SOUTH);
+ player_node->y = y + 1;
+ player_node->direction = SOUTH;
+ } else player_node->direction = SOUTH;
} else if (key[KEY_4_PAD] || key[KEY_LEFT]) {
if (get_walk(x - 1, y) != 0) {
walk(x - 1, y, WEST);
@@ -224,8 +228,9 @@ void do_input() {
src_y = y;
player_node->action = WALK;
player_node->tick_time = tick_time;
- set_coordinates(player_node->coordinates, x - 1, y, WEST);
- } else set_coordinates(player_node->coordinates, x, y, WEST);
+ player_node->x = x - 1;
+ player_node->direction = WEST;
+ } else player_node->direction = WEST;
} else if (key[KEY_6_PAD] || key[KEY_RIGHT]) {
if (get_walk(x + 1, y) != 0) {
walk(x + 1, y, EAST);
@@ -234,17 +239,18 @@ void do_input() {
src_y = y;
player_node->action = WALK;
player_node->tick_time = tick_time;
- set_coordinates(player_node->coordinates, x + 1, y, EAST);
- } else set_coordinates(player_node->coordinates, x, y, EAST);
+ player_node->x = x + 1;
+ player_node->direction = EAST;
+ } else player_node->direction = EAST;
}
}
if (player_node->action == STAND) {
if (key[KEY_LCONTROL]) {
player_node->action = ATTACK;
- attack(get_x(player_node->coordinates),
- get_y(player_node->coordinates),
- get_direction(player_node->coordinates));
+ attack(player_node->x,
+ player_node->y,
+ player_node->direction);
player_node->tick_time = tick_time;
}
}
@@ -353,7 +359,7 @@ void do_parse() {
unsigned short id;
char *temp;
char direction;
- NODE *node = NULL;
+ Being *being = NULL;
PATH_NODE *pn;
int len;
@@ -388,17 +394,17 @@ void do_parse() {
temp = (char *)malloc(RFIFOW(2)-7);
memset(temp, '\0', RFIFOW(2)-7);
memcpy(temp, RFIFOP(8), RFIFOW(2)-8);
- node = find_node(RFIFOL(4));
- if(node!=NULL) {
- if(node->speech!=NULL) {
- free(node->speech);
- node->speech = NULL;
- node->speech_time = 0;
+ being = find_node(RFIFOL(4));
+ if(being!=NULL) {
+ if(being->speech!=NULL) {
+ free(being->speech);
+ being->speech = NULL;
+ being->speech_time = 0;
}
- node->speech = temp;
- node->speech_time = SPEECH_TIME;
- node->speech_color = makecol(255, 255, 255);
- chatlog.chat_log(node->speech, BY_OTHER, font);
+ being->speech = temp;
+ being->speech_time = SPEECH_TIME;
+ being->speech_color = makecol(255, 255, 255);
+ chatlog.chat_log(being->speech, BY_OTHER, font);
}
break;
case 0x008e:
@@ -436,38 +442,42 @@ void do_parse() {
// Add new being / stop monster
case 0x0078:
if (find_node(RFIFOL(2)) == NULL) {
- node = new NODE();
- node->id = RFIFOL(2);
- node->speed = RFIFOW(6);
- if(node->speed==0) {
- node->speed = 150; // Else division by 0 when calculating frame
+ being = new Being();
+ being->id = RFIFOL(2);
+ being->speed = RFIFOW(6);
+ if(being->speed==0) {
+ being->speed = 150; // Else division by 0 when calculating frame
}
- node->job = RFIFOW(14);
- empty_path(node);
- memcpy(node->coordinates, RFIFOP(46), 3);
- node->hair_color = RFIFOW(28);
- node->hair_style = RFIFOW(16);
- add_node(node);
+ being->job = RFIFOW(14);
+ empty_path(being);
+ being->x = get_x(RFIFOP(46));
+ being->y = get_y(RFIFOP(46));
+ being->direction = get_direction(RFIFOP(46));
+ being->hair_color = RFIFOW(28);
+ being->hair_style = RFIFOW(16);
+ add_node(being);
}
else {
- if (node) {
- empty_path(node);
- memcpy(node->coordinates, RFIFOP(46), 3);
- node->frame = 0;
- node->tick_time = tick_time;
- node->action = STAND;
+ if (being) {
+ empty_path(being);
+ being->x = get_x(RFIFOP(46));
+ being->y = get_y(RFIFOP(46));
+ being->direction = get_direction(RFIFOP(46));
+ being->frame = 0;
+ being->tick_time = tick_time;
+ being->action = STAND;
}
}
break;
// Remove a being
case 0x0080:
- node = find_node(RFIFOL(2));
- if (node != NULL) {
+ being = find_node(RFIFOL(2));
+ if (being != NULL) {
if(RFIFOB(6)==1) { // Death
- if(node->job>110) {
- node->action = MONSTER_DEAD;
- node->frame = 0;
- node->tick_time = tick_time;
+ if(being->job>110) {
+ being->action = MONSTER_DEAD;
+ being->frame = 0;
+ being->tick_time = tick_time;
}
else remove_node(RFIFOL(2));
}
@@ -477,80 +487,87 @@ void do_parse() {
// Player moving
case 0x01d8:
case 0x01d9:
- node = find_node(RFIFOL(2));
- if (node == NULL) {
- node = new NODE();
- node->id = RFIFOL(2);
- node->job = RFIFOW(14);
- memcpy(node->coordinates, RFIFOP(46), 3);
- add_node(node);
- node->tick_time = tick_time;
- node->frame = 0;
- node->speed = RFIFOW(6);
- node->hair_color = RFIFOW(28);
- node->hair_style = RFIFOW(16);
+ being = find_node(RFIFOL(2));
+ if (being == NULL) {
+ being = new Being();
+ being->id = RFIFOL(2);
+ being->job = RFIFOW(14);
+ being->x = get_x(RFIFOP(46));
+ being->y = get_y(RFIFOP(46));
+ being->direction = get_direction(RFIFOP(46));
+ add_node(being);
+ being->tick_time = tick_time;
+ being->frame = 0;
+ being->speed = RFIFOW(6);
+ being->hair_color = RFIFOW(28);
+ being->hair_style = RFIFOW(16);
}
break;
// Monster moving
case 0x007b:
//case 0x01da:
- node = find_node(RFIFOL(2));
- if(node==NULL) {
- node = new NODE();
- node->action = STAND;
- set_coordinates(node->coordinates,
- get_src_x(RFIFOP(50)),
- get_src_y(RFIFOP(50)), 0);
- node->id = RFIFOL(2);
- node->speed = RFIFOW(6);
- node->job = RFIFOW(14);
- add_node(node);
+ being = find_node(RFIFOL(2));
+ if(being==NULL) {
+ being = new Being();
+ being->action = STAND;
+ being->x = get_src_x(RFIFOP(50));
+ being->y = get_src_y(RFIFOP(50));
+ being->direction = 0;
+ being->id = RFIFOL(2);
+ being->speed = RFIFOW(6);
+ being->job = RFIFOW(14);
+ add_node(being);
}
- empty_path(node);
- node->path = calculate_path(get_src_x(RFIFOP(50)),
+ empty_path(being);
+ being->path = calculate_path(get_src_x(RFIFOP(50)),
get_src_y(RFIFOP(50)),get_dest_x(RFIFOP(50)),
get_dest_y(RFIFOP(50)));
- if(node->path!=NULL) {
+ if(being->path!=NULL) {
direction = 0;
- if(node->path->next) {
- if(node->path->next->x>node->path->x && node->path->next->y>node->path->y)direction = SE;
- else if(node->path->next->x<node->path->x && node->path->next->y>node->path->y)direction = SW;
- else if(node->path->next->x>node->path->x && node->path->next->y<node->path->y)direction = NE;
- else if(node->path->next->x<node->path->x && node->path->next->y<node->path->y)direction = NW;
- else if(node->path->next->x>node->path->x)direction = EAST;
- else if(node->path->next->x<node->path->x)direction = WEST;
- else if(node->path->next->y>node->path->y)direction = SOUTH;
- else if(node->path->next->y<node->path->y)direction = NORTH;
+ if(being->path->next) {
+ if(being->path->next->x>being->path->x && being->path->next->y>being->path->y)direction = SE;
+ else if(being->path->next->x<being->path->x && being->path->next->y>being->path->y)direction = SW;
+ else if(being->path->next->x>being->path->x && being->path->next->y<being->path->y)direction = NE;
+ else if(being->path->next->x<being->path->x && being->path->next->y<being->path->y)direction = NW;
+ else if(being->path->next->x>being->path->x)direction = EAST;
+ else if(being->path->next->x<being->path->x)direction = WEST;
+ else if(being->path->next->y>being->path->y)direction = SOUTH;
+ else if(being->path->next->y<being->path->y)direction = NORTH;
}
- pn = node->path;
- node->path = node->path->next;
+ pn = being->path;
+ being->path = being->path->next;
free(pn);
- set_coordinates(node->coordinates, node->path->x, node->path->y, direction);
- node->action = WALK;
- node->tick_time = tick_time;
- node->frame = 0;
+ being->x = being->path->x;
+ being->y = being->path->y;
+ being->direction = direction;
+ being->action = WALK;
+ being->tick_time = tick_time;
+ being->frame = 0;
}
break;
// Being moving
case 0x01da:
- node = find_node(RFIFOL(2));
- if(node==NULL) {
- node = new NODE();
- node->id = RFIFOL(2);
- node->job = RFIFOW(14);
- set_coordinates(node->coordinates, get_src_x(RFIFOP(50)), get_src_y(RFIFOP(50)), 0);
- add_node(node);
+ being = find_node(RFIFOL(2));
+ if(being==NULL) {
+ being = new Being();
+ being->id = RFIFOL(2);
+ being->job = RFIFOW(14);
+ being->x = get_src_x(RFIFOP(50));
+ being->y = get_src_y(RFIFOP(50));
+ add_node(being);
}
- if(node->action!=WALK) {
- direction = get_direction(node->coordinates);
- node->action = WALK;
- if(get_dest_x(RFIFOP(50))>get_x(node->coordinates))direction = EAST;
- else if(get_dest_x(RFIFOP(50))<get_x(node->coordinates))direction = WEST;
- else if(get_dest_y(RFIFOP(50))>get_y(node->coordinates))direction = SOUTH;
- else if(get_dest_y(RFIFOP(50))<get_y(node->coordinates))direction = NORTH;
- else node->action = STAND;
- if(node->action==WALK)node->tick_time = tick_time;
- set_coordinates(node->coordinates, get_dest_x(RFIFOP(50)), get_dest_y(RFIFOP(50)), direction);
+ if(being->action!=WALK) {
+ direction = being->direction;
+ being->action = WALK;
+ if(get_dest_x(RFIFOP(50))>being->x)direction = EAST;
+ else if(get_dest_x(RFIFOP(50))<being->x)direction = WEST;
+ else if(get_dest_y(RFIFOP(50))>being->y)direction = SOUTH;
+ else if(get_dest_y(RFIFOP(50))<being->y)direction = NORTH;
+ else being->action = STAND;
+ if(being->action==WALK)being->tick_time = tick_time;
+ being->x = get_dest_x(RFIFOP(50));
+ being->y = get_dest_y(RFIFOP(50));
+ being->direction = direction;
}
break;
// NPC dialog
@@ -579,14 +596,15 @@ void do_parse() {
append_filename(map_path, "./data/map/", RFIFOP(2), 480);
if (load_map(map_path)) {
empty();
- player_node = new NODE();
+ player_node = new Being();
player_node->job = 0;
player_node->action = STAND;
player_node->frame = 0;
player_node->type = ACTION_NODE;
player_node->speed = 150;
player_node->id = account_ID;
- set_coordinates(player_node->coordinates, RFIFOW(18), RFIFOW(20), 0);
+ player_node->x = RFIFOW(18);
+ player_node->y = RFIFOW(20);
add_node(player_node);
walk_status = 0;
// Send "map loaded"
@@ -660,14 +678,14 @@ void do_parse() {
break;
// Stop walking
case 0x0088: // Disabled because giving some problems
- //if (node = find_node(RFIFOL(2))) {
- // if (node->id!=player_node->id) {
+ //if (being = find_node(RFIFOL(2))) {
+ // if (being->id!=player_node->id) {
// char ids[20];
// sprintf(ids,"%i",RFIFOL(2));
// alert(ids,"","","","",0,0);
- // node->action = STAND;
- // node->frame = 0;
- // set_coordinates(node->coordinates, RFIFOW(6), RFIFOW(8), get_direction(node->coordinates));
+ // being->action = STAND;
+ // being->frame = 0;
+ // set_coordinates(being->coordinates, RFIFOW(6), RFIFOW(8), get_direction(being->coordinates));
// }
//}
//break;
@@ -675,53 +693,53 @@ void do_parse() {
case 0x008a:
switch (RFIFOB(26)) {
case 0: // Damage
- node = find_node(RFIFOL(6));
- if (node != NULL) {
- if (node->speech != NULL) {
- free(node->speech);
- node->speech = NULL;
- //node->speech_time = SPEECH_TIME;
+ being = find_node(RFIFOL(6));
+ if(being!=NULL) {
+ if(being->speech!=NULL) {
+ free(being->speech);
+ being->speech = NULL;
+ //being->speech_time = SPEECH_TIME;
}
- node->speech = (char *)malloc(5);
- memset(node->speech, '\0', 5);
+ being->speech = (char *)malloc(5);
+ memset(being->speech, '\0', 5);
if(RFIFOW(22)==0) {
- sprintf(node->speech, "miss");
- node->speech_color = makecol(255, 255, 0);
+ sprintf(being->speech, "miss");
+ being->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);
+ sprintf(being->speech, "%i", RFIFOW(22));
+ if (being->id != player_node->id) {
+ being->speech_color = makecol(0,0,255);
}
else {
- node->speech_color = makecol(255,0,0);
+ being->speech_color = makecol(255,0,0);
}
}
- node->speech_time = SPEECH_TIME;
+ being->speech_time = SPEECH_TIME;
if (RFIFOL(2) != player_node->id) { // buggy
- node = find_node(RFIFOL(2));
- if (node != NULL) {
- if (node->job<10) {
- node->action = ATTACK;
+ being = find_node(RFIFOL(2));
+ if (being != NULL) {
+ if (being->job<10) {
+ being->action = ATTACK;
}
else {
- node->action = MONSTER_ATTACK;
+ being->action = MONSTER_ATTACK;
}
- node->frame = 0;
+ being->frame = 0;
}
}
}
break;
case 2: // Sit
case 3: // Stand up
- node = find_node(RFIFOL(2));
- if (node != NULL) {
- node->frame = 0;
+ being = find_node(RFIFOL(2));
+ if (being != NULL) {
+ being->frame = 0;
if (RFIFOB(26) == 2) {
- node->action = SIT;
+ being->action = SIT;
walk_status = 0;
}
else if (RFIFOB(26) == 3) {
- node->action = STAND;
+ being->action = STAND;
}
}
break;
@@ -760,10 +778,10 @@ void do_parse() {
break;
// Emotion
case 0x00c0:
- node = find_node(RFIFOL(2));
- if(node) {
- node->emotion = RFIFOB(6);
- node->emotion_time = EMOTION_TIME;
+ being = find_node(RFIFOL(2));
+ if(being) {
+ being->emotion = RFIFOB(6);
+ being->emotion_time = EMOTION_TIME;
}
break;
// Update skill values
@@ -916,14 +934,14 @@ void do_parse() {
case 0x00c3:
// Change hair color
if (RFIFOB(6) == 6) {
- node = find_node(RFIFOL(2));
- node->hair_color = RFIFOB(7);
+ being = find_node(RFIFOL(2));
+ being->hair_color = RFIFOB(7);
//char prova[100];
//sprintf(prova, "%i %i %i", RFIFOL(2), RFIFOB(6), RFIFOB(7));
//alert(prova,"","","","",0,0);
} else if (RFIFOB(6) == 1) {
- node = find_node(RFIFOL(2));
- node->hair_style = RFIFOB(7);
+ being = find_node(RFIFOL(2));
+ being->hair_style = RFIFOB(7);
}
break;
case 0x00a4:
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 1e40c845..27d4498d 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -102,12 +102,12 @@ char hairtable[14][4][2] = {
{ { 0, 4}, {-1, 6}, {-1, 6}, {0, 6} } // SIT
};
-int get_x_offset(NODE *node) {
+int get_x_offset(Being *being) {
int offset = 0;
- char direction = get_direction(node->coordinates);
- if (node->action == WALK) {
+ char direction = being->direction;
+ if (being->action == WALK) {
if (direction != NORTH && direction != SOUTH) {
- offset = node->frame + 1;
+ offset = being->frame + 1;
if (offset == 5)offset = 0;
offset *= 8;
if (direction == WEST || direction == NW || direction == SW) {
@@ -119,12 +119,12 @@ int get_x_offset(NODE *node) {
return offset;
}
-int get_y_offset(NODE *node) {
+int get_y_offset(Being *being) {
int offset = 0;
- char direction = get_direction(node->coordinates);
- if (node->action == WALK) {
+ char direction = being->direction;
+ if (being->action == WALK) {
if (direction != EAST && direction != WEST) {
- offset = node->frame + 1;
+ offset = being->frame + 1;
if (offset == 5) offset = 0;
offset *= 8;
if (direction == NORTH || direction == NW || direction == NE) {
@@ -235,9 +235,9 @@ GraphicEngine::~GraphicEngine() {
}
void GraphicEngine::refresh() {
- map_x = (get_x(player_node->coordinates) - 13) * 32 +
+ map_x = (player_node->x - 13) * 32 +
get_x_offset(player_node);
- map_y = (get_y(player_node->coordinates) - 9) * 32 +
+ map_y = (player_node->y - 9) * 32 +
get_y_offset(player_node);
camera_x = map_x >> 5;
@@ -269,106 +269,106 @@ void GraphicEngine::refresh() {
}
// Draw nodes
- std::list<NODE*>::iterator beingIterator = beings.begin();
+ std::list<Being*>::iterator beingIterator = beings.begin();
while (beingIterator != beings.end()) {
- NODE *node = (*beingIterator);
+ Being *being = (*beingIterator);
- unsigned short x = get_x(node->coordinates);
- unsigned short y = get_y(node->coordinates);
- unsigned char dir = get_direction(node->coordinates) / 2;
+ unsigned short x = being->x;
+ unsigned short y = being->y;
+ unsigned char dir = being->direction / 2;
int sx = x - camera_x;
int sy = y - camera_y;
#ifdef DEBUG
- textprintf_ex(buffer, font, sx*32, sy*32+40, makecol(255, 255, 255), -1, "%i,%i | %i", x, y, node->frame);
+ textprintf_ex(buffer, font, sx*32, sy*32+40, makecol(255, 255, 255), -1, "%i,%i | %i", x, y, being->frame);
rect(buffer, sx*32, sy*32, sx*32+32, sy*32+32, makecol(0,0,255));
#endif
- if ((node->job >= 100) && (node->job <= 110)) { // Draw a NPC
- npcset->spriteset[4 * (node->job - 100) + dir]->draw(buffer,
+ if ((being->job >= 100) && (being->job <= 110)) { // Draw a NPC
+ npcset->spriteset[4 * (being->job - 100) + dir]->draw(buffer,
sx * 32 - 8 - offset_x,
sy * 32 - 52 - offset_y);
}
- else if (node->job < 10) { // Draw a player
- node->text_x = sx * 32 + get_x_offset(node) - offset_x;
- node->text_y = sy * 32 + get_y_offset(node) - offset_y;
- int hf = node->hair_color - 1 + 10 * (dir + 4 *
- (node->hair_style - 1));
+ else if (being->job < 10) { // Draw a player
+ being->text_x = sx * 32 + get_x_offset(being) - offset_x;
+ being->text_y = sy * 32 + get_y_offset(being) - offset_y;
+ int hf = being->hair_color - 1 + 10 * (dir + 4 *
+ (being->hair_style - 1));
- if (node->action == SIT) node->frame = 0;
- if (node->action == ATTACK) {
- int pf = node->frame + node->action + 4 * node->weapon;
+ if (being->action == SIT) being->frame = 0;
+ if (being->action == ATTACK) {
+ int pf = being->frame + being->action + 4 * being->weapon;
playerset->spriteset[4 * pf + dir]->draw(buffer,
- node->text_x - 64, node->text_y - 80);
+ being->text_x - 64, being->text_y - 80);
hairset->spriteset[hf]->draw(buffer,
- node->text_x - 2 + 2 * hairtable[pf][dir][0],
- node->text_y - 50 + 2 * hairtable[pf][dir][1]);
+ being->text_x - 2 + 2 * hairtable[pf][dir][0],
+ being->text_y - 50 + 2 * hairtable[pf][dir][1]);
}
else {
- int pf = node->frame + node->action;
+ int pf = being->frame + being->action;
playerset->spriteset[4 * pf + dir]->draw(buffer,
- node->text_x - 64, node->text_y - 80);
+ being->text_x - 64, being->text_y - 80);
hairset->spriteset[hf]->draw(buffer,
- node->text_x - 2 + 2 * hairtable[pf][dir][0],
- node->text_y - 50 + 2 * hairtable[pf][dir][1]);
+ being->text_x - 2 + 2 * hairtable[pf][dir][0],
+ being->text_y - 50 + 2 * hairtable[pf][dir][1]);
}
- if (node->emotion != 0) {
- emotionset->spriteset[node->emotion - 1]->draw(buffer,
- sx * 32 - 5 + get_x_offset(node) - offset_x,
- sy * 32 - 45 + get_y_offset(node) - offset_y);
- node->emotion_time--;
- if (node->emotion_time == 0) {
- node->emotion = 0;
+ if (being->emotion != 0) {
+ emotionset->spriteset[being->emotion - 1]->draw(buffer,
+ sx * 32 - 5 + get_x_offset(being) - offset_x,
+ sy * 32 - 45 + get_y_offset(being) - offset_y);
+ being->emotion_time--;
+ if (being->emotion_time == 0) {
+ being->emotion = 0;
}
}
- if (node->action != STAND && node->action != SIT) {
- node->frame =
- (get_elapsed_time(node->tick_time) * 4) / (node->speed);
-
- if (node->frame >= 4) {
- node->frame = 0;
- node->action = STAND;
- if (node->id == player_node->id) {
+ if (being->action != STAND && being->action != SIT) {
+ being->frame =
+ (get_elapsed_time(being->tick_time) * 4) / (being->speed);
+
+ if (being->frame >= 4) {
+ being->frame = 0;
+ being->action = STAND;
+ if (being->id == player_node->id) {
walk_status = 0;
}
}
}
}
- else if (node->job == 45) { // Draw a warp
+ else if (being->job == 45) { // Draw a warp
} else { // Draw a monster
- if (node->frame >= 4)
- node->frame = 3;
+ if (being->frame >= 4)
+ being->frame = 3;
- node->text_x = sx * 32 - 42 + get_x_offset(node) - offset_x;
- node->text_y = sy * 32 - 65 + get_y_offset(node) - offset_y;
+ being->text_x = sx * 32 - 42 + get_x_offset(being) - offset_x;
+ being->text_y = sy * 32 - 65 + get_y_offset(being) - offset_y;
- int sprnum = dir + 4 * (node->job - 1002);
- int mf = node->frame + node->action;
+ int sprnum = dir + 4 * (being->job - 1002);
+ int mf = being->frame + being->action;
- if (node->action == MONSTER_DEAD) {
+ if (being->action == MONSTER_DEAD) {
monsterset->spriteset[sprnum + 8 * MONSTER_DEAD]->draw(buffer,
- node->text_x + 30, node->text_y + 40);
+ being->text_x + 30, being->text_y + 40);
}
else {
monsterset->spriteset[sprnum + 8 * mf]->draw(buffer,
- node->text_x + 30, node->text_y + 40);
+ being->text_x + 30, being->text_y + 40);
}
- if (node->action != STAND) {
- node->frame =
- (get_elapsed_time(node->tick_time) * 4) / (node->speed);
+ if (being->action != STAND) {
+ being->frame =
+ (get_elapsed_time(being->tick_time) * 4) / (being->speed);
- if (node->frame >= 4) {
- if (node->action != MONSTER_DEAD && node->path) {
- if (node->path->next) {
+ if (being->frame >= 4) {
+ if (being->action != MONSTER_DEAD && being->path) {
+ if (being->path->next) {
int old_x, old_y, new_x, new_y;
- old_x = node->path->x;
- old_y = node->path->y;
- node->path = node->path->next;
- new_x = node->path->x;
- new_y = node->path->y;
+ old_x = being->path->x;
+ old_y = being->path->y;
+ being->path = being->path->next;
+ new_x = being->path->x;
+ new_y = being->path->y;
direction = 0;
if (new_x > old_x) {
@@ -386,30 +386,31 @@ void GraphicEngine::refresh() {
else if (new_y < old_y) direction = NORTH;
}
- set_coordinates(node->coordinates,
- node->path->x, node->path->y, direction);
+ being->x = being->path->x;
+ being->y = being->path->y;
+ being->direction = direction;
} else {
- node->action = STAND;
+ being->action = STAND;
}
- if (node->action != MONSTER_DEAD) {
- node->frame = 0;
+ if (being->action != MONSTER_DEAD) {
+ being->frame = 0;
}
- node->tick_time = tick_time;
- //node->frame = 0;
+ being->tick_time = tick_time;
+ //being->frame = 0;
}
}
}
}
- if (node->action == MONSTER_DEAD && node->frame >= 20) {
- delete node;
+ if (being->action == MONSTER_DEAD && being->frame >= 20) {
+ delete being;
beingIterator = beings.erase(beingIterator);
}
else {
beingIterator++;
}
- // nodes are ordered so if the next node y is > then the
+ // nodes are ordered so if the next being y is > then the
// last drawed for fringe layer, draw the missing lines
}
@@ -433,28 +434,28 @@ void GraphicEngine::refresh() {
// Draw player speech
beingIterator = beings.begin();
while (beingIterator != beings.end()) {
- NODE *node = (*beingIterator);
+ Being *being = (*beingIterator);
- if (node->speech != NULL) {
- if (node->speech_color == makecol(255, 255, 255)) {
+ if (being->speech != NULL) {
+ if (being->speech_color == makecol(255, 255, 255)) {
textprintf_centre_ex(buffer, font,
- node->text_x,
- node->text_y - 60,
- node->speech_color, -1,
- "%s", node->speech);
+ being->text_x,
+ being->text_y - 60,
+ being->speech_color, -1,
+ "%s", being->speech);
}
else {
textprintf_centre_ex(buffer, font,
- node->text_x + 60,
- node->text_y,
- node->speech_color, -1,
- "%s", node->speech);
+ being->text_x + 60,
+ being->text_y,
+ being->speech_color, -1,
+ "%s", being->speech);
}
- node->speech_time--;
- if (node->speech_time == 0) {
- free(node->speech);
- node->speech = NULL;
+ being->speech_time--;
+ if (being->speech_time == 0) {
+ free(being->speech);
+ being->speech = NULL;
}
}
diff --git a/src/map.cpp b/src/map.cpp
index ec796768..c5049418 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -54,10 +54,10 @@ void set_walk(short x_c, short y_c, bool walkable) {
bool get_walk(short x_c, short y_c) {
bool ret = (tiled_map.tiles[x_c][y_c].data[3] & 0x0002)>0;
if (ret == true) {
- std::list<NODE*>::iterator i = beings.begin();
+ std::list<Being *>::iterator i = beings.begin();
while (i != beings.end() && ret == true) {
- NODE *node = (*i);
- if (get_x(node->coordinates)==x_c && get_y(node->coordinates)==y_c)
+ Being *being = (*i);
+ if (being->x==x_c && being->y==y_c)
ret = false;
i++;
}