diff options
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/ec_client.c | 21 | ||||
| -rw-r--r-- | src/engine/client/ec_font.c | 3 | ||||
| -rw-r--r-- | src/engine/client/ec_gfx.c | 46 |
3 files changed, 32 insertions, 38 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c index 8ef6cf51..1c499e85 100644 --- a/src/engine/client/ec_client.c +++ b/src/engine/client/ec_client.c @@ -727,7 +727,6 @@ static const char *client_load_map_search(const char *mapname, int wanted_crc) { const char *error = 0; char buf[512]; - char buf2[512]; dbg_msg("client", "loading map, map=%s wanted crc=%08x", mapname, wanted_crc); client_set_state(CLIENTSTATE_LOADING); @@ -738,8 +737,7 @@ static const char *client_load_map_search(const char *mapname, int wanted_crc) return error; /* try the downloaded maps */ - str_format(buf2, sizeof(buf2), "maps/%s_%8x.map", mapname, wanted_crc); - engine_savepath(buf2, buf, sizeof(buf)); + str_format(buf, sizeof(buf), "maps/%s_%8x.map", mapname, wanted_crc); error = client_load_map(mapname, buf, wanted_crc); return error; } @@ -896,15 +894,13 @@ static void client_process_packet(NETCHUNK *packet) } else { - char buf[512]; - str_format(buf, sizeof(buf), "maps/%s_%08x.map", map, map_crc); - engine_savepath(buf, mapdownload_filename, sizeof(mapdownload_filename)); + str_format(mapdownload_filename, sizeof(mapdownload_filename), "maps/%s_%08x.map", map, map_crc); dbg_msg("client/network", "starting to download map to '%s'", mapdownload_filename); mapdownload_chunk = 0; str_copy(mapdownload_name, map, sizeof(mapdownload_name)); - mapdownload_file = io_open(mapdownload_filename, IOFLAG_WRITE); + mapdownload_file = engine_openfile(mapdownload_filename, IOFLAG_WRITE); mapdownload_crc = map_crc; mapdownload_totalsize = -1; mapdownload_amount = 0; @@ -1857,14 +1853,9 @@ int main(int argc, char **argv) /* parse the command line arguments */ engine_parse_arguments(argc, argv); - - /* change into data-dir */ - if (!engine_chdir_datadir(argv[0])) - { - dbg_msg("client", "fatal error: data-dir cannot be found"); - gui_messagebox("Error", "The data-dir cannot be found."); - return -1; - } + + /* execute config file */ + console_execute_file("settings.cfg"); /* run the client*/ client_run(); diff --git a/src/engine/client/ec_font.c b/src/engine/client/ec_font.c index af9c612a..f8760d41 100644 --- a/src/engine/client/ec_font.c +++ b/src/engine/client/ec_font.c @@ -4,6 +4,7 @@ #include <string.h> #include <base/system.h> #include <engine/e_client_interface.h> +#include <engine/e_engine.h> #include "ec_font.h" typedef struct @@ -32,7 +33,7 @@ int font_load(FONT *font, const char *filename) FONT_DATA font_data; IOHANDLE file; - file = io_open(filename, IOFLAG_READ); + file = engine_openfile(filename, IOFLAG_READ); if(file) { diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c index 1f9ec642..35e43e41 100644 --- a/src/engine/client/ec_gfx.c +++ b/src/engine/client/ec_gfx.c @@ -796,21 +796,24 @@ int gfx_load_texture(const char *filename, int store_format, int flags) int gfx_load_png(IMAGE_INFO *img, const char *filename) { + char completefilename[512]; unsigned char *buffer; png_t png; /* open file for reading */ png_init(0,0); - if(png_open_file(&png, filename) != PNG_NO_ERROR) + engine_getpath(completefilename, sizeof(completefilename), filename, IOFLAG_READ); + + if(png_open_file(&png, completefilename) != PNG_NO_ERROR) { - dbg_msg("game/png", "failed to open file. filename='%s'", filename); + dbg_msg("game/png", "failed to open file. filename='%s'", completefilename); return 0; } if(png.depth != 8 || (png.color_type != PNG_TRUECOLOR && png.color_type != PNG_TRUECOLOR_ALPHA)) { - dbg_msg("game/png", "invalid format. filename='%s'", filename); + dbg_msg("game/png", "invalid format. filename='%s'", completefilename); png_close_file(&png); return 0; } @@ -865,22 +868,24 @@ void gfx_swap() IOHANDLE io; char filename[128]; char header[18] = {0}; - sprintf(filename, "capture/frame%04d.tga", record); + str_format(filename, sizeof(filename), "capture/frame%04d.tga", record); record++; - io = io_open(filename, IOFLAG_WRITE); - - header[2] = 2; /* rgb */ - header[12] = w&255; /* width */ - header[13] = w>>8; - header[14] = h&255; /* height */ - header[15] = h>>8; - header[16] = 24; - - io_write(io, header, sizeof(header)); - io_write(io, pixel_data, w*h*3); - - io_close(io); + io = engine_openfile(filename, IOFLAG_WRITE); + if(io) + { + header[2] = 2; /* rgb */ + header[12] = w&255; /* width */ + header[13] = w>>8; + header[14] = h&255; /* height */ + header[15] = h>>8; + header[16] = 24; + + io_write(io, header, sizeof(header)); + io_write(io, pixel_data, w*h*3); + + io_close(io); + } } @@ -899,17 +904,14 @@ void gfx_swap() if(do_screenshot) { /* find filename */ - char wholepath[1024]; char filename[128]; static int index = 1; for(; index < 1000; index++) { IOHANDLE io; - sprintf(filename, "screenshots/screenshot%04d.png", index); - engine_savepath(filename, wholepath, sizeof(wholepath)); - - io = io_open(wholepath, IOFLAG_READ); + str_format(filename, sizeof(filename), "screenshots/screenshot%04d.png", index); + io = engine_openfile(filename, IOFLAG_READ); if(io) io_close(io); else |