moeng-cvs Mailing List for Moonlight Engine
Status: Alpha
Brought to you by:
b_lindeijer
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(145) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(226) |
Feb
(13) |
Mar
(5) |
Apr
(13) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(3) |
2007 |
Jan
(4) |
Feb
(27) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bjørn L. <b_l...@us...> - 2007-02-13 23:46:50
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13203/src/shared Modified Files: console.cpp console.h inflate.cpp map_reader.cpp Log Message: Flush the log file instead of opening and closing and log map loading errors. Index: map_reader.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/map_reader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- map_reader.cpp 13 Feb 2007 01:49:22 -0000 1.1 +++ map_reader.cpp 13 Feb 2007 23:46:46 -0000 1.2 @@ -372,9 +372,9 @@ } xmlFree(source); } else { - printf("Warning: Failed to load tileset %s (%s) for map " - "%s\n", nameOnly, (char*)name, - path.c_str()); + console.log(CON_QUIT, CON_ALWAYS, + "Failed to load tileset %s (%s) for map %s\n", + nameOnly, (char*)name, path.c_str()); } } Index: console.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- console.h 13 Feb 2007 01:49:22 -0000 1.5 +++ console.h 13 Feb 2007 23:46:46 -0000 1.6 @@ -17,14 +17,14 @@ #include <allegro.h> -#define CON_CONSOLE 1 -#define CON_LOG 2 -#define CON_QUIT 4 -#define CON_POPUP 8 +#define CON_CONSOLE 1 /**< Log to in-game console (not functional) */ +#define CON_LOG 2 /**< Log to log file */ +#define CON_QUIT 4 /**< Write to log file and terminal and quit */ +#define CON_POPUP 8 /**< Show the message in a popup */ -#define CON_ALWAYS 1 -#define CON_DEBUG 2 -#define CON_VDEBUG 4 +#define CON_ALWAYS 1 /**< Always log this */ +#define CON_DEBUG 2 /**< Only log when debug mode is enabled */ +#define CON_VDEBUG 4 /**< Only log when verbose debugging is enabled */ /** * The console. This class handles logging as well as displaying a console with @@ -33,7 +33,7 @@ class Console { public: - Console(const char* filename); + Console(const char *filename); ~Console(); void update(); @@ -45,7 +45,6 @@ private: FILE* logFile; - char* logFilename; std::list<char*> logMessages; bool active; int progress; Index: console.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- console.cpp 13 Feb 2007 01:49:22 -0000 1.6 +++ console.cpp 13 Feb 2007 23:46:46 -0000 1.7 @@ -18,23 +18,18 @@ #include <math.h> #ifndef M_PI -#define M_PI 3.14159 +#define M_PI 3.1415926 #endif -Console::Console(const char* filename) +Console::Console(const char *filename): + enableLogfile(true), + active(false), + progress(0) { - logFilename = new char[strlen(filename) + 1]; - strcpy(logFilename, filename); - logFilename[strlen(filename)] = '\0'; + logFile = fopen(filename, "w"); - logFile = fopen(logFilename, "w"); - fclose(logFile); log(CON_LOG, CON_ALWAYS, "----- Start of RPG log file -----"); - - progress = 0; - active = false; - enableLogfile = true; } @@ -45,13 +40,13 @@ while (!logMessages.empty()) { i = logMessages.begin(); - delete (*i); + free(*i); logMessages.erase(i); } log(CON_LOG, CON_ALWAYS, "----- End of RPG log file -----"); - delete logFilename; + fclose(logFile); } void Console::update() @@ -115,7 +110,6 @@ time(&t); if (enableLogfile) { - logFile = fopen(logFilename, "a"); fprintf( logFile, "[%s%d:%s%d:%s%d] ", @@ -126,16 +120,14 @@ (t % 60 < 10) ? "0" : "", (int)(t % 60) ); - fprintf(logFile, buf); - fprintf(logFile, "\n"); - fclose(logFile); + fprintf(logFile, "%s\n", buf); + fflush(logFile); } if (where & CON_QUIT) { - logFile = fopen(logFilename, "a"); fprintf(logFile, "FATAL ERROR!\n"); - fclose(logFile); + fflush(logFile); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(buf); printf("\n"); @@ -162,7 +154,7 @@ else { // Clean up the allocated string space - delete buf; + free(buf); } } } Index: inflate.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/inflate.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- inflate.cpp 13 Feb 2007 01:49:22 -0000 1.1 +++ inflate.cpp 13 Feb 2007 23:46:46 -0000 1.2 @@ -23,6 +23,7 @@ #include "inflate.h" +#include "../common.h" #include "console.h" #include <zlib.h> @@ -47,9 +48,7 @@ errorString = "Unknown error while decompressing data!"; } - // TODO: Well, make it actually log the error - printf("%s\n", errorString); - exit(1); + console.log(CON_QUIT, CON_ALWAYS, errorString); } bool |
From: Bjørn L. <b_l...@us...> - 2007-02-13 23:46:49
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13203 Modified Files: rpg.cfg Log Message: Flush the log file instead of opening and closing and log map loading errors. Index: rpg.cfg =================================================================== RCS file: /cvsroot/moeng/BBRpg/rpg.cfg,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- rpg.cfg 13 Apr 2004 12:26:07 -0000 1.8 +++ rpg.cfg 13 Feb 2007 23:46:45 -0000 1.9 @@ -3,7 +3,7 @@ DebugVerbose=0 GameClass=BBRpg GameSpeed=100 -LogEnabled=0 +LogEnabled=1 [Video] Fullscreen=0 |
From: Bjørn L. <b_l...@us...> - 2007-02-13 10:25:49
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17859 Modified Files: rpg.cbp Added Files: rpgedit.cbp Log Message: Updated Code::Blocks project file and added one for RPG Edit. RPG Edit doesn't really seem to work properly on Windows though. --- NEW FILE: rpgedit.cbp --- <?xml version="1.0"?> <!DOCTYPE CodeBlocks_project_file> <CodeBlocks_project_file> <FileVersion major="1" minor="1"/> <Project> <Option title="Win32 Application"/> <Option makefile="Makefile"/> <Option makefile_is_custom="0"/> <Option compiler="0"/> <Build> <Target title="default"> <Option output="C:\blindeijer\Projects\BBRpg\rpgedit.exe"/> <Option working_dir="."/> <Option object_output=".objs"/> <Option deps_output=".deps"/> <Option type="0"/> <Option compiler="0"/> <Option projectResourceIncludeDirsRelation="0"/> </Target> </Build> <Compiler> <Add option="-Wall"/> </Compiler> <Linker> <Add library="gdi32"/> <Add library="user32"/> <Add library="kernel32"/> <Add library="alleg"/> <Add library="lua5.1"/> <Add library="xml2.dll"/> <Add library="z.dll"/> </Linker> <Unit filename="src\editor\agup.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\agup.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\editor\agupitrn.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\editor\aphoton.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\aphoton.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\editor\editor.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\editor.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\editor\gui_procs.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\gui_procs.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\editor\main.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\script.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\editor\script.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\base64.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\base64.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\console.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\console.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\inflate.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\inflate.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\map_reader.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\map_reader.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\module.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\module.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\object.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\object.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> <Unit filename="src\shared\tiled_map.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> </Unit> <Unit filename="src\shared\tiled_map.h"> <Option compilerVar=""/> <Option compile="0"/> <Option link="0"/> <Option target="default"/> </Unit> </Project> </CodeBlocks_project_file> Index: rpg.cbp =================================================================== RCS file: /cvsroot/moeng/BBRpg/rpg.cbp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- rpg.cbp 7 Feb 2007 18:27:30 -0000 1.2 +++ rpg.cbp 13 Feb 2007 10:25:45 -0000 1.3 @@ -25,6 +25,7 @@ <Add library="alleg"/> <Add library="lua5.1"/> <Add library="xml2.dll"/> + <Add library="z.dll"/> </Linker> <Unit filename="src\canvas.cpp"> <Option compilerVar="CPP"/> @@ -72,6 +73,16 @@ <Option link="0"/> <Option target="default"/> </Unit> + <Unit filename="src\shared\base64.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\base64.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> <Unit filename="src\shared\console.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> @@ -82,6 +93,26 @@ <Option link="0"/> <Option target="default"/> </Unit> + <Unit filename="src\shared\inflate.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\inflate.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\map_reader.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\map_reader.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> <Unit filename="src\shared\module.cpp"> <Option compilerVar="CPP"/> <Option target="default"/> |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:26
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/src/shared Modified Files: console.cpp console.h module.cpp module.h object.cpp tiled_map.cpp tiled_map.h Added Files: base64.cpp base64.h inflate.cpp inflate.h map_reader.cpp map_reader.h Log Message: Added support for loading current Tiled maps to this old engine version. Index: module.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- module.h 23 Oct 2004 11:54:19 -0000 1.3 +++ module.h 13 Feb 2007 01:49:22 -0000 1.4 @@ -41,12 +41,12 @@ private: char* makeFilename(const char *name, const char *subdir); char* addMagic(const char *file); - + DATAFILE *script_data; char *path; char *datafile_name; int loadLevel; - + map<std::string, BITMAP*> bitmaps; map<std::string, MIDI*> midis; map<std::string, SAMPLE*> samples; Index: module.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- module.cpp 23 Oct 2004 11:54:19 -0000 1.3 +++ module.cpp 13 Feb 2007 01:49:22 -0000 1.4 @@ -23,6 +23,7 @@ #include "module.h" #include "../common.h" #include "../script.h" +#include "map_reader.h" Module::Module(const char *name) @@ -30,7 +31,7 @@ // Remember the path to be able to load from files later path = new char[strlen(name) + 1]; strcpy(path, name); - + // Open the datafile datafile_name = new char[strlen(name) + 1 + 4]; sprintf(datafile_name, "%s.dat", name); @@ -73,7 +74,7 @@ else { console.log(CON_LOG, CON_ALWAYS, "%sX \"%s\" not found!", spaces, name.c_str()); } - + delete[] spaces; } @@ -113,7 +114,7 @@ } temp++; } - + // Unload the datafile unload_datafile_object(script_data); script_data = NULL; @@ -140,6 +141,9 @@ char *filename = makeFilename(name.c_str(), "/maps"); console.log(CON_LOG, CON_ALWAYS, "Loading map \"%s\"...", filename); + mmap = MapReader::readMap(filename); + + /* if (exists(filename)) { mmap = new SquareMap(TILES_W, TILES_H); if (mmap) { @@ -162,6 +166,7 @@ unload_datafile_object(df); } } + */ delete[] filename; return mmap; @@ -177,7 +182,7 @@ } else { char *filename = makeFilename(name.c_str(), "/bitmaps"); - + // Attempt to load from disk, and otherwise from the datafile if (exists(filename)) { bitmap = load_bitmap(filename, NULL); Index: tiled_map.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- tiled_map.h 8 Feb 2007 17:51:50 -0000 1.8 +++ tiled_map.h 13 Feb 2007 01:49:22 -0000 1.9 @@ -15,14 +15,13 @@ #include <map> #include <list> #include <vector> +#include <string> #include <allegro.h> #include <libxml/xmlwriter.h> #include <libxml/tree.h> -using namespace std; - class Object; - +class Tileset; #define TILES_W 24 #define TILES_H 24 @@ -84,17 +83,24 @@ class TileType { public: - TileType(BITMAP *tileBitmap, const char *tileName); + TileType(BITMAP *tileBitmap, const char *tileName, int id = 0); ~TileType(); + void + setTileset(Tileset* set) { mTileset = set; } + BITMAP* getBitmap() {return bitmap;} char* getName() {return name;} int getColor() {return color;} + int getId() const { return mId; } + protected: BITMAP* bitmap; char* name; int color; + Tileset* mTileset; + int mId; }; @@ -123,9 +129,9 @@ int tile_w, int tile_h, int tile_spacing, int tiles_in_row); TileType* getTileType(const char *tileName); - vector<TileType*> generateTileArray(); + std::vector<TileType*> generateTileArray(); protected: - map<const char*, TileType*, ltstr> tileTypes; + std::map<const char*, TileType*, ltstr> tileTypes; }; @@ -138,7 +144,6 @@ void saveTo(PACKFILE *file); void saveTo(xmlTextWriterPtr writer); void loadFrom(PACKFILE *file, TileRepository *tileRepository); - void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); void setType(TileType* tileType); TileType* getType() {return tileType;} @@ -149,6 +154,61 @@ }; +/** + * Tileset class. + */ +class Tileset +{ + public: + /** + * Constructor. + */ + Tileset(); + + void + importTileBitmap(BITMAP *tileBitmap, + const std::string &imgSource, + int tw, int th, int ts); + + TileType* + getTile(int id); + + void + setFirstGid(int gid) { firstgid = gid; } + + void + setName(const std::string &name) { mName = name; } + + int + getFirstGid() const { return firstgid; } + + int + getNumTiles() const { return tiles.size(); } + + int + getTileWidth() const { return tileWidth; } + + int + getTileHeight() const { return tileHeight; } + + int + getTileSpacing() const { return tileSpacing; } + + const std::string& + getName() const { return mName; } + + const std::string& + getImgSource() const { return mImgSource; } + + protected: + std::string mName; + std::string mImgSource; + int tileWidth, tileHeight, tileSpacing; + int firstgid; + std::vector<TileType*> tiles; +}; + + // Entity sorting helper class =============================================== class EntityP { @@ -172,7 +232,6 @@ void saveTo(PACKFILE* file); void saveTo(xmlTextWriterPtr writer); void loadFrom(PACKFILE* file, TileRepository *tileRepository); - void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); int getWidth() { return width; } int getHeight() { return height; } @@ -183,6 +242,7 @@ float getOpacity(); Tile* getTile(const Point &tileCoords); + void setTile(const Point &tileCoords, TileType*); private: int width, height; @@ -207,14 +267,15 @@ void saveTo(xmlTextWriterPtr writer); int loadMap(const char* filename); void loadFrom(PACKFILE* file, TileRepository *tileRepository); - void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); int getWidth() {return width;} int getHeight() {return height;} // Tile and entity methods //Tile* getTile(Point tileCoords); - TiledMapLayer* getLayer(int i); + TiledMapLayer* getLayer(unsigned int i); + TiledMapLayer* getLayer(const char *name); + void deleteLayers(); // Drawing the map virtual void setCamera(Point cameraCoords, Rectangle screenRect, @@ -234,6 +295,10 @@ void addReference(Object* obj); void removeObjects(); + // Tileset methods + Tileset* getTileset(const char* name) const; + TileType* getTile(int gid) const; + // Coordinate space converters virtual Point screenToTile(Point screenCoords); virtual Point tileToScreen(Point tileCoords); @@ -245,12 +310,13 @@ virtual Point getMapSize() = 0; // The layers - TiledMapLayer *mapLayers[2]; - int nrLayers; + std::vector<TiledMapLayer*> mapLayers; // Entity list - list<Object*> objects; + std::list<Object*> objects; + // Tileset list + std::list<Tileset*> tilesets; int width, height; protected: --- NEW FILE: inflate.h --- /* * The Mana World * Copyright 2006 The Mana World Development Team * * This file is part of The Mana World. * * The Mana World is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * The Mana World is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: inflate.h,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #ifndef _RAGE_INFLATE_H_ #define _RAGE_INFLATE_H_ /** * Inflates either zlib or gzip deflated memory. The inflated memory is * expected to be freed by the caller. Returns <code>true</code> if the * inflation was sucessful. */ bool inflateMemory(unsigned char *in, unsigned int inLength, unsigned char *&out, unsigned int &outLength); #endif --- NEW FILE: map_reader.cpp --- /* * RAGE - Role & Adventure Games Engine * Website: http://alternativegamers.com/ * Copyright 2005 Ramine Darabiha * * This file is part of RAGE. * * RAGE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * RAGE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RAGE; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: map_reader.cpp,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #include "map_reader.h" #include "base64.h" #include "console.h" #include "../common.h" #include "inflate.h" #include "module.h" #include "object.h" #include "tiled_map.h" TiledMap* MapReader::readMap(const char *filename) { console.log(CON_LOG, CON_VDEBUG, "- Attempting to parse XML map data"); FILE* f = fopen(filename, "rb"); char *map_string; if (!f) { console.log(CON_QUIT, CON_ALWAYS, "Error: %s failed to open!", filename); } // Get size of file fseek(f, 0, SEEK_END); long size = ftell(f); rewind(f); // Read file into character array map_string = new char[size + 1]; fread(map_string, 1, size, f); map_string[size] = '\0'; fclose(f); xmlDocPtr doc = xmlReadMemory(map_string, size, NULL, NULL, 0); delete[] map_string; if (doc) { console.log(CON_LOG, CON_VDEBUG, "- Looking for root node"); xmlNodePtr node = xmlDocGetRootElement(doc); if (!node || !xmlStrEqual(node->name, BAD_CAST "map")) { console.log(CON_LOG, CON_ALWAYS, "Warning, no map file (%s)!", filename); return NULL; } console.log(CON_LOG, CON_VDEBUG, "- Loading map from XML tree"); return readMap(node, filename); xmlFreeDoc(doc); } else { console.log(CON_LOG, CON_ALWAYS, "Error while parsing map file (%s), trying old format...!", filename); TiledMap *mmap = new SquareMap(TILES_W, TILES_H); mmap->loadMap(filename); return mmap; } return NULL; } TiledMap* MapReader::readMap(xmlNodePtr node, const std::string &path) { xmlChar *prop; prop = xmlGetProp(node, BAD_CAST "version"); xmlFree(prop); int w = getProperty(node, "width", 0); int h = getProperty(node, "height", 0); int tilew = getProperty(node, "tilewidth", TILES_W); int tileh = getProperty(node, "tileheight", TILES_H); TiledMap* map = new SquareMap(tilew, tileh); map->width = w; map->height = h; map->deleteLayers(); for (node = node->xmlChildrenNode; node != NULL; node = node->next) { if (xmlStrEqual(node->name, BAD_CAST "tileset")) { Tileset* set = readTileset(node, path); if (set) { map->tilesets.push_back(set); } } else if (xmlStrEqual(node->name, BAD_CAST "layer")) { console.log(CON_LOG, CON_VDEBUG, "- Loading layer %d", map->mapLayers.size() + 1); map->mapLayers.push_back(readLayer(node, map)); } else if (xmlStrEqual(node->name, BAD_CAST "object")) { int x = getProperty(node, "x", 0); int y = getProperty(node, "y", 0); // Spawn the object prop = xmlGetProp(node, BAD_CAST "type"); console.log(CON_LOG, CON_VDEBUG, "- Adding %s at (%d, %d)", (char*) prop, x, y); map->addObject((double) x / TILES_W, (double) y / TILES_H, (char*) prop); xmlFree(prop); } } return map; } TiledMapLayer* MapReader::readLayer(xmlNodePtr node, TiledMap *map) { TiledMapLayer *layer = new TiledMapLayer(); // Get layer attributes int w = getProperty(node, "width", 0); int h = getProperty(node, "height", 0); xmlChar *name = xmlGetProp(node, BAD_CAST "name"); bool obstacleLayer = false; if (name) { layer->setName((char*)name); if (xmlStrEqual(name, BAD_CAST "Obstacle")) { obstacleLayer = true; } xmlFree(name); } layer->resizeTo(w, h); node = node->xmlChildrenNode; int x = 0; int y = 0; // Load the tile data while (node != NULL) { if (xmlStrEqual(node->name, BAD_CAST "tile") && y < h) { xmlChar *name = xmlGetProp(node, BAD_CAST "name"); //xmlChar *obs = xmlGetProp(node, BAD_CAST "obstacle"); int gid = getProperty(node, "gid", -1); if (gid > -1) { layer->setTile(Point(x, y), map->getTile(gid)); } else if (name) { // DEPRECATED: Old way of storing tiles char buf[64]; strncpy(buf, (char*) name, 64); char *nr = strstr(buf, "."); if (nr) { *nr = '\0'; int id = atoi(++nr); Tileset* ts = map->getTileset(buf); if (ts) { layer->setTile(Point(x, y), ts->getTile(id)); } } xmlFree(name); } else { layer->setTile(Point(x, y), NULL); } /* if (obs) { tile->obstacle = ((obs[0] == '1') ? OB_TOP : 0) | ((obs[1] == '1') ? OB_RIGHT : 0) | ((obs[2] == '1') ? OB_BOTTOM : 0) | ((obs[3] == '1') ? OB_LEFT : 0); xmlFree(obs); } else { tile->obstacle = 0; } */ x++; if (x == w) {x = 0; y++;} } if (xmlStrEqual(node->name, BAD_CAST "data")) { xmlChar *encoding = xmlGetProp(node, BAD_CAST "encoding"); xmlChar *compression = xmlGetProp(node, BAD_CAST "compression"); bool base64Encoded = false; bool gzipCompressed = false; if (encoding && xmlStrEqual(encoding, BAD_CAST "base64")) { base64Encoded = true; xmlFree(encoding); } if (compression && xmlStrEqual(compression, BAD_CAST "gzip")) { gzipCompressed = true; xmlFree(compression); } if (base64Encoded) { xmlNodePtr dataChild = node->xmlChildrenNode; if (!dataChild) { console.log(CON_QUIT, CON_ALWAYS, "Layer data missing!"); } int len = strlen((char const *)dataChild->content) + 1; unsigned char *charData = new unsigned char[len + 1]; char const *charStart = (char const *)dataChild->content; unsigned char *charIndex = charData; while (*charStart) { if (*charStart != ' ' && *charStart != '\t' && *charStart != '\n') { *charIndex = *charStart; charIndex++; } charStart++; } *charIndex = '\0'; int binLen; unsigned char *binData = php3_base64_decode(charData, strlen((const char*) charData), &binLen); delete[] charData; if (!binData) { console.log(CON_QUIT, CON_ALWAYS, "Layer data decode failed!"); } if (gzipCompressed) { unsigned char *inflatedData; unsigned int inflatedLen; inflateMemory(binData, binLen, inflatedData, inflatedLen); free(binData); binData = inflatedData; binLen = inflatedLen; if (inflatedData == NULL) { console.log(CON_QUIT, CON_ALWAYS, "Layer data decompression failed!"); } } for (int i = 0; i < binLen - 3; i += 4) { int gid = binData[i] | binData[i + 1] << 8 | binData[i + 2] << 16 | binData[i + 3] << 24; TileType *type = map->getTile(gid); if (obstacleLayer) { Tile *tile = map->getLayer((unsigned int)0)->getTile( Point(x, y)); if (type) { tile->obstacle = type->getId(); } } else { layer->setTile(Point(x, y), type); } x++; if (x == w) { x = 0; y++; } } free(binData); // Make sure the while loop stops node = NULL; } else { // This is to support tile elements in a data element node = node->xmlChildrenNode; } } else { node = node->next; } } return layer; } Tileset* MapReader::readTileset(xmlNodePtr node, const std::string &path) { Tileset* set = NULL; xmlChar* prop = xmlGetProp(node, BAD_CAST "source"); if (prop) { console.log(CON_LOG, CON_ALWAYS, "Warning: External tilesets not supported yet."); xmlFree(prop); return NULL; } int firstgid = getProperty(node, "firstgid", 0); int tw = getProperty(node, "tilewidth", TILES_W); int th = getProperty(node, "tileheight", TILES_H); int ts = getProperty(node, "spacing", 0); xmlChar *name = xmlGetProp(node, BAD_CAST "name"); node = node->xmlChildrenNode; while (node != NULL) { if (xmlStrEqual(node->name, BAD_CAST "image")) { xmlChar* source = xmlGetProp(node, BAD_CAST "source"); if (source) { std::string filename = path.substr(0, path.rfind("/") + 1) + std::string((const char*)source); const char *nameOnly = get_filename(filename.c_str()); BITMAP* tilebmp = module->findBitmap(nameOnly); if (tilebmp) { set = new Tileset(); set->importTileBitmap(tilebmp, (char*)source, tw, th, ts); set->setFirstGid(firstgid); if (name) { set->setName((char*)name); } xmlFree(source); } else { printf("Warning: Failed to load tileset %s (%s) for map " "%s\n", nameOnly, (char*)name, path.c_str()); } } break; } node = node->next; } xmlFree(name); return set; } int MapReader::getProperty(xmlNodePtr node, const char* name, int def) { xmlChar *prop = xmlGetProp(node, BAD_CAST name); if (prop) { int val = atoi((char*)prop); xmlFree(prop); return val; } else { return def; } } Index: console.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- console.cpp 7 Feb 2007 17:50:31 -0000 1.5 +++ console.cpp 13 Feb 2007 01:49:22 -0000 1.6 @@ -41,7 +41,7 @@ Console::~Console() { // Deallocate console string messages - list<char*>::iterator i; + std::list<char*>::iterator i; while (!logMessages.empty()) { i = logMessages.begin(); @@ -77,7 +77,7 @@ font = engine_font; - list<char*>::iterator i = logMessages.begin(); + std::list<char*>::iterator i = logMessages.begin(); while (i != logMessages.end() && posY > - text_height(font)) { textprintf_ex(dest, font, 2, posY, makecol(200,200,200), -1, (*i)); Index: object.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/object.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- object.cpp 23 Oct 2004 11:54:19 -0000 1.8 +++ object.cpp 13 Feb 2007 01:49:22 -0000 1.9 @@ -111,7 +111,7 @@ if (col && obstacle) { // Check for map obstacle - Tile *nextTile = map->getLayer(0)->getTile( + Tile *nextTile = map->getLayer((unsigned int)0)->getTile( Point((int)next_x, (int)next_y)); if (!nextTile || next_x < 0 || next_y < 0 || @@ -126,7 +126,7 @@ } // Check for object in the way - list<Object*>::iterator i; + std::list<Object*>::iterator i; for (i = map->objects.begin(); i != map->objects.end(); i++) { Object *obj = (*i); if ((obj->obstacle) && @@ -183,7 +183,7 @@ if (!map) return; // Check if this object is now standing on something - list<Object*>::iterator i; + std::list<Object*>::iterator i; for (i = map->objects.begin(); i != map->objects.end(); i++) { Object *obj = (*i); if ((obj != this) && --- NEW FILE: inflate.cpp --- /* * The Mana World * Copyright 2006 The Mana World Development Team * * This file is part of The Mana World. * * The Mana World is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * The Mana World is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: inflate.cpp,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #include "inflate.h" #include "console.h" #include <zlib.h> static void logZlibError(int error) { char *errorString; switch (error) { case Z_MEM_ERROR: errorString = "Out of memory while decompressing data!"; break; case Z_VERSION_ERROR: errorString = "Incompatible zlib version!"; break; case Z_DATA_ERROR: errorString = "Incorrect zlib compressed data!"; break; default: errorString = "Unknown error while decompressing data!"; } // TODO: Well, make it actually log the error printf("%s\n", errorString); exit(1); } bool inflateMemory(unsigned char *in, unsigned int inLength, unsigned char *&out, unsigned int &outLength) { int bufferSize = 256 * 1024; int ret; z_stream strm; out = (unsigned char*) malloc(bufferSize); strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = (Bytef *)in; strm.avail_in = inLength; strm.next_out = (Bytef *)out; strm.avail_out = bufferSize; ret = inflateInit2(&strm, 15 + 32); if (ret != Z_OK) { logZlibError(ret); return false; } do { ret = inflate(&strm, Z_SYNC_FLUSH); switch (ret) { case Z_NEED_DICT: case Z_STREAM_ERROR: ret = Z_DATA_ERROR; case Z_DATA_ERROR: case Z_MEM_ERROR: inflateEnd(&strm); logZlibError(ret); return false; } if (ret != Z_STREAM_END) { out = (unsigned char*) realloc(out, bufferSize * 2); if (!out) { inflateEnd(&strm); logZlibError(Z_MEM_ERROR); return false; } strm.next_out = (Bytef*) (out + bufferSize); strm.avail_out = bufferSize; bufferSize *= 2; } } while (ret != Z_STREAM_END); if (strm.avail_in != 0) { logZlibError(Z_DATA_ERROR); return false; } outLength = bufferSize - strm.avail_out; inflateEnd(&strm); return true; } Index: console.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- console.h 7 Feb 2007 17:50:31 -0000 1.4 +++ console.h 13 Feb 2007 01:49:22 -0000 1.5 @@ -11,22 +11,25 @@ #ifndef _INCLUDED_CONSOLE_H_ #define _INCLUDED_CONSOLE_H_ + #include <stdio.h> #include <list> +#include <allegro.h> -using namespace std; - - -#define CON_CONSOLE 1 -#define CON_LOG 2 -#define CON_QUIT 4 -#define CON_POPUP 8 -#define CON_ALWAYS 1 -#define CON_DEBUG 2 -#define CON_VDEBUG 4 +#define CON_CONSOLE 1 +#define CON_LOG 2 +#define CON_QUIT 4 +#define CON_POPUP 8 +#define CON_ALWAYS 1 +#define CON_DEBUG 2 +#define CON_VDEBUG 4 +/** + * The console. This class handles logging as well as displaying a console with + * the log in the game when the tilde is pressed. + */ class Console { public: @@ -36,14 +39,14 @@ void update(); void draw(BITMAP *dest); bool handleInput(int key); - void log(int where, int when, const char* what, ...); + void log(int where, int when, const char *what, ...); bool enableLogfile; private: FILE* logFile; char* logFilename; - list<char*> logMessages; + std::list<char*> logMessages; bool active; int progress; }; --- NEW FILE: base64.cpp --- /* +----------------------------------------------------------------------+ | PHP HTML Embedded Scripting Language Version 3.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2000 PHP Development Team (See Credits file) | +----------------------------------------------------------------------+ | This program is free software; you can redistribute it and/or modify | | it under the terms of one of the following licenses: | | | | A) the GNU General Public License as published by the Free Software | | Foundation; either version 2 of the License, or (at your option) | | any later version. | | | | B) the PHP License as published by the PHP Development Team and | | included in the distribution in the file: LICENSE | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of both licenses referred to here. | | If you did not, or have any questions about PHP licensing, please | | contact co...@ph.... | +----------------------------------------------------------------------+ | Author: Jim Winstead (ji...@ph...) | +----------------------------------------------------------------------+ */ /* $Id: base64.cpp,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #include <string.h> #include <stdlib.h> #include "base64.h" static char base64_table[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0' }; static char base64_pad = '='; unsigned char *php3_base64_encode(const unsigned char *string, int length, int *ret_length) { const unsigned char *current = string; int i = 0; unsigned char *result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char)); while (length > 2) { /* keep going until we have less than 24 bits */ result[i++] = base64_table[current[0] >> 2]; result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)]; result[i++] = base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)]; result[i++] = base64_table[current[2] & 0x3f]; current += 3; length -= 3; /* we just handle 3 octets of data */ } /* now deal with the tail end of things */ if (length != 0) { result[i++] = base64_table[current[0] >> 2]; if (length > 1) { result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)]; result[i++] = base64_table[(current[1] & 0x0f) << 2]; result[i++] = base64_pad; } else { result[i++] = base64_table[(current[0] & 0x03) << 4]; result[i++] = base64_pad; result[i++] = base64_pad; } } if(ret_length) { *ret_length = i; } result[i] = '\0'; return result; } /* as above, but backwards. :) */ unsigned char *php3_base64_decode(const unsigned char *string, int length, int *ret_length) { const unsigned char *current = string; int ch, i = 0, j = 0, k; char *chp; unsigned char *result = (unsigned char *)malloc(length + 1); if (result == NULL) { return NULL; } /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') { if (ch == base64_pad) break; /* When Base64 gets POSTed, all pluses are interpreted as spaces. This line changes them back. It's not exactly the Base64 spec, but it is completely compatible with it (the spec says that spaces are invalid). This will also save many people considerable headache. - Turadg Aleahmad <tu...@wi...> */ if (ch == ' ') ch = '+'; chp = strchr(base64_table, ch); if (chp == NULL) continue; ch = chp - base64_table; switch(i % 4) { case 0: result[j] = ch << 2; break; case 1: result[j++] |= ch >> 4; result[j] = (ch & 0x0f) << 4; break; case 2: result[j++] |= ch >>2; result[j] = (ch & 0x03) << 6; break; case 3: result[j++] |= ch; break; } i++; } k = j; /* mop things up if we ended on a boundary */ if (ch == base64_pad) { switch(i % 4) { case 0: case 1: free(result); return NULL; case 2: k++; case 3: result[k++] = 0; } } if(ret_length) { *ret_length = j; } result[k] = '\0'; return result; } --- NEW FILE: map_reader.h --- /* * RAGE - Role & Adventure Games Engine * Website: http://alternativegamers.com/ * Copyright 2005 Ramine Darabiha * * This file is part of RAGE. * * RAGE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * RAGE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RAGE; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: map_reader.h,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #ifndef _RAGE_MAPREADER_H #define _RAGE_MAPREADER_H #include <string> #include <libxml/xmlwriter.h> class TiledMap; class TiledMapLayer; class Tileset; /** * Map reader. */ class MapReader { public: static TiledMap* readMap(const char *filename); static TiledMap* readMap(xmlNodePtr node, const std::string &path); private: static TiledMapLayer* readLayer(xmlNodePtr node, TiledMap *map); static Tileset* readTileset(xmlNodePtr node, const std::string &path); static int getProperty(xmlNodePtr node, const char *name, int def); }; #endif Index: tiled_map.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- tiled_map.cpp 8 Feb 2007 17:51:50 -0000 1.11 +++ tiled_map.cpp 13 Feb 2007 01:49:22 -0000 1.12 @@ -16,6 +16,7 @@ #include <stdio.h> #include <allegro.h> #include <map> +#include <cassert> #include <algorithm> #include <libxml/xmlwriter.h> #include <libxml/xmlreader.h> @@ -39,11 +40,11 @@ this->z = z; } -Vector::Vector(const Vector &v) +Vector::Vector(const Vector &v): + x(v.x), + y(v.y), + z(v.z) { - this->x = v.x; - this->y = v.y; - this->z = v.z; } Vector Vector::operator*(double c) @@ -108,23 +109,27 @@ bool Rectangle::collides(const Rectangle &r) { - return !( - x + w < r.x || - y + h < r.y || - x > r.x + r.w || - y > r.y + r.h - ); + return !(x + w < r.x || + y + h < r.y || + x > r.x + r.w || + y > r.y + r.h); } // TileType ================================================================== // An object holding static information about a tile type. -TileType::TileType(BITMAP *tileBitmap, const char *tileName) +TileType::TileType(BITMAP *tileBitmap, const char *tileName, int id): + mId(id) { bitmap = tileBitmap; - name = (char*)malloc(ustrsizez(tileName)); - ustrcpy(name, tileName); + if (tileName) { + name = (char*)malloc(ustrsizez(tileName)); + ustrcpy(name, tileName); + } + else { + name = NULL; + } int x, y; unsigned long r = 0, g = 0, b = 0; unsigned long pixels = tileBitmap->w * tileBitmap->h; @@ -152,8 +157,8 @@ // Tile class ================================================================ Tile::Tile(): - tileType(NULL), - obstacle(0) + obstacle(0), + tileType(NULL) { } @@ -201,32 +206,6 @@ obstacle = pack_igetw(file); } -void Tile::loadFrom(xmlNodePtr cur, TileRepository *tileRepository) -{ - xmlChar *prop; - - prop = xmlGetProp(cur, BAD_CAST "name"); - if (prop) { - setType(tileRepository->getTileType((char*)prop)); - xmlFree(prop); - } - else { - setType(NULL); - } - prop = xmlGetProp(cur, BAD_CAST "obstacle"); - if (prop) { - obstacle = - ((prop[0] == '1') ? OB_TOP : 0) | - ((prop[1] == '1') ? OB_RIGHT : 0) | - ((prop[2] == '1') ? OB_BOTTOM : 0) | - ((prop[3] == '1') ? OB_LEFT : 0); - xmlFree(prop); - } - else { - obstacle = 0; - } -} - void Tile::setType(TileType *tileType) { this->tileType = tileType; @@ -280,7 +259,7 @@ tempTileType = new TileType(tempBitmap, get_datafile_property(file, DAT_ID('N','A','M','E'))); - tileTypes.insert(make_pair( + tileTypes.insert(std::make_pair( tempTileType->getName(), tempTileType)); break; } @@ -316,7 +295,7 @@ y * (tileBitmap->w / tile_w) + x); tempTileType = new TileType(tempBitmap, tempTilename); - tileTypes.insert(make_pair(tempTileType->getName(), tempTileType)); + tileTypes.insert(std::make_pair(tempTileType->getName(), tempTileType)); } } } @@ -347,9 +326,9 @@ const char *filename, int tile_w, int tile_h, int tile_spacing, int tiles_in_row) { - list<TileType*> tiles_to_save; - map<const char*, TileType*, ltstr>::iterator i; - list<TileType*>::iterator j; + std::list<TileType*> tiles_to_save; + std::map<const char*, TileType*, ltstr>::iterator i; + std::list<TileType*>::iterator j; char tempTilename[256]; char tempFilename[256]; replace_extension(tempFilename, get_filename(filename), "", 256); @@ -404,7 +383,7 @@ TileType* TileRepository::getTileType(const char *tileName) { - map<const char*, TileType*, ltstr>::iterator found = + std::map<const char*, TileType*, ltstr>::iterator found = tileTypes.find(tileName); if (found != tileTypes.end()) { @@ -414,10 +393,10 @@ } } -vector<TileType*> TileRepository::generateTileArray() +std::vector<TileType*> TileRepository::generateTileArray() { - map<const char*, TileType*, ltstr>::iterator i; - vector<TileType*> tileArray; + std::map<const char*, TileType*, ltstr>::iterator i; + std::vector<TileType*> tileArray; for (i = tileTypes.begin(); i != tileTypes.end(); i++) { @@ -427,6 +406,52 @@ return tileArray; } +// Tileset =================================================================== + +Tileset::Tileset() +{ + tileWidth = tileHeight = tileSpacing = 0; + firstgid = 0; +} + +void +Tileset::importTileBitmap(BITMAP *tileImage, + const std::string &source, + int tw, int th, int ts) +{ + assert(tw > 0 && th > 0 && ts >= 0 && tileImage); + + mImgSource = source; + int x, y, id = 0; + tileWidth = tw; + tileHeight = th; + tileSpacing = ts; + + for (y = 0; y < (tileImage->h / (th + ts)); y++) + { + for (x = 0; x < (tileImage->w / (tw + ts)); x++) + { + // Create a new tile type and add it to the vector + BITMAP *subImage = create_sub_bitmap(tileImage, + x * (tw + ts), + y * (th + ts), + tw, th); + + TileType *tileType = new TileType(subImage, NULL, id++); + tileType->setTileset(this); + tiles.push_back(tileType); + } + } +} + +TileType* Tileset::getTile(int id) +{ + if (id >= 0 && (unsigned int) id < tiles.size()) { + return tiles[id]; + } else { + return NULL; + } +} // TiledMapLayer ============================================================= // Defines a tiled layer, used by tiled maps @@ -568,39 +593,9 @@ getTile(Point(x,y))->loadFrom(file, tileRepository); } -void TiledMapLayer::loadFrom(xmlNodePtr cur, TileRepository *tileRep) -{ - xmlChar *prop; - - // Load the map header - prop = xmlGetProp(cur, BAD_CAST "width"); - int w = atoi((char*)prop); - xmlFree(prop); - prop = xmlGetProp(cur, BAD_CAST "height"); - int h = atoi((char*)prop); - xmlFree(prop); - - resizeTo(w, h); - - cur = cur->xmlChildrenNode; - int x = 0; - int y = 0; - - // Load the tile data - while (cur != NULL) { - if (xmlStrEqual(cur->name, BAD_CAST "tile") && y < height) { - getTile(Point(x,y))->loadFrom(cur, tileRepository); - x++; - if (x == width) {x = 0; y++;} - } - cur = cur->next; - } -} - Tile *TiledMapLayer::getTile(const Point &tile) { - if (tile.x < 0 || tile.x >= width || - tile.y < 0 || tile.y >= height) + if (tile.x < 0 || tile.x >= width || tile.y < 0 || tile.y >= height) { return NULL; } @@ -610,26 +605,38 @@ } } +void +TiledMapLayer::setTile(const Point &tile, TileType *type) +{ + if (!(tile.x < 0 || tile.x >= width || tile.y < 0 || tile.y >= height)) { + tileMap[tile.x + tile.y * width]->setType(type); + } +} + // TiledMap class ============================================================ // Defines a generic tiled map interface and data model. TiledMap::TiledMap(): -nrLayers(2), width(0), height(0) + width(0), height(0) { - mapLayers[0] = new TiledMapLayer(); - mapLayers[1] = new TiledMapLayer(); + mapLayers.push_back(new TiledMapLayer()); + mapLayers.push_back(new TiledMapLayer()); } TiledMap::~TiledMap() { - // Delete the layers - for (int i = 0; i < nrLayers; i++) { + deleteLayers(); +} + +void TiledMap::deleteLayers() +{ + for (unsigned int i = 0; i < mapLayers.size(); i++) { if (mapLayers[i]) { delete mapLayers[i]; - mapLayers[i] = NULL; } } + mapLayers.clear(); } void TiledMap::setCamera(Point cam, Rectangle rect, bool center, bool modify) @@ -650,8 +657,10 @@ void TiledMap::resizeTo(int w, int h, int dx, int dy) { - mapLayers[0]->resizeTo(w, h, dx, dy); - mapLayers[1]->resizeTo(w, h, dx, dy); + for (unsigned int i = 0; i < mapLayers.size(); i++) + { + mapLayers[i]->resizeTo(w, h, dx, dy); + } width = w; height = h; } @@ -666,15 +675,15 @@ // Version 3: Object list stored at end of tile data. pack_iputw(3, file); // The map header - pack_iputw(nrLayers, file); + pack_iputw(mapLayers.size(), file); // The tile data - for (int i = 0; i < nrLayers; i++) { + for (unsigned int i = 0; i < mapLayers.size(); i++) { mapLayers[i]->saveTo(file); } // Object data - list<Object*>::iterator i; + std::list<Object*>::iterator i; pack_iputw(objects.size(), file); for (i = objects.begin(); i != objects.end(); i++) { pack_iputw(int(TILES_W * (*i)->x), file); @@ -695,13 +704,14 @@ xmlTextWriterWriteAttribute(writer, BAD_CAST "version", BAD_CAST "4.0"); // Tile data - for (int i = 0; i < nrLayers; i++) { + for (unsigned int i = 0; i < mapLayers.size(); i++) { mapLayers[i]->saveTo(writer); } // Object data - list<Object*>::iterator i; - for (i = objects.begin(); i != objects.end(); i++) { + std::list<Object*>::iterator i; + for (i = objects.begin(); i != objects.end(); i++) + { xmlTextWriterStartElement(writer, BAD_CAST "object"); snprintf(strbuf, 16, "%d", int(TILES_W * (*i)->x)); @@ -724,57 +734,18 @@ { console.log(CON_LOG, CON_VDEBUG, "- Attempting to parse XML map data"); - FILE* f = fopen(filename, "rb"); - char *map_string; - - if (!f) { - console.log(CON_QUIT, CON_ALWAYS, "Error: %s failed to open!", - filename); - } - - // Get size of file - fseek(f, 0, SEEK_END); - long size = ftell(f); - rewind(f); - - // Read file into character array - map_string = new char[size + 1]; - fread(map_string, 1, size, f); - map_string[size] = '\0'; - - fclose(f); - - xmlDocPtr doc = xmlReadMemory(map_string, size, NULL, NULL, 0); - delete[] map_string; - - if (doc) { - console.log(CON_LOG, CON_VDEBUG, "- Looking for root node"); - xmlNodePtr cur = xmlDocGetRootElement(doc); - - if (!cur || !xmlStrEqual(cur->name, BAD_CAST "map")) { - console.log(CON_LOG, CON_ALWAYS, - "Warning, no map file (%s)!", filename); - return 1; - } + console.log(CON_LOG, CON_VDEBUG, "- Attempting to load packfile map"); + PACKFILE *file = pack_fopen(filename, F_READ_PACKED); - console.log(CON_LOG, CON_VDEBUG, "- Loading map from XML tree"); - loadFrom(cur, tileRepository); - xmlFreeDoc(doc); + if (!file) { + console.log(CON_LOG, CON_ALWAYS, + "Warning, no such file (%s)!", filename); + return 1; } - else { - console.log(CON_LOG, CON_VDEBUG, "- Attempting to load packfile map"); - PACKFILE *file = pack_fopen(filename, F_READ_PACKED); - if (!file) { - console.log(CON_LOG, CON_ALWAYS, - "Warning, no such file (%s)!", filename); - return 1; - } - - console.log(CON_LOG, CON_VDEBUG, "- Loading map from packfile"); - this->loadFrom(file, tileRepository); - pack_fclose(file); - } + console.log(CON_LOG, CON_VDEBUG, "- Loading map from packfile"); + this->loadFrom(file, tileRepository); + pack_fclose(file); return 0; } @@ -820,57 +791,9 @@ height = mapLayers[0]->getHeight(); } -void TiledMap::loadFrom(xmlNodePtr cur, TileRepository *tileRep) -{ - int layerNr = 0; - xmlChar *prop; - - removeObjects(); - - prop = xmlGetProp(cur, BAD_CAST "version"); - xmlFree(prop); - - cur = cur->xmlChildrenNode; - - while (cur != NULL) { - if (xmlStrEqual(cur->name, BAD_CAST "layer")) { - if (layerNr < 2) { - console.log(CON_LOG, CON_VDEBUG, "- Loading layer %d", - layerNr + 1); - mapLayers[layerNr]->loadFrom(cur, tileRepository); - layerNr++; - } - } - else if (xmlStrEqual(cur->name, BAD_CAST "object")) { - prop = xmlGetProp(cur, BAD_CAST "x"); - int x = atoi((char*)prop); - xmlFree(prop); - prop = xmlGetProp(cur, BAD_CAST "y"); - int y = atoi((char*)prop); - xmlFree(prop); - - // Spawn the object - prop = xmlGetProp(cur, BAD_CAST "type"); - - console.log(CON_LOG, CON_VDEBUG, "- Adding %s at (%d, %d)", - (char*)prop, x, y); - addObject( - double(x) / TILES_W, - double(y) / TILES_H, - (char*)prop); - xmlFree(prop); - } - - cur = cur->next; - } - - width = mapLayers[0]->getWidth(); - height = mapLayers[0]->getHeight(); -} - -TiledMapLayer *TiledMap::getLayer(int i) +TiledMapLayer *TiledMap::getLayer(unsigned int i) { - if (i < 0 || i >= nrLayers) { + if (i < 0 || i >= mapLayers.size()) { return NULL; } else { @@ -878,6 +801,17 @@ } } +TiledMapLayer* +TiledMap::getLayer(const char *name) +{ + for (unsigned int i = 0; i < mapLayers.size(); i++) { + if (mapLayers[i] && strcmp(mapLayers[i]->getName(), name) == 0) { + return mapLayers[i]; + } + } + return NULL; +} + Object* TiledMap::addObject(double x, double y, const char* type) { int objectInstance = 0; @@ -937,7 +871,7 @@ void TiledMap::removeObjects() { // Delete the objects - list<Object*>::iterator i; + std::list<Object*>::iterator i; while (!objects.empty()) { i = objects.begin(); delete (*i); @@ -946,11 +880,35 @@ } +Tileset* TiledMap::getTileset(const char* name) const +{ + std::list<Tileset*>::const_iterator i; + for (i = tilesets.begin(); i != tilesets.end(); i++) { + if (!strcmp(name, (*i)->getName().c_str())) { + return (*i); + } + } + return NULL; +} + +TileType* TiledMap::getTile(int gid) const +{ + std::list<Tileset*>::const_reverse_iterator i; + for (i = tilesets.rbegin(); i != tilesets.rend(); i++) + { + if ((*i)->getFirstGid() <= gid) + { + return (*i)->getTile(gid - (*i)->getFirstGid()); + } + } + return NULL; +} + void TiledMap::drawEntities(BITMAP *dest) { - list<EntityP> visibleEnts; - list<Object*>::iterator i; - list<EntityP>::iterator j; + std::list<EntityP> visibleEnts; + std::list<Object*>::iterator i; + std::list<EntityP>::iterator j; for (i = objects.begin(); i != objects.end(); i++) { @@ -983,9 +941,9 @@ void TiledMap::drawAirborneEntities(BITMAP *dest) { - list<EntityP> visibleEnts; - list<Object*>::iterator i; - list<EntityP>::iterator j; + std::list<EntityP> visibleEnts; + std::list<Object*>::iterator i; + std::list<EntityP>::iterator j; for (i = objects.begin(); i != objects.end(); i++) { @@ -1013,7 +971,7 @@ void TiledMap::updateObjects() { - list<Object*>::iterator i; + std::list<Object*>::iterator i; // Destroy all objects at the beginning of the object map // that should be destroyed @@ -1029,7 +987,7 @@ for (i = objects.begin(); i != objects.end(); i++) { if ((*i)->_destroy) { - list<Object*>::iterator i2 = i; + std::list<Object*>::iterator i2 = i; // We can safely iterate one back because the first object never // needs to be destroyed. @@ -1087,9 +1045,13 @@ oldClip.clipToRect(dest); cameraScreenRect.rectToClip(dest); - if (mapLayers[0]) drawLayer(dest, drawObstacle, mapLayers[0]); + if (mapLayers.size() > 0 && mapLayers[0]) { + drawLayer(dest, drawObstacle, mapLayers[0]); + } drawEntities(dest); - if (mapLayers[1]) drawLayer(dest, drawObstacle, mapLayers[1]); + if (mapLayers.size() > 1 && mapLayers[1]) { + drawLayer(dest, drawObstacle, mapLayers[1]); + } drawAirborneEntities(dest); oldClip.rectToClip(dest); --- NEW FILE: base64.h --- /* +----------------------------------------------------------------------+ | PHP HTML Embedded Scripting Language Version 3.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997,1998 PHP Development Team (See Credits file) | +----------------------------------------------------------------------+ | This program is free software; you can redistribute it and/or modify | | it under the terms of one of the following licenses: | | | | A) the GNU General Public License as published by the Free Software | | Foundation; either version 2 of the License, or (at your option) | | any later version. | | | | B) the PHP License as published by the PHP Development Team and | | included in the distribution in the file: LICENSE | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of both licenses referred to here. | | If you did not, or have any questions about PHP licensing, please | | contact co...@ph.... | +----------------------------------------------------------------------+ | Author: Jim Winstead (ji...@ph...) | +----------------------------------------------------------------------+ */ /* $Id: base64.h,v 1.1 2007/02/13 01:49:22 b_lindeijer Exp $ */ #ifndef _RAGE_BASE64_H_ #define _RAGE_BASE64_H_ /** * Encode binary data into base64. */ extern unsigned char* php3_base64_encode(const unsigned char *string, int length, int *ret_length); /** * Decode a base64 string into binary data. */ extern unsigned char* php3_base64_decode(const unsigned char *string, int length, int *ret_length); #endif |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:26
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860 Modified Files: TODO Log Message: Added support for loading current Tiled maps to this old engine version. Index: TODO =================================================================== RCS file: /cvsroot/moeng/BBRpg/TODO,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- TODO 8 Feb 2007 00:03:31 -0000 1.41 +++ TODO 13 Feb 2007 01:49:20 -0000 1.42 @@ -11,7 +11,7 @@ - Walk together so the player has to walk less in the game. - For corpses: draw skeleton and flesh, fade out the flesh. - Improve tha blues -- Make the combat more interesting, maybe use crowbar to fight? +- Make the combat more interesting, maybe use crowbar to fight? - Speed up the game? - Make the map appear more natural? - Improve prisonguardAI |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:26
|
Update of /cvsroot/moeng/BBRpg/data/bitmaps In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/data/bitmaps Added Files: tiles_forest.bmp tiles_obstacle.bmp Log Message: Added support for loading current Tiled maps to this old engine version. --- NEW FILE: tiles_obstacle.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: tiles_forest.bmp --- (This appears to be a binary file; contents omitted.) |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:25
|
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/src/editor Modified Files: editor.cpp editor.h gui_procs.cpp main.cpp Log Message: Added support for loading current Tiled maps to this old engine version. Index: main.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/main.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- main.cpp 23 Oct 2004 11:54:18 -0000 1.10 +++ main.cpp 13 Feb 2007 01:49:22 -0000 1.11 @@ -46,9 +46,25 @@ clean_up(); return 0; } -END_OF_MAIN(); +END_OF_MAIN() + + +void xmlNullLogger(void *ctx, const char *msg, ...) +{ + // Does nothing, that's the whole point of it +} +// Initialize libxml2 and check for potential ABI mismatches between +// compiled version and the shared library actually used. +void initXML() +{ + console.log(CON_LOG, CON_ALWAYS, "Initializing libxml2..."); + xmlInitParser(); + LIBXML_TEST_VERSION; + // Suppress libxml2 error messages + xmlSetGenericErrorFunc(NULL, xmlNullLogger); +} void initialize() { @@ -56,7 +72,7 @@ int i; // Do the libxml binary compatibility check - LIBXML_TEST_VERSION + initXML(); // Initialise Allegro allegro_init(); Index: editor.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- editor.cpp 23 Oct 2004 11:54:18 -0000 1.11 +++ editor.cpp 13 Feb 2007 01:49:22 -0000 1.12 @@ -31,7 +31,7 @@ int debug_mode = 0; FONT* engine_font = NULL; DATAFILE *engine_data = NULL; -list<Object*> selectedObjects; +std::list<Object*> selectedObjects; int selectedObjectType = 0; bool selecting = false; @@ -45,8 +45,8 @@ int selectedObstacle = 15; int selectedLayer = 0; -vector<char*> tileSets; -vector<TileType*> activeTileset; +std::vector<char*> tileSets; +std::vector<TileType*> activeTileset; char map_filename[1024] = ""; char status_message[1024] = ""; @@ -365,11 +365,12 @@ char path_buf[1024] = ""; if (file_select_ex( - "Load XML map... (*.tmx)", path_buf, "tmx", sizeof path_buf, + "Load map... (*.map)", path_buf, "map", sizeof path_buf, MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) )) { + /* xmlDocPtr doc = xmlParseFile(path_buf); if (doc != NULL) { @@ -389,7 +390,9 @@ set_map_changed(false); update_window_title(); } - else { + else + */ + { alert(NULL, "No XML map, trying PACKFILE format...", NULL, "OK", NULL, 13, 0); @@ -426,9 +429,9 @@ if (writer) { xmlTextWriterSetIndent(writer, 1); xmlTextWriterStartDocument(writer, NULL, NULL, NULL); - + currentMap->saveTo(writer); - + xmlTextWriterEndDocument(writer); xmlFreeTextWriter(writer); set_map_changed(false); @@ -529,7 +532,7 @@ { BITMAP *tile_bitmap; PALETTE pal; - vector<TileType*>::iterator i; + std::vector<TileType*>::iterator i; int x = 0; int y = 0; int tile_w = (activeTileset[0]->getBitmap())->w; @@ -683,7 +686,7 @@ int mapWidth = currentMap->getWidth(); int mapHeight = currentMap->getHeight(); TileType *tt; - + // Create bitmap the size of the map BITMAP* temp_bitmap = create_bitmap(mapWidth, mapHeight); @@ -693,7 +696,7 @@ // Paint current map to temporary bitmap for (x = 0; x < temp_bitmap->w; x++) { for (y = 0; y < temp_bitmap->h; y++) { - tt = currentMap->getLayer(0)->getTile(Point(x, y))->getType(); + tt = currentMap->getLayer((unsigned int)0)->getTile(Point(x, y))->getType(); putpixel(temp_bitmap, x, y, tt->getColor()); } } @@ -727,9 +730,9 @@ } xmlTextWriterSetIndent(writer, 1); xmlTextWriterStartDocument(writer, NULL, NULL, NULL); - + currentMap->saveTo(writer); - + xmlTextWriterEndDocument(writer); xmlFreeTextWriter(writer); ustrcpy(map_filename, path_buf); @@ -901,18 +904,18 @@ selectedObjects.push_front(obj); } -void select_objects(list<Object*> objs) +void select_objects(std::list<Object*> objs) { deselect_objects(); - list<Object*>::iterator i; + std::list<Object*>::iterator i; for (i = objs.begin(); i != objs.end(); i++) { (*i)->selected = true; selectedObjects.push_front((*i)); } } -void delete_objects(list<Object*> objs) +void delete_objects(std::list<Object*> objs) { while (objs.size() > 0) { Object* obj = objs.front(); Index: editor.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- editor.h 7 Feb 2007 17:50:31 -0000 1.11 +++ editor.h 13 Feb 2007 01:49:22 -0000 1.12 @@ -27,7 +27,7 @@ extern int debug_mode; extern FONT* engine_font; extern Console console; -extern list<Object*> selectedObjects; +extern std::list<Object*> selectedObjects; extern int selectedObjectType; extern bool selecting; extern int selection_start_x, selection_end_x; @@ -39,8 +39,8 @@ extern int selectedObstacle; extern int selectedLayer; -extern vector<char*> tileSets; -extern vector<TileType*> activeTileset; +extern std::vector<char*> tileSets; +extern std::vector<TileType*> activeTileset; extern int map_edit_mode; @@ -145,8 +145,8 @@ void deselect_objects(); void select_object(Object* obj); -void select_objects(list<Object*> objs); -void delete_objects(list<Object*> objs); +void select_objects(std::list<Object*> objs); +void delete_objects(std::list<Object*> objs); void import_tile_bitmap( const char* filename, Index: gui_procs.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/gui_procs.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gui_procs.cpp 23 Oct 2004 11:54:18 -0000 1.11 +++ gui_procs.cpp 13 Feb 2007 01:49:22 -0000 1.12 @@ -277,7 +277,7 @@ currentMap->drawLayer(buffer, (map_edit_mode == EM_OBSTACLE), currentMap->mapLayers[0]); { - list<Object*>::iterator i; + std::list<Object*>::iterator i; // Iterate through all objects, calling the preRender function for (i = currentMap->objects.begin(); i != currentMap->objects.end(); i++) { callMemberFunction((*i)->tableRef, "preRender"); @@ -452,7 +452,7 @@ { // In obstacle edit mode while (gui_mouse_b() & 1) { - Tile* cursorTile = currentMap->getLayer(0)->getTile(currentMap->screenToTile(Point(gui_mouse_x(), gui_mouse_y()))); + Tile* cursorTile = currentMap->getLayer((unsigned int)0)->getTile(currentMap->screenToTile(Point(gui_mouse_x(), gui_mouse_y()))); if (cursorTile && selectedObstacle != cursorTile->obstacle) { @@ -564,7 +564,7 @@ { // In tile edit mode: clear tile obstacle settings while (gui_mouse_b() & 2) { - Tile* cursorTile = currentMap->getLayer(0)->getTile(currentMap->screenToTile(Point(gui_mouse_x(), gui_mouse_y()))); + Tile* cursorTile = currentMap->getLayer((unsigned int)0)->getTile(currentMap->screenToTile(Point(gui_mouse_x(), gui_mouse_y()))); if (cursorTile && cursorTile->obstacle) { @@ -589,8 +589,8 @@ double new_end_x, new_end_y; selection_end_x = selection_start_x; selection_end_y = selection_start_y; - list<Object*> objects; - list<Object*>::iterator i; + std::list<Object*> objects; + std::list<Object*>::iterator i; select_objects(objects); while (gui_mouse_b() & 2) { |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:25
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/src Modified Files: rpg.cpp rpg.h script.cpp Log Message: Added support for loading current Tiled maps to this old engine version. Index: rpg.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- rpg.h 7 Feb 2007 17:50:31 -0000 1.8 +++ rpg.h 13 Feb 2007 01:49:21 -0000 1.9 @@ -32,7 +32,7 @@ extern int gameClassInstance; extern TileType *selectedTile; -extern list<TiledMap*> maps; +extern std::list<TiledMap*> maps; extern bool game_end; extern bool exclusive_mode; Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- script.cpp 8 Feb 2007 17:51:49 -0000 1.19 +++ script.cpp 13 Feb 2007 01:49:21 -0000 1.20 @@ -542,7 +542,7 @@ lua_newtable(L); - list<Object*>::iterator i; + std::list<Object*>::iterator i; for (i = map->objects.begin(); i != map->objects.end(); i++) { Object *obj = (*i); if (((obj->x + obj->w > x && obj->x <= x) && @@ -568,7 +568,7 @@ lua_newtable(L); - list<Object*>::iterator i; + std::list<Object*>::iterator i; for (i = map->objects.begin(); i != map->objects.end(); i++) { Object *obj = (*i); lua_getref(L, obj->tableRef); @@ -780,7 +780,7 @@ { double loudness; Object* nm; // The noise maker - list<Object*>::iterator i; + std::list<Object*>::iterator i; getLuaArguments(L, "od", &nm, &loudness); @@ -902,7 +902,7 @@ getLuaArguments(L, "iiiiddm", &x, &y, &w, &h, &tx, &ty, &map); if (map) { - list<Object*>::iterator i; + std::list<Object*>::iterator i; // Iterate through all objects, calling the preRender function for (i = map->objects.begin(); i != map->objects.end(); i++) { callMemberFunction((*i)->tableRef, "preRender"); @@ -952,8 +952,12 @@ if (map) { Tile* tile = map->mapLayers[0]->getTile(Point(x, y)); - if (tile && tile->getType()) { - char *tileTypeName = tile->getType()->getName(); + if (tile) { + TileType *type = tile->getType(); + char *tileTypeName = ""; + if (type && type->getName()) { + tileTypeName = type->getName(); + } return putLuaArguments(L, "si", tileTypeName, tile->obstacle); } else { return 0; Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- rpg.cpp 9 Feb 2007 15:29:41 -0000 1.15 +++ rpg.cpp 13 Feb 2007 01:49:21 -0000 1.16 @@ -74,8 +74,25 @@ return 0; } -END_OF_MAIN(); +END_OF_MAIN() + + +void xmlNullLogger(void *ctx, const char *msg, ...) +{ + // Does nothing, that's the whole point of it +} + +// Initialize libxml2 and check for potential ABI mismatches between +// compiled version and the shared library actually used. +void initXML() +{ + console.log(CON_LOG, CON_ALWAYS, "Initializing libxml2..."); + xmlInitParser(); + LIBXML_TEST_VERSION; + // Suppress libxml2 error messages + xmlSetGenericErrorFunc(NULL, xmlNullLogger); +} void init_engine() { @@ -86,6 +103,7 @@ install_timer(); three_finger_flag = 0; set_display_switch_mode(SWITCH_BACKAMNESIA); + initXML(); set_config_file("rpg.cfg"); |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:25
|
Update of /cvsroot/moeng/BBRpg/data/maps In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/data/maps Modified Files: jail.map jakesplace.map leesplace.map restplace.map Added Files: forest.tmx Log Message: Added support for loading current Tiled maps to this old engine version. --- NEW FILE: forest.tmx --- <?xml version="1.0"?> <map version="0.99b" orientation="orthogonal" width="64" height="64" tilewidth="24" tileheight="24"> <tileset name="Forest" firstgid="1" tilewidth="24" tileheight="24"> <image source="../bitmaps/tiles_forest.bmp" trans="ff00ff"/> </tileset> <tileset name="Obstacles" firstgid="122" tilewidth="24" tileheight="24"> <image source="../bitmaps/tiles_obstacle.bmp" trans="ff00ff"/> </tileset> <layer name="Ground" width="64" height="64"> <data encoding="base64" compression="gzip"> H4sIAAAAAAAAAO1awU4cMQydlSjXgjTnnkftqV3ECX4ARNtDVbUgbsAB8f9nMtJGCpHj+NlOmKo5PMHuZhw/+9nJZOZsmqazgYGBgYEBELsN+DDQDxcB+/8s77sD7+uAmwO+HbA32J03wK3GO/5/w4CLgZbj1mLD8V/xdZLpYeV1MfnopxfOBfxTUDYi5+vC+EXpm/Y6KXYg95R/qmFufK4DitOcfc7HzMy1VlA+3wpyz+Uc7SMU72V6W0sRl0S8NHmX5G7FcYE/qhtKCynnnCsX19b5L+EKzDnnf8xhvvZK/fDsrRYuFO4rvy9Oc3v0A00PtMJLR14aoGx/eIe4aJD3TaT3ta6F7wE/ldf9SMDZsK4FeVzQ2HO/PwQ8Kfj/DfgT8Cvgd8BdxYeWqPGP+AzErGZ/5b/uQZ4DXhj+qPaR2pDoIV+HpPzTtb6km8cEJQ15cS1Bem+wxkHay6+E4yTwrv30s2VdPALGoutM9DHfK3vkm6vNjwEnAaeO+aO4zYIxLe8LkXsDKY6F4yTzcr576gA9F/DIPYdY6zlHtA64mKD3tCXfvfiX+MyF763wyl1pXOlcIbVBcabOAeJZgFfeaznnenqr/EvseZwztqpdqw3kbEAbA48+581/UVyvjYGVu0W71mtRe978PeyX1i9Ol5I+ivQ/bRzW5yKtnnFoc6L1p7UOpNDWPhID637Hgz+3b2vRk1Ota86cLXxjnC+F46zcOR+/MNdI70UR7nku0zOTJfvrwbvkY2+t1zRG1WhL/q3sSnLe28fctvYsh9rzS9Y8SyzzMdrnENqceOjAkz+SGw+7vfhbYye1LTnH1syL9Dxqv9qLP1X/+XncXjFHfIaJnv976Qe1Xbsm5YH2S+T8v+SjZX2WrsmSOmjVL0pzWfeiCP9aXtN3P3vx145BOCPa0mhZA8k8Hvx75JIDsn+hfKf2LQh37TkKqlUPSHth79xLa9U6j7T2LPzTd0sk76Yga0cv/Vj53x6A8ufscr+/J/987YvvlqwovVcieUaK8s9ttuJJ8U7nTPl/ajhvzZ9e/DV10orzlsDpcct+D/xbGBp6G4ue8XgFlfIutQBAAAA= </data> <tileproperties/> </layer> <layer name="Upper" width="64" height="64"> <data encoding="base64" compression="gzip"> H4sIAAAAAAAAAO1aPW/cMAzV1qRjgCxNA6jDbR26pVOBTEX//x+qhZQIofCbknzF6QEa7mzTJPVEUpRL2djY2NjY2NjYkPByjD9nK3ECvjP/34ovOPsbbsEHL8b7HpyyfgV0WQ1p7jG+HOPZKeN/4I7V/otwTePPNfshar/1OUDEB5RfR6+pR+N9P7rf1pjRg9PfKm80l+oxvg2WKaG3/3WQnAysHBiBfv6iPBrJg3qMr2U9F7KQYnIUVi58Osb9MT5P0MEKSz3iRS1vXND4cEH3w/ipyG41xBOSn/Ff8z9Xj4wEl+co7mk5kYpZ3jwqvX8GPLVdxP5o/JvBfQqe2s56b9Tmxvmnf+NM7s9As+2uyDFhFecBK+3HfOZy0CrOA1bZ3+8ta3nPEXis4DyGZZ3inAb89dZQq3ltgTVGRfKgRcYZiPCd0t27n7gW+yN5idK9Ft860Oyf3V/KxDlJdysPtLiuzUvfm/AiWo80SLrXInMA6hlvX5FClAu/g89B3NdyksQBbd5XxNFa3nLXrJwF8iP53MvLTE/I6+vsmtMQiUmZeBiNgbNq0qg+UR9Yudb3MGbVpJmYPLOeWFGrZGxviNYTFkT4DvZo3By139Lsj/pXOgP0vIvzw6g+/Iia3CqXg+Zjrm4e0X+nODpCtjXnWXjMraPsGpA4mo0rAK3O0GyInKVbwXGUkwt9N08fPmu/9Hx2nXrth/s979Xs13gmPV9Lbp1y64qzD9Z0e6/l3KeBi99W7mb5gwF7SK0eq4Xf51BxzaqDp/8PyPIHw1uPWM+zZvZ+LedA0nkAnnNvPcLZ1XNglf3cex6EezJ7Lolb2AejciUFas1I+ypsf+TcNzOXcM4f6et7YP2+LLL/GtXfk2qINncZ/1i/i/Lan517zDUuh0o1BPBH67FZ84jX/kw91ceZWt7XJ7blIlzH+o7Yg3ljH6WTBGtuwbZQOj0S1zy64LiDR6bf1Ot8Vz7OSaSvS+lUhWu9LhRmf9v03P1H8XUmsC7XcNZN8fWWUMs5ft/Y2JiDv7mRzjkAQAAA </data> <tileproperties/> </layer> <layer name="Obstacle" width="64" height="64"> <data encoding="base64" compression="gzip"> H4sIAAAAAAAAAO1XS7LDMAzK9d+t3zaTsRVAyJ/GzHTRxkIgy4p7XQcHBwcHBwcR/h6fr+Dpu/X5VfR8fqUGiDemFjv1D6Mv8oScnxVroGq7xyA+V62BqondW7UPqvsps/eKllYMenYqapD1n8mZ9eeowQz/LR5HH2Y1jMbMHnbGZ/M6+ygTvzPc82g3uM6AOodmw30fqL7bVLzDXfuwq383VE/oWheq/a+IETN79r0AWVOpcQf/lfln+Hf9N3LlHxXb4xhVCweP03/E666Dq44V/ivvIL2cKhz7cY/J3qsq1iNcGd4Wh6oDiXXOUbV3n2uz/plY9+zszS6Go/Vd1cTkdb2zomfo7HbOYlW7mvMtBzInK/VEmkbmQ9Zl0ZtHjhwoH9vz7pnc0+DgZs7+2zOn73ueCm5XH1fsy5P/nsfJi/Q7y7Wj/+zsruyB1vl3wulfiZ3B28sR/fYWv4J/JS/yXkM1tr5nMMu/Et/iykLpK5cXNsYxAyMehrtqVr7lyuaLari6f3UN2jdsnXf1H3HsAnQesP3s0lUNtqcRPqeu6lzuM+rUlPHv7p9Z/tEz+Xw+07/yTovuJhn/rBZWA6Pp6vz2FofURqkfokPZS1Rzaz3LFz1ntGS8sppHnFdWi9u7quUr+LL3X8Y/++vSTgBAAAA= </data> <tileproperties/> </layer> </map> Index: jakesplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/jakesplace.map,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 Binary files /tmp/cvseCALuK and /tmp/cvsSi0PZj differ Index: leesplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/leesplace.map,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 Binary files /tmp/cvsPcq9DP and /tmp/cvsKPB6hp differ Index: jail.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/jail.map,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 Binary files /tmp/cvsH7nQPV and /tmp/cvspFse0v differ Index: restplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/restplace.map,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 Binary files /tmp/cvs55yzMf and /tmp/cvsPl06rQ differ |
From: Bjørn L. <b_l...@us...> - 2007-02-13 01:49:25
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27860/data/scripts Modified Files: BBRpg.lua MainMenu.lua Added Files: Forest.lua Log Message: Added support for loading current Tiled maps to this old engine version. --- NEW FILE: Forest.lua --- -- -- The forest map (for testing of Tiled maps) -- import("Map.lua") Forest = Map:subclass { name = "Forest"; init = function(self) Map.init(self, "forest.tmx") end; defaultproperties = { } } Index: MainMenu.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/MainMenu.lua,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- MainMenu.lua 13 Jan 2004 16:32:35 -0000 1.34 +++ MainMenu.lua 13 Feb 2007 01:49:21 -0000 1.35 @@ -24,7 +24,7 @@ ActionCallFunction(elwood.addToInventory, elwood, cityMap.walkieTalkie), ActionSetPosition(elwood, 94, 73, DIR_UP, cityMap), -- ActionSetPosition(elwood, 37, 12, DIR_UP, cityMap), --- ActionSetPosition(elwood, 34, 65, DIR_UP, cellsMap), +-- ActionSetPosition(elwood, 10, 20, DIR_UP, forestMap), ActionSetPosition(jake, 93, 73, DIR_UP, cityMap), ActionSetCameraTarget(elwood, false), ActionSetPosition(copcar, 88, 77), Index: BBRpg.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/BBRpg.lua,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- BBRpg.lua 8 Jul 2004 21:40:45 -0000 1.28 +++ BBRpg.lua 13 Feb 2007 01:49:21 -0000 1.29 @@ -19,6 +19,8 @@ m_import_tile_bmp("jail_tiles.bmp", 24, 24, 0) m_import_tile_bmp("tiles_subcity.bmp", 24, 24, 0) m_import_tile_bmp("tiles_sewers.bmp", 24, 24, 0) + --m_import_tile_bmp("tiles_forest.bmp", 24, 24, 0) + --m_import_tile_bmp("tiles_obstacle.bmp", 24, 24, 0) -- Load the maps cityMap = City() @@ -28,6 +30,7 @@ jakesMap = JakesPlace() cellsMap = Cells() restMap = RestPlace() + --forestMap = Forest() -- Links between portals cityMap.jakePortal:linkToPortal(jakesMap.doorPortal) |
From: Bjørn L. <b_l...@us...> - 2007-02-09 15:29:46
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv536 Modified Files: rpg.cpp Log Message: Changed the engine back to using gui.dat now that the corruption problem has been solved. Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- rpg.cpp 8 Feb 2007 00:03:32 -0000 1.14 +++ rpg.cpp 9 Feb 2007 15:29:41 -0000 1.15 @@ -166,10 +166,10 @@ console.log(CON_LOG, CON_ALWAYS, "Creating tile repository..."); tileRepository = new TileRepository(); - console.log(CON_LOG, CON_ALWAYS, "Loading engine.dat..."); - engine_data = load_datafile("engine.dat"); + console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); + engine_data = load_datafile("gui.dat"); if (!engine_data) { - console.log(CON_QUIT, CON_ALWAYS, "Error while loading: engine.dat"); + console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); } // Set font to use |
From: Bjørn L. <b_l...@us...> - 2007-02-09 15:29:41
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv510/data/scripts Modified Files: BBRpgLang.lua Jail.lua Log Message: Changed the engine back to using gui.dat now that the corruption problem has been solved. Index: BBRpgLang.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/BBRpgLang.lua,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- BBRpgLang.lua 8 Jul 2004 21:40:45 -0000 1.35 +++ BBRpgLang.lua 9 Feb 2007 15:29:31 -0000 1.36 @@ -320,7 +320,7 @@ {{"{PLAYER}", "It's a washstand."}}, }, Toilet = { - {{"{PLAYER}", "It's a toilet. Dawm, it's dirty."}}, + {{"{PLAYER}", "It's a toilet. Damn, it's dirty."}}, }, Clock = { {{"{PLAYER}", "It's a clock."}}, Index: Jail.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Jail.lua,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Jail.lua 13 Apr 2004 12:26:08 -0000 1.8 +++ Jail.lua 9 Feb 2007 15:29:31 -0000 1.9 @@ -28,8 +28,8 @@ self:spawn(ElecDoor, 14, 35); self:spawn(ElecDoor, 16, 35); self:spawn(ElecDoor, 18, 35); - obj = self:spawn(ElecDoor, 47, 13); obj.isLocked = true - obj = self:spawn(ElecDoor, 44, 49); obj.isLocked = true + obj = self:spawn(ElecDoor, 47, 13); obj.isLocked = true + obj = self:spawn(ElecDoor, 44, 49); obj.isLocked = true obj = self:spawn(ElecDoor, 54, 49); obj.isLocked = true obj = self:spawn(ElecDoor, 37, 35); obj.isLocked = true obj = self:spawn(ElecDoor, 25, 35); obj.isLocked = true |
From: Bjørn L. <b_l...@us...> - 2007-02-09 15:29:35
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv510 Removed Files: engine.dat Log Message: Changed the engine back to using gui.dat now that the corruption problem has been solved. --- engine.dat DELETED --- |
From: Bjørn L. <b_l...@us...> - 2007-02-08 18:36:12
|
Update of /cvsroot/moeng/CVSROOT In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv10554 Modified Files: loginfo Log Message: Changed to unified diff. Index: loginfo =================================================================== RCS file: /cvsroot/moeng/CVSROOT/loginfo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** loginfo 11 Dec 2003 01:26:13 -0000 1.2 --- loginfo 8 Feb 2007 18:36:07 -0000 1.3 *************** *** 25,27 **** # or #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} moe...@li... --- 25,27 ---- # or #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail -u %{sVv} moe...@li... |
From: Bjørn L. <b_l...@us...> - 2007-02-08 17:52:03
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24535/shared Modified Files: tiled_map.cpp tiled_map.h Log Message: Added some sanity checks to prevent crashing and adapted three for loops to Lua 5.1. Probably a lot more will need fixing though. Index: tiled_map.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tiled_map.cpp 23 Oct 2004 11:54:19 -0000 1.10 --- tiled_map.cpp 8 Feb 2007 17:51:50 -0000 1.11 *************** *** 21,25 **** #include <libxml/xmlreader.h> ! // Vector class ============================================================== --- 21,28 ---- #include <libxml/xmlreader.h> ! inline int clamp(int a, int min, int max) ! { ! return (a < min) ? min : ((a > max) ? max : a); ! } // Vector class ============================================================== *************** *** 70,74 **** return result; } ! Vector Vector::operator-(const Vector &v) { --- 73,77 ---- return result; } ! Vector Vector::operator-(const Vector &v) { *************** *** 149,156 **** // Tile class ================================================================ ! Tile::Tile() { - tileType = NULL; - obstacle = 0; } --- 152,159 ---- // Tile class ================================================================ ! Tile::Tile(): ! tileType(NULL), ! obstacle(0) { } *************** *** 169,178 **** { xmlTextWriterStartElement(writer, BAD_CAST "tile"); ! if (tileType) { xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tileType->getName()); } ! if (obstacle) { char obs[5]; --- 172,181 ---- { xmlTextWriterStartElement(writer, BAD_CAST "tile"); ! if (tileType) { xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST tileType->getName()); } ! if (obstacle) { char obs[5]; *************** *** 185,189 **** BAD_CAST "obstacle", BAD_CAST obs); } ! xmlTextWriterEndElement(writer); } --- 188,192 ---- BAD_CAST "obstacle", BAD_CAST obs); } ! xmlTextWriterEndElement(writer); } *************** *** 404,408 **** map<const char*, TileType*, ltstr>::iterator found = tileTypes.find(tileName); ! if (found != tileTypes.end()) { return (*found).second; --- 407,411 ---- map<const char*, TileType*, ltstr>::iterator found = tileTypes.find(tileName); ! if (found != tileTypes.end()) { return (*found).second; *************** *** 535,539 **** { char strbuf[16]; ! xmlTextWriterStartElement(writer, BAD_CAST "layer"); --- 538,542 ---- { char strbuf[16]; ! xmlTextWriterStartElement(writer, BAD_CAST "layer"); *************** *** 569,573 **** { xmlChar *prop; ! // Load the map header prop = xmlGetProp(cur, BAD_CAST "width"); --- 572,576 ---- { xmlChar *prop; ! // Load the map header prop = xmlGetProp(cur, BAD_CAST "width"); *************** *** 577,581 **** int h = atoi((char*)prop); xmlFree(prop); ! resizeTo(w, h); --- 580,584 ---- int h = atoi((char*)prop); xmlFree(prop); ! resizeTo(w, h); *************** *** 583,587 **** int x = 0; int y = 0; ! // Load the tile data while (cur != NULL) { --- 586,590 ---- int x = 0; int y = 0; ! // Load the tile data while (cur != NULL) { *************** *** 590,599 **** x++; if (x == width) {x = 0; y++;} ! } cur = cur->next; } } ! Tile *TiledMapLayer::getTile(Point tile) { if (tile.x < 0 || tile.x >= width || --- 593,602 ---- x++; if (x == width) {x = 0; y++;} ! } cur = cur->next; } } ! Tile *TiledMapLayer::getTile(const Point &tile) { if (tile.x < 0 || tile.x >= width || *************** *** 638,643 **** if (modify) { Point mapSize = getMapSize(); ! cam.x = MAX(0, MIN(mapSize.x - rect.w, cam.x)); ! cam.y = MAX(0, MIN(mapSize.y - rect.h, cam.y)); } --- 641,646 ---- if (modify) { Point mapSize = getMapSize(); ! cam.x = clamp(cam.x, 0, mapSize.x - rect.w); ! cam.y = clamp(cam.y, 0, mapSize.y - rect.h); } *************** *** 679,683 **** pack_fputs((*i)->className, file); pack_fputs("\n", file); ! } // Extra newline fixes last tile not loaded. --- 682,686 ---- pack_fputs((*i)->className, file); pack_fputs("\n", file); ! } // Extra newline fixes last tile not loaded. *************** *** 701,711 **** for (i = objects.begin(); i != objects.end(); i++) { xmlTextWriterStartElement(writer, BAD_CAST "object"); ! snprintf(strbuf, 16, "%d", int(TILES_W * (*i)->x)); xmlTextWriterWriteAttribute(writer, BAD_CAST "x", BAD_CAST strbuf); ! snprintf(strbuf, 16, "%d", int(TILES_H * (*i)->y)); xmlTextWriterWriteAttribute(writer, BAD_CAST "y", BAD_CAST strbuf); ! snprintf(strbuf, 64, "%d", int(TILES_W * (*i)->x)); xmlTextWriterWriteAttribute(writer, BAD_CAST "type", --- 704,714 ---- for (i = objects.begin(); i != objects.end(); i++) { xmlTextWriterStartElement(writer, BAD_CAST "object"); ! snprintf(strbuf, 16, "%d", int(TILES_W * (*i)->x)); xmlTextWriterWriteAttribute(writer, BAD_CAST "x", BAD_CAST strbuf); ! snprintf(strbuf, 16, "%d", int(TILES_H * (*i)->y)); xmlTextWriterWriteAttribute(writer, BAD_CAST "y", BAD_CAST strbuf); ! snprintf(strbuf, 64, "%d", int(TILES_W * (*i)->x)); xmlTextWriterWriteAttribute(writer, BAD_CAST "type", *************** *** 713,717 **** xmlTextWriterEndElement(writer); ! } xmlTextWriterEndElement(writer); --- 716,720 ---- xmlTextWriterEndElement(writer); ! } xmlTextWriterEndElement(writer); *************** *** 741,748 **** fclose(f); ! xmlDocPtr doc = xmlReadMemory(map_string, size, NULL, NULL, 0); delete[] map_string; ! if (doc) { console.log(CON_LOG, CON_VDEBUG, "- Looking for root node"); --- 744,751 ---- fclose(f); ! xmlDocPtr doc = xmlReadMemory(map_string, size, NULL, NULL, 0); delete[] map_string; ! if (doc) { console.log(CON_LOG, CON_VDEBUG, "- Looking for root node"); *************** *** 754,758 **** return 1; } ! console.log(CON_LOG, CON_VDEBUG, "- Loading map from XML tree"); loadFrom(cur, tileRepository); --- 757,761 ---- return 1; } ! console.log(CON_LOG, CON_VDEBUG, "- Loading map from XML tree"); loadFrom(cur, tileRepository); *************** *** 768,777 **** return 1; } ! console.log(CON_LOG, CON_VDEBUG, "- Loading map from packfile"); this->loadFrom(file, tileRepository); pack_fclose(file); } ! return 0; } --- 771,780 ---- return 1; } ! console.log(CON_LOG, CON_VDEBUG, "- Loading map from packfile"); this->loadFrom(file, tileRepository); pack_fclose(file); } ! return 0; } *************** *** 809,813 **** double(y) / TILES_H, className); ! delete[] className; } --- 812,816 ---- double(y) / TILES_H, className); ! delete[] className; } *************** *** 822,826 **** int layerNr = 0; xmlChar *prop; ! removeObjects(); --- 825,829 ---- int layerNr = 0; xmlChar *prop; ! removeObjects(); *************** *** 829,833 **** cur = cur->xmlChildrenNode; ! while (cur != NULL) { if (xmlStrEqual(cur->name, BAD_CAST "layer")) { --- 832,836 ---- cur = cur->xmlChildrenNode; ! while (cur != NULL) { if (xmlStrEqual(cur->name, BAD_CAST "layer")) { *************** *** 846,853 **** int y = atoi((char*)prop); xmlFree(prop); ! // Spawn the object prop = xmlGetProp(cur, BAD_CAST "type"); ! console.log(CON_LOG, CON_VDEBUG, "- Adding %s at (%d, %d)", (char*)prop, x, y); --- 849,856 ---- int y = atoi((char*)prop); xmlFree(prop); ! // Spawn the object prop = xmlGetProp(cur, BAD_CAST "type"); ! console.log(CON_LOG, CON_VDEBUG, "- Adding %s at (%d, %d)", (char*)prop, x, y); *************** *** 1109,1119 **** cameraScreenRect.y + cameraScreenRect.h - 1)); ! start.x = MAX(0, MIN(width - 1, start.x)); ! start.y = MAX(0, MIN(height - 1, start.y)); ! for (int y = start.y; y <= end.y; y++) { ! for (int x = start.x; x <= end.x; x++) { tempTile = layer->getTile(Point(x, y)); tempTileType = tempTile->getType(); if (tempTileType) { --- 1112,1125 ---- cameraScreenRect.y + cameraScreenRect.h - 1)); ! start.x = clamp(start.x, 0, width - 1); ! start.y = clamp(start.y, 0, height - 1); ! for (int y = start.y; y <= end.y; y++) ! { ! for (int x = start.x; x <= end.x; x++) ! { tempTile = layer->getTile(Point(x, y)); + if (!tempTile) continue; tempTileType = tempTile->getType(); if (tempTileType) { *************** *** 1168,1172 **** line(dest, tx + 2, ty + th - 3, tx + tw - 3, ty + th - 3, makecol(255,0,0)); ! line(dest, tx + 3, ty + th - 2, tx + tw - 2, ty + th - 2, makecol(0,0,0)); } --- 1174,1178 ---- line(dest, tx + 2, ty + th - 3, tx + tw - 3, ty + th - 3, makecol(255,0,0)); ! line(dest, tx + 3, ty + th - 2, tx + tw - 2, ty + th - 2, makecol(0,0,0)); } *************** *** 1199,1207 **** Point SquareMap::mapToTile(Point mapCoords) { ! return Point( ! MIN(width - 1, MAX(0, mapCoords.x / tileWidth)), ! MIN(height - 1, MAX(0, mapCoords.y / tileHeight)), ! mapCoords.z ! ); } --- 1205,1211 ---- Point SquareMap::mapToTile(Point mapCoords) { ! return Point(clamp(mapCoords.x / tileWidth, 0, width - 1), ! clamp(mapCoords.y / tileHeight, 0, height - 1), ! mapCoords.z); } Index: tiled_map.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tiled_map.h 23 Oct 2004 11:54:19 -0000 1.7 --- tiled_map.h 8 Feb 2007 17:51:50 -0000 1.8 *************** *** 183,187 **** float getOpacity(); ! Tile* getTile(Point tileCoords); private: --- 183,187 ---- float getOpacity(); ! Tile* getTile(const Point &tileCoords); private: |
From: Bjørn L. <b_l...@us...> - 2007-02-08 17:51:59
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24535 Modified Files: script.cpp Log Message: Added some sanity checks to prevent crashing and adapted three for loops to Lua 5.1. Probably a lot more will need fixing though. Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** script.cpp 7 Feb 2007 17:50:31 -0000 1.18 --- script.cpp 8 Feb 2007 17:51:49 -0000 1.19 *************** *** 834,837 **** --- 834,838 ---- if (found_bitmap) { + console.log(CON_LOG, CON_ALWAYS, "Loaded bitmap %s", name); return putLuaArguments(L, "b", found_bitmap); } else { *************** *** 952,956 **** if (map) { Tile* tile = map->mapLayers[0]->getTile(Point(x, y)); ! if (tile) { char *tileTypeName = tile->getType()->getName(); return putLuaArguments(L, "si", tileTypeName, tile->obstacle); --- 953,957 ---- if (map) { Tile* tile = map->mapLayers[0]->getTile(Point(x, y)); ! if (tile && tile->getType()) { char *tileTypeName = tile->getType()->getName(); return putLuaArguments(L, "si", tileTypeName, tile->obstacle); *************** *** 977,981 **** TileType *type = tileRepository->getTileType(tileName); Tile *tile = map->mapLayers[0]->getTile(Point(x, y)); ! if (tile) tile->setType(type); return 0; } --- 978,982 ---- TileType *type = tileRepository->getTileType(tileName); Tile *tile = map->mapLayers[0]->getTile(Point(x, y)); ! if (tile) tile->setType(type); return 0; } *************** *** 1017,1021 **** int object_gettable(lua_State *L) { ! if (lua_isstring(L, -1)) { const char *index = lua_tostring(L, -1); // table key --- 1018,1022 ---- int object_gettable(lua_State *L) { ! if (lua_isstring(L, -1)) { const char *index = lua_tostring(L, -1); // table key |
From: Bjørn L. <b_l...@us...> - 2007-02-08 17:51:44
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24515 Modified Files: AdvAIRandom.lua Enemy.lua Log Message: Added some sanity checks to prevent crashing and adapted three for loops to Lua 5.1. Probably a lot more will need fixing though. Index: Enemy.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Enemy.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Enemy.lua 1 Jan 2004 17:39:40 -0000 1.5 --- Enemy.lua 8 Feb 2007 17:51:38 -0000 1.6 *************** *** 1,81 **** ! ! import("Character.lua") ! ! ! Enemy = Character:subclass ! { ! name = "Enemy"; ! ! --== Commands ==-- ! ! attack = function(self) ! if (self.bAttacking == false and self.walking == 0 and self.charging == 0) then ! self:log("attacking.") ! self.bAttacking = true ! ! -- See if there is something at the attacked location ! local ax, ay = self.x, self.y ! if (self.dir == DIR_LEFT) then ax = ax - 1 end ! if (self.dir == DIR_RIGHT) then ax = ax + 1 end ! if (self.dir == DIR_UP) then ay = ay - 1 end ! if (self.dir == DIR_DOWN) then ay = ay + 1 end ! ! local attackedObjs = m_get_objects_at(ax, ay, self.map) ! local damage = self.attackMinDam + math.random(self.attackMaxDam - self.attackMinDam) ! ! -- Deal damage ! for index, object in attackedObjs do ! if (object:instanceOf(Actor)) then ! object:takeDamage(damage, self) ! end ! end ! ! -- Enable next attack after attackTime + chargeTime game ticks ! ActionController:addSequence{ ! ActionWait(self.attackTime), ! ActionSetVariable(self, "bAttacking", false), ! ActionSetVariable(self, "charging", self.chargeTime), ! } ! end ! end; ! ! ! --== Notifications ==-- ! ! died = function(self, killer, damageType, location) ! -- Let character adapt to dead status ! Character.died(self, killer, damageType, location) ! ! -- Give players experience ! if (killer and killer:instanceOf(Player)) then ! killer:gainExperience(self.experience) ! end ! ! -- Fade away ! ActionController:addSequence({ ! ActionWait(100), ! ActionSetVariable(self, "draw_mode", DM_TRANS), ! ActionTweenVariable(self, "alpha", 200, 0), ! ActionDestroyObject(self), ! }) ! ! -- Enemies don't need tick when dead ! self.tick_time = 0 ! end; ! ! ! defaultproperties = { ! experience = 0, ! attackTime = 50, ! chargeTime = 100, ! charging = 0, ! attackMinDam = 0, ! attackMaxDam = 5, ! ! bAttacking = false, ! ! deathBitmap = nil, ! ! controllerClass = AIController, ! }; ! } --- 1,81 ---- ! ! import("Character.lua") ! ! ! Enemy = Character:subclass ! { ! name = "Enemy"; ! ! --== Commands ==-- ! ! attack = function(self) ! if (self.bAttacking == false and self.walking == 0 and self.charging == 0) then ! self:log("attacking.") ! self.bAttacking = true ! ! -- See if there is something at the attacked location ! local ax, ay = self.x, self.y ! if (self.dir == DIR_LEFT) then ax = ax - 1 end ! if (self.dir == DIR_RIGHT) then ax = ax + 1 end ! if (self.dir == DIR_UP) then ay = ay - 1 end ! if (self.dir == DIR_DOWN) then ay = ay + 1 end ! ! local attackedObjs = m_get_objects_at(ax, ay, self.map) ! local damage = self.attackMinDam + math.random(self.attackMaxDam - self.attackMinDam) ! ! -- Deal damage ! for index, object in ipairs(attackedObjs) do ! if (object:instanceOf(Actor)) then ! object:takeDamage(damage, self) ! end ! end ! ! -- Enable next attack after attackTime + chargeTime game ticks ! ActionController:addSequence{ ! ActionWait(self.attackTime), ! ActionSetVariable(self, "bAttacking", false), ! ActionSetVariable(self, "charging", self.chargeTime), ! } ! end ! end; ! ! ! --== Notifications ==-- ! ! died = function(self, killer, damageType, location) ! -- Let character adapt to dead status ! Character.died(self, killer, damageType, location) ! ! -- Give players experience ! if (killer and killer:instanceOf(Player)) then ! killer:gainExperience(self.experience) ! end ! ! -- Fade away ! ActionController:addSequence({ ! ActionWait(100), ! ActionSetVariable(self, "draw_mode", DM_TRANS), ! ActionTweenVariable(self, "alpha", 200, 0), ! ActionDestroyObject(self), ! }) ! ! -- Enemies don't need tick when dead ! self.tick_time = 0 ! end; ! ! ! defaultproperties = { ! experience = 0, ! attackTime = 50, ! chargeTime = 100, ! charging = 0, ! attackMinDam = 0, ! attackMaxDam = 5, ! ! bAttacking = false, ! ! deathBitmap = nil, ! ! controllerClass = AIController, ! }; ! } Index: AdvAIRandom.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/AdvAIRandom.lua,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AdvAIRandom.lua 13 Jan 2004 16:32:35 -0000 1.7 --- AdvAIRandom.lua 8 Feb 2007 17:51:38 -0000 1.8 *************** *** 77,86 **** goingDirection = function(self, dir, notdir) local dirs = self.pawn:freeTilesAround() ! for v in dirs do if (v == dir) then return dir end; end; ! for v in dirs do if (v ~= notdir) then return v; --- 77,86 ---- goingDirection = function(self, dir, notdir) local dirs = self.pawn:freeTilesAround() ! for k,v in pairs(dirs) do if (v == dir) then return dir end; end; ! for k,v in pairs(dirs) do if (v ~= notdir) then return v; |
From: Bjørn L. <b_l...@us...> - 2007-02-08 00:03:37
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6800 Modified Files: engine.dat README TODO Log Message: Added font_sansserif_8 to engine.dat. Index: README =================================================================== RCS file: /cvsroot/moeng/BBRpg/README,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** README 27 Jan 2007 02:14:47 -0000 1.9 --- README 8 Feb 2007 00:03:31 -0000 1.10 *************** *** 89,96 **** --- 89,98 ---- 1.1.1 - X January, 2006 (Final release) + * Upgraded to Lua 5.1 * First proper source release * A lot of small fixes and improvements + 1.1.0 - 10 January, 2004 (First post-compo release) Index: TODO =================================================================== RCS file: /cvsroot/moeng/BBRpg/TODO,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** TODO 8 Feb 2004 14:53:57 -0000 1.40 --- TODO 8 Feb 2007 00:03:31 -0000 1.41 *************** *** 23,26 **** --- 23,27 ---- ? Fix brother still lying in bed when he slept - Corpses should not be obstacles in most of the cases + - Fix "this door is locked" remark after door has been opened Georg: Index: engine.dat =================================================================== RCS file: /cvsroot/moeng/BBRpg/engine.dat,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvscvdjke and /tmp/cvssiPHW7 differ |
From: Bjørn L. <b_l...@us...> - 2007-02-08 00:03:37
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6800/src Modified Files: rpg.cpp Log Message: Added font_sansserif_8 to engine.dat. Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** rpg.cpp 7 Feb 2007 18:26:25 -0000 1.13 --- rpg.cpp 8 Feb 2007 00:03:32 -0000 1.14 *************** *** 175,179 **** // Set font to use DATAFILE *temp = find_datafile_object(engine_data, "SmallFont"); ! if (temp) {engine_font = ((FONT *)temp->dat);} console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); --- 175,183 ---- // Set font to use DATAFILE *temp = find_datafile_object(engine_data, "SmallFont"); ! if (temp) { ! engine_font = ((FONT *)temp->dat); ! } else { ! console.log(CON_LOG, CON_ALWAYS, "Warning: SmallFont not found!"); ! } console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); |
From: Bjørn L. <b_l...@us...> - 2007-02-08 00:03:37
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6800/data/scripts Modified Files: BBRpgLangDutch.lua Log Message: Added font_sansserif_8 to engine.dat. Index: BBRpgLangDutch.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/BBRpgLangDutch.lua,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BBRpgLangDutch.lua 8 Jul 2004 21:40:45 -0000 1.10 --- BBRpgLangDutch.lua 8 Feb 2007 00:03:31 -0000 1.11 *************** *** 201,205 **** {"Jake", "Goed idee."}, {"Elw00t", "Waarom beginnen we niet met zijn drieen een band?"}, ! }, NotYetFightGuards = { {"{PLAYER}","Daar binnen zitten gevangenisbewaarders. Voordat ik hier terugkom kan ik maar beter zorgen dat ik sterk genoeg ben om ze te verslaan."}, --- 201,205 ---- {"Jake", "Goed idee."}, {"Elw00t", "Waarom beginnen we niet met zijn drieen een band?"}, ! }, NotYetFightGuards = { {"{PLAYER}","Daar binnen zitten gevangenisbewaarders. Voordat ik hier terugkom kan ik maar beter zorgen dat ik sterk genoeg ben om ze te verslaan."}, |
From: Bjørn L. <b_l...@us...> - 2007-02-07 18:27:34
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25565 Modified Files: rpg.cbp Log Message: Changes to Code::Blocks project file. Index: rpg.cbp =================================================================== RCS file: /cvsroot/moeng/BBRpg/rpg.cbp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rpg.cbp 7 Feb 2007 17:50:31 -0000 1.1 --- rpg.cbp 7 Feb 2007 18:27:30 -0000 1.2 *************** *** 6,12 **** --- 6,20 ---- <Option title="Win32 Application"/> <Option makefile="Makefile"/> + <Option makefile_is_custom="0"/> + <Option compiler="0"/> <Build> <Target title="default"> + <Option output="C:\blindeijer\Projects\BBRpg\rpg.exe"/> + <Option working_dir="."/> + <Option object_output=".objs"/> + <Option deps_output=".deps"/> <Option type="0"/> + <Option compiler="0"/> + <Option projectResourceIncludeDirsRelation="0"/> </Target> </Build> *************** *** 15,19 **** --- 23,126 ---- <Add library="user32"/> <Add library="kernel32"/> + <Add library="alleg"/> + <Add library="lua5.1"/> + <Add library="xml2.dll"/> </Linker> + <Unit filename="src\canvas.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\canvas.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\common.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\engine.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\engine.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\rpg.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\rpg.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\script.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\script.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\console.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\console.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\module.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\module.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\object.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\object.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\tiled_map.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\shared\tiled_map.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> + <Unit filename="src\sound.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> + <Unit filename="src\sound.h"> + <Option compilerVar=""/> + <Option compile="0"/> + <Option link="0"/> + <Option target="default"/> + </Unit> </Project> </CodeBlocks_project_file> |
From: Bjørn L. <b_l...@us...> - 2007-02-07 18:26:42
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25122 Added Files: engine.dat Log Message: Changed engine to use minimal engine.dat instead of gui.dat. --- NEW FILE: engine.dat --- (This appears to be a binary file; contents omitted.) |
From: Bjørn L. <b_l...@us...> - 2007-02-07 18:26:42
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25122/src Modified Files: rpg.cpp Log Message: Changed engine to use minimal engine.dat instead of gui.dat. Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** rpg.cpp 23 Oct 2004 11:54:18 -0000 1.12 --- rpg.cpp 7 Feb 2007 18:26:25 -0000 1.13 *************** *** 167,174 **** tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! engine_data = load_datafile("gui.dat"); if (!engine_data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); } --- 167,174 ---- tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading engine.dat..."); ! engine_data = load_datafile("engine.dat"); if (!engine_data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: engine.dat"); } |
From: Bjørn L. <b_l...@us...> - 2007-02-07 17:50:50
|
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9875/src/editor Modified Files: aphoton.cpp editor.h gui_procs.h script.cpp Log Message: Converted files to use UNIX newlines and added Code::Blocks project file. Index: editor.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** editor.h 23 Oct 2004 11:54:18 -0000 1.10 --- editor.h 7 Feb 2007 17:50:31 -0000 1.11 *************** *** 1,164 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003 Bjørn Lindeijer ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! */ ! ! #ifndef INCLUDED_EDITOR ! ! #include <allegro.h> ! #include <vector> ! #include "../shared/tiled_map.h" ! #include "../shared/console.h" ! #include "../shared/object.h" ! #include "../shared/module.h" ! ! ! #define PROGRAM_VERSION_STRING "RPG Edit III 0.9.2" ! ! ! // Global variables ! ! extern int debug_mode; ! extern FONT* engine_font; ! extern Console console; ! extern list<Object*> selectedObjects; ! extern int selectedObjectType; ! extern bool selecting; ! extern int selection_start_x, selection_end_x; ! extern int selection_start_y, selection_end_y; ! ! extern TiledMap* currentMap; ! extern TileType* selectedTile; ! extern int selectedTileset; ! extern int selectedObstacle; ! extern int selectedLayer; ! ! extern vector<char*> tileSets; ! extern vector<TileType*> activeTileset; ! ! extern int map_edit_mode; ! ! extern bool mapChanged; ! extern bool showTileGrid; ! extern bool snapToGrid; ! ! extern int selectedColor[6]; ! ! extern char map_filename[1024]; ! extern char status_message[1024]; ! extern char status_mapinfo[1024]; ! ! extern DIALOG main_dlg[]; ! extern DIALOG about_dlg[]; ! extern DIALOG import_tileset_dlg[]; ! extern DIALOG export_tileset_dlg[]; ! extern DIALOG resizemap_dlg[]; ! extern DIALOG newmap_dlg[]; ! extern DIALOG edit_tile_layer[]; ! extern DIALOG edit_obstacle_layer[]; ! extern DIALOG edit_objects_layer[]; ! ! extern MENU menu_file[]; ! extern MENU menu_main[]; ! extern MENU menu_edit[]; ! extern MENU menu_help[]; ! ! ! // Slider types (R, G, B, and H, S, V) ! ! #define S_R 0 ! #define S_G 1 ! #define S_B 2 ! #define S_H 3 ! #define S_S 4 ! #define S_V 5 ! ! #define S_C 6 ! ! ! // Map edit modes ! ! #define EM_TILE 0 ! #define EM_OBSTACLE 1 ! #define EM_OBJECTS 2 ! ! ! // Dialogs ! ! #define MAIN_START_OF_NULL 12 ! #define NEWMAP_OK 9 ! #define IMPORT_TILESET_OK 7 ! #define EXPORT_TILESET_OK 5 ! #define RESIZEMAP_OK 13 ! ! #define D_MAP main_dlg[3] ! #define D_SCROLL_VER main_dlg[4] ! #define D_SCROLL_HOR main_dlg[5] ! #define D_AUTOTEXT_STATUS main_dlg[8] ! #define D_AUTOTEXT_MAPINFO main_dlg[9] ! #define D_TILE main_dlg[ 1 + MAIN_START_OF_NULL] ! #define D_CHECK_GRID main_dlg[ 2 + MAIN_START_OF_NULL] ! #define D_CHECK_SNAP main_dlg[ 2 + MAIN_START_OF_NULL] ! #define D_TILESET_LIST main_dlg[16 + MAIN_START_OF_NULL] ! #define D_TILESET main_dlg[18 + MAIN_START_OF_NULL] ! #define D_TILESET_SCROLL main_dlg[19 + MAIN_START_OF_NULL] ! ! ! // Messages ! ! #define MSG_NEW_MAP MSG_USER ! #define MSG_NEW_TILESET MSG_USER ! ! ! // Flags ! ! #define SCROLL_VER D_USER ! ! ! // Menu item functions ! ! int menu_item_new_map(); ! int menu_item_load_map(); ! int menu_item_save_map(); ! int menu_item_save_map_as(); ! int menu_item_import_tileset(); ! int menu_item_export_tileset(); ! int menu_item_exit(); ! int menu_item_resize_map(); ! int menu_item_edit_tiles_1(); ! int menu_item_edit_tiles_2(); ! int menu_item_edit_obs(); ! int menu_item_edit_objects(); ! int menu_item_about(); ! int menu_item_toggle_debug(); ! int menu_item_save_map_image(); ! int menu_item_save_map_as_xml(); ! ! ! void update_screen(int x, int y, int w, int h); ! ! void deselect_objects(); ! void select_object(Object* obj); ! void select_objects(list<Object*> objs); ! void delete_objects(list<Object*> objs); ! ! void import_tile_bitmap( ! const char* filename, ! int tile_w, int tile_h, int spacing); ! ! void set_map_changed(bool value); ! bool close_current_map(); ! void update_window_title(); ! ! void set_dialog_size(DIALOG *d, int x, int y, int w, int h); ! ! void activate_mode(DIALOG* dialog); ! ! ! #endif --- 1,164 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003 Bjørn Lindeijer ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! */ ! ! #ifndef INCLUDED_EDITOR ! ! #include <allegro.h> ! #include <vector> ! #include "../shared/tiled_map.h" ! #include "../shared/console.h" ! #include "../shared/object.h" ! #include "../shared/module.h" ! ! ! #define PROGRAM_VERSION_STRING "RPG Edit III 0.9.2" ! ! ! // Global variables ! ! extern int debug_mode; ! extern FONT* engine_font; ! extern Console console; ! extern list<Object*> selectedObjects; ! extern int selectedObjectType; ! extern bool selecting; ! extern int selection_start_x, selection_end_x; ! extern int selection_start_y, selection_end_y; ! ! extern TiledMap* currentMap; ! extern TileType* selectedTile; ! extern int selectedTileset; ! extern int selectedObstacle; ! extern int selectedLayer; ! ! extern vector<char*> tileSets; ! extern vector<TileType*> activeTileset; ! ! extern int map_edit_mode; ! ! extern bool mapChanged; ! extern bool showTileGrid; ! extern bool snapToGrid; ! ! extern int selectedColor[6]; ! ! extern char map_filename[1024]; ! extern char status_message[1024]; ! extern char status_mapinfo[1024]; ! ! extern DIALOG main_dlg[]; ! extern DIALOG about_dlg[]; ! extern DIALOG import_tileset_dlg[]; ! extern DIALOG export_tileset_dlg[]; ! extern DIALOG resizemap_dlg[]; ! extern DIALOG newmap_dlg[]; ! extern DIALOG edit_tile_layer[]; ! extern DIALOG edit_obstacle_layer[]; ! extern DIALOG edit_objects_layer[]; ! ! extern MENU menu_file[]; ! extern MENU menu_main[]; ! extern MENU menu_edit[]; ! extern MENU menu_help[]; ! ! ! // Slider types (R, G, B, and H, S, V) ! ! #define S_R 0 ! #define S_G 1 ! #define S_B 2 ! #define S_H 3 ! #define S_S 4 ! #define S_V 5 ! ! #define S_C 6 ! ! ! // Map edit modes ! ! #define EM_TILE 0 ! #define EM_OBSTACLE 1 ! #define EM_OBJECTS 2 ! ! ! // Dialogs ! ! #define MAIN_START_OF_NULL 12 ! #define NEWMAP_OK 9 ! #define IMPORT_TILESET_OK 7 ! #define EXPORT_TILESET_OK 5 ! #define RESIZEMAP_OK 13 ! ! #define D_MAP main_dlg[3] ! #define D_SCROLL_VER main_dlg[4] ! #define D_SCROLL_HOR main_dlg[5] ! #define D_AUTOTEXT_STATUS main_dlg[8] ! #define D_AUTOTEXT_MAPINFO main_dlg[9] ! #define D_TILE main_dlg[ 1 + MAIN_START_OF_NULL] ! #define D_CHECK_GRID main_dlg[ 2 + MAIN_START_OF_NULL] ! #define D_CHECK_SNAP main_dlg[ 2 + MAIN_START_OF_NULL] ! #define D_TILESET_LIST main_dlg[16 + MAIN_START_OF_NULL] ! #define D_TILESET main_dlg[18 + MAIN_START_OF_NULL] ! #define D_TILESET_SCROLL main_dlg[19 + MAIN_START_OF_NULL] ! ! ! // Messages ! ! #define MSG_NEW_MAP MSG_USER ! #define MSG_NEW_TILESET MSG_USER ! ! ! // Flags ! ! #define SCROLL_VER D_USER ! ! ! // Menu item functions ! ! int menu_item_new_map(); ! int menu_item_load_map(); ! int menu_item_save_map(); ! int menu_item_save_map_as(); ! int menu_item_import_tileset(); ! int menu_item_export_tileset(); ! int menu_item_exit(); ! int menu_item_resize_map(); ! int menu_item_edit_tiles_1(); ! int menu_item_edit_tiles_2(); ! int menu_item_edit_obs(); ! int menu_item_edit_objects(); ! int menu_item_about(); ! int menu_item_toggle_debug(); ! int menu_item_save_map_image(); ! int menu_item_save_map_as_xml(); ! ! ! void update_screen(int x, int y, int w, int h); ! ! void deselect_objects(); ! void select_object(Object* obj); ! void select_objects(list<Object*> objs); ! void delete_objects(list<Object*> objs); ! ! void import_tile_bitmap( ! const char* filename, ! int tile_w, int tile_h, int spacing); ! ! void set_map_changed(bool value); ! bool close_current_map(); ! void update_window_title(); ! ! void set_dialog_size(DIALOG *d, int x, int y, int w, int h); ! ! void activate_mode(DIALOG* dialog); ! ! ! #endif Index: gui_procs.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/gui_procs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gui_procs.h 23 Oct 2004 11:54:18 -0000 1.2 --- gui_procs.h 7 Feb 2007 17:50:31 -0000 1.3 *************** *** 1,36 **** ! /* ! * The Moonlight RPG engine (see readme.txt about version info) ! * By Bjørn Lindeijer ! * ! ************************************************************************************/ ! ! #ifndef GUIPROCS_INCLUDED ! #define GUIPROCS_INCLUDED ! ! // GUI procs ! ! int d_bjorn_scroll_proc(int msg, DIALOG *d, int c); ! int d_bjorn_camera_knop(int msg, DIALOG *d, int c); ! int d_bjorn_map_proc(int msg, DIALOG *d, int c); ! int d_bjorn_tile_proc(int msg, DIALOG *d, int c); ! int d_bjorn_check_grid(int msg, DIALOG *d, int c); ! int d_bjorn_color_proc(int msg, DIALOG *d, int c); ! int d_bjorn_close_proc(int msg, DIALOG *d, int c); ! int d_bjorn_edit_proc(int msg, DIALOG *d, int c); ! int d_bjorn_objects_list(int msg, DIALOG *d, int c); ! int d_bjorn_tileset_list(int msg, DIALOG *d, int c); ! int d_bjorn_tileset(int msg, DIALOG *d, int c); ! int d_bjorn_autotext_proc(int msg, DIALOG *d, int c); ! int d_bjorn_slider_proc(int msg, DIALOG *d, int c); ! int d_bjorn_obs_preset_proc(int msg, DIALOG *d, int c); ! int d_bjorn_obs_proc(int msg, DIALOG *d, int c); ! int d_bjorn_check_snap(int msg, DIALOG *d, int c); ! ! int update_color(void *dp3, int d2); ! void resizemap_change(DIALOG *d); ! ! char *list_tilesets(int index, int *list_size); ! const char *list_objects(int index, int *list_size); ! ! ! #endif --- 1,36 ---- ! /* ! * The Moonlight RPG engine (see readme.txt about version info) ! * By Bjørn Lindeijer ! * ! ************************************************************************************/ ! ! #ifndef GUIPROCS_INCLUDED ! #define GUIPROCS_INCLUDED ! ! // GUI procs ! ! int d_bjorn_scroll_proc(int msg, DIALOG *d, int c); ! int d_bjorn_camera_knop(int msg, DIALOG *d, int c); ! int d_bjorn_map_proc(int msg, DIALOG *d, int c); ! int d_bjorn_tile_proc(int msg, DIALOG *d, int c); ! int d_bjorn_check_grid(int msg, DIALOG *d, int c); ! int d_bjorn_color_proc(int msg, DIALOG *d, int c); ! int d_bjorn_close_proc(int msg, DIALOG *d, int c); ! int d_bjorn_edit_proc(int msg, DIALOG *d, int c); ! int d_bjorn_objects_list(int msg, DIALOG *d, int c); ! int d_bjorn_tileset_list(int msg, DIALOG *d, int c); ! int d_bjorn_tileset(int msg, DIALOG *d, int c); ! int d_bjorn_autotext_proc(int msg, DIALOG *d, int c); ! int d_bjorn_slider_proc(int msg, DIALOG *d, int c); ! int d_bjorn_obs_preset_proc(int msg, DIALOG *d, int c); ! int d_bjorn_obs_proc(int msg, DIALOG *d, int c); ! int d_bjorn_check_snap(int msg, DIALOG *d, int c); ! ! int update_color(void *dp3, int d2); ! void resizemap_change(DIALOG *d); ! ! char *list_tilesets(int index, int *list_size); ! const char *list_objects(int index, int *list_size); ! ! ! #endif Index: aphoton.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/aphoton.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** aphoton.cpp 23 Oct 2004 11:54:18 -0000 1.4 --- aphoton.cpp 7 Feb 2007 17:50:31 -0000 1.5 *************** *** 794,798 **** rectfill(screen, x+2, y+1, x+w-3, y+h-3, highlight); } else { ! rectfill(screen, x+2, y+1, x+w-3, y+h-3, menu_gray_to); // was menu_gray_from } } --- 794,798 ---- rectfill(screen, x+2, y+1, x+w-3, y+h-3, highlight); } else { ! rectfill(screen, x+2, y+1, x+w-3, y+h-3, menu_gray_to); // was menu_gray_from } } Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** script.cpp 27 Jan 2007 02:14:47 -0000 1.8 --- script.cpp 7 Feb 2007 17:50:31 -0000 1.9 *************** *** 1,641 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003 Bjørn Lindeijer ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! */ [...1253 lines suppressed...] ! obj->dir = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "tick_time") == 0) { ! obj->tick = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "obstacle" ) == 0) { ! obj->obstacle = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "bitmap" ) == 0) { ! obj->bitmap = (BITMAP*)lua_touserdata(L, -1);} ! else if (strcmp(index, "map" ) == 0) { ! TiledMap* newMap = (TiledMap*)lua_touserdata(L, -1); ! if (newMap != obj->getMap()) obj->setMap(newMap); ! } ! else { ! // Deal with the assigned value normally ! lua_rawset(L, -3); ! } ! } ! ! lua_settop(L, 0); ! return 0; ! } |
From: Bjørn L. <b_l...@us...> - 2007-02-07 17:50:50
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9875 Added Files: rpg.cbp Log Message: Converted files to use UNIX newlines and added Code::Blocks project file. --- NEW FILE: rpg.cbp --- <?xml version="1.0"?> <!DOCTYPE CodeBlocks_project_file> <CodeBlocks_project_file> <FileVersion major="1" minor="1"/> <Project> <Option title="Win32 Application"/> <Option makefile="Makefile"/> <Build> <Target title="default"> <Option type="0"/> </Target> </Build> <Linker> <Add library="gdi32"/> <Add library="user32"/> <Add library="kernel32"/> </Linker> </Project> </CodeBlocks_project_file> |