Permalink
Browse files

Merge http://github.com/etam/gish into etam

  • Loading branch information...
2 parents 1967418 + 2903a05 commit b595e01679e06abe34b2240162824799438a6b74 @blinry committed Jun 15, 2010
Showing with 469 additions and 175 deletions.
  1. +4 −0 CMakeLists.txt
  2. +3 −2 Makefile.linux
  3. +1 −1 config.h
  4. +36 −3 game/config.c
  5. +1 −0 game/config.h
  6. +3 −1 game/debug.c
  7. +2 −0 game/debug.h
  8. +1 −0 game/editor.c
  9. +67 −0 game/gametexture.c
  10. +6 −2 game/high.c
  11. +171 −10 game/level.c
  12. +6 −2 game/player.c
  13. +1 −4 game/vsmode.c
  14. +11 −0 main.c
  15. +9 −1 music/License.txt
  16. BIN music/hell.ogg
  17. +142 −145 video/texture.c
  18. +5 −4 video/texture.h
View
@@ -9,12 +9,15 @@ find_package(SDL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Vorbis REQUIRED)
+find_package(PNG REQUIRED)
+
include_directories(
${SDL_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${Vorbis_INCLUDE_DIR}
+ ${PNG_INCLUDE_DIR}
)
set(GISH_SRCS
@@ -148,4 +151,5 @@ target_link_libraries(gish
${OPENAL_LIBRARY}
${OPENGL_LIBRARIES}
${Vorbis_LIBRARIES}
+ ${PNG_LIBRARIES}
)
View
@@ -1,7 +1,8 @@
CC = gcc
-CFLAGS = -O2 $(shell pkg-config openal gl vorbisfile --cflags) $(shell sdl-config --cflags)
+CFLAGS = -O2 $(shell pkg-config sdl openal gl vorbisfile libpng --cflags)
+#CFLAGS += -DDATAPATH=/usr/share/gish
LD = gcc
-LDFLAGS = $(shell pkg-config openal gl vorbisfile --libs) $(shell sdl-config --libs)
+LDFLAGS = $(shell pkg-config sdl openal gl vorbisfile libpng --libs)
OBJS = audio/audio.o \
game/ai.o \
game/animation.o \
View
@@ -23,6 +23,6 @@
#define INLINE inline
#endif
-typedef enum {FALSE = 0, TRUE = 1} BOOLEAN;
+typedef enum {FALSE = 0, TRUE = 1} bool;
#endif /* GISH_CONFIG_H */
View
@@ -25,6 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../sdl/sdl.h"
#include <stdio.h>
+#include <limits.h>
+
+#ifdef LINUX
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
#include "../game/config.h"
#include "../game/options.h"
@@ -38,10 +45,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
_config config;
+char* userpath(char *result, char *path)
+ {
+#ifdef LINUX
+ char *home=getenv("HOME");
+
+ if (!home)
+ return path;
+
+ if (snprintf(result,PATH_MAX,"%s/.gish",home) < 0)
+ return path;
+
+ /* Ignore failure. May exist already. */
+ mkdir(result, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ if (snprintf(result,PATH_MAX,"%s/.gish/%s",home,path) < 0)
+ return path;
+
+ return result;
+#else
+ return path;
+#endif
+ }
+
void loadconfig(void)
{
int count,count2;
char tempstr[32];
+ char path[PATH_MAX];
config.resolutionx=800;
config.resolutiony=600;
@@ -99,7 +130,7 @@ void loadconfig(void)
for (count=0;count<4;count++)
control[3].button[count+4]=count;
- loadtextfile("config.txt");
+ loadtextfile(userpath(path,"config.txt"));
optionreadint(&config.resolutionx,"screenwidth=");
optionreadint(&config.resolutiony,"screenheight=");
optionreadint(&config.bitsperpixel,"bitsperpixel=");
@@ -157,6 +188,7 @@ void saveconfig(void)
int count,count2;
char tempstr[32];
FILE *fp;
+ char path[PATH_MAX];
config.resolutionx=windowinfo.resolutionx;
config.resolutiony=windowinfo.resolutiony;
@@ -165,7 +197,7 @@ void saveconfig(void)
config.stencilbits=windowinfo.stencilbits;
config.fullscreen=windowinfo.fullscreen;
- if ((fp=fopen("config.txt","wb"))==NULL)
+ if ((fp=fopen(userpath(path,"config.txt"),"wb"))==NULL)
return;
optionwriteint(fp, &config.resolutionx,"screenwidth=");
@@ -219,6 +251,7 @@ void notsupportedmenu(void)
char *glversion;
char *ext;
FILE *fp;
+ char path[PATH_MAX];
glvendor=(char *) glGetString(GL_VENDOR);
glrenderer=(char *) glGetString(GL_RENDERER);
@@ -294,7 +327,7 @@ void notsupportedmenu(void)
resetmenuitems();
- if ((fp=fopen("glreport.txt","wb"))==NULL)
+ if ((fp=fopen(userpath(path,"glreport.txt"),"wb"))==NULL)
return;
fprintf(fp,"%s\r\n",glversion);
View
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
+char* userpath(char *result, char *path);
void loadconfig(void);
void saveconfig(void);
void notsupportedmenu(void);
View
@@ -22,4 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../config.h"
#include "../game/debug.h"
-int debugit=0;
+int debugit=0;
+int debug_level_saveload=0;
+int debug_texture_load=0;
View
@@ -22,5 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
extern int debugit;
+extern int debug_level_saveload;
+extern int debug_texture_load;
#endif /* GISH_GAME_DEBUG_H */
View
@@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../video/texture.h"
_editor editor;
+char currentTextureFilename[256];
void editlevel(void)
{
View
@@ -85,6 +85,7 @@ void edittextures(void)
for (count=0;count<32;count++)
{
+
glBindTexture(GL_TEXTURE_2D,texture[count+textureedit.pagenum*32].glname);
glBegin(GL_QUADS);
@@ -114,6 +115,22 @@ void edittextures(void)
glVertex3f(vec[0],vec[1],-1.0f);
glEnd();
+
+ if (texture[count+textureedit.pagenum*32].filename[0])
+ {
+ char cleanFilename[256];
+ int filenameLength;
+ filenameLength = strlen(texture[count+textureedit.pagenum*32].filename);
+ memcpy(cleanFilename, texture[count+textureedit.pagenum*32].filename, filenameLength);
+ if (filenameLength>4)
+ cleanFilename[filenameLength-4] = '\0';
+ else
+ cleanFilename[filenameLength] = '\0';
+
+
+ drawtext(cleanFilename,
+ ((count&7)*64+32)|TEXT_CENTER, 14+60+(count>>3)*64,8,1.0f,1.0f,1.0f,1.0f);
+ }
}
for (count=0;count<16;count++)
{
@@ -254,6 +271,55 @@ void edittextures(void)
textureedit.texturenum=-1;
}
+ if (mouse.rmb && !prevmouse.rmb)
+ {
+ int clickedTexture = -1;
+ for (count=0;count<32;count++)
+ if (mouse.x>=(count&7)*64+4 && mouse.x<(count&7)*64+60)
+ if (mouse.y>=16+4+(count>>3)*64 && mouse.y<16+60+(count>>3)*64)
+ clickedTexture=count+textureedit.pagenum*32;
+ if (clickedTexture>=0)
+ {
+ char filename[256];
+ strcpy(filename, texture[clickedTexture].filename);
+ while(!menuitem[1].active && !menuitem[2].active && !windowinfo.shutdown)
+ {
+ glClearColor(0.0f,0.0f,0.0f,0.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ numofmenuitems=0;
+ createmenuitem("File ",(320|TEXT_CENTER),240,16,1.0f,1.0f,1.0f,1.0f);
+ setmenuitem(MO_STRINGINPUT,filename);
+
+ createmenuitem("Ok",(320|TEXT_CENTER),272,16,1.0f,1.0f,1.0f,1.0f);
+ setmenuitem(MO_HOTKEY,SCAN_ENTER);
+
+ createmenuitem("Cancel",(320|TEXT_CENTER),288,16,1.0f,1.0f,1.0f,1.0f);
+ setmenuitem(MO_HOTKEY,SCAN_ESC);
+
+ checksystemmessages();
+ checkkeyboard();
+ checkmouse();
+ checkmenuitems();
+
+ setuptextdisplay();
+
+ drawmenuitems();
+
+ drawmousecursor(768+font.cursornum,mouse.x,mouse.y,16,1.0f,1.0f,1.0f,1.0f);
+
+ SDL_GL_SwapBuffers();
+ }
+ if (menuitem[1].active)
+ {
+ if (strlen(filename) == 0)
+ texture[clickedTexture].filename[0] = 0;
+ else
+ loadtexturetga(clickedTexture,filename,0,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,GL_LINEAR,GL_LINEAR);
+ }
+ continue;
+ }
+ }
if (menuitem[1].active)
{
loadleveltiles(textureedit.filename);
@@ -286,6 +352,7 @@ void copytexture(int texturenum,int oldtexturenum)
texture[texturenum].wrapt=texture[oldtexturenum].wrapt;
texture[texturenum].magfilter=texture[oldtexturenum].magfilter;
texture[texturenum].minfilter=texture[oldtexturenum].minfilter;
+ texture[texturenum].filename[0] = '\0';
for (mipmaplevel=0;mipmaplevel<texture[texturenum].mipmaplevels;mipmaplevel++)
{
View
@@ -27,8 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#include "../game/high.h"
+#include "../game/config.h"
#include "../game/gameaudio.h"
#include "../game/english.h"
#include "../game/game.h"
@@ -238,8 +240,9 @@ void savescores(void)
int count,count2;
int version;
FILE *fp;
+ char path[PATH_MAX];
- if ((fp=fopen("gish.his","wb"))!=NULL)
+ if ((fp=fopen(userpath(path,"gish.his"),"wb"))!=NULL)
{
version=2;
fwrite2(&version,4,1,fp);
@@ -258,6 +261,7 @@ void loadscores(void)
int count,count2;
int version;
FILE *fp;
+ char path[PATH_MAX];
for (count=0;count<32;count++)
for (count2=0;count2<16;count2++)
@@ -266,7 +270,7 @@ void loadscores(void)
strcpy(highscore[count][count2].name,"Empty");
}
- if ((fp=fopen("gish.his","rb"))!=NULL)
+ if ((fp=fopen(userpath(path,"gish.his"),"rb"))!=NULL)
{
fread2(&version,4,1,fp);
if (version==2)
Oops, something went wrong.

0 comments on commit b595e01

Please sign in to comment.