summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2004-12-11 17:39:25 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2004-12-11 17:39:25 +0000
commit3fcde31ec23e0bb8f5403e2dcba6ac030fb310a2 (patch)
tree81fc3e70dc98a9ed9f1f86614df8b886508abcfc
parentaf7060d953e1c0f54a7d5bf46894191d41d853ff (diff)
downloadmana-3fcde31ec23e0bb8f5403e2dcba6ac030fb310a2.tar.gz
mana-3fcde31ec23e0bb8f5403e2dcba6ac030fb310a2.tar.bz2
mana-3fcde31ec23e0bb8f5403e2dcba6ac030fb310a2.tar.xz
mana-3fcde31ec23e0bb8f5403e2dcba6ac030fb310a2.zip
Core sprite classes of the new graphic engine
-rw-r--r--ManaWorld.vcproj6
-rw-r--r--The Mana World.dev48
-rw-r--r--src/being.cpp12
-rw-r--r--src/graphic/graphic.cpp46
-rw-r--r--src/graphic/graphic.h1
-rw-r--r--src/log.cpp44
-rw-r--r--src/log.h12
-rw-r--r--src/main.cpp5
-rw-r--r--src/net/network.cpp4
9 files changed, 99 insertions, 79 deletions
diff --git a/ManaWorld.vcproj b/ManaWorld.vcproj
index 33623297..0b2b1ea1 100644
--- a/ManaWorld.vcproj
+++ b/ManaWorld.vcproj
@@ -204,6 +204,12 @@
<File
RelativePath=".\src\graphic\graphic.h">
</File>
+ <File
+ RelativePath=".\src\graphic\image.cpp">
+ </File>
+ <File
+ RelativePath=".\src\graphic\image.h">
+ </File>
</Filter>
<Filter
Name="net"
diff --git a/The Mana World.dev b/The Mana World.dev
index 01b4d69b..2af3e286 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -1,12 +1,12 @@
[Project]
FileName=The Mana World.dev
Name=tmw
-UnitCount=45
+UnitCount=47
Type=0
Ver=1
ObjFiles=
-Includes=C:\Dev-Cpp\alfont\include;C:\Dev-Cpp\jgmod\src
-Libs=C:\Dev-Cpp\alfont\lib\mingw32;C:\Dev-Cpp\jgmod\lib\mingw32
+Includes=
+Libs=
PrivateResource=The_Mana_World_private.rc
ResourceIncludes=
MakeIncludes=
@@ -14,7 +14,7 @@ Compiler=
CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@_
Linker=-ljgmod_@@_-lalfont_@@_-lalleg_@@_-lwsock32_@@_
IsCpp=1
-Icon=
+Icon=The Mana World.ico
ExeOutput=
ObjectOutput=src\objects
OverrideOutput=1
@@ -27,13 +27,13 @@ CustomMakefile=
IncludeVersionInfo=1
SupportXPThemes=0
CompilerSet=0
-CompilerSettings=0000001001001000001101
+CompilerSettings=0010001001001000001101
[VersionInfo]
Major=0
Minor=0
Release=8
-Build=331
+Build=590
LanguageID=1033
CharsetID=1252
CompanyName=The Mana World Development Team
@@ -484,9 +484,39 @@ OverrideBuildCmd=0
BuildCmd=
[Unit44]
+FileName=src\weapon.h
+CompileCpp=1
+Folder=tmw
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit46]
+FileName=src\gui\setup.h
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit47]
+FileName=src\gui\setup.cpp
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit48]
FileName=src\gui\setup.cpp
CompileCpp=1
-Folder=tmw/gui
+Folder=gui
Compile=1
Link=1
Priority=1000
@@ -494,9 +524,9 @@ OverrideBuildCmd=0
BuildCmd=
[Unit45]
-FileName=src\gui\setup.h
+FileName=src\graphic\image.h
CompileCpp=1
-Folder=tmw/gui
+Folder=graphic
Compile=1
Link=1
Priority=1000
diff --git a/src/being.cpp b/src/being.cpp
index 625919a2..92a1989e 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -28,7 +28,7 @@
NODE *player_node = NULL;
NODE *head = NULL; // First node of the list
-unsigned int count = 0; // Number of beings in the list
+unsigned int b_count = 0; // Number of beings in the list
/** Create a path node */
PATH_NODE::PATH_NODE(unsigned short x, unsigned short y):
@@ -67,7 +67,7 @@ NODE::NODE():
/** Returns number of beings in the list */
unsigned int get_count() {
- return count;
+ return b_count;
}
/** Removes all beings from the list */
@@ -79,7 +79,7 @@ void empty() {
delete node;
node = next;
}
- count = 0;
+ b_count = 0;
head = NULL;
}
@@ -91,7 +91,7 @@ void add_node(NODE *node) {
temp = temp->next;
temp->next = node;
} else head = node;
- count++;
+ b_count++;
}
/** Remove a node */
@@ -106,12 +106,12 @@ void remove_node(unsigned int id) {
if(node_new==NULL) {
head = node_old->next;
delete node_old;
- count--;
+ b_count--;
return;
} else {
node_new->next = node_old->next;
delete node_old;
- count--;
+ b_count--;
return;
}
} else {
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index cbea749f..d7babb44 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -53,6 +53,8 @@ bool show_skill_dialog = false;
bool show_skill_list_dialog = false;
char npc_button[10] = "Close";
+SPRITESET *new_tileset, *new_playerset, *new_npcset, *new_emotionset, *new_monsterset;
+
DIALOG npc_dialog[] = {
/* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
{ tmw_dialog_proc, 300, 200, 260, 150, 0, 0, 0, 0, 0, 0, (char *)"NPC", NULL, NULL },
@@ -256,6 +258,13 @@ void init_graphic() {
vmonsterset = load_graphic_file("./data/graphic/monsterset.bmp");
gui_bitmap = vpage[page_num];
+
+ new_emotionset = new SPRITESET("./data/graphic/emotionset.dat");
+ new_tileset = new SPRITESET("./data/graphic/desert.dat");
+ new_npcset = new SPRITESET("./data/graphic/npcset.dat");
+ new_playerset = new SPRITESET("./data/graphic/playerset.dat");
+ new_monsterset = new SPRITESET("./data/graphic/monsterset.dat");
+
}
@@ -277,33 +286,36 @@ void do_graphic(void) {
if(is_video_bitmap(vbuffer))
acquire_bitmap(vbuffer);
#endif
+
+new_tileset->spriteset[0]->draw(vbuffer, 0, 0);
for(int j=0;j<20;j++)
for(int i=0;i<26;i++) {
- //if(get_tile(i+camera_x, j+camera_y, 0) < 600)
- blit(vtileset, vbuffer, get_tile_x(i+camera_x, j+camera_y, 0)*16, get_tile_y(i+camera_x, j+camera_y, 0)*16, i*16-offset_x, j*16-offset_y, 16, 16);
- if(get_tile(i+camera_x, j+camera_y, 1) > 0 /*&& get_tile(i+camera_x, j+camera_y, 1)<600*/)
- masked_blit(vtileset, vbuffer, get_tile_x(i+camera_x, j+camera_y, 1)*16, get_tile_y(i+camera_x, j+camera_y, 1)*16, i*16-offset_x, j*16-offset_y, 16, 16);
+
+ if(get_tile(i+camera_x, j+camera_y, 0) < 600)
+ new_tileset->spriteset[get_tile(i+camera_x, j+camera_y, 0)]->draw(vbuffer, i*16-offset_x, j*16-offset_y);
+ if(get_tile(i+camera_x, j+camera_y, 1) > 0 /*&& get_tile(i+camera_x, j+camera_y, 1)<600*/)
+ new_tileset->spriteset[get_tile(i+camera_x, j+camera_y, 1)]->draw(vbuffer, i*16-offset_x, j*16-offset_y);
}
NODE *node = get_head();
while(node) {
if((node->job>=100)&&(node->job<=110)) { // Draw a NPC
- masked_blit(vnpcset, vbuffer, (get_direction(node->coordinates)/2+4*(node->job-100))*25, 0, (get_x(node->coordinates)-camera_x)*16-4-offset_x, (get_y(node->coordinates)-camera_y)*16-24-offset_y, 25, 40);
+ new_npcset->spriteset[4*(node->job-100)+get_direction(node->coordinates)/2]->draw(vbuffer, (get_x(node->coordinates)-camera_x)*16-4-offset_x, (get_y(node->coordinates)-camera_y)*16-24-offset_y);
} else if(node->job<10) { // Draw a player
node->text_x = (get_x(node->coordinates)-camera_x)*16 -34+get_x_offset(node)-offset_x;
node->text_y = (get_y(node->coordinates)-camera_y)*16 -36+get_y_offset(node)-offset_y;
if(node->action==SIT)node->frame = 0;
if(node->action==ATTACK) {
- masked_blit(vplayerset, vbuffer, 80*(get_direction(node->coordinates)/2), 60*(node->frame+node->action+4*node->weapon), node->text_x, node->text_y, 80, 60);
+ new_playerset->spriteset[(get_direction(node->coordinates)/2)+4*(node->frame+node->action+4*node->weapon)]->draw(vbuffer, node->text_x, node->text_y);
draw_rle_sprite(vbuffer, (RLE_SPRITE *)weaponset[16*node->weapon+4*node->frame+get_direction(node->coordinates)/2].dat, node->text_x, node->text_y);
masked_blit(hairset, vbuffer, 20*(node->hair_color-1), 20*(get_direction(node->coordinates)/2+4*(node->hair_style-1)), node->text_x+31+hairtable[node->action+node->frame+4*node->weapon][get_direction(node->coordinates)/2][0], node->text_y+15+hairtable[node->action+node->frame+4*node->weapon][get_direction(node->coordinates)/2][1], 20, 20);
} else {
- masked_blit(vplayerset, vbuffer, 80*(get_direction(node->coordinates)/2), 60*(node->frame+node->action), node->text_x, node->text_y, 80, 60);
+ new_playerset->spriteset[4*(node->frame+node->action)+get_direction(node->coordinates)/2]->draw(vbuffer, node->text_x, node->text_y);
masked_blit(hairset, vbuffer, 20*(node->hair_color-1), 20*(get_direction(node->coordinates)/2+4*(node->hair_style-1)), node->text_x+31+hairtable[node->action+node->frame][get_direction(node->coordinates)/2][0], node->text_y+15+hairtable[node->action+node->frame][get_direction(node->coordinates)/2][1], 20, 20);
}
if(node->emotion!=0) {
- draw_sprite(vbuffer, (BITMAP *)emotions[node->emotion-1].dat, (get_x(node->coordinates)-camera_x)*16-5+get_x_offset(node)-offset_x, (get_y(node->coordinates)-camera_y)*16-45+get_y_offset(node)-offset_y);
+ new_emotionset->spriteset[node->emotion-1]->draw(vbuffer, (get_x(node->coordinates)-camera_x)*16-5+get_x_offset(node)-offset_x, (get_y(node->coordinates)-camera_y)*16-45+get_y_offset(node)-offset_y);
node->emotion_time--;
if(node->emotion_time==0)
node->emotion = 0;
@@ -319,16 +331,11 @@ void do_graphic(void) {
}
} else if(node->job==45) { // Draw a warp
- //rectfill(buffer, (get_x(node->coordinates)-map_x)*16-player_x-get_x_offset(node->frame, get_direction(node->coordinates)), (get_y(node->coordinates)-map_y)*16-player_y-get_y_offset(node->frame, get_direction(node->coordinates)), (get_x(node->coordinates)-map_x)*16-player_x-get_x_offset(node->frame, get_direction(node->coordinates))+16, (get_y(node->coordinates)-map_y)*16-player_y-get_y_offset(node->frame, get_direction(node->coordinates))+16, makecol(0,0,255));
} else { // Draw a monster
- //node->speed = 10000;
- if(node->frame>=4) {
- //alert("","","","","",0,0);
+ if(node->frame>=4)
node->frame = 3;
- }
-
node->text_x = (get_x(node->coordinates)-camera_x)*16-22+get_x_offset(node)-offset_x;
node->text_y = (get_y(node->coordinates)-camera_y)*16-25+get_y_offset(node)-offset_y;
@@ -336,15 +343,10 @@ void do_graphic(void) {
int r_x = node->text_x-get_x_offset(node);
int r_y = node->text_y-get_y_offset(node);
- //rectfill(buffer, node->text_x+22, node->text_y+25, node->text_x+16+22, node->text_y+16+25, makecol(0,0,255));
-
- //if(node->action==MONSTER_DEAD)node->frame = 0;
if(node->action==MONSTER_DEAD)
- masked_blit(vmonsterset, vbuffer, (get_direction(node->coordinates)/2)*60+240*(node->job-1002), 60*MONSTER_DEAD, node->text_x, node->text_y, 60, 60);
+ new_monsterset->spriteset[(get_direction(node->coordinates)/2)+4*(node->job-1002)+16*MONSTER_DEAD]->draw(vbuffer, node->text_x, node->text_y);
else
- masked_blit(vmonsterset, vbuffer, (get_direction(node->coordinates)/2)*60+240*(node->job-1002), 60*(node->frame+node->action), node->text_x, node->text_y, 60, 60);
-
- //alfont_textprintf(buffer, gui_font, node->text_x, node->text_y, MAKECOL_WHITE, "%i", node->id);
+ new_monsterset->spriteset[(get_direction(node->coordinates)/2)+4*(node->job-1002)+16*(node->frame+node->action)]->draw(vbuffer, node->text_x, node->text_y);
if(node->action!=STAND) {
node->frame = (get_elapsed_time(node->tick_time)*4)/(node->speed);
@@ -394,7 +396,7 @@ void do_graphic(void) {
for(int j=0;j<20;j++)
for(int i=0;i<26;i++)
if(get_tile(i+camera_x, j+camera_y, 2)>0 && get_tile(i+camera_x, j+camera_y, 2)<600)
- masked_blit(vtileset, vbuffer, get_tile_x(i+camera_x, j+camera_y, 2)*16, get_tile_y(i+camera_x, j+camera_y, 2)*16, i*16-offset_x, j*16-offset_y, 16, 16);
+ new_tileset->spriteset[get_tile(i+camera_x, j+camera_y, 2)]->draw(vbuffer, i*16-offset_x, j*16-offset_y);
#ifdef WIN32
if(is_video_bitmap(vbuffer))
release_bitmap(vbuffer);
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index c8fbbd0e..e4fd66aa 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -39,6 +39,7 @@
#include "../gui/inventory.h"
#include "../gui/npc.h"
#include "../../data/graphic/gfx_data.h"
+#include "image.h"
extern BITMAP *buffer, *double_buffer;
extern char speech[255];
diff --git a/src/log.cpp b/src/log.cpp
index 4cc48d1f..710a1fc3 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -21,42 +21,36 @@
#include "log.h"
+int warning_n; // Keep warning number
FILE* logfile;
#define LOG_FILE "./docs/tmw.log"
-/*
- * Initializes log file by opening it for writing.
- */
+
void init_log() {
logfile = fopen(LOG_FILE, "w");
if (!logfile) {
printf("Warning: error while opening log file.\n");
}
+ warning_n = 0;
}
-/*
- * Enter a message in the log with a certain category. The message will be
- * timestamped.
- */
void log(const char *category, const char *log_text, ...) {
if (logfile) {
char* buf = new char[1024];
- va_list ap;
- time_t t;
- // Use a temporary buffer to fill in the variables
+ va_list ap;
va_start(ap, log_text);
vsprintf(buf, log_text, ap);
va_end(ap);
- // Get the current system time
+ time_t t;
time(&t);
- // Print the log entry
- fprintf(logfile,
+ fprintf(
+ logfile,
"[%s%d:%s%d:%s%d] %s: %s\n",
(((t / 60) / 60) % 24 < 10) ? "0" : "",
(int)(((t / 60) / 60) % 24),
@@ -66,40 +60,28 @@ void log(const char *category, const char *log_text, ...) {
(int)(t % 60),
category, buf
);
-
- // Flush the log file
fflush(logfile);
- // Delete temporary buffer
delete[] buf;
}
}
-/*
- * Log an error and quit. The error will pop-up in Windows and will be printed
- * to standard error everywhere else.
- */
-void error(const char *error_text) {
- log("Error", error_text);
+
+void error(string error_text) {
+ log("Error", error_text.c_str());
#ifdef WIN32
- MessageBox(NULL, error_text, "Error", MB_ICONERROR|MB_OK);
+ MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR|MB_OK);
#else
- fprintf(stderr, "Error: %s\n", error_text);
+ printf("Error: %s", error_text);
#endif
- exit(1);
+ //exit(1);
}
-/*
- * Shortcut to log a warning.
- */
void warning(const char *warning_text) {
log("Warning", warning_text);
}
-/*
- * Shortcut to log a status update, will only really be logged in debug mode.
- */
void status(const char *status_text) {
#ifdef DEBUG
log("Status", status_text);
diff --git a/src/log.h b/src/log.h
index 3b91bf8a..a173fa5a 100644
--- a/src/log.h
+++ b/src/log.h
@@ -19,21 +19,23 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef WIN32
- #pragma warning (disable:4312)
-#endif
-
#ifndef _LOG_H
#define _LOG_H
#include <stdlib.h>
#include <stdio.h>
+#include <string>
+using namespace std;
#include <stdarg.h>
#include <time.h>
+#ifdef WIN32
+#include <allegro.h>
+#include <winalleg.h>
+#endif
void init_log();
void log(const char *category, const char *log_text, ...);
-void error(const char *error_text);
+void error(string error_text);
void warning(const char *warning_text);
void status(const char *status_text);
diff --git a/src/main.cpp b/src/main.cpp
index fbccd95c..907c1e39 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -76,7 +76,7 @@ SERVER_INFO *server_info;
PLAYER_INFO *char_info = new PLAYER_INFO;
BITMAP *playerset, *hairset;
-DATAFILE *graphic, *emotions, *weaponset;
+DATAFILE *graphic, *weaponset;
char username[LEN_USERNAME];
char password[LEN_PASSWORD];
@@ -259,9 +259,6 @@ void init_engine() {
if(graphic==NULL)
error("Unable to load graphic datafile");
playerset = (BITMAP*)graphic[PLAYERSET_BMP].dat;
- emotions = load_datafile("./data/graphic/emotions.dat");
- if(emotions==NULL)
- error("Unable to load emotions datafile");
hairset = load_bitmap("./data/graphic/hairset.bmp", NULL);
if(hairset==NULL)
error("Unable to load hairset bitmap");
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 8f34787b..0cb41750 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -150,7 +150,7 @@ void flush() {
if(ret==SOCKET_ERROR) {
error("Socket Error");
#ifdef WIN32
- log_int("Error", "socket_error", WSAGetLastError());
+ log("Error", "Socket error: %i ", WSAGetLastError());
#else
log("Error", "socket_error", "Undefined socket error");
#endif
@@ -164,7 +164,7 @@ void flush() {
ret = recv(sock, in+in_size, RFIFOSPACE, 0);
if(ret==SOCKET_ERROR) {
#ifdef WIN32
- log_int("Error", "socket_error", WSAGetLastError());
+ log("Error", "Socket error: %i ", WSAGetLastError());
#else
log("Error", "socket_error", "Undefined socket error");
#endif