Skip to content

Commit

Permalink
Merge git://github.com/raduprv/Eternal-Lands
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbroad committed Dec 9, 2018
2 parents b6d1d92 + 0196a88 commit d4d4e22
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 52 deletions.
30 changes: 28 additions & 2 deletions dialogues.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,36 @@ static int cm_npcname_handler(window_info *win, int widget_id, int mx, int my, i
copy_to_clipboard((const char *)npc_name);
else if (option == 1)
{
char str[80];
safe_snprintf(str, sizeof(str), npc_mark_str, npc_name);
char *str = NULL, *del_pos = NULL;
const char *delim = "%s";
size_t delim_len = strlen(delim);
size_t npc_name_len = 0, start_len = 0, end_len = 0, str_len = 0;

if (npc_mark_str == NULL || npc_name == NULL || !strlen(npc_mark_str) ||
!(npc_name_len = strlen((char *)npc_name)) ||
((del_pos = strstr(npc_mark_str, delim)) == NULL))
{
LOG_TO_CONSOLE(c_red1, invalidnpcmark_str);
return 0;
}

start_len = del_pos - npc_mark_str;
end_len = strlen(&npc_mark_str[start_len + delim_len]);
str_len = start_len + npc_name_len + end_len + 1;

if ((str = (char *)malloc(str_len)) == NULL)
return 0;

// previously used sprintf() but its unsafe to use a user specified target string
safe_strncpy2(str, npc_mark_str, str_len, start_len);
str[start_len] = 0;
safe_strcat(str, (char *)npc_name, str_len);
safe_strcat(str, &npc_mark_str[start_len + delim_len], str_len);

command_unmark_special(str, strlen(str), 0);
command_mark(str, strlen(str));

free(str);
}
else
return 0;
Expand Down
2 changes: 1 addition & 1 deletion elc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define VER_MAJOR 1
#define VER_MINOR 9
#define VER_RELEASE 5
#define VER_BUILD 2
#define VER_BUILD 3
#define COMPANY_NAME ""
#define FILE_VERSION "1.9.5"
#ifdef OTHER_LIFE
Expand Down
14 changes: 14 additions & 0 deletions gamewin.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "storage.h"
#include "tabs.h"
#include "textures.h"
#include "translate.h"
#include "trade.h"
#include "url.h"
#include "weather.h"
Expand Down Expand Up @@ -105,6 +106,15 @@ void check_to_auto_disable_ranging_lock(void)
toggle_ranging_lock();
}

static void toggle_target_close_clicked_creature(void)
{
toggle_OPT_BOOL_by_name("target_close_clicked_creature");
if (target_close_clicked_creature)
LOG_TO_CONSOLE(c_green1, close_click_targetting_on_str);
else
LOG_TO_CONSOLE(c_green1, close_click_targetting_off_str);
}

