data-dir autodetection; data-dir override; compiled-in data-dir; messagebox if detection fails; does chdir into data-dir

This commit is contained in:
Dominik Geyer 2008-10-01 17:16:22 +00:00
parent fb3e8dec79
commit 397b9a764b
14 changed files with 248 additions and 94 deletions

View file

@ -172,69 +172,69 @@ def FileList(format, num):
return [format%(x+1) for x in xrange(0,num)]
container = DataContainer()
container.sounds.Add(SoundSet("gun_fire", FileList("data/audio/wp_gun_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("shotgun_fire", FileList("data/audio/wp_shotty_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("gun_fire", FileList("audio/wp_gun_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("shotgun_fire", FileList("audio/wp_shotty_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_fire", FileList("data/audio/wp_flump_launch-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_fire", FileList("data/audio/wp_hammer_swing-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_hit", FileList("data/audio/wp_hammer_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_fire", FileList("data/audio/wp_ninja_attack-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_explode", FileList("data/audio/wp_flump_explo-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_hit", FileList("data/audio/wp_ninja_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("rifle_fire", FileList("data/audio/wp_rifle_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("rifle_bounce", FileList("data/audio/wp_rifle_bnce-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_switch", FileList("data/audio/wp_switch-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_fire", FileList("audio/wp_flump_launch-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_fire", FileList("audio/wp_hammer_swing-%02d.wv", 3)))
container.sounds.Add(SoundSet("hammer_hit", FileList("audio/wp_hammer_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_fire", FileList("audio/wp_ninja_attack-%02d.wv", 3)))
container.sounds.Add(SoundSet("grenade_explode", FileList("audio/wp_flump_explo-%02d.wv", 3)))
container.sounds.Add(SoundSet("ninja_hit", FileList("audio/wp_ninja_hit-%02d.wv", 3)))
container.sounds.Add(SoundSet("rifle_fire", FileList("audio/wp_rifle_fire-%02d.wv", 3)))
container.sounds.Add(SoundSet("rifle_bounce", FileList("audio/wp_rifle_bnce-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_switch", FileList("audio/wp_switch-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_pain_short", FileList("data/audio/vo_teefault_pain_short-%02d.wv", 12)))
container.sounds.Add(SoundSet("player_pain_long", FileList("data/audio/vo_teefault_pain_long-%02d.wv", 2)))
container.sounds.Add(SoundSet("player_pain_short", FileList("audio/vo_teefault_pain_short-%02d.wv", 12)))
container.sounds.Add(SoundSet("player_pain_long", FileList("audio/vo_teefault_pain_long-%02d.wv", 2)))
container.sounds.Add(SoundSet("body_land", FileList("data/audio/foley_land-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_airjump", FileList("data/audio/foley_dbljump-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_jump", FileList("data/audio/foley_foot_left-%02d.wv", 4) + FileList("data/audio/foley_foot_right-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_die", FileList("data/audio/foley_body_splat-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_spawn", FileList("data/audio/vo_teefault_spawn-%02d.wv", 7)))
container.sounds.Add(SoundSet("player_skid", FileList("data/audio/sfx_skid-%02d.wv", 4)))
container.sounds.Add(SoundSet("tee_cry", FileList("data/audio/vo_teefault_cry-%02d.wv", 2)))
container.sounds.Add(SoundSet("body_land", FileList("audio/foley_land-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_airjump", FileList("audio/foley_dbljump-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_jump", FileList("audio/foley_foot_left-%02d.wv", 4) + FileList("audio/foley_foot_right-%02d.wv", 4)))
container.sounds.Add(SoundSet("player_die", FileList("audio/foley_body_splat-%02d.wv", 3)))
container.sounds.Add(SoundSet("player_spawn", FileList("audio/vo_teefault_spawn-%02d.wv", 7)))
container.sounds.Add(SoundSet("player_skid", FileList("audio/sfx_skid-%02d.wv", 4)))
container.sounds.Add(SoundSet("tee_cry", FileList("audio/vo_teefault_cry-%02d.wv", 2)))
container.sounds.Add(SoundSet("hook_loop", FileList("data/audio/hook_loop-%02d.wv", 2)))
container.sounds.Add(SoundSet("hook_loop", FileList("audio/hook_loop-%02d.wv", 2)))
container.sounds.Add(SoundSet("hook_attach_ground", FileList("data/audio/hook_attach-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_attach_player", FileList("data/audio/foley_body_impact-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_noattach", FileList("data/audio/hook_noattach-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_health", FileList("data/audio/sfx_pickup_hrt-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_armor", FileList("data/audio/sfx_pickup_arm-%02d.wv", 4)))
container.sounds.Add(SoundSet("hook_attach_ground", FileList("audio/hook_attach-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_attach_player", FileList("audio/foley_body_impact-%02d.wv", 3)))
container.sounds.Add(SoundSet("hook_noattach", FileList("audio/hook_noattach-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_health", FileList("audio/sfx_pickup_hrt-%02d.wv", 2)))
container.sounds.Add(SoundSet("pickup_armor", FileList("audio/sfx_pickup_arm-%02d.wv", 4)))
container.sounds.Add(SoundSet("pickup_grenade", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("pickup_shotgun", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("pickup_ninja", FileList("data/audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("weapon_spawn", FileList("data/audio/sfx_spawn_wpn-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_noammo", FileList("data/audio/wp_noammo-%02d.wv", 5)))
container.sounds.Add(SoundSet("pickup_grenade", FileList("audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("pickup_shotgun", FileList("audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("pickup_ninja", FileList("audio/sfx_pickup_arm-%02d.wv", 1)))
container.sounds.Add(SoundSet("weapon_spawn", FileList("audio/sfx_spawn_wpn-%02d.wv", 3)))
container.sounds.Add(SoundSet("weapon_noammo", FileList("audio/wp_noammo-%02d.wv", 5)))
container.sounds.Add(SoundSet("hit", FileList("data/audio/sfx_hit_weak-%02d.wv", 2)))
container.sounds.Add(SoundSet("hit", FileList("audio/sfx_hit_weak-%02d.wv", 2)))
container.sounds.Add(SoundSet("chat_server", ["data/audio/sfx_msg-server.wv"]))
container.sounds.Add(SoundSet("chat_client", ["data/audio/sfx_msg-client.wv"]))
container.sounds.Add(SoundSet("ctf_drop", ["data/audio/sfx_ctf_drop.wv"]))
container.sounds.Add(SoundSet("ctf_return", ["data/audio/sfx_ctf_rtn.wv"]))
container.sounds.Add(SoundSet("ctf_grab_pl", ["data/audio/sfx_ctf_grab_pl.wv"]))
container.sounds.Add(SoundSet("ctf_grab_en", ["data/audio/sfx_ctf_grab_en.wv"]))
container.sounds.Add(SoundSet("ctf_capture", ["data/audio/sfx_ctf_cap_pl.wv"]))
container.sounds.Add(SoundSet("chat_server", ["audio/sfx_msg-server.wv"]))
container.sounds.Add(SoundSet("chat_client", ["audio/sfx_msg-client.wv"]))
container.sounds.Add(SoundSet("ctf_drop", ["audio/sfx_ctf_drop.wv"]))
container.sounds.Add(SoundSet("ctf_return", ["audio/sfx_ctf_rtn.wv"]))
container.sounds.Add(SoundSet("ctf_grab_pl", ["audio/sfx_ctf_grab_pl.wv"]))
container.sounds.Add(SoundSet("ctf_grab_en", ["audio/sfx_ctf_grab_en.wv"]))
container.sounds.Add(SoundSet("ctf_capture", ["audio/sfx_ctf_cap_pl.wv"]))
image_null = Image("null", "")
image_particles = Image("particles", "data/particles.png")
image_game = Image("game", "data/game.png")
image_browseicons = Image("browseicons", "data/browse_icons.png")
image_emoticons = Image("emoticons", "data/emoticons.png")
image_particles = Image("particles", "particles.png")
image_game = Image("game", "game.png")
image_browseicons = Image("browseicons", "browse_icons.png")
image_emoticons = Image("emoticons", "emoticons.png")
container.images.Add(image_null)
container.images.Add(image_game)
container.images.Add(image_particles)
container.images.Add(Image("cursor", "data/gui_cursor.png"))
container.images.Add(Image("banner", "data/gui_logo.png"))
container.images.Add(Image("cursor", "gui_cursor.png"))
container.images.Add(Image("banner", "gui_logo.png"))
container.images.Add(image_emoticons)
container.images.Add(image_browseicons)
container.images.Add(Image("console_bg", "data/console.png"))
container.images.Add(Image("console_bar", "data/console_bar.png"))
container.images.Add(Image("console_bg", "console.png"))
container.images.Add(Image("console_bar", "console_bar.png"))
container.pickups.Add(Pickup("health"))
container.pickups.Add(Pickup("armor"))

View file

@ -909,6 +909,43 @@ int fs_makedir(const char *path)
#endif
}
int fs_is_dir(const char *path)
{
#if defined(CONF_FAMILY_WINDOWS)
/* TODO: do this smarter */
WIN32_FIND_DATA finddata;
HANDLE handle;
char buffer[1024*2];
str_format(buffer, sizeof(buffer), "%s/*", path);
if ((handle = FindFirstFileA(buffer, &finddata)) == INVALID_HANDLE_VALUE)
return 0;
FindClose(handle);
return 1;
#else
struct stat sb;
if (stat(path, &sb) == -1)
return 0;
if (S_ISDIR(sb.st_mode))
return 1;
else
return 0;
#endif
}
int fs_chdir(const char *path)
{
if (fs_is_dir(path))
{
chdir(path);
return 0;
}
else
return 1;
}
void swap_endian(void *data, unsigned elem_size, unsigned num)
{
char *src = (char*) data;

View file

@ -824,6 +824,23 @@ int fs_makedir(const char *path);
*/
int fs_storage_path(const char *appname, char *path, int max);
/*
Function: fs_is_dir
Checks if directory exists
Returns:
Returns 1 on success, 0 on failure.
*/
int fs_is_dir(const char *path);
/*
Function: fs_chdir
Changes current working directory
Returns:
Returns 0 on success, 1 on failure.
*/
int fs_chdir(const char *path);
/*
Group: Undocumented

View file

@ -550,7 +550,7 @@ void client_disconnect()
static int client_load_data()
{
debug_font = gfx_load_texture("data/debug_font.png", IMG_AUTO, TEXLOAD_NORESAMPLE);
debug_font = gfx_load_texture("debug_font.png", IMG_AUTO, TEXLOAD_NORESAMPLE);
return 1;
}
@ -698,7 +698,7 @@ static const char *client_load_map_search(const char *mapname, int wanted_crc)
client_set_state(CLIENTSTATE_LOADING);
/* try the normal maps folder */
str_format(buf, sizeof(buf), "data/maps/%s.map", mapname);
str_format(buf, sizeof(buf), "maps/%s.map", mapname);
error = client_load_map(buf, wanted_crc);
if(!error)
return error;
@ -1601,18 +1601,6 @@ void client_save_line(const char *line)
int main(int argc, char **argv)
{
#if defined(CONF_PLATFORM_MACOSX)
char buffer[512];
unsigned pos = strrchr(argv[0], '/') - argv[0];
if(pos >= 512)
return -1;
strncpy(buffer, argv[0], 511);
buffer[pos] = 0;
chdir(buffer);
#endif
/* init the engine */
dbg_msg("client", "starting...");
engine_init("Teeworlds");
@ -1624,6 +1612,14 @@ 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;
}
/* run the client*/
client_run();

View file

@ -13,6 +13,9 @@
#include <engine/e_network.h>
#include "e_linereader.h"
/* compiled-in data-dir path */
#define DATA_DIR "data"
static JOBPOOL hostlookuppool;
static void con_dbg_dumpmem(void *result, void *user_data)
@ -22,6 +25,7 @@ static void con_dbg_dumpmem(void *result, void *user_data)
static char application_save_path[512] = {0};
char *datadir_override;
const char *engine_savepath(const char *filename, char *buffer, int max)
{
@ -89,6 +93,11 @@ void engine_parse_arguments(int argc, char **argv)
abs = 1;
i++;
}
else if(argv[i][0] == '-' && argv[i][1] == 'd' && argv[i][2] == 0 && argc - i > 1)
{
datadir_override = argv[i+1];
i++;
}
}
if(abs)
@ -405,3 +414,100 @@ void engine_hostlookup(HOSTLOOKUP *lookup, const char *hostname)
jobs_add(&hostlookuppool, &lookup->job, hostlookup_thread, lookup);
}
int engine_chdir_datadir(char *argv0)
{
#if defined(CONF_FAMILY_UNIX)
static const char *sdirs[] = {
"/usr/share/teeworlds",
"/usr/local/share/teeworlds"
};
static const int sdirs_count = sizeof(sdirs) / sizeof(sdirs[0]);
#endif
int found = 0;
char data_dir[1024*2];
/* 1) use provided data-dir override */
if (datadir_override)
{
if (fs_is_dir(datadir_override))
{
str_copy(data_dir, datadir_override, sizeof(data_dir));
dbg_msg("engine/datadir", "using override '%s'", data_dir);
found = 1;
}
else
{
dbg_msg("engine/datadir",
"specified data-dir '%s' does not exist",
datadir_override);
return 0;
}
}
#if defined(CONF_FAMILY_UNIX)
/* 2) use data-dir in PWD if present */
if (!found && fs_is_dir("data"))
{
strcpy(data_dir, "data");
found = 1;
}
/* 3) use compiled-in data-dir if present */
if (!found && fs_is_dir(DATA_DIR))
{
strcpy(data_dir, DATA_DIR);
found = 1;
}
/* 4) check for usable path in argv[0] */
if (!found)
{
unsigned int pos = strrchr(argv0, '/') - argv0;
if (pos < sizeof(data_dir))
{
char basedir[sizeof(data_dir)];
strncpy(basedir, argv0, pos);
basedir[pos] = '\0';
str_format(data_dir, sizeof(data_dir),
"%s/data", basedir);
if (fs_is_dir(data_dir))
found = 1;
}
}
/* 5) check for all default locations */
if (!found)
{
int i;
for (i = 0; i < sdirs_count; i++)
{
if (fs_is_dir(sdirs[i]))
{
strcpy(data_dir, sdirs[i]);
found = 1;
break;
}
}
}
#elif defined(CONF_FAMILY_WINDOWS)
/* FIXME: any alternative directories to search? %PROGRAM_FILES%/.../ */
if (!found && fs_is_dir("data"))
{
strcpy(data_dir, "data");
found = 1;
}
#endif
if (found)
{
dbg_msg("engine/datadir", "using '%s'", data_dir);
/* change working directory to data-dir */
fs_chdir(data_dir);
}
return found;
}

View file

@ -10,6 +10,8 @@ int engine_config_write_start();
void engine_config_write_line(const char *line);
void engine_config_write_stop();
int engine_chdir_datadir(char *argv0);
int engine_stress(float probability);
typedef struct HOSTLOOKUP

View file

@ -53,7 +53,7 @@ int map_is_loaded()
int map_load(const char *mapname)
{
char buf[512];
str_format(buf, sizeof(buf), "data/maps/%s.map", mapname);
str_format(buf, sizeof(buf), "maps/%s.map", mapname);
map = datafile_load(buf);
return map != 0;
}

View file

@ -882,7 +882,7 @@ static int server_load_map(const char *mapname)
{
DATAFILE *df;
char buf[512];
str_format(buf, sizeof(buf), "data/maps/%s.map", mapname);
str_format(buf, sizeof(buf), "maps/%s.map", mapname);
df = datafile_load(buf);
if(!df)
return 0;
@ -1145,17 +1145,6 @@ static void server_register_commands()
int main(int argc, char **argv)
{
#if defined(CONF_PLATFORM_MACOSX)
char buffer[512];
unsigned pos = strrchr(argv[0], '/') - argv[0];
if(pos >= 512)
return -1;
strncpy(buffer, argv[0], 511);
buffer[pos] = 0;
chdir(buffer);
#endif
#if defined(CONF_FAMILY_WINDOWS)
int i;
for(i = 1; i < argc; i++)
@ -1181,6 +1170,13 @@ 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("server", "fatal error: data-dir cannot be found");
return -1;
}
/* run the server */
server_run();
return 0;

View file

@ -31,7 +31,7 @@ void MAPIMAGES::on_reset()
{
char buf[256];
char *name = (char *)map_get_data(img->image_name);
str_format(buf, sizeof(buf), "data/mapres/%s.png", name);
str_format(buf, sizeof(buf), "mapres/%s.png", name);
textures[i] = gfx_load_texture(buf, IMG_AUTO, 0);
}
else

View file

@ -1030,7 +1030,7 @@ void MENUS::render_background()
//gfx_clear(1,1,1);
//render_sunrays(0,0);
if(texture_blob == -1)
texture_blob = gfx_load_texture("data/blob.png", IMG_AUTO, 0);
texture_blob = gfx_load_texture("blob.png", IMG_AUTO, 0);
float sw = 300*gfx_screenaspect();

View file

@ -24,7 +24,7 @@ void SKINS::skinscan(const char *name, int is_dir, void *user)
return;
char buf[512];
str_format(buf, sizeof(buf), "data/skins/%s", name);
str_format(buf, sizeof(buf), "skins/%s", name);
IMAGE_INFO info;
if(!gfx_load_png(&info, buf))
{
@ -119,7 +119,7 @@ void SKINS::init()
{
// load skins
num_skins = 0;
fs_listdir("data/skins", skinscan, this);
fs_listdir("skins", skinscan, this);
}
int SKINS::num()

View file

@ -179,7 +179,7 @@ void GAMECLIENT::on_init()
int64 start = time_get();
int before = gfx_memory_usage();
font_set_load(&default_font, "data/fonts/default_font%d.tfnt", "data/fonts/default_font%d.png", "data/fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
font_set_load(&default_font, "fonts/default_font%d.tfnt", "fonts/default_font%d.png", "fonts/default_font%d_b.png", 14, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 36);
dbg_msg("font", "gfx memory used for font textures: %d", gfx_memory_usage()-before);
gfx_text_set_default_font(&default_font);

View file

@ -541,11 +541,11 @@ static void do_toolbar(RECT toolbar)
// ctrl+o to open
if(inp_key_down('O') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL)))
editor.invoke_file_dialog("Open Map", "Open", "data/maps/", "", callback_open_map);
editor.invoke_file_dialog("Open Map", "Open", "maps/", "", callback_open_map);
// ctrl+s to save
if(inp_key_down('S') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL)))
editor.invoke_file_dialog("Save Map", "Save", "data/maps/", "", callback_save_map);
editor.invoke_file_dialog("Save Map", "Save", "maps/", "", callback_save_map);
// animate button
ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar);
@ -1670,7 +1670,7 @@ static int popup_image(RECT view)
ui_hsplit_t(&view, 12.0f, &slot, &view);
if(do_editor_button(&replace_button, "Replace", 0, &slot, draw_editor_button_menuitem, 0, "Replaces the image with a new one"))
{
editor.invoke_file_dialog("Replace Image", "Replace", "data/mapres/", "", replace_image);
editor.invoke_file_dialog("Replace Image", "Replace", "mapres/", "", replace_image);
return 1;
}
@ -1751,7 +1751,7 @@ static void render_images(RECT toolbox, RECT toolbar, RECT view)
ui_hsplit_t(&toolbox, 10.0f, &slot, &toolbox);
ui_hsplit_t(&toolbox, 12.0f, &slot, &toolbox);
if(do_editor_button(&new_image_button, "Add", 0, &slot, draw_editor_button, 0, "Load a new image to use in the map"))
editor.invoke_file_dialog("Add Image", "Add", "data/mapres/", "", add_image);
editor.invoke_file_dialog("Add Image", "Add", "mapres/", "", add_image);
}
@ -2288,7 +2288,7 @@ static int popup_menu_file(RECT view)
ui_hsplit_t(&view, 12.0f, &slot, &view);
if(do_editor_button(&open_button, "Open", 0, &slot, draw_editor_button_menuitem, 0, "Opens a map for editing"))
{
editor.invoke_file_dialog("Open Map", "Open", "data/maps/", "", callback_open_map);
editor.invoke_file_dialog("Open Map", "Open", "maps/", "", callback_open_map);
return 1;
}
@ -2296,7 +2296,7 @@ static int popup_menu_file(RECT view)
ui_hsplit_t(&view, 12.0f, &slot, &view);
if(do_editor_button(&append_button, "Append", 0, &slot, draw_editor_button_menuitem, 0, "Opens a map and adds everything from that map to the current one"))
{
editor.invoke_file_dialog("Append Map", "Append", "data/maps/", "", callback_append_map);
editor.invoke_file_dialog("Append Map", "Append", "maps/", "", callback_append_map);
return 1;
}
@ -2311,7 +2311,7 @@ static int popup_menu_file(RECT view)
ui_hsplit_t(&view, 12.0f, &slot, &view);
if(do_editor_button(&save_as_button, "Save As", 0, &slot, draw_editor_button_menuitem, 0, "Saves the current map under a new name"))
{
editor.invoke_file_dialog("Save Map", "Save", "data/maps/", "", callback_save_map);
editor.invoke_file_dialog("Save Map", "Save", "maps/", "", callback_save_map);
return 1;
}
@ -2523,10 +2523,10 @@ void MAP::create_default(int entities_texture)
extern "C" void editor_init()
{
checker_texture = gfx_load_texture("data/editor/checker.png", IMG_AUTO, 0);
background_texture = gfx_load_texture("data/editor/background.png", IMG_AUTO, 0);
cursor_texture = gfx_load_texture("data/editor/cursor.png", IMG_AUTO, 0);
entities_texture = gfx_load_texture("data/editor/entities.png", IMG_AUTO, 0);
checker_texture = gfx_load_texture("editor/checker.png", IMG_AUTO, 0);
background_texture = gfx_load_texture("editor/background.png", IMG_AUTO, 0);
cursor_texture = gfx_load_texture("editor/cursor.png", IMG_AUTO, 0);
entities_texture = gfx_load_texture("editor/entities.png", IMG_AUTO, 0);
tileset_picker.make_palette();
tileset_picker.readonly = true;
@ -2599,13 +2599,13 @@ extern "C" void editor_update_and_render()
editor.gui_active = !editor.gui_active;
if(inp_key_down(KEY_F5))
editor.save("data/maps/debug_test2.map");
editor.save("maps/debug_test2.map");
if(inp_key_down(KEY_F6))
editor.load("data/maps/debug_test2.map");
editor.load("maps/debug_test2.map");
if(inp_key_down(KEY_F8))
editor.load("data/maps/debug_test.map");
editor.load("maps/debug_test.map");
if(inp_key_down(KEY_F10))
editor.show_mouse_pointer = false;

View file

@ -398,7 +398,7 @@ int MAP::load(const char *filename)
if(item->external)
{
char buf[256];
sprintf(buf, "data/mapres/%s.png", name);
sprintf(buf, "mapres/%s.png", name);
// load external
EDITOR_IMAGE imginfo;