void draw_special_cursors(void)
{
const float RET_WID = 4.0f;
Expand Down Expand Up @@ -2028,6 +2038,10 @@ int keypress_root_common (Uint32 key, Uint32 unikey)
{
view_window(&range_win, -1);
}
else if(key == K_TARGET_CLOSE)
{
toggle_target_close_clicked_creature();
}
else if (key == K_SIT)
{
toggle_sit_stand ();
Expand Down
2 changes: 2 additions & 0 deletions keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Uint32 K_ECDEBUGWIN=ALT|CTRL|'c';
#endif
Uint32 K_EMOTES=CTRL|'j';
Uint32 K_RANGINGWIN=CTRL|'t';
Uint32 K_TARGET_CLOSE=ALT|'t';

// Remaining keys are not assigned to the keyboard but
// can be redefined or used by the #keypress command.
Expand Down Expand Up @@ -221,6 +222,7 @@ static key_store_entry key_store[] =
#endif
{ "#K_EMOTES", &K_EMOTES },
{ "#K_RANGINGWIN", &K_RANGINGWIN },
{ "#K_TARGET_CLOSE", &K_TARGET_CLOSE },
{ "#K_COUNTERS", &K_COUNTERS },
{ "#K_HELPSKILLS", &K_HELPSKILLS }
};
Expand Down
1 change: 1 addition & 0 deletions keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern Uint32 K_ECDEBUGWIN; /*!< open Eye Candy debug window */
#endif /* ECDEBUGWIN */
extern Uint32 K_EMOTES; /*!< key used to toggle display of \ref emotes_window */
extern Uint32 K_RANGINGWIN; /*!< key used to toggle display of ranging win */
extern Uint32 K_TARGET_CLOSE; /*!< toggle target_close_clicked_creature option */
extern Uint32 K_COUNTERS; /*!< key used to toggle display of counters window */
extern Uint32 K_HELPSKILLS; /*!< key used to toggle display of help window skills tab */
/*! @} */
Expand Down
4 changes: 2 additions & 2 deletions map_editor/2d_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int get_2d_bbox (int id, AABBOX* box)
int add_2d_obj(char * file_name, float x_pos, float y_pos, float z_pos, float x_rot, float y_rot, float z_rot)
{
size_t i;
char fname[128];
char fname[80];
obj_2d_def *returned_obj_2d_def;
obj_2d *our_object;
short sector;
Expand All @@ -440,7 +440,7 @@ int add_2d_obj(char * file_name, float x_pos, float y_pos, float z_pos, float x_
returned_obj_2d_def=load_obj_2d_def_cache(fname);
if(!returned_obj_2d_def)
{
char str[120];
char str[200];
sprintf(str,"Error: Can't load 2d object: %s\n",fname);
log_error(__FILE__, __LINE__, str);
return 0;
Expand Down
6 changes: 3 additions & 3 deletions map_editor/3d_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ e3d_object * load_e3d_cache(char * file_name)

int add_e3d_at_id (int id, char * file_name, float x_pos, float y_pos, float z_pos, float x_rot, float y_rot, float z_rot, char self_lit, char blended, float r, float g, float b)
{
char fname[128];
char fname[80];
e3d_object *returned_e3d;
object3d *our_object;

Expand All @@ -227,7 +227,7 @@ int add_e3d_at_id (int id, char * file_name, float x_pos, float y_pos, float z_p
returned_e3d=load_e3d_cache(fname);
if(returned_e3d==NULL)
{
char str[120];
char str[200];
sprintf (str, "Error: Something nasty happened while trying to process: %s\n", fname);
LOG_ERROR(str);

Expand All @@ -241,7 +241,7 @@ int add_e3d_at_id (int id, char * file_name, float x_pos, float y_pos, float z_p
our_object = calloc (1, sizeof(object3d));

// and fill it in
snprintf (our_object->file_name, 80, "%s", fname);
snprintf (our_object->file_name, sizeof(our_object->file_name), "%s", fname);
our_object->x_pos = x_pos;
our_object->y_pos = y_pos;
our_object->z_pos = z_pos;
Expand Down
123 changes: 92 additions & 31 deletions map_editor/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,38 @@ FEATURES += NEW_LIGHT_FORMAT
FEATURES += ZLIB
FEATURES += ZLIBW

WARN = -Wall -Wdeclaration-after-statement # -W -Werror
CXXWARN = -Wall # -W -Werror
OPTIONS = -DLINUX -DMAP_EDITOR $(foreach FEATURE, $(FEATURES), -D$(FEATURE)) -D_7ZIP_ST
OPTIONS += -DGL_GLEXT_PROTOTYPES # needed in my SDL_opengl.h for some function declarations

GTK_CFLAGS = $(shell gtk-config --cflags) #If you wish to use the old gtk, compile with "make gtk"
GTK2_CFLAGS = $(shell pkg-config gtk+-2.0 --cflags) -DGTK2

CFLAGS=$(OPTIONS) $(GTK2_CFLAGS) $(shell sdl-config --cflags) $(shell xml2-config --cflags) -g $(WARN)
_CFLAGS=$(OPTIONS) -mcpu=i686 -O3 -fomit-frame-pointer -ffast-math -pipe $(GTK_CFLAGS) $(shell sdl-config --cflags) $(shell sdl-config --cflags) $(shell xml2-config --cflags)
CXXFLAGS=$(OPTIONS) $(GTK2_CFLAGS) $(shell sdl-config --cflags) $(shell xml2-config --cflags) -g $(CXXWARN)
_CXXFLAGS=$(OPTIONS) -mcpu=i686 -O3 -fomit-frame-pointer -ffast-math -pipe $(GTK_CFLAGS) $(shell sdl-config --cflags) $(shell sdl-config --cflags) $(shell xml2-config --cflags)

GTK_LIBS = $(shell gtk-config --libs)
GTK2_LIBS = $(shell pkg-config gtk+-2.0 --libs)

LIBS=$(shell sdl-config --libs) -lGL -lGLU $(shell xml2-config --libs) -lcal3d -lSDL_image -lz
PLATFORM=-march=native
CWARN=-Wall -Wdeclaration-after-statement
CXXWARN=-Wall
EXTRA_INCLUDES=

OPTIONS = -DLINUX -DMAP_EDITOR $(foreach FEATURE, $(FEATURES), -D$(FEATURE)) -D_7ZIP_ST \
$(shell pkg-config gtk+-2.0 --cflags) -DGTK2 \
$(shell pkg-config sdl --cflags) \
$(shell pkg-config SDL_image --cflags) \
$(shell pkg-config libxml-2.0 --cflags) \
$(shell pkg-config cal3d --cflags) \
$(shell pkg-config gl --cflags) \
$(shell pkg-config glu --cflags) \
$(shell pkg-config zlib --cflags)

CFLAGS=$(PLATFORM) $(CWARN) -O0 -ggdb -pipe $(OPTIONS) -fno-strict-aliasing $(EXTRA_INCLUDES)

CXXFLAGS=$(PLATFORM) $(CXXWARN) -O0 -ggdb -pipe $(OPTIONS) -fno-strict-aliasing $(EXTRA_INCLUDES)

LDFLAGS=$(shell pkg-config sdl --libs) \
$(shell pkg-config gtk+-2.0 --libs) \
$(shell pkg-config libxml-2.0 --libs) \
$(shell pkg-config SDL_image --libs) \
$(shell pkg-config cal3d --libs) \
$(shell pkg-config gl --libs) \
$(shell pkg-config glu --libs) \
$(shell pkg-config zlib --libs) \
$(shell pkg-config x11 --libs) -lm -lstdc++

_CFLAGS=$(PLATFORM) -O2 -fomit-frame-pointer -ffast-math -pipe $(OPTIONS) -fno-strict-aliasing $(EXTRA_INCLUDES)
_LDFLAGS=$(XDIR) -lGL -lpthread -lstdc++
_CXXFLAGS=$(PLATFORM) -O3 -fomit-frame-pointer -ffast-math -pipe $(OPTIONS) -fno-strict-aliasing $(EXTRA_INCLUDES)

COBJS=2d_objects.o 3d_objects.o \
browser.o draw_scene.o \
Expand Down Expand Up @@ -77,6 +92,17 @@ ELC_XZ_CCOBJS = 7zCrc.o 7zCrcOpt.o Alloc.o Bra86.o Bra.o BraIA64.o \
OBJS = $(COBJS) $(CXXOBJS) $(ELC_COBJS) $(ELC_CXXOBJS) $(ELC_IO_COBJS) $(ELC_IO_CXXOBJS) \
$(ELC_EC_CXXOBJS) $(ELC_EXCEPTION_CXXOBJS) $(ELC_ENGINE_CXXOBJS) $(ELC_XZ_CCOBJS)

DEP_FILES=$(foreach OBJ, $(COBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_COBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_IO_COBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_IO_CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_EXCEPTION_CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_EC_CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_ENGINE_CXXOBJS), .deps/$(OBJ).P) \
$(foreach OBJ, $(ELC_XZ_CCOBJS), .deps/$(OBJ).P)

EXE=mapedit.x86.linux.bin

GENDEP=Makefile.linux
Expand All @@ -85,57 +111,90 @@ all: $(EXE)

$(EXE): $(OBJS)
@echo " LINK $(EXE)"
@$(LINK) $(CFLAGS) -o $@ $^ $(LIBS) $(GTK2_LIBS)
@$(LINK) $(CFLAGS) -o $(EXE) $(OBJS) $(LDFLAGS)

release:
make -f Makefile.linux 'CFLAGS=$(_CFLAGS)'
@$(MAKE) -f Makefile.linux 'CFLAGS=$(_CFLAGS)' 'CXXFLAGS=$(_CXXFLAGS)'

gtk:
make -f Makefile.linux 'GTK2_CFLAGS=$(GTK_CFLAGS)' 'GTK2_LIBS=$(GTK_LIBS)'
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

$(COBJS): %.o: %.c $(GENDEP)
@echo " CC $@"
@$(CC) $(CFLAGS) -c -o $@ $<
@if $(CC) $(CFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(CXXOBJS): %.o : %.cpp $(GENDEP)
@echo " CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_COBJS): %.o : ../%.c $(GENDEP)
@echo " ELC CC $@"
@$(CC) $(CFLAGS) -c -o $@ $<
@if $(CC) $(CFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_IO_COBJS): %.o : ../io/%.c $(GENDEP)
@echo " ELC IO CC $@"
@$(CC) $(CFLAGS) -c -o $@ $<
@if $(CC) $(CFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_IO_CXXOBJS): %.o : ../io/%.cpp $(GENDEP)
@echo " ELC IO CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_EXCEPTION_CXXOBJS): %.o : ../exceptions/%.cpp $(GENDEP)
@echo " ELC EXC CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_CXXOBJS): %.o : ../%.cpp $(GENDEP)
@echo " ELC CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_EC_CXXOBJS): %.o : ../eye_candy/%.cpp $(GENDEP)
@echo " ELC EC CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_ENGINE_CXXOBJS): %.o : ../engine/%.cpp $(GENDEP)
@echo " ELC ENG CXX $@"
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@if $(CXX) $(CXXFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

$(ELC_XZ_CCOBJS): %.o : ../xz/%.c $(GENDEP)
@echo " ELC XZ CC $@"
@$(CC) $(CFLAGS) -c -o $@ $<
@if $(CC) $(CFLAGS) -MT '$@' -MD -MP -MF '.deps/[email protected]' -c $< -o $@; then \
mv ".deps/[email protected]" ".deps/[email protected]"; \
else rm -f ".deps/[email protected]"; exit 1; \
fi

clean:
-rm -f $(OBJS) $(EXE)

.depend: $(foreach HEADER_DIR, $(HEADER_DIRS), $(wildcard $(HEADER_DIR)/*.h))
$(CC) $(CFLAGS) -MM $(patsubst %.o, %.c, $(COBJS)) >.depend
$(CXX) $(CXXFLAGS) -MM $(patsubst %.o, %.cpp, $(CXXOBJS)) >>.depend

# Based on the main client static build, this works on Ubuntu 8.04 (LTS) at least
# Its only a little bit static but it may work
# Install these packages in addition to those required for a standard build
Expand All @@ -154,3 +213,5 @@ STATICLIBS=$(LIBD)/libSDL_net.a $(LIBD)/libSDL.a $(LIBD)/libSDL_image.a \

static: $(OBJS)
@$(MAKE) -f Makefile.linux 'LIBS=$(STATICLIBS)'

-include $(DEP_FILES)
8 changes: 6 additions & 2 deletions map_editor/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int dc=-1,cd=-1,cp=0,cc=-1,mc=1,ccat=0;
int setobject(int n, char *fn,float xrot, float yrot, float zrot)
{
object3d *our_object=&o3d[n];
snprintf(our_object->file_name,80,"%s",fn);
snprintf(our_object->file_name,sizeof(our_object->file_name),"%s",fn);

our_object->e3d_data = NULL;
our_object->e3d_data=load_e3d_cache(fn);
Expand Down Expand Up @@ -362,7 +362,11 @@ void init_browser()
}
line = 1;
while(!feof(fp)){
fgets(temp,511,fp);
if (fgets(temp,511,fp) == NULL)
{
log_error(__FILE__, __LINE__, "browser.lst red error");
return;
}
if(!strncmp(temp,"Category",8)){
cc++;
strcpy(Cat[cc].Name,&temp[9]);
Expand Down
14 changes: 14 additions & 0 deletions map_editor/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ void hide_open_win(GtkWidget * widget, GtkWidget * win)
gtk_widget_hide(win);
}

static void check_escape(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
if (gtk_open_win && event->keyval == GDK_KEY_Escape)
gtk_widget_hide(gtk_open_win);
}

static void kill_window(GtkWidget *widget, GdkEvent *event, gpointer data)
{
if (gtk_open_win)
gtk_widget_hide(gtk_open_win);
}

void show_open_window(char * name, char * folder, GtkFileFilter * filter)
{
if(!gtk_open_win) {
Expand All @@ -139,6 +151,8 @@ void show_open_window(char * name, char * folder, GtkFileFilter * filter)

g_signal_connect ((gpointer) cancel, "clicked", G_CALLBACK (hide_open_win), gtk_open_win);
g_signal_connect ((gpointer) ok_button, "clicked", G_CALLBACK (open_button_clicked), NULL);
g_signal_connect(gtk_open_win, "key_press_event", G_CALLBACK(check_escape), NULL);
g_signal_connect(gtk_open_win, "delete_event", G_CALLBACK(kill_window), NULL);

gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtk_open_win), e3d_filter);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtk_open_win), e2d_filter);
Expand Down
Loading

0 comments on commit d4d4e22

Please sign in to comment.