moeng-cvs Mailing List for Moonlight Engine (Page 2)
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-07 17:50:50
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9875/src/shared Modified Files: console.cpp console.h Log Message: Converted files to use UNIX newlines and added Code::Blocks project file. Index: console.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** console.h 23 Oct 2004 11:54:19 -0000 1.3 --- console.h 7 Feb 2007 17:50:31 -0000 1.4 *************** *** 1,53 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_CONSOLE_H_ ! #define _INCLUDED_CONSOLE_H_ ! #include <stdio.h> ! #include <list> ! ! 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 ! ! ! class Console ! { ! public: ! Console(const char* filename); ! ~Console(); ! ! void update(); ! void draw(BITMAP *dest); ! bool handleInput(int key); ! void log(int where, int when, const char* what, ...); ! ! bool enableLogfile; ! ! private: ! FILE* logFile; ! char* logFilename; ! list<char*> logMessages; ! bool active; ! int progress; ! }; ! ! ! #endif ! --- 1,53 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_CONSOLE_H_ ! #define _INCLUDED_CONSOLE_H_ ! #include <stdio.h> ! #include <list> ! ! 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 ! ! ! class Console ! { ! public: ! Console(const char* filename); ! ~Console(); ! ! void update(); ! void draw(BITMAP *dest); ! bool handleInput(int key); ! void log(int where, int when, const char* what, ...); ! ! bool enableLogfile; ! ! private: ! FILE* logFile; ! char* logFilename; ! list<char*> logMessages; ! bool active; ! int progress; ! }; ! ! ! #endif ! Index: console.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** console.cpp 23 Oct 2004 11:54:19 -0000 1.4 --- console.cpp 7 Feb 2007 17:50:31 -0000 1.5 *************** *** 1,169 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! #include <stdio.h> ! #include <stdarg.h> ! #include <allegro.h> ! #include <list> ! #include "console.h" ! #include "../common.h" ! #include <math.h> ! ! #ifndef M_PI ! #define M_PI 3.14159 ! #endif ! ! ! Console::Console(const char* filename) ! { ! logFilename = new char[strlen(filename) + 1]; ! strcpy(logFilename, filename); ! logFilename[strlen(filename)] = '\0'; ! ! logFile = fopen(logFilename, "w"); ! fclose(logFile); ! log(CON_LOG, CON_ALWAYS, "----- Start of RPG log file -----"); ! ! progress = 0; ! active = false; ! enableLogfile = true; ! } ! ! ! Console::~Console() ! { ! // Deallocate console string messages ! list<char*>::iterator i; ! while (!logMessages.empty()) ! { ! i = logMessages.begin(); ! delete (*i); ! logMessages.erase(i); ! } ! ! log(CON_LOG, CON_ALWAYS, "----- End of RPG log file -----"); ! ! delete logFilename; ! } ! ! void Console::update() ! { ! if (active && progress < 100) progress = MIN(100, progress + 2); ! if (!active && progress > 0) progress = MAX(0, progress - 2); ! } ! ! void Console::draw(BITMAP *dest) ! { ! if (progress > 0) { ! int posY = (int)((double)(dest->h / 4) * ! sin(((0.5 * M_PI) / (double)100) * ! (double)progress) - text_height(font)); ! ! line(dest, 0, posY + text_height(font) + 1, dest->w - 1, ! posY + text_height(font) + 1, makecol(0,0,0)); ! set_trans_blender(0,0,0,100); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! rectfill(dest, 0, 0, dest->w - 1, posY + text_height(font), ! makecol(0,0,0)); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! ! font = engine_font; ! ! 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)); ! posY -= text_height(font) + 1; ! i++; ! } ! } ! } ! ! bool Console::handleInput(int key) ! { ! if ((progress == 0 || progress == 100) && ! (key == KEY_TILDE || key == KEY_C)) { ! active = !active; ! return true; ! } ! return false; ! } ! ! void Console::log(int where, int when, const char *what, ...) ! { ! if ((when & CON_ALWAYS) || ((when & CON_DEBUG) && debug_mode) || ! ((when & CON_VDEBUG) && debug_mode == 2)) ! { ! char* buf = (char*)malloc(1024 * sizeof(char)); ! ! va_list ap; ! va_start(ap, what); ! uvsprintf(buf, what, ap); ! va_end(ap); ! ! if (where & (CON_LOG | CON_QUIT)) ! { ! time_t t; ! time(&t); ! ! if (enableLogfile) { ! logFile = fopen(logFilename, "a"); ! fprintf( ! logFile, ! "[%s%d:%s%d:%s%d] ", ! (((t / 60) / 60) % 24 < 10) ? "0" : "", ! (int)(((t / 60) / 60) % 24), ! ((t / 60) % 60 < 10) ? "0" : "", ! (int)((t / 60) % 60), ! (t % 60 < 10) ? "0" : "", ! (int)(t % 60) ! ); ! fprintf(logFile, buf); ! fprintf(logFile, "\n"); ! fclose(logFile); ! } ! ! if (where & CON_QUIT) ! { ! logFile = fopen(logFilename, "a"); ! fprintf(logFile, "FATAL ERROR!\n"); ! fclose(logFile); ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message(buf); ! printf("\n"); ! exit(1); ! } ! } ! ! if (where & CON_POPUP) ! { ! allegro_message(buf); ! } ! ! if (where & CON_CONSOLE) ! { ! // Add the message to the console ! logMessages.push_front(buf); ! ! // Clean up the log memory (only keep the last 20 messages) ! if (logMessages.size() > 20) { ! free(logMessages.back()); ! logMessages.pop_back(); ! } ! } ! else ! { ! // Clean up the allocated string space ! delete buf; ! } ! } ! } ! --- 1,168 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! #include <stdio.h> ! #include <stdarg.h> ! #include <allegro.h> ! #include <list> ! #include "console.h" ! #include "../common.h" ! #include <math.h> ! ! #ifndef M_PI ! #define M_PI 3.14159 ! #endif ! ! ! Console::Console(const char* filename) ! { ! logFilename = new char[strlen(filename) + 1]; ! strcpy(logFilename, filename); ! logFilename[strlen(filename)] = '\0'; ! ! logFile = fopen(logFilename, "w"); ! fclose(logFile); ! log(CON_LOG, CON_ALWAYS, "----- Start of RPG log file -----"); ! ! progress = 0; ! active = false; ! enableLogfile = true; ! } ! ! ! Console::~Console() ! { ! // Deallocate console string messages ! list<char*>::iterator i; ! while (!logMessages.empty()) ! { ! i = logMessages.begin(); ! delete (*i); ! logMessages.erase(i); ! } ! ! log(CON_LOG, CON_ALWAYS, "----- End of RPG log file -----"); ! ! delete logFilename; ! } ! ! void Console::update() ! { ! if (active && progress < 100) progress = MIN(100, progress + 2); ! if (!active && progress > 0) progress = MAX(0, progress - 2); ! } ! ! void Console::draw(BITMAP *dest) ! { ! if (progress > 0) { ! int posY = (int)((double)(dest->h / 4) * ! sin(((0.5 * M_PI) / (double)100) * ! (double)progress) - text_height(font)); ! ! line(dest, 0, posY + text_height(font) + 1, dest->w - 1, ! posY + text_height(font) + 1, makecol(0,0,0)); ! set_trans_blender(0,0,0,100); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! rectfill(dest, 0, 0, dest->w - 1, posY + text_height(font), ! makecol(0,0,0)); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! ! font = engine_font; ! ! 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)); ! posY -= text_height(font) + 1; ! i++; ! } ! } ! } ! ! bool Console::handleInput(int key) ! { ! if ((progress == 0 || progress == 100) && ! (key == KEY_TILDE || key == KEY_C)) { ! active = !active; ! return true; ! } ! return false; ! } ! ! void Console::log(int where, int when, const char *what, ...) ! { ! if ((when & CON_ALWAYS) || ((when & CON_DEBUG) && debug_mode) || ! ((when & CON_VDEBUG) && debug_mode == 2)) ! { ! char* buf = (char*)malloc(1024 * sizeof(char)); ! ! va_list ap; ! va_start(ap, what); ! uvsprintf(buf, what, ap); ! va_end(ap); ! ! if (where & (CON_LOG | CON_QUIT)) ! { ! time_t t; ! time(&t); ! ! if (enableLogfile) { ! logFile = fopen(logFilename, "a"); ! fprintf( ! logFile, ! "[%s%d:%s%d:%s%d] ", ! (((t / 60) / 60) % 24 < 10) ? "0" : "", ! (int)(((t / 60) / 60) % 24), ! ((t / 60) % 60 < 10) ? "0" : "", ! (int)((t / 60) % 60), ! (t % 60 < 10) ? "0" : "", ! (int)(t % 60) ! ); ! fprintf(logFile, buf); ! fprintf(logFile, "\n"); ! fclose(logFile); ! } ! ! if (where & CON_QUIT) ! { ! logFile = fopen(logFilename, "a"); ! fprintf(logFile, "FATAL ERROR!\n"); ! fclose(logFile); ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message(buf); ! printf("\n"); ! exit(1); ! } ! } ! ! if (where & CON_POPUP) ! { ! allegro_message(buf); ! } ! ! if (where & CON_CONSOLE) ! { ! // Add the message to the console ! logMessages.push_front(buf); ! ! // Clean up the log memory (only keep the last 20 messages) ! if (logMessages.size() > 20) { ! free(logMessages.back()); ! logMessages.pop_back(); ! } ! } ! else ! { ! // Clean up the allocated string space ! delete buf; ! } ! } ! } |
From: Bjørn L. <b_l...@us...> - 2007-02-07 17:50:50
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9875/src Modified Files: canvas.cpp canvas.h rpg.h script.cpp sound.cpp sound.h Log Message: Converted files to use UNIX newlines and added Code::Blocks project file. Index: canvas.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** canvas.h 23 Oct 2004 11:54:17 -0000 1.4 --- canvas.h 7 Feb 2007 17:50:31 -0000 1.5 *************** *** 1,50 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_CANVAS_H_ ! #define _INCLUDED_CANVAS_H_ ! ! #include <allegro.h> ! #include "shared/tiled_map.h" ! ! class Canvas ! { ! public: ! void init(); ! void getCursor(int *x, int *y); ! void setCursor(int x, int y); ! void getClip(int *x1, int *y1, int *x2, int *y2); ! void setClip(int x1, int y1, int x2, int y2); ! void setColor(int color); ! void setDrawMode(int drawMode); ! int getDrawMode() {return drawMode;} ! void setAlpha(int alpha); ! int getAlpha() {return alpha;} ! void setFont(FONT* font); ! void textSize(const char *text, int *width, int *height); ! void bitmapSize(BITMAP *bmp, int *width, int *height); ! void drawText(const char *text); ! void drawBitmap(BITMAP *bmp,int dw,int dh,int sx,int sy,int sw,int sh); ! void drawViewport(int x,int y,int w,int h,int tx,int ty,TiledMap* map); ! ! private: ! int curX, curY; // The current cursor position ! int drawColor; // The currently used draw color ! int alpha; // The currently used opacity ! FONT* myFont; // The currently used font ! int drawMode; // The currently used drawmode ! }; ! ! ! extern Canvas canvas; ! ! ! #endif --- 1,50 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_CANVAS_H_ ! #define _INCLUDED_CANVAS_H_ ! ! #include <allegro.h> ! #include "shared/tiled_map.h" ! ! class Canvas ! { ! public: ! void init(); ! void getCursor(int *x, int *y); ! void setCursor(int x, int y); ! void getClip(int *x1, int *y1, int *x2, int *y2); ! void setClip(int x1, int y1, int x2, int y2); ! void setColor(int color); ! void setDrawMode(int drawMode); ! int getDrawMode() {return drawMode;} ! void setAlpha(int alpha); ! int getAlpha() {return alpha;} ! void setFont(FONT* font); ! void textSize(const char *text, int *width, int *height); ! void bitmapSize(BITMAP *bmp, int *width, int *height); ! void drawText(const char *text); ! void drawBitmap(BITMAP *bmp,int dw,int dh,int sx,int sy,int sw,int sh); ! void drawViewport(int x,int y,int w,int h,int tx,int ty,TiledMap* map); ! ! private: ! int curX, curY; // The current cursor position ! int drawColor; // The currently used draw color ! int alpha; // The currently used opacity ! FONT* myFont; // The currently used font ! int drawMode; // The currently used drawmode ! }; ! ! ! extern Canvas canvas; ! ! ! #endif Index: canvas.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** canvas.cpp 23 Oct 2004 11:54:09 -0000 1.5 --- canvas.cpp 7 Feb 2007 17:50:31 -0000 1.6 *************** *** 1,194 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! #include <allegro.h> ! #include "common.h" ! #include "rpg.h" ! #include "canvas.h" ! ! ! //=================== The canvas =======================================/ ! ! Canvas canvas; ! ! ! ! //=================== The canvas methods ===============================/ ! ! void Canvas::init() ! { ! curX = 0; ! curY = 0; ! set_clip_rect(buffer, 0, 0, SCREEN_W - 1, SCREEN_H - 1); ! myFont = font; ! drawColor = makecol(255,255,255); ! alpha = 255; ! drawMode = DM_MASKED; ! } ! ! void Canvas::getCursor(int *x, int *y) ! { ! ASSERT(x && y); ! *x = curX; ! *y = curY; ! } ! ! void Canvas::setCursor(int x, int y) ! { ! curX = x; ! curY = y; ! } ! ! void Canvas::getClip(int *x1, int *y1, int *x2, int *y2) ! { ! ASSERT(x1 && y1 && x2 && y2); ! *x1 = buffer->cl; ! *y1 = buffer->ct; ! *x2 = buffer->cr; ! *y2 = buffer->cb; ! } ! ! void Canvas::setClip(int x1, int y1, int x2, int y2) ! { ! set_clip_rect(buffer, x1, y1, x2, y2); ! } ! ! void Canvas::setColor(int color) ! { ! drawColor = color; ! } ! ! void Canvas::setDrawMode(int drawMode) ! { ! this->drawMode = drawMode; ! } ! ! void Canvas::setAlpha(int alpha) ! { ! this->alpha = alpha; ! } ! ! void Canvas::setFont(FONT *font) ! { ! if (font) myFont = font; ! } ! ! void Canvas::textSize(const char *text, int *w, int *h) ! { ! ASSERT(w && h); ! *w = text_length(myFont, text); ! *h = text_height(myFont); ! } ! ! void Canvas::drawText(const char *text) ! { ! ASSERT(text); ! textout_ex(buffer, myFont, text, curX, curY, drawColor, -1); ! curX += text_length(myFont, text); ! } ! ! void Canvas::drawBitmap(BITMAP *bmp, int dw, int dh, int sx, int sy, int sw, int sh) ! { ! /* ! console.log( ! CON_LOG | CON_CONSOLE, ! CON_DEBUG, ! "Processing draw_bitmap(bmp, %d, %d, %d, %d, %d, %d)", ! dw, dh, sx, sy, sw, sh ! ); ! */ ! ASSERT(bitmap); ! BITMAP *src = NULL; ! ! // Don't try to process invalid surfaces ! if (dw < 0 || dh < 0) return; ! ! if (sx != 0 || sy != 0 || sw != bmp->w || sh != bmp->h) ! { ! // The source bitmap needs to be adapted first ! src = create_bitmap(sw, sh); ! ASSERT(src); ! ! // Determine the point where we should start drawing ! int start_x = -sx % bmp->w; ! int start_y = -sy % bmp->h; ! if (start_x > 0) start_x -= bmp->w; ! if (start_y > 0) start_y -= bmp->h; ! int x = start_x; ! int y = start_y; ! ! // Create tiled pattern ! while (y < sh) { ! while (x < sw) { ! blit(bmp, src, 0, 0, x, y, bmp->w, bmp->h); ! x += bmp->w; ! } ! x = start_x; ! y += bmp->h; ! } ! ! bmp = src; ! } ! ! // Now we'll put this sprite on the screen ! switch (drawMode) { ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! } ! if ((drawMode == DM_TRANS && alpha < 255) || drawMode == DM_ALPHA || drawMode == DM_ADD) { ! if (sw == dw && sh == dh) { ! draw_trans_sprite(buffer, bmp, curX, curY); ! } ! else { ! BITMAP *stretch = create_bitmap(dw, dh); ! if (stretch) { ! stretch_sprite(stretch, bmp, 0, 0, dw, dh); ! draw_trans_sprite(buffer, stretch, curX, curY); ! destroy_bitmap(stretch); ! } ! } ! } ! else ! { ! if (sw == dw && sh == dh) { ! draw_sprite(buffer, bmp, curX, curY); ! } ! else { ! stretch_sprite(buffer, bmp, curX, curY, dw, dh); ! } ! } ! switch (drawMode) { ! case DM_TRANS: ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! ! if (src) destroy_bitmap(src); ! ! // And don't forget to move that cursor ! curX += dw; ! } ! ! void Canvas::drawViewport(int x, int y, int w, int h, int tx, int ty, TiledMap* map) ! { ! map->setCamera( ! Point(tx, ty), ! Rectangle(x, y, w, h), ! true, true ! ); ! ! map->draw(buffer, debug_mode); ! } --- 1,194 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! #include <allegro.h> ! #include "common.h" ! #include "rpg.h" ! #include "canvas.h" ! ! ! //=================== The canvas =======================================/ ! ! Canvas canvas; ! ! ! ! //=================== The canvas methods ===============================/ ! ! void Canvas::init() ! { ! curX = 0; ! curY = 0; ! set_clip_rect(buffer, 0, 0, SCREEN_W - 1, SCREEN_H - 1); ! myFont = font; ! drawColor = makecol(255,255,255); ! alpha = 255; ! drawMode = DM_MASKED; ! } ! ! void Canvas::getCursor(int *x, int *y) ! { ! ASSERT(x && y); ! *x = curX; ! *y = curY; ! } ! ! void Canvas::setCursor(int x, int y) ! { ! curX = x; ! curY = y; ! } ! ! void Canvas::getClip(int *x1, int *y1, int *x2, int *y2) ! { ! ASSERT(x1 && y1 && x2 && y2); ! *x1 = buffer->cl; ! *y1 = buffer->ct; ! *x2 = buffer->cr; ! *y2 = buffer->cb; ! } ! ! void Canvas::setClip(int x1, int y1, int x2, int y2) ! { ! set_clip_rect(buffer, x1, y1, x2, y2); ! } ! ! void Canvas::setColor(int color) ! { ! drawColor = color; ! } ! ! void Canvas::setDrawMode(int drawMode) ! { ! this->drawMode = drawMode; ! } ! ! void Canvas::setAlpha(int alpha) ! { ! this->alpha = alpha; ! } ! ! void Canvas::setFont(FONT *font) ! { ! if (font) myFont = font; ! } ! ! void Canvas::textSize(const char *text, int *w, int *h) ! { ! ASSERT(w && h); ! *w = text_length(myFont, text); ! *h = text_height(myFont); ! } ! ! void Canvas::drawText(const char *text) ! { ! ASSERT(text); ! textout_ex(buffer, myFont, text, curX, curY, drawColor, -1); ! curX += text_length(myFont, text); ! } ! ! void Canvas::drawBitmap(BITMAP *bmp, int dw, int dh, int sx, int sy, int sw, int sh) ! { ! /* ! console.log( ! CON_LOG | CON_CONSOLE, ! CON_DEBUG, ! "Processing draw_bitmap(bmp, %d, %d, %d, %d, %d, %d)", ! dw, dh, sx, sy, sw, sh ! ); ! */ ! ASSERT(bitmap); ! BITMAP *src = NULL; ! ! // Don't try to process invalid surfaces ! if (dw < 0 || dh < 0) return; ! ! if (sx != 0 || sy != 0 || sw != bmp->w || sh != bmp->h) ! { ! // The source bitmap needs to be adapted first ! src = create_bitmap(sw, sh); ! ASSERT(src); ! ! // Determine the point where we should start drawing ! int start_x = -sx % bmp->w; ! int start_y = -sy % bmp->h; ! if (start_x > 0) start_x -= bmp->w; ! if (start_y > 0) start_y -= bmp->h; ! int x = start_x; ! int y = start_y; ! ! // Create tiled pattern ! while (y < sh) { ! while (x < sw) { ! blit(bmp, src, 0, 0, x, y, bmp->w, bmp->h); ! x += bmp->w; ! } ! x = start_x; ! y += bmp->h; ! } ! ! bmp = src; ! } ! ! // Now we'll put this sprite on the screen ! switch (drawMode) { ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! } ! if ((drawMode == DM_TRANS && alpha < 255) || drawMode == DM_ALPHA || drawMode == DM_ADD) { ! if (sw == dw && sh == dh) { ! draw_trans_sprite(buffer, bmp, curX, curY); ! } ! else { ! BITMAP *stretch = create_bitmap(dw, dh); ! if (stretch) { ! stretch_sprite(stretch, bmp, 0, 0, dw, dh); ! draw_trans_sprite(buffer, stretch, curX, curY); ! destroy_bitmap(stretch); ! } ! } ! } ! else ! { ! if (sw == dw && sh == dh) { ! draw_sprite(buffer, bmp, curX, curY); ! } ! else { ! stretch_sprite(buffer, bmp, curX, curY, dw, dh); ! } ! } ! switch (drawMode) { ! case DM_TRANS: ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! ! if (src) destroy_bitmap(src); ! ! // And don't forget to move that cursor ! curX += dw; ! } ! ! void Canvas::drawViewport(int x, int y, int w, int h, int tx, int ty, TiledMap* map) ! { ! map->setCamera( ! Point(tx, ty), ! Rectangle(x, y, w, h), ! true, true ! ); ! ! map->draw(buffer, debug_mode); ! } Index: sound.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sound.cpp 23 Oct 2004 11:54:18 -0000 1.11 --- sound.cpp 7 Feb 2007 17:50:31 -0000 1.12 *************** *** 1,272 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! ! ! #include <allegro.h> ! #include "shared/console.h" ! #include "sound.h" ! #include "rpg.h" ! #include "script.h" ! #include "common.h" ! ! #ifdef ENABLE_MUSIC ! #include <alogg/alogg.h> ! #endif ! ! ! int sound_enabled = 1; ! int sfx_enabled = 1; ! int sfx_vol = 255; ! int music_vol = 255; ! int music_format = 0; ! ! ! // Currently playing OGG file ! struct { ! SAMPLE *sample; ! int voice; ! struct alogg_stream *stream; ! AUDIOSTREAM *ass; ! char filename[128]; ! } channels[CHANNELS]; ! ! char *error; ! ! ! ! void init_sound() { ! // To achieve the max possible volume ! set_volume_per_voice(0); ! ! // Initialize alogg ! ! int midi_driver = MIDI_NONE; ! int sound_driver = DIGI_NONE; ! ! if (sound_enabled && music_format == MUSIC_MIDI) { ! midi_driver = MIDI_AUTODETECT; ! } ! if (sfx_enabled || (sound_enabled && music_format != MUSIC_MIDI)) { ! #ifdef ENABLE_MUSIC ! alogg_init(); ! #endif ! sound_driver = DIGI_AUTODETECT; ! } ! ! // Install sound driver ! if (install_sound(sound_driver, midi_driver, NULL) != 0) { ! console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); ! return; ! } ! ! #ifdef ENABLE_MUSIC ! // Initialize channels to NULL ! for (int i = 0; i < CHANNELS; i++) { ! channels[i].voice = 0; ! channels[i].sample = NULL; ! channels[i].stream = NULL; ! channels[i].ass = NULL; ! } ! #endif ! } ! ! ! ! /* play_music(filename, channel) ! */ ! int l_play_music(lua_State *L) ! { ! char* filename; ! int channel; ! getLuaArguments(L, "si", &filename, &channel); ! ! error = NULL; ! ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! ! if (sound_enabled && error == NULL) { ! if (music_format == MUSIC_MIDI) { ! replace_extension(channels[channel].filename, get_filename(filename), "mid", 128); ! ! MIDI *midi = module->findMidi(channels[channel].filename); ! if (midi) { ! play_looped_midi(midi, 0, -1); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, ! "Could not find MIDI file in datafile (%s)", ! channels[channel].filename); ! } ! } else { ! #ifdef ENABLE_MUSIC ! // Stop currently playing music ! stop_music(channel); ! ! if (!exists(filename)) {error = "file does not exist";} ! ! strncpy(channels[channel].filename, filename, 128); ! ! channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); ! if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", channels[channel].filename); ! alogg_exit(); ! exit(1); ! } ! channels[channel].ass = alogg_get_audio_stream(channels[channel].stream); ! voice_set_volume(channels[channel].ass->voice, music_vol); ! #endif ! } ! } ! ! if (error == NULL) { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing music file (%s)", filename); ! } ! else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing music file \"%s\" (%s)", filename, error); ! } ! ! return 0; ! } ! ! ! #ifdef ENABLE_MUSIC ! ! /* adjust_channel(channel, volume, panning, speed) ! */ ! int l_adjust_channel(lua_State *L) ! { ! int channel, vol, pan, speed; ! getLuaArguments(L, "iiii", &channel, &vol, &pan, &speed); ! ! error = NULL; ! ! if (sound_enabled && music_format != MUSIC_MIDI) { ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!channels[channel].ass) {error = "no music on this channel to adjust";} ! else if (vol < 0 || vol > 255) {error = "illegal volume value";} ! else if (pan < 0 || pan > 255) {error = "illegal panning value";} ! else if (speed < 0) {error = "illegal speed value";} ! ! if (error == NULL) { ! voice_set_volume(channels[channel].ass->voice, int(vol * (float(music_vol) / 255.0f))); ! //console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Adjusted channel parameters (%d, %d, %d, %d)", channel, vol, pan, speed); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error adjusting channel parameters (%s)", error); ! } ! } ! ! return 0; ! } ! ! /* get_number_of_channels() ! */ ! int l_get_number_of_channels(lua_State *L) ! { ! return putLuaArguments(L, "i", CHANNELS); ! } ! ! ! void poll_sound() ! { ! if (music_format != MUSIC_MIDI) { ! for (int i = 0; i < CHANNELS; i++) { ! if (channels[i].stream) { ! int ret = alogg_update_streaming(channels[i].stream); ! if (ret == 0) { ! // Loop song ! stop_music(i); ! channels[i].stream = alogg_start_streaming(channels[i].filename, BLOCK_SIZE); ! if (!channels[i].stream) { ! fprintf(stderr,"Error opening %s\n", channels[i].filename); ! alogg_exit(); ! exit(1); ! } ! channels[i].ass = alogg_get_audio_stream(channels[i].stream); ! break; ! } ! } ! } ! } ! } ! ! void stop_music(int channel) ! { ! /* ! if (channels[channel].voice) { ! deallocate_voice(channels[channel].voice); ! destroy_sample(channels[channel].sample); ! channels[channel].voice = 0; ! channels[channel].sample = NULL; ! } ! */ ! if (music_format != MUSIC_MIDI && channels[channel].stream) { ! alogg_stop_streaming(channels[channel].stream); ! channels[channel].stream = NULL; ! channels[channel].ass = NULL; ! } ! } ! ! ! /* stop_music(channel) ! */ ! int l_stop_music(lua_State *L) ! { ! int channel; ! getLuaArguments(L, "i", &channel); ! ! error = NULL; ! if (channel < 0 || channel >= CHANNELS) {error = "invalid channel";} ! ! if (error == NULL) { ! stop_music(channel); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error stopping music (%s)", error); ! } ! return 0; ! } ! ! #endif ! ! ! /* play_sample(filename) ! */ ! int l_play_sample(lua_State *L) ! { ! char* name; ! getLuaArguments(L, "s", &name); ! ! if (sfx_enabled) { ! SAMPLE *sample = module->findSample(name); ! ! if (sample) { ! console.log(CON_LOG, CON_ALWAYS, "Playing sample: %s", name); ! play_sample(sample, sfx_vol, 128, 1000, 0); ! } else { ! console.log(CON_LOG, CON_ALWAYS, ! "Error: Cannot find requested sample (%s)!", name); ! } ! } ! ! return 0; ! } ! ! void exit_sound() ! { ! #ifdef ENABLE_MUSIC ! for (int i = 0; i < CHANNELS; i++) { ! stop_music(i); ! } ! ! if (sound_enabled && music_format != MUSIC_MIDI) { ! alogg_exit(); ! } ! #endif ! } --- 1,270 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ ! ! #include <allegro.h> ! #include "shared/console.h" ! #include "sound.h" ! #include "rpg.h" ! #include "script.h" ! #include "common.h" ! ! #ifdef ENABLE_MUSIC ! #include <alogg/alogg.h> ! #endif ! ! ! int sound_enabled = 1; ! int sfx_enabled = 1; ! int sfx_vol = 255; ! int music_vol = 255; ! int music_format = 0; ! ! ! // Currently playing OGG file ! struct { ! SAMPLE *sample; ! int voice; ! struct alogg_stream *stream; ! AUDIOSTREAM *ass; ! char filename[128]; ! } channels[CHANNELS]; ! ! char *error; ! ! ! ! void init_sound() { ! // To achieve the max possible volume ! set_volume_per_voice(0); ! ! // Initialize alogg ! ! int midi_driver = MIDI_NONE; ! int sound_driver = DIGI_NONE; ! ! if (sound_enabled && music_format == MUSIC_MIDI) { ! midi_driver = MIDI_AUTODETECT; ! } ! if (sfx_enabled || (sound_enabled && music_format != MUSIC_MIDI)) { ! #ifdef ENABLE_MUSIC ! alogg_init(); ! #endif ! sound_driver = DIGI_AUTODETECT; ! } ! ! // Install sound driver ! if (install_sound(sound_driver, midi_driver, NULL) != 0) { ! console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); ! return; ! } ! ! #ifdef ENABLE_MUSIC ! // Initialize channels to NULL ! for (int i = 0; i < CHANNELS; i++) { ! channels[i].voice = 0; ! channels[i].sample = NULL; ! channels[i].stream = NULL; ! channels[i].ass = NULL; ! } ! #endif ! } ! ! ! ! /* play_music(filename, channel) ! */ ! int l_play_music(lua_State *L) ! { ! char* filename; ! int channel; ! getLuaArguments(L, "si", &filename, &channel); ! ! error = NULL; ! ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! ! if (sound_enabled && error == NULL) { ! if (music_format == MUSIC_MIDI) { ! replace_extension(channels[channel].filename, get_filename(filename), "mid", 128); ! ! MIDI *midi = module->findMidi(channels[channel].filename); ! if (midi) { ! play_looped_midi(midi, 0, -1); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, ! "Could not find MIDI file in datafile (%s)", ! channels[channel].filename); ! } ! } else { ! #ifdef ENABLE_MUSIC ! // Stop currently playing music ! stop_music(channel); ! ! if (!exists(filename)) {error = "file does not exist";} ! ! strncpy(channels[channel].filename, filename, 128); ! ! channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); ! if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", channels[channel].filename); ! alogg_exit(); ! exit(1); ! } ! channels[channel].ass = alogg_get_audio_stream(channels[channel].stream); ! voice_set_volume(channels[channel].ass->voice, music_vol); ! #endif ! } ! } ! ! if (error == NULL) { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing music file (%s)", filename); ! } ! else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing music file \"%s\" (%s)", filename, error); ! } ! ! return 0; ! } ! ! ! #ifdef ENABLE_MUSIC ! ! /* adjust_channel(channel, volume, panning, speed) ! */ ! int l_adjust_channel(lua_State *L) ! { ! int channel, vol, pan, speed; ! getLuaArguments(L, "iiii", &channel, &vol, &pan, &speed); ! ! error = NULL; ! ! if (sound_enabled && music_format != MUSIC_MIDI) { ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!channels[channel].ass) {error = "no music on this channel to adjust";} ! else if (vol < 0 || vol > 255) {error = "illegal volume value";} ! else if (pan < 0 || pan > 255) {error = "illegal panning value";} ! else if (speed < 0) {error = "illegal speed value";} ! ! if (error == NULL) { ! voice_set_volume(channels[channel].ass->voice, int(vol * (float(music_vol) / 255.0f))); ! //console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Adjusted channel parameters (%d, %d, %d, %d)", channel, vol, pan, speed); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error adjusting channel parameters (%s)", error); ! } ! } ! ! return 0; ! } ! ! /* get_number_of_channels() ! */ ! int l_get_number_of_channels(lua_State *L) ! { ! return putLuaArguments(L, "i", CHANNELS); ! } ! ! ! void poll_sound() ! { ! if (music_format != MUSIC_MIDI) { ! for (int i = 0; i < CHANNELS; i++) { ! if (channels[i].stream) { ! int ret = alogg_update_streaming(channels[i].stream); ! if (ret == 0) { ! // Loop song ! stop_music(i); ! channels[i].stream = alogg_start_streaming(channels[i].filename, BLOCK_SIZE); ! if (!channels[i].stream) { ! fprintf(stderr,"Error opening %s\n", channels[i].filename); ! alogg_exit(); ! exit(1); ! } ! channels[i].ass = alogg_get_audio_stream(channels[i].stream); ! break; ! } ! } ! } ! } ! } ! ! void stop_music(int channel) ! { ! /* ! if (channels[channel].voice) { ! deallocate_voice(channels[channel].voice); ! destroy_sample(channels[channel].sample); ! channels[channel].voice = 0; ! channels[channel].sample = NULL; ! } ! */ ! if (music_format != MUSIC_MIDI && channels[channel].stream) { ! alogg_stop_streaming(channels[channel].stream); ! channels[channel].stream = NULL; ! channels[channel].ass = NULL; ! } ! } ! ! ! /* stop_music(channel) ! */ ! int l_stop_music(lua_State *L) ! { ! int channel; ! getLuaArguments(L, "i", &channel); ! ! error = NULL; ! if (channel < 0 || channel >= CHANNELS) {error = "invalid channel";} ! ! if (error == NULL) { ! stop_music(channel); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error stopping music (%s)", error); ! } ! return 0; ! } ! ! #endif ! ! ! /* play_sample(filename) ! */ ! int l_play_sample(lua_State *L) ! { ! char* name; ! getLuaArguments(L, "s", &name); ! ! if (sfx_enabled) { ! SAMPLE *sample = module->findSample(name); ! ! if (sample) { ! console.log(CON_LOG, CON_ALWAYS, "Playing sample: %s", name); ! play_sample(sample, sfx_vol, 128, 1000, 0); ! } else { ! console.log(CON_LOG, CON_ALWAYS, ! "Error: Cannot find requested sample (%s)!", name); ! } ! } ! ! return 0; ! } ! ! void exit_sound() ! { ! #ifdef ENABLE_MUSIC ! for (int i = 0; i < CHANNELS; i++) { ! stop_music(i); ! } ! ! if (sound_enabled && music_format != MUSIC_MIDI) { ! alogg_exit(); ! } ! #endif ! } Index: sound.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sound.h 23 Oct 2004 11:54:18 -0000 1.8 --- sound.h 7 Feb 2007 17:50:31 -0000 1.9 *************** *** 1,53 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_SOUND_H_ ! #define _INCLUDED_SOUND_H_ ! ! #include <allegro.h> ! #include "script.h" ! ! #ifdef ENABLE_MUSIC ! #include <alogg/alogg.h> ! #endif ! ! ! extern int sound_enabled; ! extern int sfx_enabled; ! extern int sfx_vol; ! extern int music_vol; ! extern int music_format; ! ! #define MUSIC_MIDI 0 ! #define MUSIC_OGG 1 ! ! ! #define CHANNELS (1 << 1) /* (2) number of channels */ ! #define BLOCK_SIZE 40960 ! ! void init_sound(); ! int l_play_sample(lua_State *L); ! void exit_sound(); ! ! void play_music(const char *filename); ! int l_play_music(lua_State *L); ! ! #ifdef ENABLE_MUSIC ! void stop_music(int channel); ! void poll_sound(); ! int l_get_number_of_channels(lua_State *L); ! int l_stop_music(lua_State *L); ! int l_adjust_channel(lua_State *L); ! #endif ! ! ! #endif // #ifndef _INCLUDED_SOUND_H_ ! --- 1,53 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_SOUND_H_ ! #define _INCLUDED_SOUND_H_ ! ! #include <allegro.h> ! #include "script.h" ! ! #ifdef ENABLE_MUSIC ! #include <alogg/alogg.h> ! #endif ! ! ! extern int sound_enabled; ! extern int sfx_enabled; ! extern int sfx_vol; ! extern int music_vol; ! extern int music_format; ! ! #define MUSIC_MIDI 0 ! #define MUSIC_OGG 1 ! ! ! #define CHANNELS (1 << 1) /* (2) number of channels */ ! #define BLOCK_SIZE 40960 ! ! void init_sound(); ! int l_play_sample(lua_State *L); ! void exit_sound(); ! ! void play_music(const char *filename); ! int l_play_music(lua_State *L); ! ! #ifdef ENABLE_MUSIC ! void stop_music(int channel); ! void poll_sound(); ! int l_get_number_of_channels(lua_State *L); ! int l_stop_music(lua_State *L); ! int l_adjust_channel(lua_State *L); ! #endif ! ! ! #endif // #ifndef _INCLUDED_SOUND_H_ ! Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** script.cpp 27 Jan 2007 02:14:47 -0000 1.17 --- script.cpp 7 Feb 2007 17:50:31 -0000 1.18 *************** *** 1,1190 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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. ! */ [...2351 lines suppressed...] ! } ! else if (strcmp(index, "in_air") == 0) { ! obj->in_air = (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; ! } Index: rpg.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rpg.h 23 Oct 2004 11:54:18 -0000 1.7 --- rpg.h 7 Feb 2007 17:50:31 -0000 1.8 *************** *** 1,48 **** ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_RPG_H_ ! #define _INCLUDED_RPG_H_ ! ! #include "shared/tiled_map.h" ! #include "shared/console.h" ! #include "shared/module.h" ! #include <map> ! #include <allegro.h> ! ! // Some engine settings ! #define PROGRAM_ID "Moonlight RPG engine" ! extern int lps; // Game loops per second - sets the game speed and possible frame rate ! ! ! extern volatile int frames_to_do; ! extern volatile int fps, fps_counter; ! ! extern int inkey; // Last pressed key ! ! extern DATAFILE *interface_graphics; ! extern int gameClassInstance; ! ! extern TileType *selectedTile; ! extern list<TiledMap*> maps; ! ! extern bool game_end; ! extern bool exclusive_mode; ! ! void init_engine(); ! void init_rpg(); ! void init_graphics(); ! void handle_input(); ! void update_screen(); ! void draw_screen(); ! void exit_program(); ! ! #endif --- 1,48 ---- ! /* ! The Moonlight Engine - An extendable, portable, RPG-focused game engine. ! Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 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_RPG_H_ ! #define _INCLUDED_RPG_H_ ! ! #include "shared/tiled_map.h" ! #include "shared/console.h" ! #include "shared/module.h" ! #include <map> ! #include <allegro.h> ! ! // Some engine settings ! #define PROGRAM_ID "Moonlight RPG engine" ! extern int lps; // Game loops per second - sets the game speed and possible frame rate ! ! ! extern volatile int frames_to_do; ! extern volatile int fps, fps_counter; ! ! extern int inkey; // Last pressed key ! ! extern DATAFILE *interface_graphics; ! extern int gameClassInstance; ! ! extern TileType *selectedTile; ! extern list<TiledMap*> maps; ! ! extern bool game_end; ! extern bool exclusive_mode; ! ! void init_engine(); ! void init_rpg(); ! void init_graphics(); ! void handle_input(); ! void update_screen(); ! void draw_screen(); ! void exit_program(); ! ! #endif |
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13247/data/scripts Modified Files: Action.lua ActionController.lua Actor.lua Animation.lua Canvas.lua ConversationWindow.lua Decoration.lua ElecDoor.lua Game.lua GuiMenu.lua InteractionMaster.lua MessPile.lua Pawn.lua Player.lua PlayerController.lua PlayerSwitcher.lua SnowyWeather.lua SubcityObjects.lua Log Message: Upgraded BBRpg to work with Lua 5.1. Index: SnowyWeather.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/SnowyWeather.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SnowyWeather.lua 28 Dec 2003 20:04:34 -0000 1.2 --- SnowyWeather.lua 27 Jan 2007 02:14:47 -0000 1.3 *************** *** 69,73 **** -- Add snow particles to reach density ! while (table.getn(self.particles) < self.density) do local p = self.map:spawn(SnowParticle, 0, 0, self) p.x = math.random(minx * 24, maxx * 24) / 24; --- 69,73 ---- -- Add snow particles to reach density ! while (#self.particles < self.density) do local p = self.map:spawn(SnowParticle, 0, 0, self) p.x = math.random(minx * 24, maxx * 24) / 24; Index: GuiMenu.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/GuiMenu.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuiMenu.lua 3 Jan 2004 20:08:34 -0000 1.6 --- GuiMenu.lua 27 Jan 2007 02:14:47 -0000 1.7 *************** *** 37,41 **** local curr = 0 ! for i = 1, table.getn(self.menuItems) do local tw, th = m_text_size(self.menuItems[i].text) m_set_color(0, 0, 0) --- 37,41 ---- local curr = 0 ! for i = 1, #self.menuItems do local tw, th = m_text_size(self.menuItems[i].text) m_set_color(0, 0, 0) *************** *** 48,52 **** local curr = 0 ! for i = 1, table.getn(self.menuItems) do if (i == self.selected) then guiTheme:drawBox(self.x, self.y + curr, self.w, self.menuItems[i]:getHeight()) --- 48,52 ---- local curr = 0 ! for i = 1, #self.menuItems do if (i == self.selected) then guiTheme:drawBox(self.x, self.y + curr, self.w, self.menuItems[i]:getHeight()) *************** *** 66,75 **** if (key == "up") then self.selected = self.selected - 1 ! if (self.selected == 0) then self.selected = table.getn(self.menuItems) end m_play_sample("bbsfx_hit1.wav") return true elseif (key == "down") then self.selected = self.selected + 1 ! if (self.selected > table.getn(self.menuItems)) then self.selected = 1 end m_play_sample("bbsfx_hit1.wav") return true --- 66,75 ---- if (key == "up") then self.selected = self.selected - 1 ! if (self.selected == 0) then self.selected = #self.menuItems end m_play_sample("bbsfx_hit1.wav") return true elseif (key == "down") then self.selected = self.selected + 1 ! if (self.selected > #self.menuItems) then self.selected = 1 end m_play_sample("bbsfx_hit1.wav") return true *************** *** 100,102 **** selected = 1, } ! } \ No newline at end of file --- 100,102 ---- selected = 1, } ! } Index: Actor.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Actor.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Actor.lua 4 Jan 2004 16:42:25 -0000 1.9 --- Actor.lua 27 Jan 2007 02:14:47 -0000 1.10 *************** *** 140,144 **** local tileName, obstacle = m_get_tile_at(self.map, x - 0.5, y - 0.5) ! if (table.getn(objectsAtTile) == 0 and obstacle == 0) then table.insert(dirs, i - 1) end --- 140,144 ---- local tileName, obstacle = m_get_tile_at(self.map, x - 0.5, y - 0.5) ! if (#objectsAtTile == 0 and obstacle == 0) then table.insert(dirs, i - 1) end *************** *** 149,153 **** randomFreeTileAround = function(self) local dirs = self:freeTilesAround() ! if (table.getn(dirs) > 0) then return dirs[math.random(table.getn(dirs))] end return nil end; --- 149,153 ---- randomFreeTileAround = function(self) local dirs = self:freeTilesAround() ! if (#dirs > 0) then return dirs[math.random(#dirs)] end return nil end; Index: SubcityObjects.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/SubcityObjects.lua,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** SubcityObjects.lua 10 Dec 2004 14:15:37 -0000 1.41 --- SubcityObjects.lua 27 Jan 2007 02:14:47 -0000 1.42 *************** *** 185,189 **** elseif (not self.bOccupied) then local afterTable = lang:getConv("BedTiredAfterTable") ! local options = table.getn(afterTable) - 1 ActionController:addSequence{ --- 185,189 ---- elseif (not self.bOccupied) then local afterTable = lang:getConv("BedTiredAfterTable") ! local options = #afterTable - 1 ActionController:addSequence{ Index: Decoration.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Decoration.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Decoration.lua 4 Jan 2004 16:42:25 -0000 1.5 --- Decoration.lua 27 Jan 2007 02:14:47 -0000 1.6 *************** *** 33,37 **** if (self.convTable) then self:log("Showing conversation..."); ! n = get_new_n(self.prev_random, table.getn(self.convTable)) self.prev_random = n write_conversation(self.convTable[n]) --- 33,37 ---- if (self.convTable) then self:log("Showing conversation..."); ! n = get_new_n(self.prev_random, #self.convTable) self.prev_random = n write_conversation(self.convTable[n]) Index: Canvas.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Canvas.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Canvas.lua 2 Jan 2004 02:49:56 -0000 1.4 --- Canvas.lua 27 Jan 2007 02:14:47 -0000 1.5 *************** *** 8,62 **** Canvas = Object:subclass { ! name = "Canvas"; ! drawBitmap = function(self, bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) ! m_draw_bitmap(bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) ! end; ! drawPattern = function(self, bitmap, dest_w, dest_h, org_x, org_y, scale) ! if (scale) then ! local cur_x, cur_y = m_get_cursor() ! m_draw_bitmap(bitmap, dest_w, dest_h, (cur_x - org_x) / scale, (cur_y - org_y) / scale, dest_w / scale, dest_h / scale) ! elseif (org_x and org_y) then ! local cur_x, cur_y = m_get_cursor() ! m_draw_bitmap(bitmap, dest_w, dest_h, cur_x - org_x, cur_y - org_y, dest_w, dest_h) ! else ! m_draw_bitmap(bitmap, dest_w, dest_h, 0, 0, dest_w, dest_h) ! end ! end; ! drawIcon = function(self, bitmap, scale) ! local bitmap_w, bitmap_h = m_bitmap_size(bitmap) ! if (not scale or scale == 1) then ! m_draw_bitmap(bitmap, bitmap_w, bitmap_h, 0, 0, bitmap_w, bitmap_h) ! else ! m_draw_bitmap(bitmap, bitmap_w * scale, bitmap_h * scale, 0, 0, bitmap_w, bitmap_h) ! end ! end; ! drawRect = function(self, bitmap, rect_x, rect_y) ! local bitmap_w, bitmap_h = m_bitmap_size(bitmap) ! m_draw_bitmap(bitmap, rect_x, rect_y, 0, 0, bitmap_w, bitmap_h) ! end; ! moveCursor = function(self, dx, dy) ! local x, y = self:getCursor() ! self:setCursor(x + dx, y + dy) ! end; ! setCursor = function(self, x, y) ! m_set_cursor(x, y) ! end; ! getCursor = function(self) ! return m_get_cursor() ! end; ! setAlpha = function(self, alpha) ! return m_set_alpha(alpha) ! end; ! setDrawMode = function(self, drawMode) ! m_set_drawmode(drawMode) ! end; } --- 8,62 ---- Canvas = Object:subclass { ! name = "Canvas"; ! drawBitmap = function(self, bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) ! m_draw_bitmap(bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) ! end; ! drawPattern = function(self, bitmap, dest_w, dest_h, org_x, org_y, scale) ! if (scale) then ! local cur_x, cur_y = m_get_cursor() ! m_draw_bitmap(bitmap, dest_w, dest_h, (cur_x - org_x) / scale, (cur_y - org_y) / scale, dest_w / scale, dest_h / scale) ! elseif (org_x and org_y) then ! local cur_x, cur_y = m_get_cursor() ! m_draw_bitmap(bitmap, dest_w, dest_h, cur_x - org_x, cur_y - org_y, dest_w, dest_h) ! else ! m_draw_bitmap(bitmap, dest_w, dest_h, 0, 0, dest_w, dest_h) ! end ! end; ! drawIcon = function(self, bitmap, scale) ! local bitmap_w, bitmap_h = m_bitmap_size(bitmap) ! if (not scale or scale == 1) then ! m_draw_bitmap(bitmap, bitmap_w, bitmap_h, 0, 0, bitmap_w, bitmap_h) ! else ! m_draw_bitmap(bitmap, bitmap_w * scale, bitmap_h * scale, 0, 0, bitmap_w, bitmap_h) ! end ! end; ! drawRect = function(self, bitmap, rect_x, rect_y) ! local bitmap_w, bitmap_h = m_bitmap_size(bitmap) ! m_draw_bitmap(bitmap, rect_x, rect_y, 0, 0, bitmap_w, bitmap_h) ! end; ! moveCursor = function(self, dx, dy) ! local x, y = self:getCursor() ! self:setCursor(x + dx, y + dy) ! end; ! setCursor = function(self, x, y) ! m_set_cursor(x, y) ! end; ! getCursor = function(self) ! return m_get_cursor() ! end; ! setAlpha = function(self, alpha) ! return m_set_alpha(alpha) ! end; ! setDrawMode = function(self, drawMode) ! m_set_drawmode(drawMode) ! end; } Index: InteractionMaster.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/InteractionMaster.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InteractionMaster.lua 28 Dec 2003 15:39:20 -0000 1.4 --- InteractionMaster.lua 27 Jan 2007 02:14:47 -0000 1.5 *************** *** 30,34 **** -- Search for the Interaction iIndex = -1; ! for i = 1, table.getn(interactionArray) do if (interactionArray[i] == interaction) then iIndex = i --- 30,34 ---- -- Search for the Interaction iIndex = -1; ! for i = 1, #interactionArray do if (interactionArray[i] == interaction) then iIndex = i *************** *** 57,61 **** --end ! if (table.getn(interactionArray) == 0) then m_message("Attempt to setFocusTo with an empty interactions array."); return --- 57,61 ---- --end ! if (#interactionArray) == 0 then m_message("Attempt to setFocusTo with an empty interactions array."); return *************** *** 64,68 **** -- Search for the Interaction iIndex = -1; ! for i = 1, table.getn(interactionArray) do if (interactionArray[i] == interaction) then iIndex = i --- 64,68 ---- -- Search for the Interaction iIndex = -1; ! for i = 1, #interactionArray do if (interactionArray[i] == interaction) then iIndex = i *************** *** 96,100 **** local ia = self.globalInteractions ! for i = 1, table.getn(ia) do if (ia[i].bRequiresTick) then ia[i]:tick() --- 96,100 ---- local ia = self.globalInteractions ! for i = 1, #ia do if (ia[i].bRequiresTick) then ia[i]:tick() *************** *** 106,110 **** local ia = self.globalInteractions ! for i = 1, table.getn(ia) do if (ia[i].bVisible) then ia[i]:preRender() --- 106,110 ---- local ia = self.globalInteractions ! for i = 1, #ia do if (ia[i].bVisible) then ia[i]:preRender() *************** *** 116,120 **** local ia = self.globalInteractions ! for i = table.getn(ia), 1, -1 do if (ia[i].bVisible) then ia[i]:postRender(canvas) --- 116,120 ---- local ia = self.globalInteractions ! for i = #ia, 1, -1 do if (ia[i].bVisible) then ia[i]:postRender(canvas) *************** *** 126,130 **** local ia = self.globalInteractions ! for i = 1, table.getn(ia) do if (ia[i].bActive) then if (ia[i]:keyType(key)) then --- 126,130 ---- local ia = self.globalInteractions ! for i = 1, #ia do if (ia[i].bActive) then if (ia[i]:keyType(key)) then *************** *** 140,144 **** local ia = self.globalInteractions ! for i = 1, table.getn(ia) do ia[i]:levelChange(level) end --- 140,144 ---- local ia = self.globalInteractions ! for i = 1, #ia do ia[i]:levelChange(level) end Index: ActionController.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/ActionController.lua,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ActionController.lua 2 Jan 2004 02:49:56 -0000 1.3 --- ActionController.lua 27 Jan 2007 02:14:47 -0000 1.4 *************** *** 38,43 **** -- Execute all running actions ! for i = 1, table.getn(self.actions) do ! if (i <= table.getn(self.actions) and self.actions[i] == execEnv) then m_message("Finished executing "..self.actions[i].name .." (".. self.actions[i]._id ..")") table.remove(self.actions, i) --- 38,43 ---- -- Execute all running actions ! for i = 1, #self.actions do ! if (i <= #self.actions and self.actions[i] == execEnv) then m_message("Finished executing "..self.actions[i].name .." (".. self.actions[i]._id ..")") table.remove(self.actions, i) *************** *** 52,57 **** -- Execute all running actions ! for i = 1, table.getn(self.actions) do ! if (i <= table.getn(self.actions) and self.actions[i]:exec()) then m_message("Finished executing "..self.actions[i].name .." (".. self.actions[i]._id ..")") table.remove(self.actions, i) --- 52,57 ---- -- Execute all running actions ! for i = 1, #self.actions do ! if (i <= #self.actions and self.actions[i]:exec()) then m_message("Finished executing "..self.actions[i].name .." (".. self.actions[i]._id ..")") table.remove(self.actions, i) Index: Game.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Game.lua,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Game.lua 2 Jan 2004 02:49:56 -0000 1.10 --- Game.lua 27 Jan 2007 02:14:47 -0000 1.11 *************** *** 187,191 **** end ! local n = table.getn(conversation) convBox.lines = {} convBox.lines_todo = {} --- 187,191 ---- end ! local n = #conversation convBox.lines = {} convBox.lines_todo = {} Index: ConversationWindow.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/ConversationWindow.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConversationWindow.lua 25 Apr 2004 16:39:52 -0000 1.6 --- ConversationWindow.lua 27 Jan 2007 02:14:47 -0000 1.7 *************** *** 25,29 **** detokenize = function(tokens) ! token_cnt = table.getn(tokens) if (token_cnt > 0) then --- 25,29 ---- detokenize = function(tokens) ! token_cnt = #tokens if (token_cnt > 0) then *************** *** 89,94 **** return ! elseif (self.state == CB_READY and table.getn(self.lines_todo) > 0) then ! if (table.getn(self.lines) < self.nr_lines) then -- There is space, start writing the line. --- 89,94 ---- return ! elseif (self.state == CB_READY and #self.lines_todo > 0) then ! if (#self.lines < self.nr_lines) then -- There is space, start writing the line. *************** *** 100,104 **** table.remove(tokens, 1) ! while (table.getn(tokens) > 0 and m_text_size(new_line.." "..tokens[1]) < self.w) do new_line = new_line.." "..tokens[1] table.remove(tokens, 1) --- 100,104 ---- table.remove(tokens, 1) ! while (#tokens > 0 and m_text_size(new_line.." "..tokens[1]) < self.w) do new_line = new_line.." "..tokens[1] table.remove(tokens, 1) *************** *** 107,111 **** -- Continue indicates if writing should continue after this line -- or if it should show a blinking square (end of sentence) ! if (table.getn(tokens) > 0) then self.continue = 1 self.lines_todo[1] = detokenize(tokens) --- 107,111 ---- -- Continue indicates if writing should continue after this line -- or if it should show a blinking square (end of sentence) ! if (#tokens > 0) then self.continue = 1 self.lines_todo[1] = detokenize(tokens) *************** *** 154,158 **** elseif (self.state == CB_WRITING) then ! local current_string = self.lines[table.getn(self.lines)] local length = string.len(current_string) --- 154,158 ---- elseif (self.state == CB_WRITING) then ! local current_string = self.lines[#self.lines] local length = string.len(current_string) *************** *** 220,227 **** -- Draw the shadow of the text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) ! for n = 1, table.getn(self.lines) do m_set_color(0, 0, 0) m_set_cursor(self.x + 1, self.y + (n - 1) * self.line_height - self.scroll + 1) ! if (n == table.getn(self.lines)) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else --- 220,227 ---- -- Draw the shadow of the text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) ! for n = 1, #self.lines do m_set_color(0, 0, 0) m_set_cursor(self.x + 1, self.y + (n - 1) * self.line_height - self.scroll + 1) ! if (n == #self.lines) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else *************** *** 251,258 **** -- Draw the lines of text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) ! for n = 1, table.getn(self.lines) do m_set_color(guiTheme:getTextColor()) m_set_cursor(self.x, self.y + (n - 1) * self.line_height - self.scroll) ! if (n == table.getn(self.lines)) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else --- 251,258 ---- -- Draw the lines of text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) ! for n = 1, #self.lines do m_set_color(guiTheme:getTextColor()) m_set_cursor(self.x, self.y + (n - 1) * self.line_height - self.scroll) ! if (n == #self.lines) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else Index: Pawn.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Pawn.lua,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Pawn.lua 13 Jan 2004 16:32:35 -0000 1.11 --- Pawn.lua 27 Jan 2007 02:14:47 -0000 1.12 *************** *** 58,63 **** -- A scream perhaps? ! if (table.getn(self.hitSounds) > 0) then ! local sampleFile = self.hitSounds[math.random(table.getn(self.hitSounds))] m_play_sample(sampleFile) end --- 58,63 ---- -- A scream perhaps? ! if (#self.hitSounds > 0) then ! local sampleFile = self.hitSounds[math.random(#self.hitSounds)] m_play_sample(sampleFile) end Index: MessPile.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/MessPile.lua,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MessPile.lua 13 Jan 2004 16:32:35 -0000 1.10 --- MessPile.lua 27 Jan 2007 02:14:47 -0000 1.11 *************** *** 27,31 **** activatedBy = function(self, obj) if (self.containsEngines) then ! if (table.getn(obj.inventory) >= 3) then ActionController:addSequence{ ActionConversation(lang:getConv("InventoryFullAtRockets")), --- 27,31 ---- activatedBy = function(self, obj) if (self.containsEngines) then ! if (#obj.inventory >= 3) then ActionController:addSequence{ ActionConversation(lang:getConv("InventoryFullAtRockets")), Index: PlayerController.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/PlayerController.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PlayerController.lua 31 Dec 2003 17:05:55 -0000 1.6 --- PlayerController.lua 27 Jan 2007 02:14:47 -0000 1.7 *************** *** 40,44 **** local i = 1 ! while (i <= table.getn(objs) and not activated) do if (objs[i].bCanActivate) then -- By returning true, an object can indicate nothing else should be activated --- 40,44 ---- local i = 1 ! while (i <= #objs and not activated) do if (objs[i].bCanActivate) then -- By returning true, an object can indicate nothing else should be activated Index: Action.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Action.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Action.lua 3 Jan 2004 00:16:32 -0000 1.9 --- Action.lua 27 Jan 2007 02:14:47 -0000 1.10 *************** *** 63,70 **** init = function(self, seq) ! m_message("ActionSequence initializing with ".. table.getn(seq) .." actions.") self.actions = {} ! for i = 1, table.getn(seq) do local env = {} setmetatable(env, {__index = seq[i]}) --- 63,70 ---- init = function(self, seq) ! m_message("ActionSequence initializing with ".. #seq .." actions.") self.actions = {} ! for i = 1, #seq do local env = {} setmetatable(env, {__index = seq[i]}) *************** *** 76,85 **** exec = function(self) ! while (self.i <= table.getn(self.actions) and self.actions[self.i]:exec()) do m_message("ActionSequence finished executing ".. self.actions[self.i].name) self.i = self.i + 1 end ! return (self.i > table.getn(self.actions)) end; } --- 76,85 ---- exec = function(self) ! while (self.i <= #self.actions and self.actions[self.i]:exec()) do m_message("ActionSequence finished executing ".. self.actions[self.i].name) self.i = self.i + 1 end ! return (self.i > #self.actions) end; } *************** *** 90,99 **** init = function(self, actions) ! m_message("ActionParallel initializing with ".. table.getn(actions) .." actions.") self.actions = {} -- Add all actions to the list of actions to execute. local i ! for i = 1, table.getn(actions) do if (actions[i] and actions[i]:instanceOf(Action)) then -- Create an action execution environment for this action --- 90,99 ---- init = function(self, actions) ! m_message("ActionParallel initializing with ".. #actions .." actions.") self.actions = {} -- Add all actions to the list of actions to execute. local i ! for i = 1, #actions do if (actions[i] and actions[i]:instanceOf(Action)) then -- Create an action execution environment for this action *************** *** 113,118 **** -- Execute all running actions ! for i = 1, table.getn(self.actions) do ! if (i <= table.getn(self.actions) and self.actions[i]:exec()) then m_message("ActionParallel finished executing "..self.actions[i].name) table.remove(self.actions, i) --- 113,118 ---- -- Execute all running actions ! for i = 1, #self.actions do ! if (i <= #self.actions) and self.actions[i]:exec() then m_message("ActionParallel finished executing "..self.actions[i].name) table.remove(self.actions, i) *************** *** 121,125 **** end ! return table.getn(self.actions) == 0 end; } --- 121,125 ---- end ! return #self.actions == 0 end; } *************** *** 150,154 **** init = function(self, f, ...) self.f = f ! self.arg = arg end; --- 150,154 ---- init = function(self, f, ...) self.f = f ! self.arg = {...} end; *************** *** 298,302 **** self.actions = {} ! for w in string.gfind(path, "[UDLR]%d*") do local dir = string.sub(w,1,1) if (dir == "U") then dir = DIR_UP end --- 298,302 ---- self.actions = {} ! for w in string.gmatch(path, "[UDLR]%d*") do local dir = string.sub(w,1,1) if (dir == "U") then dir = DIR_UP end *************** *** 349,353 **** table.insert(exModeArray, m_get_ex_mode()) m_set_ex_mode(1) ! --m_message("Exclusive mode turned on (".. table.getn(exModeArray) ..")") return true end; --- 349,353 ---- table.insert(exModeArray, m_get_ex_mode()) m_set_ex_mode(1) ! --m_message("Exclusive mode turned on (".. #exModeArray) ..")") return true end; *************** *** 359,366 **** exec = function(self) ! if (table.getn(exModeArray) > 0) then ! m_set_ex_mode(exModeArray[table.getn(exModeArray)]) ! table.remove(exModeArray, table.getn(exModeArray)) ! --m_message("Exclusive mode turned off (".. table.getn(exModeArray) ..")") else m_set_ex_mode(0) --- 359,366 ---- exec = function(self) ! if (#exModeArray > 0) then ! m_set_ex_mode(exModeArray[#exModeArray]) ! table.remove(exModeArray, #exModeArray) ! --m_message("Exclusive mode turned off (".. #exModeArray) ..")") else m_set_ex_mode(0) Index: ElecDoor.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/ElecDoor.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ElecDoor.lua 13 Jan 2004 16:32:35 -0000 1.9 --- ElecDoor.lua 27 Jan 2007 02:14:47 -0000 1.10 *************** *** 26,30 **** if (self.closeTimer <= 0) then self.closeTimer = 1 ! if (table.getn(m_get_objects_at(self.x + 0.5, self.y - 0.5, self.map)) == 1) then self.closeTimer = 0 self.toStatus = 0 --- 26,30 ---- if (self.closeTimer <= 0) then self.closeTimer = 1 ! if (#m_get_objects_at(self.x + 0.5, self.y - 0.5, self.map) == 1) then self.closeTimer = 0 self.toStatus = 0 *************** *** 55,59 **** updateBitmap = function(self) local s = math.sin(self.status * 0.5 * math.pi) ! local bi = (table.getn(self.bitmaps) - 1) * s + 1 self.bitmap = self.bitmaps[math.ceil(bi - 0.5)] --- 55,59 ---- updateBitmap = function(self) local s = math.sin(self.status * 0.5 * math.pi) ! local bi = (#self.bitmaps - 1) * s + 1 self.bitmap = self.bitmaps[math.ceil(bi - 0.5)] Index: PlayerSwitcher.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/PlayerSwitcher.lua,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayerSwitcher.lua 3 Jan 2004 18:50:44 -0000 1.7 --- PlayerSwitcher.lua 27 Jan 2007 02:14:47 -0000 1.8 *************** *** 47,55 **** table.remove(self.playerHosts, iIndex) if (iIndex == self.currentHost) then ! if (self.currentHost > table.getn(self.playerHosts)) then self.currentHost = 1 end ! if (table.getn(self.playerHosts) > 0) then self:selectPlayerHost(self.playerHosts[self.currentHost]) else --- 47,55 ---- table.remove(self.playerHosts, iIndex) if (iIndex == self.currentHost) then ! if (self.currentHost > #self.playerHosts) then self.currentHost = 1 end ! if #self.playerHosts > 0 then self:selectPlayerHost(self.playerHosts[self.currentHost]) else *************** *** 84,88 **** -- Search for the Interaction iIndex = -1; ! for i = 1, table.getn(self.playerHosts) do if (self.playerHosts[i] == playerHost) then iIndex = i --- 84,88 ---- -- Search for the Interaction iIndex = -1; ! for i = 1, #self.playerHosts do if (self.playerHosts[i] == playerHost) then iIndex = i *************** *** 94,98 **** keyType = function(self, key) ! if (key == "tab" and table.getn(self.playerHosts) > 0 and m_get_ex_mode() == 0) then local prevHost = self:getCurrentHost() --- 94,98 ---- keyType = function(self, key) ! if (key == "tab" and #self.playerHosts > 0 and m_get_ex_mode() == 0) then local prevHost = self:getCurrentHost() *************** *** 100,108 **** self.currentHost = self.currentHost - 1 if (self.currentHost < 1) then ! self.currentHost = table.getn(self.playerHosts) end else self.currentHost = self.currentHost + 1 ! if (self.currentHost > table.getn(self.playerHosts)) then self.currentHost = 1 end --- 100,108 ---- self.currentHost = self.currentHost - 1 if (self.currentHost < 1) then ! self.currentHost = #self.playerHosts end else self.currentHost = self.currentHost + 1 ! if (self.currentHost > #self.playerHosts) then self.currentHost = 1 end *************** *** 152,156 **** -- and highlight the selected player ! for i = 1, table.getn(self.playerHosts) do local player = self.playerHosts[i] local health_perc = player.health / player.maxHealth --- 152,156 ---- -- and highlight the selected player ! for i = 1, #self.playerHosts do local player = self.playerHosts[i] local health_perc = player.health / player.maxHealth *************** *** 160,164 **** local invHeight = 19 ! if (table.getn(player.inventory) == 0) then invHeight = 0 end --- 160,164 ---- local invHeight = 19 ! if (#player.inventory) == 0 then invHeight = 0 end Index: Player.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Player.lua,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Player.lua 13 Jan 2004 16:32:35 -0000 1.12 --- Player.lua 27 Jan 2007 02:14:47 -0000 1.13 *************** *** 49,53 **** if (self.dir == DIR_DOWN) then ay = ay + 1 end local attacked_objs = m_get_objects_at(ax, ay, self.map) ! for index, object in attacked_objs do if (object:instanceOf(Actor)) then local damage = (self.attack_min_dam + math.random(self.attack_max_dam - self.attack_min_dam))*(self.strength/95 + 18/19) --- 49,53 ---- if (self.dir == DIR_DOWN) then ay = ay + 1 end local attacked_objs = m_get_objects_at(ax, ay, self.map) ! for index, object in ipairs(attacked_objs) do if (object:instanceOf(Actor)) then local damage = (self.attack_min_dam + math.random(self.attack_max_dam - self.attack_min_dam))*(self.strength/95 + 18/19) Index: Animation.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Animation.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Animation.lua 25 Dec 2003 20:50:41 -0000 1.2 --- Animation.lua 27 Jan 2007 02:14:47 -0000 1.3 *************** *** 15,19 **** init = function(self, animation) self.animSeq = animation ! self.animLength = table.getn(animation) end; --- 15,19 ---- init = function(self, animation) self.animSeq = animation ! self.animLength = #animation end; *************** *** 103,109 **** update_bitmap = function(self) ! local nr = table.getn(self.animation) ! if (self.animation and table.getn(self.animation) > 0) then self.bitmap = self.animation[self.animation_count] end --- 103,109 ---- update_bitmap = function(self) ! local nr = #self.animation ! if (self.animation and #self.animation > 0) then self.bitmap = self.animation[self.animation_count] end *************** *** 152,156 **** update_bitmap = function(self) if (self.animation) then ! local nr = table.getn(self.animation) if (nr == 1) then self.bitmap = self.animation[1] --- 152,156 ---- update_bitmap = function(self) if (self.animation) then ! local nr = #self.animation if (nr == 1) then self.bitmap = self.animation[1] *************** *** 197,206 **** update_bitmap = function(self) ! if (self.animation and table.getn(self.animation) > 0) then ! while (self.animation and table.getn(self.animation) > 0 and self.frame_count > self.animation[self.animation_count][2]) do self.frame_count = self.frame_count - self.animation[self.animation_count][2] self.animation_count = self.animation_count + 1 ! if (self.animation_count > table.getn(self.animation)) then self.animation_count = 1 --- 197,206 ---- update_bitmap = function(self) ! if (self.animation and #self.animation > 0) then ! while (self.animation and #self.animation > 0 and self.frame_count > self.animation[self.animation_count][2]) do self.frame_count = self.frame_count - self.animation[self.animation_count][2] self.animation_count = self.animation_count + 1 ! if (self.animation_count > #self.animation) then self.animation_count = 1 *************** *** 211,215 **** end ! if (self.animation and table.getn(self.animation) > 0) then self.bitmap = self.animation[self.animation_count][1] end --- 211,215 ---- end ! if (self.animation and #self.animation > 0) then self.bitmap = self.animation[self.animation_count][1] end |
From: Bjørn L. <b_l...@us...> - 2007-01-27 02:14:51
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13247 Modified Files: README configure Log Message: Upgraded BBRpg to work with Lua 5.1. Index: README =================================================================== RCS file: /cvsroot/moeng/BBRpg/README,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README 10 Dec 2004 14:15:36 -0000 1.8 --- README 27 Jan 2007 02:14:47 -0000 1.9 *************** *** 88,99 **** ------- ! 1.1.1 - October, Xth (Final release) ! ! / A lot of small fixes ! / Some more efficient object handling ! TODO: Examine commit messages ! ! 1.1.0 - January, 10th (First post-compo release) * Added the Blues music, the biggest thing missing in our previous version --- 88,97 ---- ------- ! 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) * Added the Blues music, the biggest thing missing in our previous version *************** *** 104,106 **** ! 1.0.0 - January, 2nd (First public release) --- 102,104 ---- ! 1.0.0 - 2 January, 2004 (First public release) Index: configure =================================================================== RCS file: /cvsroot/moeng/BBRpg/configure,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** configure 13 Apr 2004 12:26:07 -0000 1.13 --- configure 27 Jan 2007 02:14:47 -0000 1.14 *************** *** 170,178 **** EOF ! echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null" >>$LOG ! echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null" >>$LOGERR ! if $CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null >>$LOG 2>>$LOGERR ; then # gelukt ! LIBS="$LIBS -llua -llualib" echo "yes" else --- 170,178 ---- EOF ! echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -ldl -o /dev/null" >>$LOG ! echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -ldl -o /dev/null" >>$LOGERR ! if $CC $CPPFLAGS conftest.cpp $LIBS -llua -ldl -o /dev/null >>$LOG 2>>$LOGERR ; then # gelukt ! LIBS="$LIBS -llua" echo "yes" else |
From: Bjørn L. <b_l...@us...> - 2007-01-27 02:14:51
|
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13247/src/editor Modified Files: script.cpp Log Message: Upgraded BBRpg to work with Lua 5.1. Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** script.cpp 23 Oct 2004 11:54:18 -0000 1.7 --- script.cpp 27 Jan 2007 02:14:47 -0000 1.8 *************** *** 96,100 **** lua_register(L, "import", l_import); ! handleLuaError(lua_dostring(L, lua_include), "lua_include"); --- 96,100 ---- lua_register(L, "import", l_import); ! handleLuaError(luaL_dostring(L, lua_include), "lua_include"); *************** *** 450,454 **** const char *name; getLuaArguments(L, "s", &name); ! BITMAP* found_bitmap = found_bitmap = module->findBitmap(name); if (found_bitmap) { --- 450,454 ---- const char *name; getLuaArguments(L, "s", &name); ! BITMAP* found_bitmap = module->findBitmap(name); if (found_bitmap) { |
From: Bjørn L. <b_l...@us...> - 2007-01-27 02:14:50
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13247/src Modified Files: script.cpp Log Message: Upgraded BBRpg to work with Lua 5.1. Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** script.cpp 23 Oct 2004 11:54:18 -0000 1.16 --- script.cpp 27 Jan 2007 02:14:47 -0000 1.17 *************** *** 62,73 **** { // Create Lua state ! L = lua_open(); // Enable these Lua libraries to the script ! luaopen_base(L); ! luaopen_string(L); ! luaopen_math(L); ! luaopen_table(L); ! luaopen_io(L); // Add the Object type to Lua --- 62,73 ---- { // Create Lua state ! L = luaL_newstate(); // Enable these Lua libraries to the script ! lua_pushcfunction(L, luaopen_base); lua_call(L, 0, 0); ! lua_pushcfunction(L, luaopen_string); lua_call(L, 0, 0); ! lua_pushcfunction(L, luaopen_math); lua_call(L, 0, 0); ! lua_pushcfunction(L, luaopen_table); lua_call(L, 0, 0); ! lua_pushcfunction(L, luaopen_io); lua_call(L, 0, 0); // Add the Object type to Lua *************** *** 152,156 **** lua_register(L, "m_get_shift", l_get_shift); ! handleLuaError(lua_dostring(L, lua_include), "lua_include"); --- 152,156 ---- lua_register(L, "m_get_shift", l_get_shift); ! handleLuaError(luaL_dostring(L, lua_include), "lua_include"); |
From: Bjørn L. <b_l...@us...> - 2004-12-15 12:09:07
|
Update of /cvsroot/moeng/CaveAdventure/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/src Modified Files: rpg.cpp Log Message: Make latest CaveAdventure CVS at least compile with latest GCC Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/src/rpg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rpg.cpp 13 Jan 2004 17:18:07 -0000 1.1 --- rpg.cpp 15 Dec 2004 12:08:53 -0000 1.2 *************** *** 1,12 **** /* ! 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. ! */ #include "rpg.h" --- 1,12 ---- /* ! * 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. ! */ #include "rpg.h" *************** *** 53,73 **** BITMAP *buffer; ! void main() { ! init_engine(); ! do { ! // Handle user input ! if (frames_to_do > 0) { ! handle_input(); ! frames_to_do--; ! // If less than 2 extra frames are waiting, take time to display current frame ! if (frames_to_do < 2) {draw_screen();} ! else if (frames_to_do > 10) {frames_to_do = frames_to_do % 10;} ! } ! } while (!game_end); ! exit_program(); } END_OF_MAIN(); --- 53,75 ---- BITMAP *buffer; ! int main() { ! init_engine(); ! do { ! // Handle user input ! if (frames_to_do > 0) { ! handle_input(); ! frames_to_do--; ! // If less than 2 extra frames are waiting, take time to display ! if (frames_to_do < 2) {draw_screen();} ! else if (frames_to_do > 10) {frames_to_do = frames_to_do % 10;} ! } ! } while (!game_end); ! exit_program(); ! ! return 0; } END_OF_MAIN(); *************** *** 76,215 **** void init_engine() { ! // Allegro initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initializing Allegro..."); ! allegro_init(); ! install_keyboard(); ! install_timer(); ! three_finger_flag = 0; ! set_display_switch_mode(SWITCH_BACKAMNESIA); ! //register_datafile_object(DAT_MAPDATA, load_tiledmapdata, destroy_tiledmapdata); ! set_config_file("rpg.cfg"); ! lps = get_config_int("Engine", "GameSpeed", 100); ! debug_mode = (get_config_int("Engine", "DebugMode", 0)) ? 1 : 0; ! debug_mode += (get_config_int("Engine", "DebugVerbose", 0)) ? 1 : 0; ! int driver = GFX_AUTODETECT_WINDOWED; ! if (get_config_int("Video", "Fullscreen", 0)) { ! driver = GFX_AUTODETECT_FULLSCREEN; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! bVSync = get_config_int("Video", "VSync", 0); ! ! sound_enabled = (get_config_int("Sound", "MusicEnabled", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "SfxEnabled", 1)) ? 1 : 0; ! music_vol = get_config_int("Sound", "MusicVolume", 255); ! sfx_vol = get_config_int("Sound", "SfxVolume", 255); ! music_format = (strcmp(get_config_string("Sound", "MusicFormat", "MIDI"), "MIDI") == 0) ? MUSIC_MIDI : MUSIC_OGG; ! console.enableLogfile = (get_config_int("Engine", "LogEnabled", 1)); ! // Screen initialisation ! int width, height, colordepth = 0; ! width = get_config_int("Video", "ResolutionWidth", 640); ! height = get_config_int("Video", "ResolutionHeight", 480); ! if (driver == GFX_AUTODETECT_FULLSCREEN) {colordepth = desktop_color_depth();} ! if (colordepth == 0) {colordepth = 16;} ! colordepth = get_config_int("Video", "ColorDepth", colordepth); ! bDoubleSize = get_config_int("Video", "DoubleSize", 0); ! if (bDoubleSize) { ! width = width * 2; ! height = height * 2; ! } ! console.log(CON_LOG, CON_ALWAYS, "Setting screen mode (%dx%dx%d)...", width, height, colordepth); ! set_color_depth(colordepth); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_LOG, CON_ALWAYS, "Failed, trying screen mode (%dx%dx15)...", width, height); ! set_color_depth(15); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_QUIT, CON_ALWAYS, "%s", allegro_error); ! } ! } ! set_window_title("Moonlight RPG engine"); ! text_mode(-1); ! textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(255,0,0), "LOADING..."); ! console.log(CON_LOG, CON_ALWAYS, "Creating screen buffer..."); ! if (bDoubleSize) { ! buffer = create_bitmap(SCREEN_W / 2, SCREEN_H / 2); ! } else { ! buffer = create_bitmap(SCREEN_W, SCREEN_H); ! } ! clear(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Creating tile repository..."); ! tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! interface_graphics = load_datafile("gui.dat"); ! if (!interface_graphics) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); ! } ! // Set font to use ! DATAFILE *temp = find_datafile_object(interface_graphics, "SmallFont"); ! if (temp) {engine_font = ((FONT *)temp->dat);} ! console.log(CON_LOG, CON_ALWAYS, "Loading data.dat..."); ! bitmap_data = load_datafile("data.dat"); ! if (!bitmap_data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); ! } ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); ! init_sound(); ! } ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising Lua scripting environment..."); ! initScripting(); ! console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); ! LOCK_VARIABLE(frames_to_do); // Game speed handler ! LOCK_FUNCTION(handle_game_time); ! LOCK_VARIABLE(fps); // Frames per second counter ! LOCK_VARIABLE(fps_counter); ! LOCK_FUNCTION(handle_fps_counter); ! install_int_ex(handle_game_time, BPS_TO_TIMER(lps)); ! install_int_ex(handle_fps_counter, BPS_TO_TIMER(1)); ! console.log(CON_LOG, CON_ALWAYS, "Initialising canvas..."); ! canvas.init(); ! console.log(CON_LOG, CON_ALWAYS, "All finished, initializing game..."); ! const char* gameClass = get_config_string("Engine", "GameClass", "Game"); ! lua_pushstring(L, gameClass); lua_gettable(L, LUA_GLOBALSINDEX); ! if (!lua_isnil(L, -1)) { ! lua_call(L, 0, 1); ! if (lua_istable(L, -1)) { ! gameClassInstance = lua_ref(L, -1); ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, "Error while instaniating game class \"%s\"", gameClass); ! } ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, "Error: could not find game class \"%s\"", gameClass); ! } ! clear(screen); } --- 78,225 ---- void init_engine() { ! // Allegro initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initializing Allegro..."); ! allegro_init(); ! install_keyboard(); ! install_timer(); ! three_finger_flag = 0; ! set_display_switch_mode(SWITCH_BACKAMNESIA); ! set_config_file("rpg.cfg"); ! lps = get_config_int("Engine", "GameSpeed", 100); ! debug_mode = (get_config_int("Engine", "DebugMode", 0)) ? 1 : 0; ! debug_mode += (get_config_int("Engine", "DebugVerbose", 0)) ? 1 : 0; ! int driver = GFX_AUTODETECT_WINDOWED; ! if (get_config_int("Video", "Fullscreen", 0)) { ! driver = GFX_AUTODETECT_FULLSCREEN; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! bVSync = get_config_int("Video", "VSync", 0); ! sound_enabled = (get_config_int("Sound", "MusicEnabled", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "SfxEnabled", 1)) ? 1 : 0; ! music_vol = get_config_int("Sound", "MusicVolume", 255); ! sfx_vol = get_config_int("Sound", "SfxVolume", 255); ! music_format = (strcmp(get_config_string("Sound", "MusicFormat", "MIDI"), ! "MIDI") == 0) ? MUSIC_MIDI : MUSIC_OGG; ! console.enableLogfile = (get_config_int("Engine", "LogEnabled", 1)); ! // Screen initialisation ! int width, height, colordepth = 0; ! width = get_config_int("Video", "ResolutionWidth", 640); ! height = get_config_int("Video", "ResolutionHeight", 480); ! if (driver == GFX_AUTODETECT_FULLSCREEN) { ! colordepth = desktop_color_depth(); ! } ! if (colordepth == 0) { ! colordepth = 16; ! } ! colordepth = get_config_int("Video", "ColorDepth", colordepth); ! bDoubleSize = get_config_int("Video", "DoubleSize", 0); ! if (bDoubleSize) { ! width = width * 2; ! height = height * 2; ! } ! console.log(CON_LOG, CON_ALWAYS, ! "Setting screen mode (%dx%dx%d)...", width, height, colordepth); ! set_color_depth(colordepth); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_LOG, CON_ALWAYS, ! "Failed, trying screen mode (%dx%dx15)...", width, height); ! set_color_depth(15); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_QUIT, CON_ALWAYS, "%s", allegro_error); ! } ! } ! set_window_title("Moonlight RPG engine"); ! textprintf_centre_ex( ! screen, font, SCREEN_W/2, SCREEN_H/2, makecol(255,0,0), -1, ! "LOADING..."); ! console.log(CON_LOG, CON_ALWAYS, "Creating screen buffer..."); ! if (bDoubleSize) { ! buffer = create_bitmap(SCREEN_W / 2, SCREEN_H / 2); ! } else { ! buffer = create_bitmap(SCREEN_W, SCREEN_H); ! } ! clear(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Creating tile repository..."); ! tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! interface_graphics = load_datafile("gui.dat"); ! if (!interface_graphics) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); ! } ! // Set font to use ! DATAFILE *temp = find_datafile_object(interface_graphics, "SmallFont"); ! if (temp) {engine_font = ((FONT *)temp->dat);} ! console.log(CON_LOG, CON_ALWAYS, "Loading data.dat..."); ! bitmap_data = load_datafile("data.dat"); ! if (!bitmap_data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); ! } ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); ! init_sound(); ! } ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment..."); ! initScripting(); ! console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); ! LOCK_VARIABLE(frames_to_do); // Game speed handler ! LOCK_FUNCTION(handle_game_time); ! LOCK_VARIABLE(fps); // Frames per second counter ! LOCK_VARIABLE(fps_counter); ! LOCK_FUNCTION(handle_fps_counter); ! install_int_ex(handle_game_time, BPS_TO_TIMER(lps)); ! install_int_ex(handle_fps_counter, BPS_TO_TIMER(1)); ! console.log(CON_LOG, CON_ALWAYS, "Initialising canvas..."); ! canvas.init(); ! console.log(CON_LOG, CON_ALWAYS, "All finished, initializing game..."); ! const char* gameClass = get_config_string("Engine", "GameClass", "Game"); ! lua_pushstring(L, gameClass); lua_gettable(L, LUA_GLOBALSINDEX); ! if (!lua_isnil(L, -1)) { ! lua_call(L, 0, 1); ! if (lua_istable(L, -1)) { ! gameClassInstance = lua_ref(L, -1); ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, ! "Error while instaniating game class \"%s\"", gameClass); ! } ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, ! "Error: could not find game class \"%s\"", gameClass); ! } ! clear(screen); } *************** *** 217,256 **** void handle_input() { ! if (keypressed()) { ! inkey = (readkey() >> 8); ! if (console.handleInput(inkey)) inkey = 0; ! } ! else { ! inkey = 0; ! } ! if (inkey > 0) ! { ! char *key_name = "anykey"; ! if (inkey == KEY_ESC) key_name = "esc"; ! if (inkey == KEY_TAB) key_name = "tab"; ! if (inkey == KEY_SPACE || inkey == KEY_ENTER) key_name = "action"; ! if (inkey == KEY_UP) key_name = "up"; ! if (inkey == KEY_LEFT) key_name = "left"; ! if (inkey == KEY_RIGHT) key_name = "right"; ! if (inkey == KEY_DOWN) key_name = "down"; ! if (inkey == KEY_LCONTROL || inkey == KEY_RCONTROL) key_name = "ctrl"; ! callMemberFunction(gameClassInstance, "event_keypress", "s", key_name); ! } ! update_objects(); ! callMemberFunction(gameClassInstance, "event_logic_update"); ! console.update(); #ifdef ENABLE_MUSIC ! if (sound_enabled && sound_counter == 0) { ! poll_sound(); ! sound_counter = 10; ! } ! sound_counter--; #endif } --- 227,266 ---- void handle_input() { ! if (keypressed()) { ! inkey = (readkey() >> 8); ! if (console.handleInput(inkey)) inkey = 0; ! } ! else { ! inkey = 0; ! } ! if (inkey > 0) ! { ! char *key_name = "anykey"; ! if (inkey == KEY_ESC) key_name = "esc"; ! if (inkey == KEY_TAB) key_name = "tab"; ! if (inkey == KEY_SPACE || inkey == KEY_ENTER) key_name = "action"; ! if (inkey == KEY_UP) key_name = "up"; ! if (inkey == KEY_LEFT) key_name = "left"; ! if (inkey == KEY_RIGHT) key_name = "right"; ! if (inkey == KEY_DOWN) key_name = "down"; ! if (inkey == KEY_LCONTROL || inkey == KEY_RCONTROL) key_name = "ctrl"; ! callMemberFunction(gameClassInstance, "event_keypress", "s", key_name); ! } ! update_objects(); ! callMemberFunction(gameClassInstance, "event_logic_update"); ! console.update(); #ifdef ENABLE_MUSIC ! if (sound_enabled && sound_counter == 0) { ! poll_sound(); ! sound_counter = 10; ! } ! sound_counter--; #endif } *************** *** 259,287 **** void draw_screen() { ! clear_bitmap(buffer); ! callMemberFunction(gameClassInstance, "event_render"); ! canvas.init(); ! if (debug_mode) { ! font = engine_font; ! textprintf_centre(buffer, font, buffer->w / 2 + 1, 12, makecol(0,0,0) , "%d fps", fps); ! textprintf_centre(buffer, font, buffer->w / 2, 11, makecol(128,128,150), "%d fps", fps); ! } ! console.draw(buffer); ! update_screen(); ! fps_counter++; } void update_screen() { ! if (bVSync) vsync(); ! if (bDoubleSize) { ! stretch_blit(buffer, screen, 0, 0, buffer->w, buffer->h, 0, 0, buffer->w * 2, buffer->h * 2); ! } else { ! blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h); ! } } --- 269,303 ---- void draw_screen() { ! clear_bitmap(buffer); ! callMemberFunction(gameClassInstance, "event_render"); ! canvas.init(); ! if (debug_mode) { ! font = engine_font; ! textprintf_centre_ex( ! buffer, font, buffer->w / 2 + 1, 12, makecol(0,0,0), -1, ! "%d fps", fps); ! textprintf_centre_ex( ! buffer, font, buffer->w / 2, 11, makecol(128,128,150), -1, ! "%d fps", fps); ! } ! console.draw(buffer); ! update_screen(); ! fps_counter++; } void update_screen() { ! if (bVSync) vsync(); ! if (bDoubleSize) { ! stretch_blit(buffer, screen, ! 0, 0, buffer->w, buffer->h, ! 0, 0, buffer->w * 2, buffer->h * 2); ! } else { ! blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h); ! } } *************** *** 289,325 **** void exit_program() { ! console.log(CON_LOG, CON_ALWAYS, "Game ended"); ! console.log(CON_LOG, CON_ALWAYS, "Deleting objects..."); ! list<TiledMap*>::iterator i; ! while (!maps.empty()) ! { ! i = maps.begin(); ! delete (*i); ! maps.erase(i); ! } ! console.log(CON_LOG, CON_ALWAYS, "Deleting tile repository..."); ! delete tileRepository; ! console.log(CON_LOG, CON_ALWAYS, "Removing timers..."); ! remove_int(handle_fps_counter); ! remove_int(handle_game_time); ! console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(interface_graphics); ! unload_datafile(bitmap_data); ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Deinitializing sound..."); ! exit_sound(); ! } ! console.log(CON_LOG, CON_ALWAYS, "Destroying screen buffer..."); ! destroy_bitmap(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Closing Lua scripting environment..."); ! exitScripting(); ! exit(0); } --- 305,342 ---- void exit_program() { ! console.log(CON_LOG, CON_ALWAYS, "Game ended"); ! console.log(CON_LOG, CON_ALWAYS, "Deleting objects..."); ! list<TiledMap*>::iterator i; ! while (!maps.empty()) ! { ! i = maps.begin(); ! delete (*i); ! maps.erase(i); ! } ! console.log(CON_LOG, CON_ALWAYS, "Deleting tile repository..."); ! delete tileRepository; ! console.log(CON_LOG, CON_ALWAYS, "Removing timers..."); ! remove_int(handle_fps_counter); ! remove_int(handle_game_time); ! console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(interface_graphics); ! unload_datafile(bitmap_data); ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Deinitializing sound..."); ! exit_sound(); ! } ! console.log(CON_LOG, CON_ALWAYS, "Destroying screen buffer..."); ! destroy_bitmap(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Closing scripting environment..."); ! exitScripting(); ! console.log(CON_LOG, CON_ALWAYS, "Shutdown complete, exiting..."); ! exit(0); } |
From: Bjørn L. <b_l...@us...> - 2004-12-10 14:15:46
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25632/data/scripts Modified Files: SubcityObjects.lua Log Message: Fixed bed bug Index: SubcityObjects.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/SubcityObjects.lua,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** SubcityObjects.lua 8 Feb 2004 14:53:59 -0000 1.40 --- SubcityObjects.lua 10 Dec 2004 14:15:37 -0000 1.41 *************** *** 6,225 **** WallJakesPlace = Decoration:subclass { ! name = "WallJakesPlace"; ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! obstacle = 0, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("wall_jakes_place.bmp"), ! } } Dustbin = Decoration:subclass { ! name = "Dustbin"; ! bPlaceable = true; ! ! beginPlay = function(self) ! Decoration.beginPlay(self) ! self.snowTop = self:spawn(SnowOnDustbin, x, y) ! end; ! setPosition = function(self, x, y) ! Decoration.setPosition(self, x, y) ! if (self.snowTop) then ! self.snowTop.x = self.x ! self.snowTop.y = self.y ! end ! end; ! takeDamage = function(self, damage) ! m_play_sample("bbsfx_hit4.wav") ! ActionController:addSequence{ ! ActionParallel{ ! ActionTweenVariable( ! self, "offset_x", 20, 1, self.offset_x, ! function(from, to, perc) ! return from + math.ceil(math.mod(perc * 6, 2) - 0.5) ! end ! ), ! }, ! ActionSetVariable(self, "offset_x", self.offset_x), ! } ! if (self.snowTop) then ! ActionController:addSequence{ ! ActionTweenVariable( ! self.snowTop, "offset_x", 20, 1, self.snowTop.offset_x, ! function(from, to, perc) ! return from + math.ceil(math.mod(perc * 6, 2) - 0.5) ! end ! ), ! ActionSetVariable(self.snowTop, "offset_x", -7), ! } ! end ! if (self.snowTop and (not self.snowfalling)) then ! ActionController:addSequence{ ! ActionSetVariable(self, "snowfalling", true), ! ActionTweenVariable(self.snowTop, "offset_z", 20, -6), ! ActionSetVariable(self.snowTop, "offset_z", 14), ! ActionChangeBitmap(self.snowTop, m_get_bitmap("dustbin_snow3.bmp")), ! ActionTweenVariable(self.snowTop, "alpha", 300, 0), ! ActionChangeBitmap(self.snowTop, m_get_bitmap("dustbin_snow1.bmp")), ! ActionTweenVariable(self.snowTop, "alpha", 500, 122), ! ActionSetVariable(self, "snowfalling", false), ! ActionTweenVariable(self.snowTop, "alpha", 500, 255), ! } ! end ! end; ! ! defaultproperties = { ! obstacle = 1, ! snowfalling = false, ! draw_mode = DM_ALPHA, ! bitmap = m_get_bitmap("dustbin.tga"), ! convTableKeyword = "Dustbin", ! snowTop = SnowOnDustbin, ! } } SnowOnDustbin = Actor:subclass { ! name = "SnowOnDustbin"; ! bPlaceable = false; ! ! defaultproperties = { ! offset_z = 14, ! offset_y = 10, ! offset_x = -7, ! alpha = 255, ! draw_mode = DM_TRANS, ! bitmap = m_get_bitmap("dustbin_snow1.bmp"), ! } } Keyboard = Decoration:subclass { ! name = "Keyboard"; ! ! tick = function(self) ! self.counter = math.mod(self.counter + 1, 8) ! self:updateBitmap() ! end; ! updateBitmap = function(self) ! self.counter = self.counter + 1 ! if (self.counter == 1) then self:setBitmap(self.bitmaps[5]) ! elseif (self.counter == 5) then self:setBitmap(self.bitmaps[1]) ! elseif (self.counter == 2 or self.counter == 6) then self:setBitmap(self.bitmaps[2]) ! elseif (self.counter == 3 or self.counter == 7) then self:setBitmap(self.bitmaps[3]) ! elseif (self.counter == 4 or self.counter == 8) then self:setBitmap(self.bitmaps[4]) end ! self.counter = self.counter - 1 ! end; ! defaultproperties = { ! offset_z = 15, ! obstacle = 0, ! tick_time = 60, ! counter = 1, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("keyboard.bmp"), 56, 13), ! convTableKeyword = "Keyboard", ! } } Onderstel = Decoration:subclass { ! name = "Onderstel"; ! bPlaceable = true; ! defaultproperties = { ! obstacle = 0, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("onderstel.bmp"), ! } } Guitar = Decoration:subclass { ! name = "Guitar"; ! ! init = function(self) ! Decoration.init(self) ! end; ! defaultproperties = { ! obstacle = 1, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("guitar.bmp"), ! convTableKeyword = "Guitar", ! } } TV = Decoration:subclass { ! name = "TV"; ! bPlaceable = true; ! defaultproperties = { ! obstacle = 1, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("tv.bmp"), ! convTableKeyword = "TV", ! } } Bed = Decoration:subclass { ! name = "Bed"; ! bPlaceable = true; ! activatedBy = function(self, obj) ! local bitmapje = self.bitmap ! ! if (obj.health == obj.maxHealth) then ! ActionController:addSequence{ ! ActionConversation(lang:getConv("BedAwake")), ! } ! elseif (not self.bOccupied) then ! ActionController:addSequence{ ! ActionSetVariable(self, "bOccupied", true), ! ActionConversation(lang:getConv("BedTiredBefore")), ! ActionCallFunction(obj.setSleeping, obj, true), ! ActionChangeBitmap(self, obj.sleepBitmap), ! ActionSetVariable(obj, "onActivate", ! function(self2) ! self2.onActivate = nil ! ActionController:addSequence{ ! ActionCallFunction(obj.setSleeping, obj, false), ! ActionSetVariable(obj, "dir", DIR_DOWN), ! ActionChangeBitmap(self, bitmapje), ! ActionConversation(lang:getConv("BedTiredAfterTable")[math.floor(table.getn(lang:getConv("BedTiredAfterTable")) * obj.health / obj.maxHealth) + 1]), ! ActionSetVariable(obj, "obstacle", 1), ! ActionSetVariable(self, "bOccupied", false), ! } ! end),get_new_n(self.prev_random, table.getn(self.convTable)) ! } ! else ! ActionController:addSequence{ ! ActionConversation(lang:getConv("BedOccupied")), ! } ! end ! end; ! ! defaultproperties = { ! bOccupied = false, ! bCanActivate = true, ! bCenterOnTile = false, ! bCenterBitmap = false, ! offset_x = 2, ! offset_y = -5, ! obstacle = 1, ! w = 2, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("bed.bmp"), ! } ! } --- 6,227 ---- WallJakesPlace = Decoration:subclass { ! name = "WallJakesPlace"; ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! obstacle = 0, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("wall_jakes_place.bmp"), ! } } Dustbin = Decoration:subclass { ! name = "Dustbin"; ! bPlaceable = true; ! beginPlay = function(self) ! Decoration.beginPlay(self) ! self.snowTop = self:spawn(SnowOnDustbin, x, y) ! end; ! setPosition = function(self, x, y) ! Decoration.setPosition(self, x, y) ! if (self.snowTop) then ! self.snowTop.x = self.x ! self.snowTop.y = self.y ! end ! end; ! ! takeDamage = function(self, damage) ! m_play_sample("bbsfx_hit4.wav") ! ActionController:addSequence{ ! ActionParallel{ ! ActionTweenVariable( ! self, "offset_x", 20, 1, self.offset_x, ! function(from, to, perc) ! return from + math.ceil(math.mod(perc * 6, 2) - 0.5) ! end ! ), ! }, ! ActionSetVariable(self, "offset_x", self.offset_x), ! } ! if (self.snowTop) then ! ActionController:addSequence{ ! ActionTweenVariable( ! self.snowTop, "offset_x", 20, 1, self.snowTop.offset_x, ! function(from, to, perc) ! return from + math.ceil(math.mod(perc * 6, 2) - 0.5) ! end ! ), ! ActionSetVariable(self.snowTop, "offset_x", -7), ! } ! end ! if (self.snowTop and (not self.snowfalling)) then ! ActionController:addSequence{ ! ActionSetVariable(self, "snowfalling", true), ! ActionTweenVariable(self.snowTop, "offset_z", 20, -6), ! ActionSetVariable(self.snowTop, "offset_z", 14), ! ActionChangeBitmap(self.snowTop, m_get_bitmap("dustbin_snow3.bmp")), ! ActionTweenVariable(self.snowTop, "alpha", 300, 0), ! ActionChangeBitmap(self.snowTop, m_get_bitmap("dustbin_snow1.bmp")), ! ActionTweenVariable(self.snowTop, "alpha", 500, 122), ! ActionSetVariable(self, "snowfalling", false), ! ActionTweenVariable(self.snowTop, "alpha", 500, 255), ! } ! end ! end; ! ! defaultproperties = { ! obstacle = 1, ! snowfalling = false, ! draw_mode = DM_ALPHA, ! bitmap = m_get_bitmap("dustbin.tga"), ! convTableKeyword = "Dustbin", ! snowTop = SnowOnDustbin, ! } } SnowOnDustbin = Actor:subclass { ! name = "SnowOnDustbin"; ! bPlaceable = false; ! ! defaultproperties = { ! offset_z = 14, ! offset_y = 10, ! offset_x = -7, ! alpha = 255, ! draw_mode = DM_TRANS, ! bitmap = m_get_bitmap("dustbin_snow1.bmp"), ! } } Keyboard = Decoration:subclass { ! name = "Keyboard"; ! tick = function(self) ! self.counter = math.mod(self.counter + 1, 8) ! self:updateBitmap() ! end; ! updateBitmap = function(self) ! self.counter = self.counter + 1 ! if (self.counter == 1) then self:setBitmap(self.bitmaps[5]) ! elseif (self.counter == 5) then self:setBitmap(self.bitmaps[1]) ! elseif (self.counter == 2 or self.counter == 6) then self:setBitmap(self.bitmaps[2]) ! elseif (self.counter == 3 or self.counter == 7) then self:setBitmap(self.bitmaps[3]) ! elseif (self.counter == 4 or self.counter == 8) then self:setBitmap(self.bitmaps[4]) end ! self.counter = self.counter - 1 ! end; ! ! defaultproperties = { ! offset_z = 15, ! obstacle = 0, ! tick_time = 60, ! counter = 1, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("keyboard.bmp"), 56, 13), ! convTableKeyword = "Keyboard", ! } } Onderstel = Decoration:subclass { ! name = "Onderstel"; ! bPlaceable = true; ! defaultproperties = { ! obstacle = 0, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("onderstel.bmp"), ! } } Guitar = Decoration:subclass { ! name = "Guitar"; ! init = function(self) ! Decoration.init(self) ! end; ! ! defaultproperties = { ! obstacle = 1, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("guitar.bmp"), ! convTableKeyword = "Guitar", ! } } TV = Decoration:subclass { ! name = "TV"; ! bPlaceable = true; ! defaultproperties = { ! obstacle = 1, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("tv.bmp"), ! convTableKeyword = "TV", ! } } Bed = Decoration:subclass { ! name = "Bed"; ! bPlaceable = true; ! activatedBy = function(self, obj) ! local bitmapje = self.bitmap ! ! if (obj.health == obj.maxHealth) then ! ActionController:addSequence{ ! ActionConversation(lang:getConv("BedAwake")), ! } ! elseif (not self.bOccupied) then ! local afterTable = lang:getConv("BedTiredAfterTable") ! local options = table.getn(afterTable) - 1 ! ! ActionController:addSequence{ ! ActionSetVariable(self, "bOccupied", true), ! ActionConversation(lang:getConv("BedTiredBefore")), ! ActionCallFunction(obj.setSleeping, obj, true), ! ActionChangeBitmap(self, obj.sleepBitmap), ! ActionSetVariable(obj, "onActivate", ! function(self2) ! self2.onActivate = nil ! ActionController:addSequence{ ! ActionCallFunction(obj.setSleeping, obj, false), ! ActionSetVariable(obj, "dir", DIR_DOWN), ! ActionChangeBitmap(self, bitmapje), ! ActionConversation(afterTable[math.floor(options * obj.health / obj.maxHealth) + 1]), ! ActionSetVariable(obj, "obstacle", 1), ! ActionSetVariable(self, "bOccupied", false), ! } ! end), ! } ! else ! ActionController:addSequence{ ! ActionConversation(lang:getConv("BedOccupied")), ! } ! end ! end; ! ! defaultproperties = { ! bOccupied = false, ! bCanActivate = true, ! bCenterOnTile = false, ! bCenterBitmap = false, ! offset_x = 2, ! offset_y = -5, ! obstacle = 1, ! w = 2, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("bed.bmp"), ! } } |
From: Bjørn L. <b_l...@us...> - 2004-12-10 14:15:45
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25632 Modified Files: README Log Message: Fixed bed bug Index: README =================================================================== RCS file: /cvsroot/moeng/BBRpg/README,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** README 13 Jan 2004 16:32:34 -0000 1.7 --- README 10 Dec 2004 14:15:36 -0000 1.8 *************** *** 88,92 **** ------- ! 1.1.0 - January, 4th (First post-compo release) * Added the Blues music, the biggest thing missing in our previous version --- 88,99 ---- ------- ! 1.1.1 - October, Xth (Final release) ! ! / A lot of small fixes ! / Some more efficient object handling ! TODO: Examine commit messages ! ! ! 1.1.0 - January, 10th (First post-compo release) * Added the Blues music, the biggest thing missing in our previous version |
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3801/shared Modified Files: console.cpp console.h module.cpp module.h object.cpp object.h tiled_map.cpp tiled_map.h Removed Files: engine.cpp engine.h Log Message: Merged in some engine changes from DGE/hecate to BBRpg on SourceForge Index: module.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** module.h 25 Apr 2004 16:39:53 -0000 1.2 --- module.h 23 Oct 2004 11:54:19 -0000 1.3 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 29,41 **** ~Module(); ! void loadScript(std::string name); void loadScripts(); ! TiledMap* loadMap(std::string name); ! BITMAP* findBitmap(std::string name); ! MIDI* findMidi(std::string name); ! SAMPLE* findSample(std::string name); ! FONT* findFont(std::string name); ! char* findScript(std::string name); private: --- 29,41 ---- ~Module(); ! void loadScript(const std::string name); void loadScripts(); ! TiledMap* loadMap(const std::string name); ! BITMAP* findBitmap(const std::string name); ! MIDI* findMidi(const std::string name); ! SAMPLE* findSample(const std::string name); ! FONT* findFont(const std::string name); ! char* findScript(const std::string name); private: Index: object.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/object.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** object.h 13 Apr 2004 12:26:08 -0000 1.4 --- object.h 23 Oct 2004 11:54:19 -0000 1.5 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 37,41 **** int id; int tableRef; // A reference to the associated Lua table ! char *className; Object(int luaTableRef, TiledMap* myMap); --- 37,41 ---- int id; int tableRef; // A reference to the associated Lua table ! const char *className; Object(int luaTableRef, TiledMap* myMap); *************** *** 54,58 **** // Methods void walk(int dir, bool col); ! void set_dir(int dir); void setX(double x); void setY(double y); --- 54,58 ---- // Methods void walk(int dir, bool col); ! void setDir(int dir); void setX(double x); void setY(double y); --- engine.h DELETED --- --- engine.cpp DELETED --- Index: tiled_map.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tiled_map.h 13 Apr 2004 12:26:08 -0000 1.6 --- tiled_map.h 23 Oct 2004 11:54:19 -0000 1.7 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 24,28 **** class Object; - #define DAT_MAPDATA DAT_ID('M','A','P',' ') #define TILES_W 24 --- 24,27 ---- *************** *** 42,51 **** - // Allegro DATAFILE map routines =========================================== - - void *load_tiledmapdata(PACKFILE *f, long size); - void destroy_tiledmapdata(void *data); - - // Point class =============================================================== --- 41,44 ---- *************** *** 59,62 **** --- 52,70 ---- + // Vector class ============================================================== + + struct Vector + { + Vector(); + Vector(double x, double y, double z); + Vector(const Vector &v); + Vector operator*(double c); + Vector operator/(double c); + Vector operator+(const Vector &v); + Vector operator-(const Vector &v); + double x, y, z; + }; + + // Rectangle class =========================================================== *************** *** 64,70 **** public: Rectangle() {x = y = w = h = 0;} ! Rectangle(int X, int Y, int W, int H) {x = X; y = Y; w = W; h = H;} void rectToClip(BITMAP *dest); void clipToRect(BITMAP *src); int x, y, w, h; }; --- 72,79 ---- public: Rectangle() {x = y = w = h = 0;} ! Rectangle(int x, int y, int w, int h); void rectToClip(BITMAP *dest); void clipToRect(BITMAP *src); + bool collides(const Rectangle &r); int x, y, w, h; }; *************** *** 166,177 **** void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} Tile* getTile(Point tileCoords); private: ! int mapWidth; ! int mapHeight; Tile** tileMap; }; --- 175,192 ---- void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() { return width; } ! int getHeight() { return height; } ! ! void setName(const char* newName); ! void setOpacity(float opacity); ! const char* getName(); ! float getOpacity(); Tile* getTile(Point tileCoords); private: ! int width, height; ! char *name; ! float opacity; Tile** tileMap; }; *************** *** 195,200 **** void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} // Tile and entity methods --- 210,215 ---- void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() {return width;} ! int getHeight() {return height;} // Tile and entity methods *************** *** 202,209 **** TiledMapLayer* getLayer(int i); ! // Draw the map virtual void setCamera(Point cameraCoords, Rectangle screenRect, bool centerCamera = false, bool modify = true); ! virtual void draw(BITMAP *dest, bool drawObstacle = false) = 0; virtual void drawLayer(BITMAP *dest, bool drawObstacle, TiledMapLayer *layer, int opacity = 255) = 0; --- 217,224 ---- TiledMapLayer* getLayer(int i); ! // Drawing the map virtual void setCamera(Point cameraCoords, Rectangle screenRect, bool centerCamera = false, bool modify = true); ! virtual void draw(BITMAP *dest, bool drawObstacle) = 0; virtual void drawLayer(BITMAP *dest, bool drawObstacle, TiledMapLayer *layer, int opacity = 255) = 0; *************** *** 212,215 **** --- 227,231 ---- void drawAirborneEntities(BITMAP *dest); + // Entity methods Object* addObject(double x, double y, const char* type); Object* registerObject(int tableRef); *************** *** 237,244 **** protected: - //Tile** tileMap; - int mapWidth, mapHeight; - // Camera properties Point cameraCoords; --- 253,258 ---- + int width, height; protected: // Camera properties Point cameraCoords; *************** *** 283,286 **** --- 297,302 ---- // Draw the map virtual void draw(BITMAP *dest, bool drawObstacle = false); + virtual void drawLayer(BITMAP *dest, bool drawObstacle, + TiledMapLayer *layer, int opacity = 255); // Coordinate space converters Index: console.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** console.cpp 13 Apr 2004 12:26:08 -0000 1.3 --- console.cpp 23 Oct 2004 11:54:19 -0000 1.4 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 25,39 **** Console::Console(const char* filename) { ! logFilename = new char[strlen(filename) + 1]; ! strcpy(logFilename, filename); ! logFilename[strlen(filename)] = '\0'; ! logFile = fopen(logFilename, "w"); ! fclose(logFile); ! log(CON_LOG, CON_ALWAYS, "----- Start of RPG log file -----"); ! progress = 0; ! active = false; ! enableLogfile = true; } --- 25,39 ---- Console::Console(const char* filename) { ! logFilename = new char[strlen(filename) + 1]; ! strcpy(logFilename, filename); ! logFilename[strlen(filename)] = '\0'; ! logFile = fopen(logFilename, "w"); ! fclose(logFile); ! log(CON_LOG, CON_ALWAYS, "----- Start of RPG log file -----"); ! progress = 0; ! active = false; ! enableLogfile = true; } *************** *** 41,163 **** Console::~Console() { ! // Deallocate console string messages ! list<char*>::iterator i; ! while (!logMessages.empty()) ! { ! i = logMessages.begin(); ! delete (*i); ! logMessages.erase(i); ! } ! log(CON_LOG, CON_ALWAYS, "----- End of RPG log file -----"); ! delete logFilename; } void Console::update() { ! if (active && progress < 100) progress = MIN(100, progress + 2); ! if (!active && progress > 0) progress = MAX(0, progress - 2); } void Console::draw(BITMAP *dest) { ! if (progress > 0) { ! int posY = (int)((double)(dest->h / 4) * sin(((0.5 * M_PI) / (double)100) * (double)progress) - text_height(font)); ! line(dest, 0, posY + text_height(font) + 1, dest->w - 1, posY + text_height(font) + 1, makecol(0,0,0)); ! set_trans_blender(0,0,0,100); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! rectfill(dest, 0, 0, dest->w - 1, posY + text_height(font), makecol(0,0,0)); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! font = engine_font; ! 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)); ! posY -= text_height(font) + 1; ! i++; ! } ! } } bool Console::handleInput(int key) { ! if ((progress == 0 || progress == 100) && (key == KEY_TILDE || key == KEY_C)) { ! active = !active; ! return true; ! } ! return false; } void Console::log(int where, int when, const char *what, ...) { ! if ((when & CON_ALWAYS) || ((when & CON_DEBUG) && debug_mode) || ((when & CON_VDEBUG) && debug_mode == 2)) ! { ! char* buf = (char*)malloc(1024 * sizeof(char)); ! va_list ap; ! va_start(ap, what); ! uvsprintf(buf, what, ap); ! va_end(ap); ! if (where & (CON_LOG | CON_QUIT)) ! { ! time_t t; ! time(&t); ! if (enableLogfile) { ! logFile = fopen(logFilename, "a"); ! fprintf( ! logFile, ! "[%s%d:%s%d:%s%d] ", ! (((t / 60) / 60) % 24 < 10) ? "0" : "", ! (int)(((t / 60) / 60) % 24), ! ((t / 60) % 60 < 10) ? "0" : "", ! (int)((t / 60) % 60), ! (t % 60 < 10) ? "0" : "", ! (int)(t % 60) ! ); ! fprintf(logFile, buf); ! fprintf(logFile, "\n"); ! fclose(logFile); ! } ! if (where & CON_QUIT) ! { ! logFile = fopen(logFilename, "a"); ! fprintf(logFile, "FATAL ERROR!\n"); ! fclose(logFile); ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message(buf); printf("\n"); ! exit(1); ! } ! } ! if (where & CON_POPUP) ! { ! allegro_message(buf); ! } ! if (where & CON_CONSOLE) ! { ! // Add the message to the console ! logMessages.push_front(buf); ! // Clean up the log memory (only keep the last 20 messages) ! if (logMessages.size() > 20) { ! free(logMessages.back()); ! logMessages.pop_back(); ! } ! } ! else ! { ! // Clean up the allocated string space ! delete buf; ! } ! } } --- 41,169 ---- Console::~Console() { ! // Deallocate console string messages ! list<char*>::iterator i; ! while (!logMessages.empty()) ! { ! i = logMessages.begin(); ! delete (*i); ! logMessages.erase(i); ! } ! log(CON_LOG, CON_ALWAYS, "----- End of RPG log file -----"); ! delete logFilename; } void Console::update() { ! if (active && progress < 100) progress = MIN(100, progress + 2); ! if (!active && progress > 0) progress = MAX(0, progress - 2); } void Console::draw(BITMAP *dest) { ! if (progress > 0) { ! int posY = (int)((double)(dest->h / 4) * ! sin(((0.5 * M_PI) / (double)100) * ! (double)progress) - text_height(font)); ! line(dest, 0, posY + text_height(font) + 1, dest->w - 1, ! posY + text_height(font) + 1, makecol(0,0,0)); ! set_trans_blender(0,0,0,100); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! rectfill(dest, 0, 0, dest->w - 1, posY + text_height(font), ! makecol(0,0,0)); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! font = engine_font; ! 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)); ! posY -= text_height(font) + 1; ! i++; ! } ! } } bool Console::handleInput(int key) { ! if ((progress == 0 || progress == 100) && ! (key == KEY_TILDE || key == KEY_C)) { ! active = !active; ! return true; ! } ! return false; } void Console::log(int where, int when, const char *what, ...) { ! if ((when & CON_ALWAYS) || ((when & CON_DEBUG) && debug_mode) || ! ((when & CON_VDEBUG) && debug_mode == 2)) ! { ! char* buf = (char*)malloc(1024 * sizeof(char)); ! va_list ap; ! va_start(ap, what); ! uvsprintf(buf, what, ap); ! va_end(ap); ! if (where & (CON_LOG | CON_QUIT)) ! { ! time_t t; ! time(&t); ! if (enableLogfile) { ! logFile = fopen(logFilename, "a"); ! fprintf( ! logFile, ! "[%s%d:%s%d:%s%d] ", ! (((t / 60) / 60) % 24 < 10) ? "0" : "", ! (int)(((t / 60) / 60) % 24), ! ((t / 60) % 60 < 10) ? "0" : "", ! (int)((t / 60) % 60), ! (t % 60 < 10) ? "0" : "", ! (int)(t % 60) ! ); ! fprintf(logFile, buf); ! fprintf(logFile, "\n"); ! fclose(logFile); ! } ! if (where & CON_QUIT) ! { ! logFile = fopen(logFilename, "a"); ! fprintf(logFile, "FATAL ERROR!\n"); ! fclose(logFile); ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message(buf); printf("\n"); ! exit(1); ! } ! } ! if (where & CON_POPUP) ! { ! allegro_message(buf); ! } ! if (where & CON_CONSOLE) ! { ! // Add the message to the console ! logMessages.push_front(buf); ! // Clean up the log memory (only keep the last 20 messages) ! if (logMessages.size() > 20) { ! free(logMessages.back()); ! logMessages.pop_back(); ! } ! } ! else ! { ! // Clean up the allocated string space ! delete buf; ! } ! } } Index: console.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** console.h 13 Jan 2004 16:32:35 -0000 1.2 --- console.h 23 Oct 2004 11:54:19 -0000 1.3 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 30,50 **** class Console { ! public: ! Console(const char* filename); ! ~Console(); ! void update(); ! void draw(BITMAP *dest); ! bool handleInput(int key); ! void log(int where, int when, const char* what, ...); ! bool enableLogfile; ! private: ! FILE* logFile; ! char* logFilename; ! list<char*> logMessages; ! bool active; ! int progress; }; --- 30,50 ---- class Console { ! public: ! Console(const char* filename); ! ~Console(); ! void update(); ! void draw(BITMAP *dest); ! bool handleInput(int key); ! void log(int where, int when, const char* what, ...); ! bool enableLogfile; ! private: ! FILE* logFile; ! char* logFilename; ! list<char*> logMessages; ! bool active; ! int progress; }; Index: tiled_map.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tiled_map.cpp 25 Apr 2004 16:39:53 -0000 1.9 --- tiled_map.cpp 23 Oct 2004 11:54:19 -0000 1.10 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 23,38 **** ! // Allegro DATAFILE map routines =========================================== ! void *load_tiledmapdata(PACKFILE *f, long size) { ! void *map_data = malloc(size); ! memcpy(map_data, f, size); ! return map_data; } ! void destroy_tiledmapdata(void *data) { ! if (data) free(data); } --- 23,81 ---- ! // Vector class ============================================================== ! Vector::Vector() { ! x = y = z = 0.0f; } ! Vector::Vector(double x, double y, double z) { ! this->x = x; ! this->y = y; ! this->z = z; ! } ! ! Vector::Vector(const Vector &v) ! { ! this->x = v.x; ! this->y = v.y; ! this->z = v.z; ! } ! ! Vector Vector::operator*(double c) ! { ! Vector result; ! result.x = x * c; ! result.y = y * c; ! result.z = z * c; ! return result; ! } ! ! Vector Vector::operator/(double c) ! { ! Vector result; ! result.x = x / c; ! result.y = y / c; ! result.z = z / c; ! return result; ! } ! ! Vector Vector::operator+(const Vector &v) ! { ! Vector result; ! result.x = x + v.x; ! result.y = y + v.y; ! result.z = z + v.z; ! return result; ! } ! ! Vector Vector::operator-(const Vector &v) ! { ! Vector result; ! result.x = x - v.x; ! result.y = y - v.y; ! result.z = z - v.z; ! return result; } *************** *** 40,43 **** --- 83,94 ---- // Rectangle class =========================================================== + Rectangle::Rectangle(int x, int y, int w, int h) + { + this->x = x; + this->y = y; + this->w = w; + this->h = h; + } + void Rectangle::rectToClip(BITMAP *dest) { *************** *** 53,56 **** --- 104,117 ---- } + 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 + ); + } + // TileType ================================================================== *************** *** 263,272 **** { BITMAP *tileBitmap; - BITMAP *tempBitmap; - TileType *tempTileType; - char tempTilename[256]; char tempFilename[256]; PALETTE pal; - int x, y; tileBitmap = load_bitmap(filename, pal); --- 324,329 ---- *************** *** 279,304 **** replace_extension(tempFilename, get_filename(filename), "", 256); ! ASSERT(tileBitmap); ! ! for (y = 0; y < (tileBitmap->h / (tile_h + tile_spacing)); y++) ! { ! for (x = 0; x < (tileBitmap->w / (tile_w + tile_spacing)); x++) ! { ! // Create a new tile type and add it to the hash_map ! tempBitmap = create_bitmap(tile_w, tile_h); ! blit( ! tileBitmap, tempBitmap, ! x * (tile_w + tile_spacing), ! y * (tile_h + tile_spacing), ! 0, 0, tile_w, tile_h ! ); ! ! sprintf(tempTilename, "%s%03d", tempFilename, ! y * (tileBitmap->w / tile_w) + x); ! ! tempTileType = new TileType(tempBitmap, tempTilename); ! tileTypes.insert(make_pair(tempTileType->getName(), tempTileType)); ! } ! } destroy_bitmap(tileBitmap); --- 336,340 ---- replace_extension(tempFilename, get_filename(filename), "", 256); ! importBitmap(tileBitmap, tempFilename, tile_w, tile_h, tile_spacing); destroy_bitmap(tileBitmap); *************** *** 341,346 **** ( tiles_in_row * tile_w, ! (tiles_to_save.size() / tiles_in_row + ! tiles_to_save.size() % tiles_in_row) * tile_h ); int x = 0; --- 377,382 ---- ( tiles_in_row * tile_w, ! ((int)tiles_to_save.size() / tiles_in_row + ! (int)tiles_to_save.size() % tiles_in_row) * tile_h ); int x = 0; *************** *** 395,400 **** TiledMapLayer::TiledMapLayer() { ! mapWidth = 0; ! mapHeight = 0; tileMap = NULL; } --- 431,437 ---- TiledMapLayer::TiledMapLayer() { ! width = 0; ! height = 0; ! name = NULL; tileMap = NULL; } *************** *** 403,413 **** { // Delete tiles on map ! for (int y = 0; y < mapHeight; y++) ! for (int x = 0; x < mapWidth; x++) ! delete tileMap[x + y * mapWidth]; free(tileMap); } void TiledMapLayer::resizeTo(int w, int h, int dx, int dy) { --- 440,480 ---- { // Delete tiles on map ! for (int y = 0; y < height; y++) ! for (int x = 0; x < width; x++) ! delete tileMap[x + y * width]; free(tileMap); } + void TiledMapLayer::setName(const char *newName) + { + // Delete any previous name + if (name) { + delete[] name; + name = NULL; + } + + // Set the new name if it is not NULL + if (newName) { + name = new char[strlen(newName) + 1]; + strcpy(name, newName); + } + } + + const char* TiledMapLayer::getName() + { + return name; + } + + void TiledMapLayer::setOpacity(float opacity) + { + this->opacity = opacity; + } + + float TiledMapLayer::getOpacity() + { + return opacity; + } + void TiledMapLayer::resizeTo(int w, int h, int dx, int dy) { *************** *** 424,429 **** // Copy old map data ! for (y = 0; y < mapHeight; y++) { ! for (x = 0; x < mapWidth; x++) { xn = x + dx; --- 491,496 ---- // Copy old map data ! for (y = 0; y < height; y++) { ! for (x = 0; x < width; x++) { xn = x + dx; *************** *** 433,437 **** { Tile *newTile = newTileMap[xn + yn * w]; ! Tile *oldTile = tileMap[x + y * mapWidth]; newTile->setType(oldTile->getType()); newTile->obstacle = oldTile->obstacle; --- 500,504 ---- { Tile *newTile = newTileMap[xn + yn * w]; ! Tile *oldTile = tileMap[x + y * width]; newTile->setType(oldTile->getType()); newTile->obstacle = oldTile->obstacle; *************** *** 441,452 **** // Delete tiles on old map ! for (y = 0; y < mapHeight; y++) ! for (x = 0; x < mapWidth; x++) ! delete tileMap[x + y * mapWidth]; free(tileMap); tileMap = newTileMap; ! mapWidth = w; ! mapHeight = h; } --- 508,519 ---- // Delete tiles on old map ! for (y = 0; y < height; y++) ! for (x = 0; x < width; x++) ! delete tileMap[x + y * width]; free(tileMap); tileMap = newTileMap; ! width = w; ! height = h; } *************** *** 456,465 **** // The layer header ! pack_iputw(mapWidth, file); ! pack_iputw(mapHeight, file); // The tile data ! for (int y = 0; y < mapHeight; y++) ! for (int x = 0; x < mapWidth; x++) getTile(Point(x,y))->saveTo(file); } --- 523,532 ---- // The layer header ! pack_iputw(width, file); ! pack_iputw(height, file); // The tile data ! for (int y = 0; y < height; y++) ! for (int x = 0; x < width; x++) getTile(Point(x,y))->saveTo(file); } *************** *** 471,482 **** xmlTextWriterStartElement(writer, BAD_CAST "layer"); ! snprintf(strbuf, 16, "%d", mapWidth); xmlTextWriterWriteAttribute(writer, BAD_CAST "width", BAD_CAST strbuf); ! snprintf(strbuf, 16, "%d", mapHeight); xmlTextWriterWriteAttribute(writer, BAD_CAST "height", BAD_CAST strbuf); ! for (int y = 0; y < mapHeight; y++) ! for (int x = 0; x < mapWidth; x++) getTile(Point(x,y))->saveTo(writer); --- 538,549 ---- xmlTextWriterStartElement(writer, BAD_CAST "layer"); ! snprintf(strbuf, 16, "%d", width); xmlTextWriterWriteAttribute(writer, BAD_CAST "width", BAD_CAST strbuf); ! snprintf(strbuf, 16, "%d", height); xmlTextWriterWriteAttribute(writer, BAD_CAST "height", BAD_CAST strbuf); ! for (int y = 0; y < height; y++) ! for (int x = 0; x < width; x++) getTile(Point(x,y))->saveTo(writer); *************** *** 494,499 **** // Load the tile data ! for (int y = 0; y < mapHeight; y++) ! for (int x = 0; x < mapWidth; x++) getTile(Point(x,y))->loadFrom(file, tileRepository); } --- 561,566 ---- // Load the tile data ! for (int y = 0; y < height; y++) ! for (int x = 0; x < width; x++) getTile(Point(x,y))->loadFrom(file, tileRepository); } *************** *** 519,526 **** // Load the tile data while (cur != NULL) { ! if (xmlStrEqual(cur->name, BAD_CAST "tile") && y < mapHeight) { getTile(Point(x,y))->loadFrom(cur, tileRepository); x++; ! if (x == mapWidth) {x = 0; y++;} } cur = cur->next; --- 586,593 ---- // 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; *************** *** 530,535 **** Tile *TiledMapLayer::getTile(Point tile) { ! if (tile.x < 0 || tile.x >= mapWidth || ! tile.y < 0 || tile.y >= mapHeight) { return NULL; --- 597,602 ---- Tile *TiledMapLayer::getTile(Point tile) { ! if (tile.x < 0 || tile.x >= width || ! tile.y < 0 || tile.y >= height) { return NULL; *************** *** 537,541 **** else { ! return tileMap[tile.x + tile.y * mapWidth]; } } --- 604,608 ---- else { ! return tileMap[tile.x + tile.y * width]; } } *************** *** 546,550 **** TiledMap::TiledMap(): ! nrLayers(2), mapWidth(0), mapHeight(0) { mapLayers[0] = new TiledMapLayer(); --- 613,617 ---- TiledMap::TiledMap(): ! nrLayers(2), width(0), height(0) { mapLayers[0] = new TiledMapLayer(); *************** *** 583,588 **** mapLayers[0]->resizeTo(w, h, dx, dy); mapLayers[1]->resizeTo(w, h, dx, dy); ! mapWidth = w; ! mapHeight = h; } --- 650,655 ---- mapLayers[0]->resizeTo(w, h, dx, dy); mapLayers[1]->resizeTo(w, h, dx, dy); ! width = w; ! height = h; } *************** *** 747,752 **** } ! mapWidth = mapLayers[0]->getWidth(); ! mapHeight = mapLayers[0]->getHeight(); } --- 814,819 ---- } ! width = mapLayers[0]->getWidth(); ! height = mapLayers[0]->getHeight(); } *************** *** 795,800 **** } ! mapWidth = mapLayers[0]->getWidth(); ! mapHeight = mapLayers[0]->getHeight(); } --- 862,867 ---- } ! width = mapLayers[0]->getWidth(); ! height = mapLayers[0]->getHeight(); } *************** *** 959,964 **** for (i = objects.begin(); i != objects.end(); i++) { ! if ((*i)->_destroy) ! { list<Object*>::iterator i2 = i; --- 1026,1030 ---- for (i = objects.begin(); i != objects.end(); i++) { ! if ((*i)->_destroy) { list<Object*>::iterator i2 = i; *************** *** 970,975 **** objects.erase(i2); } ! else ! { (*i)->update(); } --- 1036,1040 ---- objects.erase(i2); } ! else { (*i)->update(); } *************** *** 1044,1054 **** cameraScreenRect.y + cameraScreenRect.h - 1)); ! start.x = MAX(0, MIN(mapWidth - 1, start.x)); ! start.y = MAX(0, MIN(mapHeight - 1, start.y)); - if (opacity < 255) { - set_trans_blender(0,0,0,opacity); - drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); - } for (int y = start.y; y <= end.y; y++) { --- 1109,1115 ---- 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++) { *************** *** 1058,1061 **** --- 1119,1124 ---- if (tempTileType) { if (opacity < 255) { + set_trans_blender(0, 0, 0, opacity); + drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); draw_trans_sprite( dest, *************** *** 1064,1067 **** --- 1127,1131 ---- cameraScreenRect.y - cameraCoords.y + y * tileHeight ); + drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } else { *************** *** 1081,1084 **** --- 1145,1150 ---- int to = tempTile->obstacle; + set_trans_blender(0, 0, 0, 100); + drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); if (to & OB_TOP) { line(dest, tx + 2, ty + 2, tx + tw - 3, ty + 2, *************** *** 1105,1116 **** makecol(0,0,0)); } } } } - if (opacity < 255) { - drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); - } - oldClip.rectToClip(dest); } --- 1171,1179 ---- makecol(0,0,0)); } + drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } } } oldClip.rectToClip(dest); } *************** *** 1137,1142 **** { return Point( ! MIN(mapWidth - 1, MAX(0, mapCoords.x / tileWidth)), ! MIN(mapHeight - 1, MAX(0, mapCoords.y / tileHeight)), mapCoords.z ); --- 1200,1205 ---- { return Point( ! MIN(width - 1, MAX(0, mapCoords.x / tileWidth)), ! MIN(height - 1, MAX(0, mapCoords.y / tileHeight)), mapCoords.z ); *************** *** 1155,1160 **** { return Point( ! tileWidth * mapWidth, ! tileHeight * mapHeight ); } --- 1218,1223 ---- { return Point( ! tileWidth * width, ! tileHeight * height ); } *************** *** 1163,1242 **** // IsometricMap class ======================================================== // Provides algorithms for isometric-tiled maps - /* - IsometricMap::IsometricMap(int tileStepX, int tileStepY) - { - this->tileGridSize = tileStepX; - this->tileStepX = tileStepX; - this->tileStepY = tileStepY; - } ! void IsometricMap::draw(BITMAP *dest, bool drawObstacle) ! { ! if (tileMap == NULL) return; ! Rectangle oldClip; ! Tile *tempTile; ! TileType *tempTileType; ! Point temp, temp2, area; ! oldClip.clipToRect(dest); ! cameraScreenRect.rectToClip(dest); ! temp = screenToTile(Point(cameraScreenRect.x, cameraScreenRect.y)); ! area = Point(cameraScreenRect.w / (tileStepX * 2) + 3, cameraScreenRect.h / tileStepY + 3); ! // Move up one row ! temp.x--; ! for (int y = 0; y < area.y; y++) { ! // Initialize temp2 to draw a horizontal line of tiles ! temp2 = temp; ! for (int x = 0; x < area.x; x++) { ! // Check if we are drawing a valid tile ! tempTile = getTile(temp2); ! if (tempTile) { ! tempTileType = tempTile->getType(); ! } else { ! tempTileType = NULL; ! } ! // Draw the tile if valid ! if (tempTileType) { ! draw_sprite( ! dest, ! tempTileType->getBitmap(), ! cameraScreenRect.x - cameraCoords.x + (temp2.x - temp2.y - 1) * tileStepX + mapHeight * tileStepX, ! cameraScreenRect.y - cameraCoords.y + (temp2.x + temp2.y ) * tileStepY ! ); ! } ! // Advance to the next tile (to the right) ! temp2.x++; temp2.y--; ! } ! // Advance to the next row ! if ((y & 1) > 0) temp.x++; else temp.y++; ! } ! // Draw a red line along the edges of the map ! //Point top = mapToScreen(Point(-1, 0)); ! //Point right = mapToScreen(Point(tileGridSize * mapWidth, 0)); ! //Point bottom = mapToScreen(Point(tileGridSize * mapWidth, tileGridSize * mapHeight + 1)); ! //Point left = mapToScreen(Point(-1, tileGridSize * mapHeight + 1)); ! //line(dest, top.x, top.y, right.x, right.y, makecol(255,0,0)); ! //line(dest, right.x, right.y, bottom.x, bottom.y, makecol(255,0,0)); ! //line(dest, bottom.x, bottom.y, left.x, left.y, makecol(255,0,0)); ! //line(dest, left.x, left.y, top.x, top.y, makecol(255,0,0)); ! // Now draw the entities ! drawEntities(dest); ! oldClip.rectToClip(dest); } Point IsometricMap::screenToMap(Point screenCoords) { ! screenCoords.x = screenCoords.x + cameraCoords.x - cameraScreenRect.x - mapHeight * tileStepX; screenCoords.y = screenCoords.y + cameraCoords.y - cameraScreenRect.y; return Point( --- 1226,1313 ---- // IsometricMap class ======================================================== // Provides algorithms for isometric-tiled maps ! IsometricMap::IsometricMap(int tileStepX, int tileStepY) ! { ! this->tileGridSize = tileStepX; ! this->tileStepX = tileStepX; ! this->tileStepY = tileStepY; ! } ! void IsometricMap::draw(BITMAP *dest, bool drawObstacle) ! { ! /* ! if (tileMap == NULL) return; ! Rectangle oldClip; ! TileType *tempTileType; ! Point temp, temp2, area; ! oldClip.clipToRect(dest); ! cameraScreenRect.rectToClip(dest); ! temp = screenToTile(Point(cameraScreenRect.x, cameraScreenRect.y)); ! area = Point( ! cameraScreenRect.w / (tileStepX * 2) + 3, ! cameraScreenRect.h / tileStepY + 3); ! // Move up one row ! temp.x--; ! for (int y = 0; y < area.y; y++) { ! // Initialize temp2 to draw a horizontal line of tiles ! temp2 = temp; ! for (int x = 0; x < area.x; x++) { ! // Check if we are drawing a valid tile ! tempTileType = getTile(temp2); ! // Draw the tile if valid ! if (tempTileType) { ! draw_sprite( ! dest, ! tempTileType->getBitmap(), ! cameraScreenRect.x - cameraCoords.x + (temp2.x - ! temp2.y - 1) * tileStepX + height * tileStepX, ! cameraScreenRect.y - cameraCoords.y + (temp2.x + ! temp2.y) * tileStepY ! ); ! } ! // Advance to the next tile (to the right) ! temp2.x++; temp2.y--; ! } ! // Advance to the next row ! if ((y & 1) > 0) temp.x++; else temp.y++; ! } ! // Draw a red line along the edges of the map ! Point top = mapToScreen(Point(-1, 0)); ! Point right = mapToScreen(Point(tileGridSize * width, 0)); ! Point bottom = mapToScreen(Point(tileGridSize * width, ! tileGridSize * height + 1)); ! Point left = mapToScreen(Point(-1, tileGridSize * height + 1)); ! line(dest, top.x, top.y, right.x, right.y, makecol(255,0,0)); ! line(dest, right.x, right.y, bottom.x, bottom.y, makecol(255,0,0)); ! line(dest, bottom.x, bottom.y, left.x, left.y, makecol(255,0,0)); ! line(dest, left.x, left.y, top.x, top.y, makecol(255,0,0)); ! // Now draw the entities ! drawEntities(dest); ! ! oldClip.rectToClip(dest); ! */ ! } ! ! void IsometricMap::drawLayer( ! BITMAP *dest, bool drawObstacle, ! TiledMapLayer *layer, int opacity) ! { } Point IsometricMap::screenToMap(Point screenCoords) { ! screenCoords.x = screenCoords.x + cameraCoords.x - cameraScreenRect.x - ! height * tileStepX; screenCoords.y = screenCoords.y + cameraCoords.y - cameraScreenRect.y; return Point( *************** *** 1250,1255 **** { return Point( ! cameraScreenRect.x - cameraCoords.x + (mapCoords.x - mapCoords.y) + mapHeight * tileStepX, ! cameraScreenRect.y - cameraCoords.y + (mapCoords.x + mapCoords.y) / 2, mapCoords.z ); --- 1321,1328 ---- { return Point( ! cameraScreenRect.x - cameraCoords.x + (mapCoords.x - mapCoords.y) + ! height * tileStepX, ! cameraScreenRect.y - cameraCoords.y + (mapCoords.x + mapCoords.y) / ! 2, mapCoords.z ); *************** *** 1259,1264 **** { return Point( ! (mapCoords.x < 0) ? mapCoords.x / tileGridSize - 1 : mapCoords.x / tileGridSize, ! (mapCoords.y < 0) ? mapCoords.y / tileGridSize - 1 : mapCoords.y / tileGridSize, mapCoords.z ); --- 1332,1339 ---- { return Point( ! (mapCoords.x < 0) ? ! mapCoords.x / tileGridSize - 1 : mapCoords.x / tileGridSize, ! (mapCoords.y < 0) ? ! mapCoords.y / tileGridSize - 1 : mapCoords.y / tileGridSize, mapCoords.z ); *************** *** 1277,1283 **** { return Point( ! tileStepX * (mapWidth + mapHeight), ! tileStepY * (mapWidth + mapHeight) ); } - */ --- 1352,1357 ---- { return Point( ! tileStepX * (width + height), ! tileStepY * (width + height) ); } Index: object.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/object.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** object.cpp 13 Apr 2004 12:26:08 -0000 1.7 --- object.cpp 23 Oct 2004 11:54:19 -0000 1.8 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 15,19 **** #include "console.h" #include "tiled_map.h" - #include "engine.h" #include "../script.h" #include "../common.h" --- 15,18 ---- *************** *** 88,92 **** case DIR_RIGHT: next_x += 1.0; break; } ! set_dir(dir); } else { --- 87,91 ---- case DIR_RIGHT: next_x += 1.0; break; } ! setDir(dir); } else { *************** *** 106,110 **** ny = next_y; walking = 100 - walking; ! set_dir(dir); } return; --- 105,109 ---- ny = next_y; walking = 100 - walking; ! setDir(dir); } return; *************** *** 158,162 **** ! void Object::set_dir(int dir) { if (dir == DIR_NONE) return; --- 157,161 ---- ! void Object::setDir(int dir) { if (dir == DIR_NONE) return; Index: module.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** module.cpp 25 Apr 2004 16:39:53 -0000 1.2 --- module.cpp 23 Oct 2004 11:54:19 -0000 1.3 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 17,26 **** #include <allegro.h> #include <string.h> #include <dirent.h> #include <string> - #include "../common.h" #include "module.h" #include "../script.h" - #include "engine.h" --- 17,27 ---- #include <allegro.h> #include <string.h> + #ifndef WIN32 #include <dirent.h> + #endif #include <string> #include "module.h" + #include "../common.h" #include "../script.h" *************** *** 44,48 **** } ! void Module::loadScript(std::string name) { // Create the indent --- 45,49 ---- } ! void Module::loadScript(const std::string name) { // Create the indent *************** *** 51,55 **** for (i = 0; i < loadLevel; i++) spaces[i] = ' '; spaces[loadLevel] = '\0'; ! map<std::string, char*, ltstr>::iterator script_i = scripts.find(name); if (script_i != scripts.end()) { --- 52,56 ---- for (i = 0; i < loadLevel; i++) spaces[i] = ' '; spaces[loadLevel] = '\0'; ! map<std::string, char*>::iterator script_i = scripts.find(name); if (script_i != scripts.end()) { *************** *** 82,85 **** --- 83,87 ---- char *dirname = makeFilename("", "/scripts"); + #ifndef WIN32 DIR *dir; *************** *** 89,93 **** struct dirent *direntry; while ((direntry = readdir(dir)) != NULL) { ! if (strstr(direntry->d_name, ".lua")) { loadLevel = 0; loadScript(direntry->d_name); --- 91,96 ---- struct dirent *direntry; while ((direntry = readdir(dir)) != NULL) { ! char *luaExt = strstr(direntry->d_name, ".lua"); ! if (luaExt != NULL && strcmp(luaExt, ".lua") == 0) { loadLevel = 0; loadScript(direntry->d_name); *************** *** 97,100 **** --- 100,104 ---- } else { + #endif // Read the scripts from the datafile script_data = load_datafile_object(datafile_name, "data/scripts"); *************** *** 115,119 **** --- 119,125 ---- script_data = NULL; } + #ifndef WIN32 } + #endif // Clean up any loaded scripts *************** *** 129,133 **** } ! TiledMap* Module::loadMap(std::string name) { TiledMap *mmap = NULL; --- 135,139 ---- } ! TiledMap* Module::loadMap(const std::string name) { TiledMap *mmap = NULL; *************** *** 162,169 **** } ! BITMAP* Module::findBitmap(std::string name) { BITMAP *bitmap = NULL; ! map<std::string, BITMAP*, ltstr>::iterator i = bitmaps.find(name); if (i != bitmaps.end()) { --- 168,175 ---- } ! BITMAP* Module::findBitmap(const std::string name) { BITMAP *bitmap = NULL; ! map<std::string, BITMAP*>::iterator i = bitmaps.find(name); if (i != bitmaps.end()) { *************** *** 190,197 **** } ! MIDI* Module::findMidi(std::string name) { MIDI *midi = NULL; ! map<std::string, MIDI*, ltstr>::iterator i = midis.find(name); char *filename = makeFilename(name.c_str(), "/music"); --- 196,203 ---- } ! MIDI* Module::findMidi(const std::string name) { MIDI *midi = NULL; ! map<std::string, MIDI*>::iterator i = midis.find(name); char *filename = makeFilename(name.c_str(), "/music"); *************** *** 218,225 **** } ! SAMPLE* Module::findSample(std::string name) { SAMPLE *sample = NULL; ! map<std::string, SAMPLE*, ltstr>::iterator i = samples.find(name); char *filename = makeFilename(name.c_str(), "/samples"); --- 224,231 ---- } ! SAMPLE* Module::findSample(const std::string name) { SAMPLE *sample = NULL; ! map<std::string, SAMPLE*>::iterator i = samples.find(name); char *filename = makeFilename(name.c_str(), "/samples"); *************** *** 246,253 **** } ! FONT* Module::findFont(std::string name) { FONT *font = NULL; ! map<std::string, FONT*, ltstr>::iterator i = fonts.find(name); if (i != fonts.end()) { --- 252,259 ---- } ! FONT* Module::findFont(const std::string name) { FONT *font = NULL; ! map<std::string, FONT*>::iterator i = fonts.find(name); if (i != fonts.end()) { *************** *** 267,274 **** } ! char* Module::findScript(std::string name) { char *script = NULL; ! map<std::string, char*, ltstr>::iterator i = scripts.find(name); char *filename = makeFilename(name.c_str(), "/scripts"); --- 273,280 ---- } ! char* Module::findScript(const std::string name) { char *script = NULL; ! map<std::string, char*>::iterator i = scripts.find(name); char *filename = makeFilename(name.c_str(), "/scripts"); |
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3801/editor Modified Files: agup.cpp aphoton.cpp aphoton.h editor.cpp editor.h gui_procs.cpp gui_procs.h main.cpp script.cpp script.h Log Message: Merged in some engine changes from DGE/hecate to BBRpg on SourceForge Index: main.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/main.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** main.cpp 25 Apr 2004 16:39:52 -0000 1.9 --- main.cpp 23 Oct 2004 11:54:18 -0000 1.10 *************** *** 15,22 **** #include "aphoton.h" #include "editor.h" - #include "../shared/tiled_map.h" #include "script.h" #include "../common.h" ! #include "../shared/engine.h" #include "../shared/module.h" --- 15,21 ---- #include "aphoton.h" #include "editor.h" #include "script.h" #include "../common.h" ! #include "../shared/tiled_map.h" #include "../shared/module.h" *************** *** 221,230 **** // Edit objects area ! w = 123; h = 120; x = margin; y = main_dlg[6].y - margin - h; set_dialog_size(&edit_objects_layer[0], x, y, w, h); ! set_dialog_size(&edit_objects_layer[1], 136, main_dlg[6].y - margin - 14, 97, 14); --- 220,229 ---- // Edit objects area ! w = 160; h = 120; x = margin; y = main_dlg[6].y - margin - h; set_dialog_size(&edit_objects_layer[0], x, y, w, h); ! set_dialog_size(&edit_objects_layer[1], w + margin * 2, main_dlg[6].y - margin - 14, 97, 14); *************** *** 257,261 **** currentMap = new SquareMap(TILES_W, TILES_H); ! ustrcpy(map_filename, "untitled.map"); // Load map specified in rpgedit.cfg --- 256,260 ---- currentMap = new SquareMap(TILES_W, TILES_H); ! ustrcpy(map_filename, "untitled.tmx"); // Load map specified in rpgedit.cfg Index: aphoton.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/aphoton.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** aphoton.h 8 Dec 2003 01:38:54 -0000 1.1 --- aphoton.h 23 Oct 2004 11:54:18 -0000 1.2 *************** *** 13,17 **** void aphoton_shutdown(void); ! void photon_scrollbar(BITMAP *bmp, int x, int y, int w, int h, int vert, int pos, int len); void photon_container(BITMAP *bmp, int x, int y, int w, int h); --- 13,18 ---- void aphoton_shutdown(void); ! void photon_scrollbar(BITMAP *bmp, int x, int y, int w, int h, ! int vert, int pos, int len); void photon_container(BITMAP *bmp, int x, int y, int w, int h); Index: editor.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** editor.h 13 Apr 2004 12:26:08 -0000 1.9 --- editor.h 23 Oct 2004 11:54:18 -0000 1.10 *************** *** 25,29 **** // Global variables - extern Module *module; extern int debug_mode; extern FONT* engine_font; --- 25,28 ---- Index: agup.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/agup.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** agup.cpp 8 Dec 2003 01:38:54 -0000 1.1 --- agup.cpp 23 Oct 2004 11:54:18 -0000 1.2 *************** *** 23,29 **** { if ((theme = thm)) { ! theme->init(); ! agup_fg_color = *(theme->fg_color); ! agup_bg_color = *(theme->bg_color); } } --- 23,29 ---- { if ((theme = thm)) { ! theme->init(); ! agup_fg_color = *(theme->fg_color); ! agup_bg_color = *(theme->bg_color); } } *************** *** 33,46 **** { if (theme) { ! theme->shutdown(); ! theme = NULL; } } ! #define MAKE_WRAPPER(wrapper, proc) \ ! int wrapper(int msg, DIALOG *d, int c) \ ! { \ ! return ((theme) && (theme->proc)) ? theme->proc(msg, d, c) : D_O_K; \ } --- 33,46 ---- { if (theme) { ! theme->shutdown(); ! theme = NULL; } } ! #define MAKE_WRAPPER(wrapper, proc) \ ! int wrapper(int msg, DIALOG *d, int c) \ ! { \ ! return ((theme) && (theme->proc)) ? theme->proc(msg, d, c) : D_O_K; \ } Index: gui_procs.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/gui_procs.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gui_procs.cpp 13 Apr 2004 12:26:08 -0000 1.10 --- gui_procs.cpp 23 Oct 2004 11:54:18 -0000 1.11 *************** *** 15,21 **** #include "gui_procs.h" #include "editor.h" - #include "../shared/tiled_map.h" #include "script.h" ! #include "../shared/engine.h" #include "../shared/object.h" #include "../common.h" --- 15,20 ---- #include "gui_procs.h" #include "editor.h" [...2568 lines suppressed...] ! itop = inew_map_h - currentMap->getHeight() - ibottom; ! resizemap_dlg[7].flags |= D_DIRTY; ! } ! if (d == &resizemap_dlg[11]) { ! iright = inew_map_w - currentMap->getWidth() - ileft; ! resizemap_dlg[12].flags |= D_DIRTY; ! } ! if (d == &resizemap_dlg[12]) { ! ileft = inew_map_w - currentMap->getWidth() - iright; ! resizemap_dlg[11].flags |= D_DIRTY; ! } ! uszprintf((char*)resizemap_dlg[3].dp, 8, "%d", inew_map_w); ! uszprintf((char*)resizemap_dlg[4].dp, 8, "%d", inew_map_h); ! uszprintf((char*)resizemap_dlg[7].dp, 8, "%d", itop); ! uszprintf((char*)resizemap_dlg[8].dp, 8, "%d", ibottom); ! uszprintf((char*)resizemap_dlg[11].dp, 8, "%d", ileft); ! uszprintf((char*)resizemap_dlg[12].dp, 8, "%d", iright); } Index: gui_procs.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/gui_procs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gui_procs.h 8 Dec 2003 01:38:54 -0000 1.1 --- gui_procs.h 23 Oct 2004 11:54:18 -0000 1.2 *************** *** 31,35 **** char *list_tilesets(int index, int *list_size); ! char *list_objects(int index, int *list_size); --- 31,35 ---- char *list_tilesets(int index, int *list_size); ! const char *list_objects(int index, int *list_size); Index: script.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** script.h 13 Apr 2004 12:26:08 -0000 1.3 --- script.h 23 Oct 2004 11:54:19 -0000 1.4 *************** *** 26,30 **** extern lua_State* L; ! extern vector<char*> objectTypes; --- 26,30 ---- extern lua_State* L; ! extern vector<std::string> objectTypes; *************** *** 36,40 **** void handleLuaError(int err, const char *string); ! int callMemberFunction(int tableRef, const char *function, const char *argfmt = NULL, ...); int callFunction(const char *function, const char *argfmt = NULL, ...); --- 36,41 ---- void handleLuaError(int err, const char *string); ! int callMemberFunction(int tableRef, const char *function, ! const char *argfmt = NULL, ...); int callFunction(const char *function, const char *argfmt = NULL, ...); Index: editor.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** editor.cpp 25 Apr 2004 16:39:52 -0000 1.10 --- editor.cpp 23 Oct 2004 11:54:18 -0000 1.11 *************** *** 20,24 **** #include "gui_procs.h" #include "../shared/tiled_map.h" - #include "../shared/engine.h" #include "../shared/object.h" #include "../shared/module.h" --- 20,23 ---- *************** *** 165,170 **** { /*(proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)*/ ! { d_bjorn_objects_list, 6, 454, 123, 120, 0, 0, 0, 0, 0, 0, (void*)list_objects, NULL, NULL }, ! { d_bjorn_check_snap, 136, 560, 97, 14, 0, 0, 0, 0, 1, 0, (void*)"Snap to grid", NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; --- 164,169 ---- { /*(proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)*/ ! { d_bjorn_objects_list, 6, 454, 153, 120, 0, 0, 0, 0, 0, 0, (void*)list_objects, NULL, NULL }, ! { d_bjorn_check_snap, 166, 560, 97, 14, 0, 0, 0, 0, 1, 0, (void*)"Snap to grid", NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; *************** *** 274,278 **** { "&Save map", menu_item_save_map, NULL, 0, NULL }, { "Save map &as...", menu_item_save_map_as_xml, NULL, 0, NULL }, - { "Save &old map as...", menu_item_save_map_as, NULL, 0, NULL }, { "Save map image", menu_item_save_map_image, NULL, 0, NULL }, { "", NULL, NULL, 0, NULL }, --- 273,276 ---- *************** *** 345,349 **** currentMap->resizeTo(0, 0); currentMap->resizeTo(imap_w, imap_h); ! ustrzcpy(map_filename, sizeof map_filename, "untitled.map"); object_message(&D_MAP, MSG_NEW_MAP, 0); set_map_changed(false); --- 343,347 ---- currentMap->resizeTo(0, 0); currentMap->resizeTo(imap_w, imap_h); ! ustrzcpy(map_filename, sizeof map_filename, "untitled.tmx"); object_message(&D_MAP, MSG_NEW_MAP, 0); set_map_changed(false); *************** *** 368,372 **** if (file_select_ex( ! "Load XML map... (*.map)", path_buf, "map", sizeof path_buf, MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) --- 366,370 ---- if (file_select_ex( ! "Load XML map... (*.tmx)", path_buf, "tmx", sizeof path_buf, MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) *************** *** 420,425 **** if (!currentMap) return D_O_K; ! if (ustrcmp(map_filename, "untitled.map") == 0) { ! menu_item_save_map_as(); return D_O_K; } --- 418,423 ---- if (!currentMap) return D_O_K; ! if (ustrcmp(map_filename, "untitled.tmx") == 0) { ! menu_item_save_map_as_xml(); return D_O_K; } *************** *** 442,474 **** } - int menu_item_save_map_as() - { - if (!currentMap) return D_O_K; - - char path_buf[1024]; - - ustrcpy(path_buf, map_filename); - - if (file_select_ex( - "Save old map... (*.map)", path_buf, "map", sizeof path_buf, - MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), - MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) - )) - { - PACKFILE *file = pack_fopen(path_buf, F_WRITE_PACKED); - if (file) { - currentMap->saveTo(file); - pack_fclose(file); - ustrcpy(map_filename, path_buf); - set_map_changed(false); - update_window_title(); - } else { - alert(NULL, "Error while trying to save map!", - NULL, "OK", NULL, 13, 0); - } - } - return D_O_K; - } - int menu_item_import_tileset() { --- 440,443 ---- *************** *** 747,751 **** if (file_select_ex( ! "Save map... (*.map)", path_buf, "map", sizeof path_buf, MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) --- 716,720 ---- if (file_select_ex( ! "Save map... (*.tmx)", path_buf, "tmx", sizeof path_buf, MAX(OLD_FILESEL_WIDTH, SCREEN_W / 2), MAX(OLD_FILESEL_HEIGHT, SCREEN_H / 2) Index: aphoton.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/aphoton.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** aphoton.cpp 13 Apr 2004 12:26:08 -0000 1.3 --- aphoton.cpp 23 Oct 2004 11:54:18 -0000 1.4 *************** *** 1,9 **** /* aphoton.c ! * ! * This file is part of the Allegro GUI Un-uglification Project. ! * It emulates the look of the QNX Photon MicroGUI widget set. ! * ! * Eric Botcazou <ebo...@mu...> ! */ --- 1,9 ---- [...1634 lines suppressed...] ! window_blue_range.from.g = int(149 * b); ! window_blue_range.from.b = int(233 * b); ! window_blue_range.to.r = int(71 * b); ! window_blue_range.to.g = int(118 * b); ! window_blue_range.to.b = int(202 * b); ! black = makecol(0, 0, 0); ! white = makecol(int(255 * b), int(255 * b), int(255 * b)); ! normal = makecol(int(216 * b), int(216 * b), int(216 * b)); ! highlight = makecol(int(144 * b), int(152 * b), int(248 * b)); ! shadow = makecol(int(127 * b), int(127 * b), int(127 * b)); ! aphoton_fg_color = black; aphoton_bg_color = normal; ! radio_bmp = generate_bitmap(radio, 14, 14); radio_sel_bmp = generate_bitmap(radio_sel, 14, 14); ! menu_arrow_bmp = generate_bitmap(menu_arrow, 6, 8); gui_menu_draw_menu = photon_draw_menu; Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** script.cpp 13 Apr 2004 12:26:08 -0000 1.6 --- script.cpp 23 Oct 2004 11:54:18 -0000 1.7 *************** *** 12,20 **** #include <allegro.h> #include <stdarg.h> - #include "../shared/engine.h" - #include "../shared/object.h" #include "editor.h" - #include "../shared/console.h" #include "script.h" #include <vector> --- 12,20 ---- #include <allegro.h> #include <stdarg.h> #include "editor.h" #include "script.h" + #include "../common.h" + #include "../shared/object.h" + #include "../shared/console.h" #include <vector> *************** *** 23,27 **** lua_State* L = NULL; ! vector<char*> objectTypes; --- 23,27 ---- lua_State* L = NULL; ! vector<std::string> objectTypes; *************** *** 85,89 **** lua_register(L, "m_get_bitmap", l_get_bitmap); - lua_register(L, "m_load_map", l_load_map); lua_register(L, "m_create_sub_bitmap", l_create_sub_bitmap); lua_register(L, "m_bitmap_size", l_bitmap_size); --- 85,88 ---- *************** *** 103,106 **** --- 102,108 ---- console.log(CON_LOG, CON_ALWAYS, "Loading scripts..."); module->loadScripts(); + #ifndef WIN32 + std::sort(objectTypes.begin(), objectTypes.end()); + #endif } *************** *** 484,511 **** - int l_load_map(lua_State *L) - { - const char *map_name; - getLuaArguments(L, "s", &map_name); - - if (exists(map_name)) { - console.log(CON_LOG, CON_ALWAYS, "Loading map \"%s\"...", map_name); - TiledMap* map = new SquareMap(TILES_W, TILES_H); - map->loadMap(map_name); - maps.push_front(map); - return putLuaArguments(L, "m", map); - } - else { - if (debug_mode) { - luaL_error(L, "Error: Attempt to load a non-existing map (%s)!", map_name); - } - else { - console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Warning: Attempt to load a non-existing map (%s)!", map_name); - } - } - - return 0; - } - --- 486,489 ---- *************** *** 531,551 **** } ! if (strcmp(index, "speed" ) == 0) {return putLuaArguments(L, "d", obj->speed );} ! if (strcmp(index, "walking" ) == 0) {return putLuaArguments(L, "d", obj->walking );} ! if (strcmp(index, "x" ) == 0) {return putLuaArguments(L, "d", obj->x );} ! if (strcmp(index, "y" ) == 0) {return putLuaArguments(L, "d", obj->y );} ! if (strcmp(index, "w" ) == 0) {return putLuaArguments(L, "i", obj->w );} ! if (strcmp(index, "h" ) == 0) {return putLuaArguments(L, "i", obj->h );} ! if (strcmp(index, "offset_x" ) == 0) {return putLuaArguments(L, "i", obj->offset_x );} ! if (strcmp(index, "offset_y" ) == 0) {return putLuaArguments(L, "i", obj->offset_y );} ! if (strcmp(index, "offset_z" ) == 0) {return putLuaArguments(L, "i", obj->offset_z );} ! if (strcmp(index, "draw_mode") == 0) {return putLuaArguments(L, "i", obj->drawMode );} ! if (strcmp(index, "alpha" ) == 0) {return putLuaArguments(L, "i", obj->alpha );} ! if (strcmp(index, "dir" ) == 0) {return putLuaArguments(L, "i", obj->dir );} ! if (strcmp(index, "tick_time") == 0) {return putLuaArguments(L, "i", obj->tick );} ! if (strcmp(index, "obstacle" ) == 0) {return putLuaArguments(L, "i", obj->obstacle );} ! if (strcmp(index, "bitmap" ) == 0) {return putLuaArguments(L, "b", obj->bitmap );} ! if (strcmp(index, "map" ) == 0) {return putLuaArguments(L, "m", obj->getMap() );} ! if (strcmp(index, "id" ) == 0) {return putLuaArguments(L, "i", obj->id );} // None of the above, so deal with the value normally --- 509,546 ---- } ! if (strcmp(index, "speed" ) == 0) { ! return putLuaArguments(L, "d", obj->speed );} ! if (strcmp(index, "walking" ) == 0) { ! return putLuaArguments(L, "d", obj->walking );} ! if (strcmp(index, "x" ) == 0) { ! return putLuaArguments(L, "d", obj->x );} ! if (strcmp(index, "y" ) == 0) { ! return putLuaArguments(L, "d", obj->y );} ! if (strcmp(index, "w" ) == 0) { ! return putLuaArguments(L, "d", obj->w );} ! if (strcmp(index, "h" ) == 0) { ! return putLuaArguments(L, "d", obj->h );} ! if (strcmp(index, "offset_x" ) == 0) { ! return putLuaArguments(L, "i", obj->offset_x );} ! if (strcmp(index, "offset_y" ) == 0) { ! return putLuaArguments(L, "i", obj->offset_y );} ! if (strcmp(index, "offset_z" ) == 0) { ! return putLuaArguments(L, "i", obj->offset_z );} ! if (strcmp(index, "draw_mode") == 0) { ! return putLuaArguments(L, "i", obj->drawMode );} ! if (strcmp(index, "alpha" ) == 0) { ! return putLuaArguments(L, "i", obj->alpha );} ! if (strcmp(index, "dir" ) == 0) { ! return putLuaArguments(L, "i", obj->dir );} ! if (strcmp(index, "tick_time") == 0) { ! return putLuaArguments(L, "i", obj->tick );} ! if (strcmp(index, "obstacle" ) == 0) { ! return putLuaArguments(L, "i", obj->obstacle );} ! if (strcmp(index, "bitmap" ) == 0) { ! return putLuaArguments(L, "b", obj->bitmap );} ! if (strcmp(index, "map" ) == 0) { ! return putLuaArguments(L, "m", obj->getMap() );} ! if (strcmp(index, "id" ) == 0) { ! return putLuaArguments(L, "i", obj->id );} // None of the above, so deal with the value normally *************** *** 602,620 **** } ! if (strcmp(index, "speed" ) == 0) {obj->speed = lua_tonumber(L, -1);} ! else if (strcmp(index, "walking" ) == 0) {obj->walking = lua_tonumber(L, -1);} ! else if (strcmp(index, "x" ) == 0) {obj->x = lua_tonumber(L, -1);} ! else if (strcmp(index, "y" ) == 0) {obj->y = lua_tonumber(L, -1);} ! else if (strcmp(index, "w" ) == 0) {obj->w = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "h" ) == 0) {obj->h = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_x" ) == 0) {obj->offset_x = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_y" ) == 0) {obj->offset_y = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_z" ) == 0) {obj->offset_z = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "draw_mode") == 0) {obj->drawMode = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "alpha" ) == 0) {obj->alpha = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "dir" ) == 0) {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); --- 597,630 ---- } ! if (strcmp(index, "speed" ) == 0) { ! obj->speed = lua_tonumber(L, -1);} ! else if (strcmp(index, "walking" ) == 0) { ! obj->walking = lua_tonumber(L, -1);} ! else if (strcmp(index, "x" ) == 0) { ! obj->setX(lua_tonumber(L, -1));} ! else if (strcmp(index, "y" ) == 0) { ! obj->setY(lua_tonumber(L, -1));} ! else if (strcmp(index, "w" ) == 0) { ! obj->w = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "h" ) == 0) { ! obj->h = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_x" ) == 0) { ! obj->offset_x = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_y" ) == 0) { ! obj->offset_y = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "offset_z" ) == 0) { ! obj->offset_z = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "draw_mode") == 0) { ! obj->drawMode = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "alpha" ) == 0) { ! obj->alpha = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "dir" ) == 0) { ! 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); |
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3801 Modified Files: canvas.cpp canvas.h common.h rpg.cpp rpg.h script.cpp script.h sound.cpp sound.h Added Files: engine.cpp engine.h Log Message: Merged in some engine changes from DGE/hecate to BBRpg on SourceForge Index: common.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/common.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** common.h 25 Apr 2004 16:39:52 -0000 1.4 --- common.h 23 Oct 2004 11:54:18 -0000 1.5 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 16,19 **** --- 16,20 ---- #include "shared/console.h" #include "shared/tiled_map.h" + #include "shared/module.h" extern int debug_mode; // Show debug info *************** *** 24,27 **** --- 25,35 ---- extern BITMAP *buffer; extern TileRepository *tileRepository; + extern Module *module; + + #define DIR_NONE -1 + #define DIR_UP 0 + #define DIR_LEFT 1 + #define DIR_RIGHT 2 + #define DIR_DOWN 3 #endif Index: canvas.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** canvas.h 13 Apr 2004 12:26:08 -0000 1.3 --- canvas.h 23 Oct 2004 11:54:17 -0000 1.4 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify Index: canvas.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** canvas.cpp 13 Apr 2004 12:26:08 -0000 1.4 --- canvas.cpp 23 Oct 2004 11:54:09 -0000 1.5 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 191,194 **** ); ! map->draw(buffer); } --- 191,194 ---- ); ! map->draw(buffer, debug_mode); } Index: sound.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sound.cpp 13 Apr 2004 12:26:08 -0000 1.10 --- sound.cpp 23 Oct 2004 11:54:18 -0000 1.11 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 251,255 **** play_sample(sample, sfx_vol, 128, 1000, 0); } else { ! return luaL_error(L, "Error: Cannot find requested sample (%s)!", name); } --- 251,255 ---- play_sample(sample, sfx_vol, 128, 1000, 0); } else { ! console.log(CON_LOG, CON_ALWAYS, "Error: Cannot find requested sample (%s)!", name); } Index: script.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** script.h 13 Apr 2004 12:26:08 -0000 1.7 --- script.h 23 Oct 2004 11:54:18 -0000 1.8 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 77,80 **** --- 77,81 ---- int l_get_tile_at(lua_State *L); int l_set_tile_at(lua_State *L); + int l_create_map(lua_State *L); int l_walk_obj(lua_State *L); Index: sound.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sound.h 13 Jan 2004 16:32:35 -0000 1.7 --- sound.h 23 Oct 2004 11:54:18 -0000 1.8 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** script.cpp 13 Apr 2004 12:26:08 -0000 1.15 --- script.cpp 23 Oct 2004 11:54:18 -0000 1.16 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 13,17 **** #include <stdarg.h> #include "rpg.h" - #include "shared/engine.h" #include "shared/object.h" #include "shared/console.h" --- 13,16 ---- *************** *** 70,73 **** --- 69,73 ---- luaopen_math(L); luaopen_table(L); + luaopen_io(L); // Add the Object type to Lua *************** *** 127,130 **** --- 127,131 ---- lua_register(L, "m_get_tile_at", l_get_tile_at); lua_register(L, "m_set_tile_at", l_set_tile_at); + lua_register(L, "m_create_map", l_create_map); lua_register(L, "m_walk_obj", l_walk_obj); *************** *** 172,181 **** { switch (*desc) { ! case 'i': lua_pushnumber (L, va_arg(vals, int )); break; // Integer ! case 'd': lua_pushnumber (L, va_arg(vals, double)); break; // Double ! case 's': lua_pushstring (L, va_arg(vals, char* )); break; // String ! case 'b': lua_pushlightuserdata(L, va_arg(vals, BITMAP*)); break; // Bitmap ! case 'o': lua_getref (L, (va_arg(vals, Object*))->tableRef); break; // Object ! case 'm': lua_pushlightuserdata(L, va_arg(vals, TiledMap*)); break; // TiledMap default: valc--; } --- 173,188 ---- { switch (*desc) { ! case 'i': // Integer ! lua_pushnumber(L, va_arg(vals, int)); break; ! case 'd': //Double ! lua_pushnumber(L, va_arg(vals, double)); break; ! case 's': // String ! lua_pushstring(L, va_arg(vals, char*)); break; ! case 'b': // Bitmap ! lua_pushlightuserdata(L, va_arg(vals, BITMAP*)); break; ! case 'o': // Object ! lua_getref(L, (va_arg(vals, Object*))->tableRef); break; ! case 'm': // TiledMap ! lua_pushlightuserdata(L, va_arg(vals, TiledMap*)); break; default: valc--; } *************** *** 217,221 **** } ! //console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, "Lua: calling function %s with %d arguments.", function, argc); lua_call(L, argc + 1, 1); --- 224,230 ---- } ! //console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, ! // "Lua: calling function %s with %d arguments.", function, ! // argc); lua_call(L, argc + 1, 1); *************** *** 252,256 **** } ! //console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, "Lua: calling function %s with %d arguments.", function, argc); //handleLuaError(lua_call(L, argc, 1), function); lua_call(L, argc, 1); --- 261,266 ---- } ! //console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, ! // "Lua: calling function %s with %d arguments.", function, argc); //handleLuaError(lua_call(L, argc, 1), function); lua_call(L, argc, 1); *************** *** 260,264 **** } else { ! console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, "Warning: called function undefined (%s).", function); lua_pop(L, 1); // Pop function } --- 270,275 ---- } else { ! console.log(CON_CONSOLE | CON_LOG, CON_VDEBUG, ! "Warning: called function undefined (%s).", function); lua_pop(L, 1); // Pop function } *************** *** 270,278 **** { switch (err) { ! case LUA_ERRRUN: console.log(CON_QUIT, CON_ALWAYS, "Lua error: Error while running script (\"%s\")", string); break; ! case LUA_ERRSYNTAX: console.log(CON_QUIT, CON_ALWAYS, "Lua error: Syntax error while precompiling script (\"%s\")", string); break; ! case LUA_ERRMEM: console.log(CON_QUIT, CON_ALWAYS, "Lua error: Out of memory in script (\"%s\")", string); break; ! case LUA_ERRERR: console.log(CON_QUIT, CON_ALWAYS, "Lua error: Error while running _ERRORMESSAGE in script (\"%s\")", string); break; ! case LUA_ERRFILE: console.log(CON_QUIT, CON_ALWAYS, "Lua error: Error while opening script file (\"%s\")", string); break; } } --- 281,306 ---- { switch (err) { ! case LUA_ERRRUN: ! console.log(CON_QUIT, CON_ALWAYS, ! "Lua error: Error while running script (\"%s\")", string); ! break; ! case LUA_ERRSYNTAX: ! console.log(CON_QUIT, CON_ALWAYS, "Lua error: Syntax error while " ! "precompiling script (\"%s\")", string); ! break; ! case LUA_ERRMEM: ! console.log(CON_QUIT, CON_ALWAYS, ! "Lua error: Out of memory in script (\"%s\")", string); ! break; ! case LUA_ERRERR: ! console.log(CON_QUIT, CON_ALWAYS, ! "Lua error: Error while running _ERRORMESSAGE in script " ! "(\"%s\")", string); ! break; ! case LUA_ERRFILE: ! console.log(CON_QUIT, CON_ALWAYS, ! "Lua error: Error while opening script file (\"%s\")", ! string); ! break; } } *************** *** 297,302 **** int n = lua_gettop(L); // Number of arguments int argc = 0; - va_list ap; va_start(ap, args); --- 325,330 ---- int n = lua_gettop(L); // Number of arguments int argc = 0; va_list ap; + va_start(ap, args); *************** *** 304,308 **** { if (argc == n) { ! lua_pushfstring(L, "This function does not take %d parameters.", n); lua_error(L); } --- 332,336 ---- { if (argc == n) { ! lua_pushfstring(L, "Wrong number of arguments (%d)", n); lua_error(L); } *************** *** 312,317 **** { int *a = va_arg(ap, int*); ! if (lua_isnumber(L, -n + argc)) *a = (int)(lua_tonumber(L, -n + argc) + 0.5); ! else luaL_typerror(L, argc+1, lua_typename(L, LUA_TNUMBER)); } break; --- 340,349 ---- { int *a = va_arg(ap, int*); ! if (lua_isnumber(L, -n + argc)) { ! *a = (int)(lua_tonumber(L, -n + argc) + 0.5); ! } else { ! const char *type = lua_typename(L, LUA_TNUMBER); ! luaL_typerror(L, argc + 1, type); ! } } break; *************** *** 320,325 **** { double *a = va_arg(ap, double*); ! if (lua_isnumber(L, -n + argc)) *a = lua_tonumber(L, -n + argc); ! else luaL_typerror(L, argc+1, lua_typename(L, LUA_TNUMBER)); } break; --- 352,361 ---- { double *a = va_arg(ap, double*); ! if (lua_isnumber(L, -n + argc)) { ! *a = lua_tonumber(L, -n + argc); ! } else { ! const char *type = lua_typename(L, LUA_TNUMBER); ! luaL_typerror(L, argc + 1, type); ! } } break; *************** *** 328,333 **** { const char **a = va_arg(ap, const char**); ! if (lua_isstring(L, -n + argc)) *a = lua_tostring(L, -n + argc); ! else luaL_typerror(L, argc+1, lua_typename(L, LUA_TSTRING)); } break; --- 364,373 ---- { const char **a = va_arg(ap, const char**); ! if (lua_isstring(L, -n + argc)) { ! *a = lua_tostring(L, -n + argc); ! } else { ! const char *type = lua_typename(L, LUA_TSTRING); ! luaL_typerror(L, argc + 1, type); ! } } break; *************** *** 341,346 **** *a = (Object*)lua_touserdata(L, -1); lua_pop(L, 1); } - else luaL_typerror(L, argc+1, lua_typename(L, LUA_TTABLE)); } break; --- 381,388 ---- *a = (Object*)lua_touserdata(L, -1); lua_pop(L, 1); + } else { + const char *type = lua_typename(L, LUA_TTABLE); + luaL_typerror(L, argc + 1, type); } } break; *************** *** 352,357 **** lua_pushvalue(L, -n + argc); *a = lua_ref(L, -1); } - else luaL_typerror(L, argc+1, lua_typename(L, LUA_TTABLE)); } break; --- 394,401 ---- lua_pushvalue(L, -n + argc); *a = lua_ref(L, -1); + } else { + const char *type = lua_typename(L, LUA_TTABLE); + luaL_typerror(L, argc + 1, type); } } break; *************** *** 360,368 **** { BITMAP **a = va_arg(ap, BITMAP**); ! if (lua_islightuserdata(L, -n + argc)) *a = (BITMAP*)lua_touserdata(L, -n + argc); ! else ! luaL_typerror(L, argc+1, ! lua_typename(L, LUA_TLIGHTUSERDATA)); } break; --- 404,413 ---- { BITMAP **a = va_arg(ap, BITMAP**); ! if (lua_islightuserdata(L, -n + argc)) { *a = (BITMAP*)lua_touserdata(L, -n + argc); ! } else { ! const char *type = lua_typename(L, LUA_TLIGHTUSERDATA); ! luaL_typerror(L, argc + 1, type); ! } } break; *************** *** 371,379 **** { TiledMap **a = va_arg(ap, TiledMap**); ! if (lua_islightuserdata(L, -n + argc)) *a = (TiledMap*)lua_touserdata(L, -n + argc); ! else ! luaL_typerror(L, argc+1, ! lua_typename(L, LUA_TLIGHTUSERDATA)); } break; --- 416,425 ---- { TiledMap **a = va_arg(ap, TiledMap**); ! if (lua_islightuserdata(L, -n + argc)) { *a = (TiledMap*)lua_touserdata(L, -n + argc); ! } else { ! const char *type = lua_typename(L, LUA_TLIGHTUSERDATA); ! luaL_typerror(L, argc + 1, type); ! } } break; *************** *** 388,392 **** if (argc != n) { ! lua_pushfstring(L, "This function does not take %d parameters.", n); lua_error(L); } --- 434,438 ---- if (argc != n) { ! lua_pushfstring(L, "Wrong number of arguments (%d)", n); lua_error(L); } *************** *** 891,895 **** } else { ! console.log(CON_CONSOLE | CON_LOG, CON_DEBUG, "Warning: map_to_screen called without a map."); } --- 937,942 ---- } else { ! console.log(CON_CONSOLE | CON_LOG, CON_DEBUG, ! "Warning: map_to_screen called without a map."); } *************** *** 941,944 **** --- 988,1007 ---- } + int l_create_map(lua_State *L) + { + int w, h, tw, th; + getLuaArguments(L, "iiii", &w, &h, &tw, &th); + + if (w > 0 && h > 0 && tw > 0 && th > 0) { + TiledMap *map = new SquareMap(tw, th); + map->resizeTo(w, h); + return putLuaArguments(L, "m", map); + } else { + console.log(CON_CONSOLE | CON_LOG, CON_ALWAYS, + "Warning: illegal arguments to m_create_map."); + return 0; + } + } + int l_quit_game(lua_State *L) *************** *** 971,992 **** } ! if (strcmp(index, "speed" ) == 0) {return putLuaArguments(L, "d", obj->speed );} ! if (strcmp(index, "walking" ) == 0) {return putLuaArguments(L, "d", obj->walking );} ! if (strcmp(index, "x" ) == 0) {return putLuaArguments(L, "d", obj->x );} ! if (strcmp(index, "y" ) == 0) {return putLuaArguments(L, "d", obj->y );} ! if (strcmp(index, "w" ) == 0) {return putLuaArguments(L, "i", obj->w );} ! if (strcmp(index, "h" ) == 0) {return putLuaArguments(L, "i", obj->h );} ! if (strcmp(index, "offset_x" ) == 0) {return putLuaArguments(L, "i", obj->offset_x );} ! if (strcmp(index, "offset_y" ) == 0) {return putLuaArguments(L, "i", obj->offset_y );} ! if (strcmp(index, "offset_z" ) == 0) {return putLuaArguments(L, "i", obj->offset_z );} ! if (strcmp(index, "draw_mode") == 0) {return putLuaArguments(L, "i", obj->drawMode );} ! if (strcmp(index, "alpha" ) == 0) {return putLuaArguments(L, "i", obj->alpha );} ! if (strcmp(index, "dir" ) == 0) {return putLuaArguments(L, "i", obj->dir );} ! if (strcmp(index, "tick_time") == 0) {return putLuaArguments(L, "i", obj->tick );} ! if (strcmp(index, "obstacle" ) == 0) {return putLuaArguments(L, "i", obj->obstacle );} ! if (strcmp(index, "bitmap" ) == 0) {return putLuaArguments(L, "b", obj->bitmap );} ! if (strcmp(index, "map" ) == 0) {return putLuaArguments(L, "m", obj->getMap() );} ! if (strcmp(index, "id" ) == 0) {return putLuaArguments(L, "i", obj->id );} ! if (strcmp(index, "in_air" ) == 0) {return putLuaArguments(L, "i", obj->in_air );} // None of the above, so deal with the value normally --- 1034,1073 ---- } ! if (strcmp(index, "speed") == 0) { ! return putLuaArguments(L, "d", obj->speed);} ! if (strcmp(index, "walking") == 0) { ! return putLuaArguments(L, "d", obj->walking);} ! if (strcmp(index, "x") == 0) { ! return putLuaArguments(L, "d", obj->x);} ! if (strcmp(index, "y") == 0) { ! return putLuaArguments(L, "d", obj->y);} ! if (strcmp(index, "w") == 0) { ! return putLuaArguments(L, "d", obj->w);} ! if (strcmp(index, "h") == 0) { ! return putLuaArguments(L, "d", obj->h);} ! if (strcmp(index, "offset_x") == 0) { ! return putLuaArguments(L, "i", obj->offset_x);} ! if (strcmp(index, "offset_y") == 0) { ! return putLuaArguments(L, "i", obj->offset_y);} ! if (strcmp(index, "offset_z") == 0) { ! return putLuaArguments(L, "i", obj->offset_z);} ! if (strcmp(index, "draw_mode") == 0) { ! return putLuaArguments(L, "i", obj->drawMode);} ! if (strcmp(index, "alpha") == 0) { ! return putLuaArguments(L, "i", obj->alpha);} ! if (strcmp(index, "dir") == 0) { ! return putLuaArguments(L, "i", obj->dir);} ! if (strcmp(index, "tick_time") == 0) { ! return putLuaArguments(L, "i", obj->tick);} ! if (strcmp(index, "obstacle") == 0) { ! return putLuaArguments(L, "i", obj->obstacle);} ! if (strcmp(index, "bitmap") == 0) { ! return putLuaArguments(L, "b", obj->bitmap);} ! if (strcmp(index, "map") == 0) { ! return putLuaArguments(L, "m", obj->getMap());} ! if (strcmp(index, "id") == 0) { ! return putLuaArguments(L, "i", obj->id);} ! if (strcmp(index, "in_air") == 0) { ! return putLuaArguments(L, "i", obj->in_air);} // None of the above, so deal with the value normally *************** *** 1081,1085 **** } else if (strcmp(index, "dir") == 0) { ! obj->dir = (int)lua_tonumber(L, -1); } else if (strcmp(index, "tick_time") == 0) { --- 1162,1166 ---- } else if (strcmp(index, "dir") == 0) { ! obj->setDir((int)lua_tonumber(L, -1)); } else if (strcmp(index, "tick_time") == 0) { --- NEW FILE: engine.h --- (This appears to be a binary file; contents omitted.) Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** rpg.cpp 25 Apr 2004 16:39:52 -0000 1.11 --- rpg.cpp 23 Oct 2004 11:54:18 -0000 1.12 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 14,19 **** #include "sound.h" #include "shared/tiled_map.h" - #include "shared/engine.h" #include "shared/module.h" #include "script.h" #include "canvas.h" --- 14,19 ---- #include "sound.h" #include "shared/tiled_map.h" #include "shared/module.h" + #include "engine.h" #include "script.h" #include "canvas.h" *************** *** 36,39 **** --- 36,40 ---- bool game_end = false; + bool exclusive_mode = false; bool bVSync = false; bool bDoubleSize = false; *************** *** 43,46 **** --- 44,48 ---- FONT* engine_font = NULL; int gameClassInstance = 0; + list<TiledMap*> maps; int lps = 100; *************** *** 53,57 **** BITMAP *buffer; ! void main() { init_engine(); --- 55,59 ---- BITMAP *buffer; ! int main() { init_engine(); *************** *** 70,73 **** --- 72,77 ---- exit_program(); + + return 0; } END_OF_MAIN(); *************** *** 84,90 **** set_display_switch_mode(SWITCH_BACKAMNESIA); - //register_datafile_object( - // DAT_MAPDATA, load_tiledmapdata, destroy_tiledmapdata); - set_config_file("rpg.cfg"); --- 88,91 ---- Index: rpg.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** rpg.h 13 Apr 2004 12:26:08 -0000 1.6 --- rpg.h 23 Oct 2004 11:54:18 -0000 1.7 *************** *** 2,6 **** 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 --- 2,6 ---- The Moonlight Engine - An extendable, portable, RPG-focused game engine. Project Home: http://moeng.sourceforge.net/ ! Copyright (C) 2003, 2004 Bjørn Lindeijer This program is free software; you can redistribute it and/or modify *************** *** 14,18 **** #include "shared/tiled_map.h" - #include "shared/engine.h" #include "shared/console.h" #include "shared/module.h" --- 14,17 ---- *************** *** 31,40 **** extern DATAFILE *interface_graphics; - extern Module *module; extern int gameClassInstance; extern TileType *selectedTile; extern bool game_end; void init_engine(); --- 30,40 ---- extern DATAFILE *interface_graphics; extern int gameClassInstance; extern TileType *selectedTile; + extern list<TiledMap*> maps; extern bool game_end; + extern bool exclusive_mode; void init_engine(); --- NEW FILE: engine.cpp --- (This appears to be a binary file; contents omitted.) |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 19:22:10
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988 Modified Files: HISTORY gui.dat update.bat Log Message: Merged engine changes from DGE RPG agian. Index: update.bat =================================================================== RCS file: /cvsroot/moeng/BBRpg/update.bat,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** update.bat 3 Jan 2004 22:16:56 -0000 1.2 --- update.bat 25 Apr 2004 16:39:51 -0000 1.3 *************** *** 1,6 **** del data.dat ! dat -a -k -t LUA data.dat data\scripts\*.lua ! dat -a -k -t BMP data.dat data\bitmaps\*.bmp data/bitmaps\*.tga ! dat -a -k -t FONT data.dat data\bitmaps\font_*.* ! dat -a -k -t MAP data.dat data\maps\*.map ! dat -a -k -t SAMP data.dat data\samples\*.wav --- 1,2 ---- del data.dat ! dat -a -k -t DATA -r -c0 data.dat data Index: gui.dat =================================================================== RCS file: /cvsroot/moeng/BBRpg/gui.dat,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsdOp9ls and /tmp/cvssN4GyZ differ Index: HISTORY =================================================================== RCS file: /cvsroot/moeng/BBRpg/HISTORY,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HISTORY 8 Dec 2003 13:02:28 -0000 1.1 --- HISTORY 25 Apr 2004 16:39:51 -0000 1.2 *************** *** 1,2 **** --- 1,7 ---- + 0.9.2 + - Saving/loading maps in XML + + 0.9.1 + - Using new Module class to load resources 0.9.0 |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 19:13:03
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/src Modified Files: common.h rpg.cpp Log Message: Merged engine changes from DGE RPG agian. Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** rpg.cpp 13 Apr 2004 12:26:08 -0000 1.10 --- rpg.cpp 25 Apr 2004 16:39:52 -0000 1.11 *************** *** 39,45 **** bool bDoubleSize = false; char filename[256]; ! DATAFILE *interface_graphics; ! Module *module; ! FONT* engine_font; int gameClassInstance = 0; --- 39,45 ---- bool bDoubleSize = false; char filename[256]; ! DATAFILE *engine_data = NULL; ! Module *module = NULL; ! FONT* engine_font = NULL; int gameClassInstance = 0; *************** *** 167,177 **** console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! interface_graphics = load_datafile("gui.dat"); ! if (!interface_graphics) { console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); } // Set font to use ! DATAFILE *temp = find_datafile_object(interface_graphics, "SmallFont"); if (temp) {engine_font = ((FONT *)temp->dat);} --- 167,177 ---- 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"); } // Set font to use ! DATAFILE *temp = find_datafile_object(engine_data, "SmallFont"); if (temp) {engine_font = ((FONT *)temp->dat);} *************** *** 323,327 **** console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(interface_graphics); delete module; --- 323,327 ---- console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(engine_data); delete module; Index: common.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/common.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** common.h 9 Dec 2003 01:42:46 -0000 1.3 --- common.h 25 Apr 2004 16:39:52 -0000 1.4 *************** *** 17,22 **** #include "shared/tiled_map.h" ! extern int debug_mode; // Show debug info extern FONT *engine_font; extern Console console; --- 17,23 ---- #include "shared/tiled_map.h" ! extern int debug_mode; // Show debug info + extern DATAFILE *engine_data; extern FONT *engine_font; extern Console console; |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 19:11:59
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/src/shared Modified Files: module.cpp module.h tiled_map.cpp Log Message: Merged engine changes from DGE RPG agian. Index: module.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** module.h 13 Apr 2004 12:28:33 -0000 1.1 --- module.h 25 Apr 2004 16:39:53 -0000 1.2 *************** *** 16,19 **** --- 16,20 ---- #include <map> #include <set> + #include <string> #include "tiled_map.h" *************** *** 28,54 **** ~Module(); ! void loadScript(const char *name); void loadScripts(); ! TiledMap* loadMap(const char *name); ! BITMAP* findBitmap(const char *name); ! MIDI* findMidi(const char *name); ! SAMPLE* findSample(const char *name); ! FONT* findFont(const char *name); ! char* findScript(const char *name); private: char* makeFilename(const char *name, const char *subdir); ! DATAFILE *datafile; char *path; int loadLevel; ! map<const char*, BITMAP*, ltstr> bitmaps; ! map<const char*, MIDI*, ltstr> midis; ! map<const char*, SAMPLE*, ltstr> samples; ! map<const char*, FONT*, ltstr> fonts; ! map<const char*, char*, ltstr> scripts; ! set<const char*> loadedScripts; }; --- 29,56 ---- ~Module(); ! void loadScript(std::string name); void loadScripts(); ! TiledMap* loadMap(std::string name); ! BITMAP* findBitmap(std::string name); ! MIDI* findMidi(std::string name); ! SAMPLE* findSample(std::string name); ! FONT* findFont(std::string name); ! char* findScript(std::string name); 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; ! map<std::string, FONT*> fonts; ! map<std::string, char*> scripts; }; Index: tiled_map.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tiled_map.cpp 13 Apr 2004 12:26:08 -0000 1.8 --- tiled_map.cpp 25 Apr 2004 16:39:53 -0000 1.9 *************** *** 653,658 **** int TiledMap::loadMap(const char* filename) { ! xmlDocPtr doc = xmlParseFile(filename); if (doc) { xmlNodePtr cur = xmlDocGetRootElement(doc); --- 653,683 ---- int TiledMap::loadMap(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 cur = xmlDocGetRootElement(doc); *************** *** 663,670 **** --- 688,697 ---- } + console.log(CON_LOG, CON_VDEBUG, "- Loading map from XML tree"); loadFrom(cur, tileRepository); xmlFreeDoc(doc); } else { + console.log(CON_LOG, CON_VDEBUG, "- Attempting to load packfile map"); PACKFILE *file = pack_fopen(filename, F_READ_PACKED); *************** *** 675,678 **** --- 702,706 ---- } + console.log(CON_LOG, CON_VDEBUG, "- Loading map from packfile"); this->loadFrom(file, tileRepository); pack_fclose(file); *************** *** 738,741 **** --- 766,771 ---- 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++; *************** *** 752,755 **** --- 782,788 ---- // 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, *************** *** 869,878 **** dest, font, cameraScreenRect.x + 10, cameraScreenRect.y + 10, ! makecol(200,200,200), -1, "%i entities", objects.size()); textprintf_ex( dest, font, cameraScreenRect.x + 10, cameraScreenRect.y + 20, ! makecol(200,200,200), -1, "%i drawn entities", visibleEnts.size()); } --- 902,911 ---- dest, font, cameraScreenRect.x + 10, cameraScreenRect.y + 10, ! makecol(200,200,200), -1, "%d entities", objects.size()); textprintf_ex( dest, font, cameraScreenRect.x + 10, cameraScreenRect.y + 20, ! makecol(200,200,200), -1, "%d drawn entities", visibleEnts.size()); } *************** *** 903,913 **** textprintf_ex( dest, font, ! cameraScreenRect.x + 10, cameraScreenRect.y + 10, ! makecol(200,200,200), -1, "%i entities", ! objects.size()); ! textprintf_ex( ! dest, font, ! cameraScreenRect.x + 10, cameraScreenRect.y + 20, ! makecol(200,200,200), -1, "%i drawn entities", visibleEnts.size()); } --- 936,941 ---- textprintf_ex( dest, font, ! cameraScreenRect.x + 10, cameraScreenRect.y + 30, ! makecol(200,200,200), -1, "%d drawn sky entities", visibleEnts.size()); } Index: module.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** module.cpp 13 Apr 2004 12:28:33 -0000 1.1 --- module.cpp 25 Apr 2004 16:39:53 -0000 1.2 *************** *** 18,21 **** --- 18,22 ---- #include <string.h> #include <dirent.h> + #include <string> #include "../common.h" #include "module.h" *************** *** 31,39 **** // Open the datafile ! char *filename = new char[strlen(name) + 1 + 4]; ! strcpy(filename, name); ! strcat(filename, ".dat"); ! datafile = load_datafile(filename); ! delete[] filename; } --- 32,39 ---- // Open the datafile ! datafile_name = new char[strlen(name) + 1 + 4]; ! sprintf(datafile_name, "%s.dat", name); ! ! script_data = NULL; } *************** *** 41,47 **** { delete[] path; } ! void Module::loadScript(const char *name) { // Create the indent --- 41,48 ---- { delete[] path; + delete[] datafile_name; } ! void Module::loadScript(std::string name) { // Create the indent *************** *** 50,70 **** for (i = 0; i < loadLevel; i++) spaces[i] = ' '; spaces[loadLevel] = '\0'; char *script = findScript(name); if (script) { ! if (loadedScripts.find(script) == loadedScripts.end()) { ! loadedScripts.insert(script); ! console.log(CON_LOG, CON_ALWAYS, "%s> \"%s\"", spaces, name); ! if (luaL_loadbuffer(L, script, strlen(script), name)) ! { ! lua_error(L); ! } ! loadLevel++; ! lua_call(L, 0, 0); // call main ! loadLevel--; } } else { ! console.log(CON_LOG, CON_ALWAYS, "%sX \"%s\" not found!", spaces, name); } --- 51,75 ---- for (i = 0; i < loadLevel; i++) spaces[i] = ' '; spaces[loadLevel] = '\0'; + map<std::string, char*, ltstr>::iterator script_i = scripts.find(name); + + if (script_i != scripts.end()) { + console.log(CON_LOG, CON_VDEBUG, "%s# Already loaded \"%s\"", + spaces, name.c_str()); + return; + } char *script = findScript(name); if (script) { ! console.log(CON_LOG, CON_ALWAYS, "%s> \"%s\"", spaces, name.c_str()); ! if (luaL_loadbuffer(L, script, strlen(script), name.c_str())) ! { ! lua_error(L); } + loadLevel++; + lua_call(L, 0, 0); // call main + loadLevel--; } else { ! console.log(CON_LOG, CON_ALWAYS, "%sX \"%s\" not found!", spaces, name.c_str()); } *************** *** 76,80 **** console.log(CON_LOG, CON_ALWAYS, "Loading scripts from \"%s\"...", path); - int i; char *dirname = makeFilename("", "/scripts"); DIR *dir; --- 81,84 ---- *************** *** 94,127 **** else { // Read the scripts from the datafile ! const char *name; ! for (i = 0; datafile[i].type != DAT_END; i++) { ! name = get_datafile_property(datafile + i, DAT_NAME); ! if (datafile[i].type == DAT_LUA) { ! loadLevel = 0; ! loadScript(name); } } } delete[] dirname; } ! TiledMap* Module::loadMap(const char *name) { - console.log(CON_LOG, CON_ALWAYS, "Loading map \"%s\"...", name); TiledMap *mmap = NULL; ! char *filename = makeFilename(name, "/maps"); if (exists(filename)) { mmap = new SquareMap(TILES_W, TILES_H); ! mmap->loadMap(filename); } ! else if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); if (df) { - //char *mapstring = new char[df->size + 1]; - //memcpy(mapstring, df->dat, df->size); - //mapstring[df->size] = '\0'; - xmlDocPtr doc = xmlReadMemory((char*)df->dat, df->size, NULL, NULL, 0); --- 98,149 ---- else { // Read the scripts from the datafile ! script_data = load_datafile_object(datafile_name, "data/scripts"); ! if (script_data) { ! DATAFILE *temp = (DATAFILE*)script_data->dat; ! const char *name; ! while (temp->type != DAT_END) { ! if (temp->type == DAT_DATA) { ! name = get_datafile_property(temp, DAT_NAME); ! loadLevel = 0; ! loadScript(name); ! } ! temp++; } + + // Unload the datafile + unload_datafile_object(script_data); + script_data = NULL; } } + // Clean up any loaded scripts + /* + set<const char*>::iterator i; + for (i = loadedScripts.begin(); i != loadedScripts.end(); i++) { + delete[] (*i); + } + loadedScripts.clear(); + */ + delete[] dirname; } ! TiledMap* Module::loadMap(std::string name) { TiledMap *mmap = NULL; ! char *filename = makeFilename(name.c_str(), "/maps"); ! console.log(CON_LOG, CON_ALWAYS, "Loading map \"%s\"...", filename); if (exists(filename)) { mmap = new SquareMap(TILES_W, TILES_H); ! if (mmap) { ! mmap->loadMap(filename); ! } else { ! console.log(CON_QUIT, CON_ALWAYS, "Insufficient memory for map!"); ! } } ! else { ! DATAFILE *df = load_datafile_object(datafile_name, filename); if (df) { xmlDocPtr doc = xmlReadMemory((char*)df->dat, df->size, NULL, NULL, 0); *************** *** 132,150 **** xmlFreeDoc(doc); } } } - //if (mmap) { - // maps.push_front(mmap); - //} - delete[] filename; return mmap; } ! BITMAP* Module::findBitmap(const char *name) { BITMAP *bitmap = NULL; ! map<const char*, BITMAP*, ltstr>::iterator i = bitmaps.find(name); if (i != bitmaps.end()) { --- 154,169 ---- xmlFreeDoc(doc); } + unload_datafile_object(df); } } delete[] filename; return mmap; } ! BITMAP* Module::findBitmap(std::string name) { BITMAP *bitmap = NULL; ! map<std::string, BITMAP*, ltstr>::iterator i = bitmaps.find(name); if (i != bitmaps.end()) { *************** *** 152,166 **** } else { ! char *filename = makeFilename(name, "/bitmaps"); // Attempt to load from disk, and otherwise from the datafile if (exists(filename)) { bitmap = load_bitmap(filename, NULL); - console.log(CON_LOG, CON_DEBUG, "From disk: \"%s\"", name); } ! else if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); ! if (df) bitmap = (BITMAP*)df->dat; ! console.log(CON_LOG, CON_DEBUG, "From datafile: \"%s\"", name); } --- 171,184 ---- } 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); } ! else { ! char *magicFilename = addMagic(filename); ! bitmap = load_bitmap(magicFilename, NULL); ! delete[] magicFilename; } *************** *** 172,179 **** } ! MIDI* Module::findMidi(const char *name) { MIDI *midi = NULL; ! map<const char*, MIDI*, ltstr>::iterator i = midis.find(name); if (i != midis.end()) { --- 190,198 ---- } ! MIDI* Module::findMidi(std::string name) { MIDI *midi = NULL; ! map<std::string, MIDI*, ltstr>::iterator i = midis.find(name); ! char *filename = makeFilename(name.c_str(), "/music"); if (i != midis.end()) { *************** *** 181,185 **** } else { - char *filename = makeFilename(name, "/music"); // Attempt to load from disk, and otherwise from the datafile --- 200,203 ---- *************** *** 187,206 **** midi = load_midi(filename); } ! else if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); ! if (df) midi = (MIDI*)df->dat; } if (midi) midis[name] = midi; - delete[] filename; } return midi; } ! SAMPLE* Module::findSample(const char *name) { SAMPLE *sample = NULL; ! map<const char*, SAMPLE*, ltstr>::iterator i = samples.find(name); if (i != samples.end()) { --- 205,226 ---- midi = load_midi(filename); } ! else { ! char *magicFilename = addMagic(filename); ! midi = load_midi(magicFilename); ! delete[] magicFilename; } if (midi) midis[name] = midi; } + delete[] filename; return midi; } ! SAMPLE* Module::findSample(std::string name) { SAMPLE *sample = NULL; ! map<std::string, SAMPLE*, ltstr>::iterator i = samples.find(name); ! char *filename = makeFilename(name.c_str(), "/samples"); if (i != samples.end()) { *************** *** 208,212 **** } else { - char *filename = makeFilename(name, "/samples"); // Attempt to load from disk, and otherwise from the datafile --- 228,231 ---- *************** *** 214,233 **** sample = load_sample(filename); } ! else if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); ! if (df) sample = (SAMPLE*)df->dat; } if (sample) samples[name] = sample; - delete[] filename; } return sample; } ! FONT* Module::findFont(const char *name) { FONT *font = NULL; ! map<const char*, FONT*, ltstr>::iterator i = fonts.find(name); if (i != fonts.end()) { --- 233,253 ---- sample = load_sample(filename); } ! else { ! char *magicFilename = addMagic(filename); ! sample = load_sample(magicFilename); ! delete[] magicFilename; } if (sample) samples[name] = sample; } + delete[] filename; return sample; } ! FONT* Module::findFont(std::string name) { FONT *font = NULL; ! map<std::string, FONT*, ltstr>::iterator i = fonts.find(name); if (i != fonts.end()) { *************** *** 236,241 **** else { // Allegro can only load fonts from a datafile ! if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); if (df) font = (FONT*)df->dat; } --- 256,261 ---- else { // Allegro can only load fonts from a datafile ! if (engine_data) { ! DATAFILE *df = find_datafile_object(engine_data, name.c_str()); if (df) font = (FONT*)df->dat; } *************** *** 247,254 **** } ! char* Module::findScript(const char *name) { char *script = NULL; ! map<const char*, char*, ltstr>::iterator i = scripts.find(name); if (i != scripts.end()) { --- 267,275 ---- } ! char* Module::findScript(std::string name) { char *script = NULL; ! map<std::string, char*, ltstr>::iterator i = scripts.find(name); ! char *filename = makeFilename(name.c_str(), "/scripts"); if (i != scripts.end()) { *************** *** 256,288 **** } else { - char *filename = makeFilename(name, "/scripts"); - if (exists(filename)) { FILE* f = fopen(filename, "rb"); // Get size of file fseek(f, 0, SEEK_END); long size = ftell(f); rewind(f); ! // Read file into character array script = new char[size + 1]; fread(script, 1, size, f); script[size] = '\0'; fclose(f); } ! else if (datafile) { ! DATAFILE *df = find_datafile_object(datafile, name); if (df) { script = new char[df->size + 1]; memcpy(script, df->dat, df->size); script[df->size] = '\0'; } } if (script) scripts[name] = script; - delete[] filename; } ! return script; } --- 277,315 ---- } else { if (exists(filename)) { FILE* f = fopen(filename, "rb"); + if (!f) { + console.log(CON_QUIT, CON_ALWAYS, + "Error: %s seems to exist but failed to open!", + filename); + } + // Get size of file fseek(f, 0, SEEK_END); long size = ftell(f); rewind(f); ! // Read file into character array script = new char[size + 1]; fread(script, 1, size, f); script[size] = '\0'; + fclose(f); } ! else { ! DATAFILE *df = load_datafile_object(datafile_name, filename); if (df) { script = new char[df->size + 1]; memcpy(script, df->dat, df->size); script[df->size] = '\0'; + unload_datafile_object(df); } } if (script) scripts[name] = script; } ! ! delete[] filename; return script; } *************** *** 292,299 **** int length = strlen(path) + strlen(subdir) + strlen(name) + 2; char *filename = new char[length]; ! strcpy(filename, path); ! strcat(filename, subdir); ! strcat(filename, "/"); ! strcat(filename, name); return filename; } --- 319,331 ---- int length = strlen(path) + strlen(subdir) + strlen(name) + 2; char *filename = new char[length]; ! sprintf(filename, "%s%s/%s", path, subdir, name); ! return filename; ! } ! ! char* Module::addMagic(const char *file) ! { ! int length = strlen(path) + strlen(file) + 6; ! char *filename = new char[length]; ! sprintf(filename, "%s.dat#%s", path, file); return filename; } |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 17:23:15
|
Update of /cvsroot/moeng/BBRpg/data/maps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4433 Modified Files: jail.map jakesplace.map leesplace.map restplace.map Log Message: Some maps to XML Index: jakesplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/jakesplace.map,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvsFvpJx9 and /tmp/cvsAfz5q5 differ Index: leesplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/leesplace.map,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsQt8y5K and /tmp/cvsnIWZTR differ Index: jail.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/jail.map,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsCTp3Bh and /tmp/cvsdtmyMo differ Index: restplace.map =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/maps/restplace.map,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsENSVkq and /tmp/cvsZcR2ky differ |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 16:43:59
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/data/scripts Modified Files: BBRpgConversationWindow.lua ConversationWindow.lua FenceSewers.lua GuiTheme.lua Log Message: Merged engine changes from DGE RPG agian. Index: FenceSewers.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/FenceSewers.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FenceSewers.lua 28 Dec 2003 15:49:45 -0000 1.4 --- FenceSewers.lua 25 Apr 2004 16:39:52 -0000 1.5 *************** *** 1,168 **** ! -- ! -- The Fences in the Sewers. ! -- By Georg Muntingh ! ! import("Decoration.lua") ! ! ! FenceH3 = Decoration:subclass ! { ! name = "FenceH3"; ! ! init = function(self) ! self:updateBitmap() ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! isOpen = false, ! obstacle = 1, ! h = 1, ! w = 3, ! draw_mode = DM_MASKED, bitmaps = extr_array(m_get_bitmap("fence_h3.bmp"), 73, 60), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceH5 = Decoration:subclass ! { ! name = "FenceH5"; ! ! init = function(self) ! self:updateBitmap() ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! isOpen = false, ! obstacle = 1, ! h = 1, ! w = 5, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("fence_h5.bmp"), 121, 60), ! bitmap = m_get_bitmap("Fence_h5.bmp"), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceH7 = Decoration:subclass ! { ! name = "FenceH7"; ! ! init = function(self) ! self.bitmap = self.bitmaps[1] ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, isOpen = false, ! obstacle = 1, ! h = 1, ! w = 7, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("fence_h7.bmp"), 169, 60), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceV8 = Decoration:subclass ! { ! name = "FenceV8"; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! offset_y = -34, offset_x = 5, ! obstacle = 1, ! w = 1, ! h = 8, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("Fence_v8.bmp"), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceV7 = Decoration:subclass ! { ! name = "FenceV7"; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! offset_y = -33, ! obstacle = 1, ! w = 1, ! h = 7, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("Fence_v7.bmp"), ! convTableKeyword = "CantPassFence", ! } } --- 1,168 ---- ! -- ! -- The Fences in the Sewers. ! -- By Georg Muntingh ! ! import("Decoration.lua") ! ! ! FenceH3 = Decoration:subclass ! { ! name = "FenceH3"; ! ! init = function(self) ! self:updateBitmap() ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! isOpen = false, ! obstacle = 1, ! h = 1, ! w = 3, ! draw_mode = DM_MASKED, bitmaps = extr_array(m_get_bitmap("fence_h3.bmp"), 73, 60), ! convTableKeyword = "CantPassFence", ! } ! } ! FenceH5 = Decoration:subclass ! { ! name = "FenceH5"; ! ! init = function(self) ! self:updateBitmap() ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, isOpen = false, ! obstacle = 1, ! h = 1, ! w = 5, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("fence_h5.bmp"), 121, 60), ! bitmap = m_get_bitmap("fence_h5.bmp"), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceH7 = Decoration:subclass ! { ! name = "FenceH7"; ! ! init = function(self) ! self.bitmap = self.bitmaps[1] ! Decoration.init(self) ! end; ! ! switch = function(self) ! if (self.isOpen == false) then ! self.isOpen = true ! self.obstacle = 0 ! else ! self.isOpen = false ! self.obstacle = 1 ! end ! ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! if (self.isOpen == false) then ! self.bitmap = self.bitmaps[1] ! else ! self.bitmap = self.bitmaps[2] ! end ! end; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! isOpen = false, ! obstacle = 1, ! h = 1, ! w = 7, ! draw_mode = DM_MASKED, ! bitmaps = extr_array(m_get_bitmap("fence_h7.bmp"), 169, 60), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceV8 = Decoration:subclass ! { ! name = "FenceV8"; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! offset_y = -34, offset_x = 5, ! obstacle = 1, ! w = 1, ! h = 8, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("fence_v8.bmp"), ! convTableKeyword = "CantPassFence", ! } ! } ! ! FenceV7 = Decoration:subclass ! { ! name = "FenceV7"; ! ! defaultproperties = { ! bCenterBitmap = false, ! bCenterOnTile = false, ! offset_y = -33, ! obstacle = 1, ! w = 1, ! h = 7, ! draw_mode = DM_MASKED, ! bitmap = m_get_bitmap("fence_v7.bmp"), ! convTableKeyword = "CantPassFence", ! } } Index: BBRpgConversationWindow.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/BBRpgConversationWindow.lua,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BBRpgConversationWindow.lua 7 Dec 2003 02:17:16 -0000 1.1.1.1 --- BBRpgConversationWindow.lua 25 Apr 2004 16:39:52 -0000 1.2 *************** *** 15,19 **** -- Get and set some sizes ! self.font = "font_sansserif8.pcx" m_set_font(self.font) self.space_width, self.line_height = m_text_size(" ") --- 15,19 ---- -- Get and set some sizes ! self.font = "font_sansserif_8" m_set_font(self.font) self.space_width, self.line_height = m_text_size(" ") Index: GuiTheme.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/GuiTheme.lua,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GuiTheme.lua 13 Apr 2004 12:26:08 -0000 1.7 --- GuiTheme.lua 25 Apr 2004 16:39:52 -0000 1.8 *************** *** 80,86 **** m_set_cursor(x, y + self.borderWidth) ! self.canvas:drawRect(bl, self.borderWidth, h - (self.borderWidth * 2)) self.canvas:drawRect(bg, w - (self.borderWidth * 2), h - (self.borderWidth * 2)) ! self.canvas:drawRect(br, self.borderWidth, h - (self.borderWidth * 2)) m_set_cursor(x, y + h - self.borderWidth) --- 80,86 ---- m_set_cursor(x, y + self.borderWidth) ! self.canvas:drawRect(bl, self.borderWidth, h - (self.borderWidth * 2)) self.canvas:drawRect(bg, w - (self.borderWidth * 2), h - (self.borderWidth * 2)) ! self.canvas:drawRect(br, self.borderWidth, h - (self.borderWidth * 2)) m_set_cursor(x, y + h - self.borderWidth) *************** *** 94,98 **** { bitmap = m_get_bitmap("gui_green.bmp"), ! font = "font_sansserif8.pcx", borderWidth = 2, canvas = nil, --- 94,98 ---- { bitmap = m_get_bitmap("gui_green.bmp"), ! font = "font_sansserif_8", borderWidth = 2, canvas = nil, Index: ConversationWindow.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/ConversationWindow.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConversationWindow.lua 13 Apr 2004 12:26:08 -0000 1.5 --- ConversationWindow.lua 25 Apr 2004 16:39:52 -0000 1.6 *************** *** 57,61 **** init = function(self) -- Get and set some sizes ! self.font = "font_sansserif8.pcx" m_set_font(self.font) self.space_width, self.line_height = m_text_size(" ") --- 57,61 ---- init = function(self) -- Get and set some sizes ! self.font = "font_sansserif_8" m_set_font(self.font) self.space_width, self.line_height = m_text_size(" ") |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 16:43:53
|
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/src/editor Modified Files: editor.cpp main.cpp Log Message: Merged engine changes from DGE RPG agian. Index: main.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/main.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** main.cpp 13 Apr 2004 12:26:08 -0000 1.8 --- main.cpp 25 Apr 2004 16:39:52 -0000 1.9 *************** *** 116,128 **** gui_text_list_proc = d_agup_text_list_proc; ! DATAFILE* font_data = load_datafile_object("gui.dat", "SmallFont"); if (font_data) font = (FONT*)font_data->dat; engine_font = font; ! DATAFILE* mouse_pointer = load_datafile_object("gui.dat", "_MS_STD_BMP"); if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat); ! DATAFILE* logo = load_datafile_object("gui.dat", "MoonlightLogo"); if (logo) about_dlg[1].dp = (BITMAP*)logo->dat; else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo"); --- 116,130 ---- gui_text_list_proc = d_agup_text_list_proc; ! engine_data = load_datafile("gui.dat"); ! ! DATAFILE* font_data = find_datafile_object(engine_data, "SmallFont"); if (font_data) font = (FONT*)font_data->dat; engine_font = font; ! DATAFILE* mouse_pointer = find_datafile_object(engine_data, "_MS_STD_BMP"); if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat); ! DATAFILE* logo = find_datafile_object(engine_data, "MoonlightLogo"); if (logo) about_dlg[1].dp = (BITMAP*)logo->dat; else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo"); *************** *** 130,137 **** console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); module = new Module("data"); - //data = load_datafile("data.dat"); - //if (!data) { - // console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); - //} // Lua initialisation --- 132,135 ---- *************** *** 288,291 **** --- 286,290 ---- destroy_bitmap(buffer); + unload_datafile(engine_data); agup_shutdown(); Index: editor.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** editor.cpp 13 Apr 2004 12:26:08 -0000 1.9 --- editor.cpp 25 Apr 2004 16:39:52 -0000 1.10 *************** *** 32,35 **** --- 32,36 ---- int debug_mode = 0; FONT* engine_font = NULL; + DATAFILE *engine_data = NULL; list<Object*> selectedObjects; int selectedObjectType = 0; |
From: Bj?rn L. <b_l...@us...> - 2004-04-25 16:43:46
|
Update of /cvsroot/moeng/BBRpg/data/bitmaps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/data/bitmaps Removed Files: font_arial10.pcx font_arial10bold.pcx font_sansserif8.pcx font_sylfaen10.pcx Log Message: Merged engine changes from DGE RPG agian. --- font_arial10.pcx DELETED --- --- font_sansserif8.pcx DELETED --- --- font_sylfaen10.pcx DELETED --- --- font_arial10bold.pcx DELETED --- |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:42:36
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15745/src/shared Added Files: module.cpp module.h Log Message: And not forgetting to add the new module module. --- NEW FILE: module.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: module.cpp --- (This appears to be a binary file; contents omitted.) |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:40:10
|
Update of /cvsroot/moeng/BBRpg/src/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15068/src/editor Modified Files: aphoton.cpp editor.cpp editor.h gui_procs.cpp main.cpp script.cpp script.h Log Message: Commiting engine changes to our beloved BBRpg on SourceForge. Index: main.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/main.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.cpp 27 Dec 2003 13:49:37 -0000 1.7 --- main.cpp 13 Apr 2004 12:26:08 -0000 1.8 *************** *** 11,14 **** --- 11,15 ---- #include <allegro.h> + #include <libxml/xmlversion.h> #include "agup.h" #include "aphoton.h" *************** *** 18,21 **** --- 19,23 ---- #include "../common.h" #include "../shared/engine.h" + #include "../shared/module.h" *************** *** 24,49 **** - int main(int argc, char *argv[]) { ! initialize(); ! // Handle a map file passed as argument ! if (argc == 2 && exists(argv[1])) ! { ! PACKFILE *file = pack_fopen(argv[1], F_READ_PACKED); ! if (file) { ! currentMap->loadFrom(file, tileRepository); ! pack_fclose(file); ! ustrcpy(map_filename, argv[1]); ! update_window_title(); ! } else { ! alert("Invalid map file:", argv[1], NULL, "OK", NULL, 13, 0); ! } ! } ! do_dialog(main_dlg, -1); ! clean_up(); ! return 0; } END_OF_MAIN(); --- 26,50 ---- int main(int argc, char *argv[]) { ! initialize(); ! // Handle a map file passed as argument ! if (argc == 2 && exists(argv[1])) ! { ! PACKFILE *file = pack_fopen(argv[1], F_READ_PACKED); ! if (file) { ! currentMap->loadFrom(file, tileRepository); ! pack_fclose(file); ! ustrcpy(map_filename, argv[1]); ! update_window_title(); ! } else { ! alert("Invalid map file:", argv[1], NULL, "OK", NULL, 13, 0); ! } ! } ! do_dialog(main_dlg, -1); ! clean_up(); ! return 0; } END_OF_MAIN(); *************** *** 53,102 **** void initialize() { ! char buf[1024]; ! int i; ! // Initialise Allegro ! allegro_init(); ! install_keyboard(); ! install_mouse(); ! install_timer(); ! set_config_file("rpgedit.cfg"); ! int grph_drv = (get_config_int("video", "fullscreen", 1)) ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED; ! int screen_w = get_config_int("video", "width", 800); ! int screen_h = get_config_int("video", "height", 600); ! if (get_config_int("tile_zoom", "grid", 1)) { ! showTileGrid = true; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! int colordepth = 0; ! if (grph_drv == GFX_AUTODETECT_WINDOWED) {colordepth = desktop_color_depth();} ! if (colordepth == 0) {colordepth = 16;} ! set_color_depth(colordepth); ! if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { ! set_color_depth(15); ! if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); ! exit(1); ! } ! } ! buffer = create_bitmap(SCREEN_W, SCREEN_H); ! // Initialize GUI look and feel stuff ! agup_init(aphoton_theme); gui_fg_color = agup_fg_color; gui_bg_color = agup_bg_color; --- 54,112 ---- void initialize() { ! char buf[1024]; ! int i; ! // Do the libxml binary compatibility check ! LIBXML_TEST_VERSION ! // Initialise Allegro ! allegro_init(); ! install_keyboard(); ! install_mouse(); ! install_timer(); ! set_config_file("rpgedit.cfg"); ! int grph_drv = (get_config_int("video", "fullscreen", 1)) ? ! GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED; ! int screen_w = get_config_int("video", "width", 800); ! int screen_h = get_config_int("video", "height", 600); ! if (get_config_int("tile_zoom", "grid", 1)) { ! showTileGrid = true; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ! ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! int colordepth = 0; ! if (grph_drv == GFX_AUTODETECT_WINDOWED) { ! colordepth = desktop_color_depth(); ! } ! if (colordepth == 0) { ! colordepth = 16; ! } ! set_color_depth(colordepth); ! if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { ! set_color_depth(15); ! if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) { ! set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); ! allegro_message("Unable to set graphic mode\n%s\n", allegro_error); ! exit(1); ! } ! } + buffer = create_bitmap(SCREEN_W, SCREEN_H); ! ! // Initialize GUI look and feel stuff ! agup_init(aphoton_theme); gui_fg_color = agup_fg_color; gui_bg_color = agup_bg_color; *************** *** 106,273 **** gui_text_list_proc = d_agup_text_list_proc; ! DATAFILE* font_data = load_datafile_object("gui.dat", "SmallFont"); ! if (font_data) font = (FONT*)font_data->dat; ! engine_font = font; ! DATAFILE* mouse_pointer = load_datafile_object("gui.dat", "_MS_STD_BMP"); ! if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat); ! DATAFILE* logo = load_datafile_object("gui.dat", "MoonlightLogo"); ! about_dlg[1].dp = (BITMAP*)logo->dat; ! console.log(CON_LOG, CON_ALWAYS, "Loading data.dat..."); ! data = load_datafile("data.dat"); ! if (!data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); ! } ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising Lua scripting environment..."); ! initScripting(); ! D_AUTOTEXT_STATUS.dp2 = status_message; ! D_AUTOTEXT_MAPINFO.dp2 = status_mapinfo; ! set_dialog_color(main_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(newmap_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(import_tileset_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(export_tileset_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(resizemap_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(about_dlg, agup_fg_color, agup_bg_color); ! - // Position the dialogs on the screen - int margin = 6; - int zoom_w = get_config_int("tile_zoom", "zoom_width", 120) - 1; - int zoom_h = get_config_int("tile_zoom", "zoom_height", 120) - 1; - int x, y, w, h; - - // Main (back + menu) - set_dialog_size(&main_dlg[0], -2, -2, SCREEN_W + 4, SCREEN_H + 4); - set_dialog_size(&main_dlg[1], 0, 0, SCREEN_W, 15); ! // Status bars ! set_dialog_size(&main_dlg[6], 0, SCREEN_H - 17, SCREEN_W - 256, 17); ! set_dialog_size(&main_dlg[7], SCREEN_W - 256, SCREEN_H - 17, 256, 17); ! set_dialog_size(&main_dlg[8], 3, SCREEN_H - 14, SCREEN_W - 262, 11); ! set_dialog_size(&main_dlg[9], SCREEN_W - 253, SCREEN_H - 14, 250, 11); ! // Edit tile area ! w = zoom_w + 4; ! h = zoom_h + 4; ! x = margin; ! y = main_dlg[6].y - margin - h; ! set_dialog_size(&edit_tile_layer[0], x, y, w, h); ! set_dialog_size(&edit_tile_layer[1], x + 2, y + 2, w - 4, h - 4); ! set_dialog_size(&edit_tile_layer[2], x + margin + w, y + h - 14, 50, 14); ! // Color sliders ! x += w + margin; ! w = 128; ! set_dialog_size(&edit_tile_layer[8], x, y, 16, 8); ! set_dialog_size(&edit_tile_layer[9], x, y + 16, 16, 8); ! set_dialog_size(&edit_tile_layer[10], x, y + 32, 16, 8); ! set_dialog_size(&edit_tile_layer[11], x, y + 48 + 8, 16, 8); ! set_dialog_size(&edit_tile_layer[12], x, y + 64 + 8, 16, 8); ! set_dialog_size(&edit_tile_layer[3], x + 16, y, w, 8); ! set_dialog_size(&edit_tile_layer[4], x + 16, y + 16, w, 8); ! set_dialog_size(&edit_tile_layer[5], x + 16, y + 32, w, 8); ! set_dialog_size(&edit_tile_layer[6], x + 16, y + 48 + 8, w, 8); ! set_dialog_size(&edit_tile_layer[7], x + 16, y + 64 + 8, w, 8); ! set_dialog_size(&edit_tile_layer[13], x + 16 + w + 4, y - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[14], x + 16 + w + 4, y + 16 - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[15], x + 16 + w + 4, y + 32 - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[20], x + 16 + w + 18, y + 4, 18, 32); ! // Select tile area ! x = edit_tile_layer[20].x + edit_tile_layer[20].w + margin; ! w = SCREEN_W - x - margin; ! set_dialog_size(&edit_tile_layer[16], x, y, 104, h); ! set_dialog_size(&edit_tile_layer[17], x + 104, y, w - 104, h); ! set_dialog_size(&edit_tile_layer[18], x + 104 + 2, y + 2, w - 104 - 4 - 11, h - 4); ! set_dialog_size(&edit_tile_layer[19], x + w - 14, y, 14, h); ! // Obstacle edit stuff ! w = 24; ! h = 24; ! x = margin; ! y = main_dlg[6].y - margin - h; ! for (i = 0; i < 5; i++) { ! set_dialog_size(&edit_obstacle_layer[i], x + i*(w+margin), y, w, h); ! set_dialog_size(&edit_obstacle_layer[i+5], x + i*(w+margin) + 2, y + 2, w - 4, h - 4); ! } ! // Edit map area ! x = margin; ! y = 16 + margin; ! w = SCREEN_W - 2 * margin; ! h = edit_obstacle_layer[0].y - margin - y; ! set_dialog_size(&main_dlg[2], x, y, w, h); ! set_dialog_size(&main_dlg[3], x + 2, y + 2, w - 15, h - 15); ! set_dialog_size(&main_dlg[4], x + w - 14, y, 14, h - 11); ! set_dialog_size(&main_dlg[5], x, y + h - 14, w - 11, 14); ! set_dialog_size(&main_dlg[10], x + w - 12, y + h - 12, 10, 10); ! // Edit objects area ! w = 123; ! h = 120; ! x = margin; ! y = main_dlg[6].y - margin - h; ! set_dialog_size(&edit_objects_layer[0], x, y, w, h); ! set_dialog_size(&edit_objects_layer[1], 136, main_dlg[6].y - margin - 14, 97, 14); ! ! // Initialize map and tile stuff ! tileRepository = new TileRepository(); ! // Import tilesets specified in rpgedit.cfg ! i = 1; ! while (i > 0) ! { ! uszprintf(buf, sizeof buf, "tileset%d", i); - const char* filename = get_config_string(buf, "filename", NULL); - int tile_w = get_config_int(buf, "tile_w", 16); - int tile_h = get_config_int(buf, "tile_h", 16); - int tile_spacing = get_config_int(buf, "tile_spacing", 0); ! if (filename) { ! if (tile_w > 0 && tile_h > 0 && tile_spacing >= 0) { ! import_tile_bitmap(filename, tile_w, tile_h, tile_spacing); ! } else { ! allegro_message("Error, incorrect parameters for automatic tile import (%s)!", filename); ! // Print warning in log file ! } ! i++; ! } else { ! i = -1; ! } ! } ! currentMap = new SquareMap(TILES_W, TILES_H); ! ustrcpy(map_filename, "untitled.map"); ! // Load map specified in rpgedit.cfg ! const char* filename = get_config_string("startup", "load_map", NULL); ! if (filename) { ! PACKFILE *file = pack_fopen(filename, F_READ_PACKED); ! if (file) { ! currentMap->loadFrom(file, tileRepository); ! pack_fclose(file); ! ustrcpy(map_filename, filename); ! object_message(&D_MAP, MSG_NEW_MAP, 0); ! set_map_changed(false); ! } else { ! allegro_message("Error while loading default map (%s)!\n", filename); ! // Print warning in log file ! } ! } ! update_window_title(); ! map_edit_mode = EM_TILE; ! menu_item_edit_objects(); ! //activate_mode(edit_objects_layer); } --- 116,282 ---- gui_text_list_proc = d_agup_text_list_proc; ! DATAFILE* font_data = load_datafile_object("gui.dat", "SmallFont"); ! if (font_data) font = (FONT*)font_data->dat; ! engine_font = font; ! DATAFILE* mouse_pointer = load_datafile_object("gui.dat", "_MS_STD_BMP"); ! if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat); ! DATAFILE* logo = load_datafile_object("gui.dat", "MoonlightLogo"); ! if (logo) about_dlg[1].dp = (BITMAP*)logo->dat; ! else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo"); ! console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); ! module = new Module("data"); ! //data = load_datafile("data.dat"); ! //if (!data) { ! // console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); ! //} ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment..."); ! initScripting(); ! D_AUTOTEXT_STATUS.dp2 = status_message; ! D_AUTOTEXT_MAPINFO.dp2 = status_mapinfo; ! set_dialog_color(main_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(newmap_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(import_tileset_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(export_tileset_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(resizemap_dlg, agup_fg_color, agup_bg_color); ! set_dialog_color(about_dlg, agup_fg_color, agup_bg_color); ! // Position the dialogs on the screen ! int margin = 6; ! int zoom_w = get_config_int("tile_zoom", "zoom_width", 120) - 1; ! int zoom_h = get_config_int("tile_zoom", "zoom_height", 120) - 1; ! int x, y, w, h; ! // Main (back + menu) ! set_dialog_size(&main_dlg[0], -2, -2, SCREEN_W + 4, SCREEN_H + 4); ! set_dialog_size(&main_dlg[1], 0, 0, SCREEN_W, 15); ! // Status bars ! set_dialog_size(&main_dlg[6], 0, SCREEN_H - 17, SCREEN_W - 256, 17); ! set_dialog_size(&main_dlg[7], SCREEN_W - 256, SCREEN_H - 17, 256, 17); ! set_dialog_size(&main_dlg[8], 3, SCREEN_H - 14, SCREEN_W - 262, 11); ! set_dialog_size(&main_dlg[9], SCREEN_W - 253, SCREEN_H - 14, 250, 11); ! // Edit tile area ! w = zoom_w + 4; ! h = zoom_h + 4; ! x = margin; ! y = main_dlg[6].y - margin - h; ! set_dialog_size(&edit_tile_layer[0], x, y, w, h); ! set_dialog_size(&edit_tile_layer[1], x + 2, y + 2, w - 4, h - 4); ! set_dialog_size(&edit_tile_layer[2], x + margin + w, y + h - 14, 50, 14); ! // Color sliders ! x += w + margin; ! w = 128; ! set_dialog_size(&edit_tile_layer[8], x, y, 16, 8); ! set_dialog_size(&edit_tile_layer[9], x, y + 16, 16, 8); ! set_dialog_size(&edit_tile_layer[10], x, y + 32, 16, 8); ! set_dialog_size(&edit_tile_layer[11], x, y + 48 + 8, 16, 8); ! set_dialog_size(&edit_tile_layer[12], x, y + 64 + 8, 16, 8); ! set_dialog_size(&edit_tile_layer[3], x + 16, y, w, 8); ! set_dialog_size(&edit_tile_layer[4], x + 16, y + 16, w, 8); ! set_dialog_size(&edit_tile_layer[5], x + 16, y + 32, w, 8); ! set_dialog_size(&edit_tile_layer[6], x + 16, y + 48 + 8, w, 8); ! set_dialog_size(&edit_tile_layer[7], x + 16, y + 64 + 8, w, 8); ! set_dialog_size(&edit_tile_layer[13], x + 16 + w + 4, y - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[14], x + 16 + w + 4, y + 16 - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[15], x + 16 + w + 4, y + 32 - 1, 11, 10); ! set_dialog_size(&edit_tile_layer[20], x + 16 + w + 18, y + 4, 18, 32); ! // Select tile area ! x = edit_tile_layer[20].x + edit_tile_layer[20].w + margin; ! w = SCREEN_W - x - margin; ! set_dialog_size(&edit_tile_layer[16], x, y, 104, h); ! set_dialog_size(&edit_tile_layer[17], x + 104, y, w - 104, h); ! set_dialog_size(&edit_tile_layer[18], x + 104 + 2, y + 2, w - 104 - 4 - 11, h - 4); ! set_dialog_size(&edit_tile_layer[19], x + w - 14, y, 14, h); ! // Obstacle edit stuff ! w = 24; ! h = 24; ! x = margin; ! y = main_dlg[6].y - margin - h; ! for (i = 0; i < 5; i++) { ! set_dialog_size(&edit_obstacle_layer[i], x + i*(w+margin), y, w, h); ! set_dialog_size(&edit_obstacle_layer[i+5], x + i*(w+margin) + 2, y + 2, w - 4, h - 4); ! } ! // Edit map area ! x = margin; ! y = 16 + margin; ! w = SCREEN_W - 2 * margin; ! h = edit_obstacle_layer[0].y - margin - y; ! set_dialog_size(&main_dlg[2], x, y, w, h); ! set_dialog_size(&main_dlg[3], x + 2, y + 2, w - 15, h - 15); ! set_dialog_size(&main_dlg[4], x + w - 14, y, 14, h - 11); ! set_dialog_size(&main_dlg[5], x, y + h - 14, w - 11, 14); ! set_dialog_size(&main_dlg[10], x + w - 12, y + h - 12, 10, 10); ! // Edit objects area ! w = 123; ! h = 120; ! x = margin; ! y = main_dlg[6].y - margin - h; ! set_dialog_size(&edit_objects_layer[0], x, y, w, h); ! set_dialog_size(&edit_objects_layer[1], 136, main_dlg[6].y - margin - 14, 97, 14); ! // Initialize map and tile stuff ! tileRepository = new TileRepository(); ! // Import tilesets specified in rpgedit.cfg ! i = 1; ! while (i > 0) ! { ! uszprintf(buf, sizeof buf, "tileset%d", i); ! const char* filename = get_config_string(buf, "filename", NULL); ! int tile_w = get_config_int(buf, "tile_w", 16); ! int tile_h = get_config_int(buf, "tile_h", 16); ! int tile_spacing = get_config_int(buf, "tile_spacing", 0); ! if (filename) { ! if (tile_w > 0 && tile_h > 0 && tile_spacing >= 0) { ! import_tile_bitmap(filename, tile_w, tile_h, tile_spacing); ! } else { ! allegro_message("Error, incorrect parameters for automatic tile import (%s)!", filename); ! // Print warning in log file ! } ! i++; ! } else { ! i = -1; ! } ! } ! currentMap = new SquareMap(TILES_W, TILES_H); ! ustrcpy(map_filename, "untitled.map"); ! ! // Load map specified in rpgedit.cfg ! const char* filename = get_config_string("startup", "load_map", NULL); ! if (filename) { ! if (!currentMap->loadMap(filename)) { ! ustrcpy(map_filename, filename); ! object_message(&D_MAP, MSG_NEW_MAP, 0); ! set_map_changed(false); ! } else { ! console.log(CON_LOG, CON_ALWAYS, ! "Error while loading default map (%s)!\n", filename); ! } ! } ! ! update_window_title(); ! ! map_edit_mode = EM_TILE; ! menu_item_edit_objects(); ! //activate_mode(edit_objects_layer); } *************** *** 275,283 **** void clean_up() { ! delete currentMap; ! delete tileRepository; ! destroy_bitmap(buffer); ! agup_shutdown(); } --- 284,292 ---- void clean_up() { ! delete currentMap; ! delete tileRepository; ! destroy_bitmap(buffer); ! agup_shutdown(); } Index: editor.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** editor.h 1 Jan 2004 16:04:36 -0000 1.8 --- editor.h 13 Apr 2004 12:26:08 -0000 1.9 *************** *** 17,28 **** #include "../shared/console.h" #include "../shared/object.h" ! #define PROGRAM_VERSION_STRING "RPG Edit III 0.9.0" // Global variables ! extern DATAFILE *data; extern int debug_mode; extern FONT* engine_font; --- 17,29 ---- #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 Module *module; extern int debug_mode; extern FONT* engine_font; *************** *** 73,123 **** // 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 --- 74,124 ---- // 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 *************** *** 126,130 **** int menu_item_new_map(); int menu_item_load_map(); - int menu_item_load_old_map(); int menu_item_save_map(); int menu_item_save_map_as(); --- 127,130 ---- *************** *** 140,143 **** --- 140,144 ---- int menu_item_toggle_debug(); int menu_item_save_map_image(); + int menu_item_save_map_as_xml(); *************** *** 149,154 **** void delete_objects(list<Object*> objs); ! void import_tile_bitmap(const char* filename, int tile_w, int tile_h, int spacing); ! //char* get_tileset_name(const char* name); void set_map_changed(bool value); --- 150,156 ---- 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); Index: script.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** script.h 9 Dec 2003 00:45:59 -0000 1.2 --- script.h 13 Apr 2004 12:26:08 -0000 1.3 *************** *** 29,33 **** ! //=================== The engine to script interface ============================/ void initScripting(); --- 29,33 ---- ! //============ The engine to script interface ============================/ void initScripting(); *************** *** 43,47 **** ! //=================== The script to engine interface ============================/ int l_alert(lua_State *L); --- 43,47 ---- ! //============ The script to engine interface ============================/ int l_alert(lua_State *L); *************** *** 61,65 **** ! //=================== Tag methods ====================================================/ int object_gettable(lua_State *L); --- 61,65 ---- ! //============ Tag methods ===============================================/ int object_gettable(lua_State *L); Index: aphoton.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/aphoton.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** aphoton.cpp 8 Dec 2003 19:55:13 -0000 1.2 --- aphoton.cpp 13 Apr 2004 12:26:08 -0000 1.3 *************** *** 148,159 **** int flags, int centre) { ! int rtm, height, len; ! ! rtm = text_mode(-1); if (flags & D_DISABLED) ! gui_textout(bmp, text, x+1, y+1, white, centre); ! gui_textout(bmp, text, x, y, (flags & D_DISABLED? shadow : black), centre); if (flags & D_GOTFOCUS) { --- 148,158 ---- int flags, int centre) { ! int height, len; if (flags & D_DISABLED) ! gui_textout_ex(bmp, text, x+1, y+1, white, -1, centre); ! gui_textout_ex( ! bmp, text, x, y, (flags & D_DISABLED? shadow : black), -1, centre); if (flags & D_GOTFOCUS) { *************** *** 166,171 **** hline(bmp, x, y+height, x+len-1, highlight); } - - text_mode(rtm); } --- 165,168 ---- *************** *** 428,432 **** { if (msg == MSG_DRAW) { ! int l, x, b, f, p, w, rtm; int fg = (d->flags & D_DISABLED) ? shadow : black; char *s = (char *)d->dp; --- 425,429 ---- { if (msg == MSG_DRAW) { ! int l, x, b, f, p, w; int fg = (d->flags & D_DISABLED) ? shadow : black; char *s = (char *)d->dp; *************** *** 476,482 **** w = text_length(font, buf); f = ((p == d->d2) && (d->flags & D_GOTFOCUS)); ! rtm = text_mode(edit_white); ! textout(screen, font, buf, d->x+x, d->y+4, fg); ! text_mode(rtm); if (f) vline(screen, d->x+x-1, d->y+3, d->y+fonth+5, black); --- 473,477 ---- w = text_length(font, buf); f = ((p == d->d2) && (d->flags & D_GOTFOCUS)); ! textout_ex(screen, font, buf, d->x+x, d->y+4, fg, edit_white); if (f) vline(screen, d->x+x-1, d->y+3, d->y+fonth+5, black); *************** *** 529,533 **** char *sel = (char *)d->dp2; char s[1024]; - int rtm; (*(getfuncptr)d->dp)(-1, &listsize); --- 524,527 ---- *************** *** 558,562 **** y = d->y + 2 + i*char_height; - rtm = text_mode(bg); rectfill(screen, x, y, x+7, y+char_height-1, bg); x += 8; --- 552,555 ---- *************** *** 568,573 **** } ! textout(screen, font, s, x, y, fg); ! text_mode(rtm); x += text_length(font, s); --- 561,565 ---- } ! textout_ex(screen, font, s, x, y, fg, bg); x += text_length(font, s); *************** *** 775,779 **** int i, j, height; char buf[256], *tok; - int rtm; if (!menu_done) { --- 767,770 ---- *************** *** 808,813 **** } - rtm = text_mode(-1); - i = 0; j = ugetc(m->text); --- 799,802 ---- *************** *** 830,835 **** } - text_mode(rtm); - if ((m->child) && (!bar)) draw_sprite(screen, menu_arrow_bmp, x+w-12, y+(h-menu_arrow_bmp->h-1)/2); --- 819,822 ---- *************** *** 863,867 **** int d_aphoton_window_proc(int msg, DIALOG *d, int c) { ! int rtm, cl, ct, cr, cb; (void)c; --- 850,854 ---- int d_aphoton_window_proc(int msg, DIALOG *d, int c) { ! int cl, ct, cr, cb; (void)c; *************** *** 899,903 **** if (d->dp) { - rtm = text_mode(-1); cl = screen->cl; ct = screen->ct; --- 886,889 ---- *************** *** 905,914 **** cb = screen->cb; ! set_clip(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1); ! textout_centre(screen, font, (char *)d->dp, d->x+d->w/2, d->y+8, black); ! set_clip(screen, cl, ct, cr, cb); ! text_mode(rtm); } } --- 891,901 ---- cb = screen->cb; ! set_clip_rect(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1); ! textout_centre_ex( ! screen, font, (char *)d->dp, ! d->x+d->w/2, d->y+8, black, -1); ! set_clip_rect(screen, cl, ct, cr, cb); } } Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/script.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** script.cpp 27 Dec 2003 14:43:15 -0000 1.5 --- script.cpp 13 Apr 2004 12:26:08 -0000 1.6 *************** *** 17,29 **** #include "../shared/console.h" #include "script.h" - #include <set> #include <vector> - using std::set; using std::vector; lua_State* L = NULL; [...1247 lines suppressed...] ! else if (strcmp(index, "offset_z" ) == 0) {obj->offset_z = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "draw_mode") == 0) {obj->drawMode = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "alpha" ) == 0) {obj->alpha = (int)lua_tonumber(L, -1);} ! else if (strcmp(index, "dir" ) == 0) {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; } Index: gui_procs.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/gui_procs.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** gui_procs.cpp 28 Dec 2003 15:53:37 -0000 1.9 --- gui_procs.cpp 13 Apr 2004 12:26:08 -0000 1.10 *************** *** 310,314 **** if (debug_mode) { ! textprintf(buffer, font, d->x+10, d->y+30, makecol(255,255,255), "%d selected entities", selectedObjects.size()); } --- 310,316 ---- if (debug_mode) { ! textprintf_ex( ! buffer, font, d->x+10, d->y+30, makecol(255,255,255), -1, ! "%d selected entities", selectedObjects.size()); } *************** *** 1211,1217 **** rectfill(buffer, d->x, d->y, d->x + d->w - 1, d->y + d->h - 1, d->bg); if (d->dp) { ! int ptm = text_mode(-1); ! textout(buffer, font, (char*)d->dp, d->x, d->y, d->fg); ! text_mode(ptm); } update_screen(d->x, d->y, d->w, d->h); --- 1213,1217 ---- rectfill(buffer, d->x, d->y, d->x + d->w - 1, d->y + d->h - 1, d->bg); if (d->dp) { ! textout_ex(buffer, font, (char*)d->dp, d->x, d->y, d->fg, -1); } update_screen(d->x, d->y, d->w, d->h); Index: editor.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/editor/editor.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** editor.cpp 1 Jan 2004 16:04:36 -0000 1.8 --- editor.cpp 13 Apr 2004 12:26:08 -0000 1.9 *************** *** 12,15 **** --- 12,18 ---- #include <allegro.h> #include <vector> + #include <libxml/xmlwriter.h> + #include <libxml/parser.h> + #include <libxml/tree.h> #include "agup.h" #include "aphoton.h" *************** *** 19,22 **** [...1715 lines suppressed...] ! deselect_objects(); ! 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) { ! while (objs.size() > 0) { ! Object* obj = objs.front(); ! if (obj->selected) selectedObjects.remove(obj); ! //callMemberFunction(obj->tableRef, "destroy", ""); ! objs.remove(obj); ! currentMap->removeReference(obj); ! delete obj; ! } } |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:40:10
|
Update of /cvsroot/moeng/BBRpg/src/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15068/src/shared Modified Files: console.cpp engine.cpp engine.h object.cpp object.h tiled_map.cpp tiled_map.h Log Message: Commiting engine changes to our beloved BBRpg on SourceForge. Index: object.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/object.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** object.cpp 1 Jan 2004 20:58:09 -0000 1.6 --- object.cpp 13 Apr 2004 12:26:08 -0000 1.7 *************** *** 22,54 **** ! //=================== Object ===================================================== int Object::id_counter = 0; Object::Object(int luaTableRef, TiledMap* myMap): ! _destroy(0), ! walking(0), speed(0), dir(0), prev_dir(0), ! count(0), tick(0), ! bitmap(NULL), ! x(0), y(0), px(0), py(0), nx(0), ny(0), w(1), h(1), obstacle(0), ! offset_x(0), offset_y(0), offset_z(0), ! tableRef(luaTableRef), className(NULL), ! drawMode(DM_MASKED), alpha(255), selected(false), in_air(0), ! map(myMap) { ! id = ++id_counter; ! // Set the metatable and _pointer value of my table in Lua ! if (tableRef) { ! lua_getref(L, tableRef); ! lua_getglobal(L, "ObjectMetatable"); ! lua_setmetatable(L, -2); ! lua_pushstring(L, "_pointer" ); ! lua_pushlightuserdata(L, this); ! lua_rawset(L, -3); ! lua_pop(L, 1); ! } ! update_entity(); } --- 22,54 ---- ! //============ Object ===================================================== int Object::id_counter = 0; Object::Object(int luaTableRef, TiledMap* myMap): ! _destroy(0), ! walking(0), speed(0), dir(0), prev_dir(0), ! count(0), tick(0), ! bitmap(NULL), ! x(0), y(0), px(0), py(0), nx(0), ny(0), w(1), h(1), obstacle(0), ! offset_x(0), offset_y(0), offset_z(0), ! tableRef(luaTableRef), className(NULL), ! drawMode(DM_MASKED), alpha(255), selected(false), in_air(0), ! map(myMap) { ! id = ++id_counter; ! // Set the metatable and _pointer value of my table in Lua ! if (tableRef) { ! lua_getref(L, tableRef); ! lua_getglobal(L, "ObjectMetatable"); ! lua_setmetatable(L, -2); ! lua_pushstring(L, "_pointer" ); ! lua_pushlightuserdata(L, this); ! lua_rawset(L, -3); ! lua_pop(L, 1); ! } ! update_entity(); } *************** *** 57,135 **** Object::~Object() { ! if (tableRef) { ! // Notify the object that it is being destroyed ! callMemberFunction(tableRef, "destroyed"); ! // Set the reference to the C++ object to NULL in the Lua table ! lua_getref(L, tableRef); // 1 ! lua_pushstring(L, "_pointer"); // 2 ! lua_pushlightuserdata(L, NULL); // 3 ! lua_rawset(L, -3); // 1 ! lua_pop(L, 1); // 0 ! // Allow Lua to garbage collect the object. ! lua_unref(L, tableRef); ! } } void Object::walk(int dir, bool col) { ! if (!map || dir == DIR_NONE) return; ! if (walking == 0) ! { ! set_dir(dir); ! update_entity(); ! // Precalculate where the player is going ! double next_x = x, next_y = y; ! switch (dir) { ! case DIR_UP: next_y -= 1.0; break; ! case DIR_DOWN: next_y += 1.0; break; ! case DIR_LEFT: next_x -= 1.0; break; ! case DIR_RIGHT: next_x += 1.0; break; ! } ! if (col) { ! // Check for map obstacle ! Tile *nextTile = map->getLayer(0)->getTile(Point((int)next_x, (int)next_y)); ! if (!nextTile || next_x < 0 || next_y < 0 || ! (dir == DIR_UP && (nextTile->obstacle & OB_BOTTOM)) || ! (dir == DIR_DOWN && (nextTile->obstacle & OB_TOP)) || ! (dir == DIR_LEFT && (nextTile->obstacle & OB_RIGHT)) || ! (dir == DIR_RIGHT && (nextTile->obstacle & OB_LEFT))) ! { ! callMemberFunction(tableRef, "event_bump_into"); ! check_stand_on(); ! return; ! } ! // Check for object in the way ! list<Object*>::iterator i; ! for (i = map->objects.begin(); i != map->objects.end(); i++) { ! Object *obj = (*i); ! if ((obstacle) && ! (obj->obstacle) && ! (((obj->x + obj->w > next_x && obj->x <= next_x) && obj->walking == 0 && ! (obj->y - obj->h < next_y && obj->y >= next_y)) || ! ((obj->nx + obj->w > next_x && obj->nx <= next_x) && obj->walking > 0 && ! (obj->ny - obj->h < next_y && obj->ny >= next_y)))) ! { ! callMemberFunction(tableRef, "event_bump_into", "o", obj); ! callMemberFunction(obj->tableRef, "event_bumped_into", "o", this); ! check_stand_on(); ! return; ! } ! } ! } ! // No obstacles, so start walking ! walking = 100; ! px = x; ! py = y; ! nx = next_x; ! ny = next_y; ! callMemberFunction(tableRef, "event_walk_start"); ! } } --- 57,158 ---- Object::~Object() { ! if (tableRef) { ! // Notify the object that it is being destroyed ! callMemberFunction(tableRef, "destroyed"); ! // Set the reference to the C++ object to NULL in the Lua table ! lua_getref(L, tableRef); // 1 ! lua_pushstring(L, "_pointer"); // 2 ! lua_pushlightuserdata(L, NULL); // 3 ! lua_rawset(L, -3); // 1 ! lua_pop(L, 1); // 0 ! // Allow Lua to garbage collect the object. ! lua_unref(L, tableRef); ! } } void Object::walk(int dir, bool col) { ! if (!map || dir == DIR_NONE) return; ! update_entity(); ! // Precalculate where the player is going ! double next_x = x, next_y = y; ! if (walking == 0) { ! switch (dir) { ! case DIR_UP: next_y -= 1.0; break; ! case DIR_DOWN: next_y += 1.0; break; ! case DIR_LEFT: next_x -= 1.0; break; ! case DIR_RIGHT: next_x += 1.0; break; ! } ! set_dir(dir); ! } ! else { ! // Support for turning 180 degrees anywhere. ! // WARNING: Still needs collision check! ! if ( ! (this->dir == DIR_UP && dir == DIR_DOWN) || ! (this->dir == DIR_DOWN && dir == DIR_UP) || ! (this->dir == DIR_LEFT && dir == DIR_RIGHT) || ! (this->dir == DIR_RIGHT && dir == DIR_LEFT)) ! { ! next_x = px; ! next_y = py; ! px = nx; ! py = ny; ! nx = next_x; ! ny = next_y; ! walking = 100 - walking; ! set_dir(dir); ! } ! return; ! } ! if (col && obstacle) { ! // Check for map obstacle ! Tile *nextTile = map->getLayer(0)->getTile( ! Point((int)next_x, (int)next_y)); ! if (!nextTile || next_x < 0 || next_y < 0 || ! (dir == DIR_UP && (nextTile->obstacle & OB_BOTTOM)) || ! (dir == DIR_DOWN && (nextTile->obstacle & OB_TOP)) || ! (dir == DIR_LEFT && (nextTile->obstacle & OB_RIGHT)) || ! (dir == DIR_RIGHT && (nextTile->obstacle & OB_LEFT))) ! { ! callMemberFunction(tableRef, "event_bump_into"); ! check_stand_on(); ! return; ! } ! // Check for object in the way ! list<Object*>::iterator i; ! for (i = map->objects.begin(); i != map->objects.end(); i++) { ! Object *obj = (*i); ! if ((obj->obstacle) && ! (((obj->x + obj->w > next_x && obj->x <= next_x) && ! obj->walking == 0 && ! (obj->y - obj->h < next_y && obj->y >= next_y)) || ! ((obj->nx + obj->w > next_x && obj->nx <= next_x) && ! obj->walking > 0 && ! (obj->ny - obj->h < next_y && obj->ny >= next_y)))) ! { ! callMemberFunction(tableRef, "event_bump_into", "o", obj); ! callMemberFunction(obj->tableRef, ! "event_bumped_into", "o", this); ! check_stand_on(); ! return; ! } ! } ! } ! ! // No obstacles, so start walking ! walking = 100; ! px = x; ! py = y; ! nx = next_x; ! ny = next_y; ! callMemberFunction(tableRef, "event_walk_start"); } *************** *** 137,228 **** void Object::set_dir(int dir) { ! if (dir == DIR_NONE) return; ! if (this->dir != dir && tableRef) { ! this->dir = dir; ! callMemberFunction(tableRef, "event_dir_change"); ! } } void Object::check_stand_on() { ! if (!map) return; ! // Check if this object is now standing on something ! list<Object*>::iterator i; ! for (i = map->objects.begin(); i != map->objects.end(); i++) { ! Object *obj = (*i); ! if ((obj != this) && ! (obj->x + obj->w > x && obj->x <= x) && ! (obj->y - obj->h < y && obj->y >= y)) ! { ! callMemberFunction(tableRef, "event_standing_on", "o", obj); ! callMemberFunction(obj->tableRef, "event_stand_on", "o", this); ! } ! } } void Object::initialize() { ! update_entity(); } void Object::update() { ! if (walking > 0) { ! walking -= speed; ! if (walking <= 0) { ! walking = 0; ! x = nx; ! y = ny; ! callMemberFunction(tableRef, "event_walk_finished"); ! // Check if this object is now standing on something ! check_stand_on(); ! } ! else { ! double wp = 1.0 - (walking / 100.0); ! x = px + (nx - px) * wp; ! y = py + (ny - py) * wp; ! } ! } ! if (tick > 0) { ! count++; ! if (count >= tick) { ! // Call script "tick" function ! callMemberFunction(tableRef, "tick"); ! count = 0; ! } ! } else { ! count = 0; ! } ! if (dir != prev_dir && tableRef) { ! prev_dir = dir; ! callMemberFunction(tableRef, "event_dir_change"); ! } } void Object::update_entity() { ! mapPos.x = int(x * TILES_W); ! mapPos.y = int(y * TILES_H); ! mapPos.z = 0; ! mapPos.x += offset_x; ! mapPos.y += offset_y; ! mapPos.z += offset_z; ! ! pos = mapPos; } void Object::setMap(TiledMap* newMap) { ! if (map != NULL) { ! map->removeReference(this); ! } ! newMap->addReference(this); ! map = newMap; } --- 160,263 ---- void Object::set_dir(int dir) { ! if (dir == DIR_NONE) return; ! if (this->dir != dir && tableRef) { ! this->dir = dir; ! callMemberFunction(tableRef, "event_dir_change"); ! } ! } ! ! void Object::setX(double x) ! { ! this->x = x; ! nx = x; ! } ! ! void Object::setY(double y) ! { ! this->y = y; ! ny = y; } void Object::check_stand_on() { ! if (!map) return; ! // Check if this object is now standing on something ! list<Object*>::iterator i; ! for (i = map->objects.begin(); i != map->objects.end(); i++) { ! Object *obj = (*i); ! if ((obj != this) && ! (obj->x + obj->w > x && obj->x <= x) && ! (obj->y - obj->h < y && obj->y >= y)) ! { ! callMemberFunction(tableRef, "event_standing_on", "o", obj); ! callMemberFunction(obj->tableRef, "event_stand_on", "o", this); ! } ! } } void Object::initialize() { ! update_entity(); } void Object::update() { ! if (walking > 0) { ! walking -= speed; ! if (walking <= 0) { ! walking = 0; ! x = nx; ! y = ny; ! callMemberFunction(tableRef, "event_walk_finished"); ! // Check if this object is now standing on something ! check_stand_on(); ! } ! else { ! double wp = 1.0 - (walking / 100.0); ! x = px + (nx - px) * wp; ! y = py + (ny - py) * wp; ! } ! } ! if (tick > 0) { ! count++; ! if (count >= tick) { ! // Call script "tick" function ! callMemberFunction(tableRef, "tick"); ! count = 0; ! } ! } else { ! count = 0; ! } ! if (dir != prev_dir && tableRef) { ! prev_dir = dir; ! callMemberFunction(tableRef, "event_dir_change"); ! } } void Object::update_entity() { ! mapPos.x = int(x * TILES_W); ! mapPos.y = int(y * TILES_H); ! mapPos.z = 0; ! mapPos.x += offset_x; ! mapPos.y += offset_y; ! mapPos.z += offset_z; ! ! pos = mapPos; } void Object::setMap(TiledMap* newMap) { ! if (map != NULL) { ! map->removeReference(this); ! } ! newMap->addReference(this); ! map = newMap; } *************** *** 230,306 **** bool Object::visible(BITMAP *dest, Point screenCoords) { ! if (!bitmap) return false; ! return !(dest->cl > screenCoords.x + bitmap->w || ! dest->cr < screenCoords.x || ! dest->ct > (screenCoords.y - pos.z) || ! dest->cb < (screenCoords.y - pos.z ) - bitmap->h); } void Object::draw(BITMAP *dest, Point screenCoords) { ! if (bitmap) { ! switch (drawMode) ! { ! case DM_MULTIPLY: ! set_multiply_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_ADD: ! set_add_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_MASKED: ! draw_sprite( ! dest, ! bitmap, ! screenCoords.x, ! screenCoords.y - bitmap->h - pos.z ! ); ! break; ! } ! switch (drawMode) { ! case DM_ADD: ! case DM_MULTIPLY: ! case DM_ALPHA: ! case DM_TRANS: ! draw_trans_sprite( ! dest, ! bitmap, ! screenCoords.x, ! screenCoords.y - bitmap->h - pos.z ! ); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! if (selected) { ! rect( ! dest, ! screenCoords.x-1, screenCoords.y - bitmap->h - pos.z-1, ! screenCoords.x + bitmap->w+1, screenCoords.y - pos.z+1, ! makecol(150,0,0) ! ); ! } ! else if (debug_mode) { ! rect( ! dest, ! screenCoords.x-1, screenCoords.y - bitmap->h - pos.z-1, ! screenCoords.x + bitmap->w+1, screenCoords.y - pos.z+1, ! makecol(0,150,0) ! ); ! } ! } ! if (debug_mode || selected) { ! textprintf(dest, font, screenCoords.x - 1, screenCoords.y + 2, makecol(128,128,128), "%i, %i", pos.x, pos.y); ! } } --- 265,360 ---- bool Object::visible(BITMAP *dest, Point screenCoords) { ! if (!bitmap) return false; ! return !(dest->cl > screenCoords.x + bitmap->w || ! dest->cr < screenCoords.x || ! dest->ct > (screenCoords.y - pos.z) || ! dest->cb < (screenCoords.y - pos.z ) - bitmap->h); } void Object::draw(BITMAP *dest, Point screenCoords) { ! if (bitmap) { ! switch (drawMode) ! { ! case DM_MULTIPLY: ! set_multiply_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_ADD: ! set_add_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_MASKED: ! draw_sprite( ! dest, ! bitmap, ! screenCoords.x, ! screenCoords.y - bitmap->h - pos.z ! ); ! break; ! } ! switch (drawMode) { ! case DM_ADD: ! case DM_MULTIPLY: ! case DM_ALPHA: ! case DM_TRANS: ! draw_trans_sprite( ! dest, ! bitmap, ! screenCoords.x, ! screenCoords.y - bitmap->h - pos.z ! ); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! if (selected) { ! // Draw line around bitmap ! rect( ! dest, ! screenCoords.x - 1, screenCoords.y - bitmap->h - pos.z - 1, ! screenCoords.x + bitmap->w + 1, screenCoords.y - pos.z + 1, ! makecol(150,0,0) ! ); ! if (obstacle) { ! Point p = map->mapToScreen( ! Point(int(x * TILES_W), int(y * TILES_H))); ! ! // Draw filled rectangle displaying obstacle region ! set_trans_blender(0,0,0,64); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! rectfill( ! dest, ! p.x, p.y, ! p.x + TILES_W * w, p.y - TILES_H * h, ! makecol(150,0,0) ! ); ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! } ! } ! else if (debug_mode) { ! rect( ! dest, ! screenCoords.x - 1, screenCoords.y - bitmap->h - pos.z - 1, ! screenCoords.x + bitmap->w + 1, screenCoords.y - pos.z + 1, ! makecol(0,150,0) ! ); ! } ! } ! ! if (debug_mode || selected) { ! textprintf_ex( ! dest, font, screenCoords.x - 1, screenCoords.y + 2, ! makecol(128,128,128), -1, "%i, %i", pos.x, pos.y); ! } } Index: object.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/object.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** object.h 28 Dec 2003 12:53:33 -0000 1.3 --- object.h 13 Apr 2004 12:26:08 -0000 1.4 *************** *** 18,69 **** ! //==================================================================================== class Object { ! public: ! static int id_counter; ! Point mapPos; // The position on the map ! int _destroy; // Object will be destroyed during next update. ! double walking, speed; ! int dir, prev_dir; ! int count, tick; ! BITMAP* bitmap; ! double x, y, px, py, nx, ny; ! int w, h; ! int obstacle; // Object is an obstacle to other objects. ! int offset_x, offset_y, offset_z; ! int id; ! int tableRef; // A reference to the associated Lua table ! char *className; ! Object(int luaTableRef, TiledMap* myMap); ! ~Object(); ! // Entity member variables/methods ! bool visible(BITMAP *dest, Point screenCoords); ! void draw(BITMAP *dest, Point topLeft); ! Point pos; ! int drawMode; ! int alpha; ! bool selected; ! int in_air; ! // Methods ! void walk(int dir, bool col); ! void set_dir(int dir); ! void initialize(); ! void check_stand_on(); ! void update(); ! void update_entity(); ! TiledMap* getMap() {return map;} ! void setMap(TiledMap *newMap); ! private: ! TiledMap* map; }; --- 18,71 ---- ! //============================================================================= class Object { ! public: ! static int id_counter; ! Point mapPos; // The position on the map ! int _destroy; // Object will be destroyed during next update. ! double walking, speed; ! int dir, prev_dir; ! int count, tick; ! BITMAP* bitmap; ! double x, y, px, py, nx, ny; ! int w, h; ! int obstacle; // Object is an obstacle to other objects. ! int offset_x, offset_y, offset_z; ! int id; ! int tableRef; // A reference to the associated Lua table ! char *className; ! Object(int luaTableRef, TiledMap* myMap); ! ~Object(); ! // Entity member variables/methods ! bool visible(BITMAP *dest, Point screenCoords); ! void draw(BITMAP *dest, Point topLeft); ! Point pos; ! int drawMode; ! int alpha; ! bool selected; ! int in_air; ! // Methods ! void walk(int dir, bool col); ! void set_dir(int dir); ! void setX(double x); ! void setY(double y); ! void initialize(); ! void check_stand_on(); ! void update(); ! void update_entity(); ! TiledMap* getMap() {return map;} ! void setMap(TiledMap *newMap); ! private: ! TiledMap* map; }; Index: engine.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/engine.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** engine.h 10 Dec 2003 20:57:38 -0000 1.4 --- engine.h 13 Apr 2004 12:26:08 -0000 1.5 *************** *** 21,39 **** extern list<TiledMap*> maps; ! #define DIR_NONE -1 ! #define DIR_UP 0 ! #define DIR_LEFT 1 ! #define DIR_RIGHT 2 ! #define DIR_DOWN 3 ! //=================== Engine functions =========================================== void update_objects(); ! //=================== Variables ================================================== extern bool exclusive_mode; --- 21,39 ---- extern list<TiledMap*> maps; ! #define DIR_NONE -1 ! #define DIR_UP 0 ! #define DIR_LEFT 1 ! #define DIR_RIGHT 2 ! #define DIR_DOWN 3 ! //============ Engine functions =========================================== void update_objects(); ! //============ Variables ================================================== extern bool exclusive_mode; Index: engine.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/engine.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** engine.cpp 9 Dec 2003 21:23:07 -0000 1.4 --- engine.cpp 13 Apr 2004 12:26:08 -0000 1.5 *************** *** 16,19 **** --- 16,20 ---- #include "tiled_map.h" #include "engine.h" + #include "module.h" #include "../script.h" #include "../common.h" *************** *** 27,36 **** ! //=================== Engine functions =========================================== void update_objects() { ! // Iterate through all maps ! for (list<TiledMap*>::iterator i = maps.begin(); i != maps.end(); i++) ! (*i)->updateObjects(); } --- 28,37 ---- ! //============ Engine functions =========================================== void update_objects() { ! // Iterate through all maps ! for (list<TiledMap*>::iterator i = maps.begin(); i != maps.end(); i++) ! (*i)->updateObjects(); } Index: tiled_map.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tiled_map.h 1 Jan 2004 16:04:36 -0000 1.5 --- tiled_map.h 13 Apr 2004 12:26:08 -0000 1.6 *************** *** 17,20 **** --- 17,22 ---- #include <vector> #include <allegro.h> + #include <libxml/xmlwriter.h> + #include <libxml/tree.h> using namespace std; *************** *** 24,41 **** #define DAT_MAPDATA DAT_ID('M','A','P',' ') ! #define TILES_W 24 ! #define TILES_H 24 ! #define DM_INVISIBLE 0 ! #define DM_ADD 1 ! #define DM_MASKED 2 ! #define DM_ALPHA 3 ! #define DM_TRANS 4 ! #define DM_MULTIPLY 5 ! #define OB_TOP 1 ! #define OB_RIGHT 2 ! #define OB_BOTTOM 4 ! #define OB_LEFT 8 --- 26,43 ---- #define DAT_MAPDATA DAT_ID('M','A','P',' ') ! #define TILES_W 24 ! #define TILES_H 24 ! #define DM_INVISIBLE 0 ! #define DM_ADD 1 ! #define DM_MASKED 2 ! #define DM_ALPHA 3 ! #define DM_TRANS 4 ! #define DM_MULTIPLY 5 ! #define OB_TOP 1 ! #define OB_RIGHT 2 ! #define OB_BOTTOM 4 ! #define OB_LEFT 8 *************** *** 49,57 **** class Point { ! public: ! Point() {x = y = z = 0;} ! Point(int X, int Y, int Z = 0) {x = X; y = Y; z = Z;} ! Point(Point p, int Z) {x = p.x; y = p.y; z = Z;} ! int x, y, z; }; --- 51,59 ---- class Point { ! public: ! Point() {x = y = z = 0;} ! Point(int X, int Y, int Z = 0) {x = X; y = Y; z = Z;} ! Point(Point p, int Z) {x = p.x; y = p.y; z = Z;} ! int x, y, z; }; *************** *** 60,69 **** class Rectangle { ! public: ! Rectangle() {x = y = w = h = 0;} ! Rectangle(int X, int Y, int W, int H) {x = X; y = Y; w = W; h = H;} ! void rectToClip(BITMAP *dest); ! void clipToRect(BITMAP *src); ! int x, y, w, h; }; --- 62,71 ---- class Rectangle { ! public: ! Rectangle() {x = y = w = h = 0;} ! Rectangle(int X, int Y, int W, int H) {x = X; y = Y; w = W; h = H;} ! void rectToClip(BITMAP *dest); ! void clipToRect(BITMAP *src); ! int x, y, w, h; }; *************** *** 73,88 **** class TileType { ! public: ! TileType(BITMAP *tileBitmap, const char *tileName); ! ~TileType(); ! BITMAP* getBitmap() {return bitmap;} ! char* getName() {return name;} ! int getColor() {return color;} ! protected: ! BITMAP* bitmap; ! char* name; ! int color; }; --- 75,90 ---- class TileType { ! public: ! TileType(BITMAP *tileBitmap, const char *tileName); ! ~TileType(); ! BITMAP* getBitmap() {return bitmap;} ! char* getName() {return name;} ! int getColor() {return color;} ! protected: ! BITMAP* bitmap; ! char* name; ! int color; }; *************** *** 95,116 **** struct ltstr { ! bool operator()(const char* s1, const char* s2) const { ! return strcmp(s1, s2) < 0; ! } }; class TileRepository { ! public: ! ~TileRepository(); ! void importDatafile(DATAFILE *dataFile); ! void importBitmap(BITMAP* tileBitmap, const char* group_name, int tile_w, int tile_h, int tile_spacing); ! void importBitmap(const char *filename, int tile_w, int tile_h, int tile_spacing); ! void exportBitmap(const char *filename, int tile_w, int tile_h, int tile_spacing, int tiles_in_row); ! TileType* getTileType(const char *tileName); ! vector<TileType*> generateTileArray(); ! protected: ! map<const char*, TileType*, ltstr> tileTypes; }; --- 97,121 ---- struct ltstr { ! bool operator()(const char* s1, const char* s2) const { ! return strcmp(s1, s2) < 0; ! } }; class TileRepository { ! public: ! ~TileRepository(); ! void importDatafile(DATAFILE *dataFile); ! void importBitmap(BITMAP* tileBitmap, const char* group_name, ! int tile_w, int tile_h, int tile_spacing); ! void importBitmap(const char *filename, ! int tile_w, int tile_h, int tile_spacing); ! void exportBitmap(const char *filename, ! int tile_w, int tile_h, int tile_spacing, int tiles_in_row); ! TileType* getTileType(const char *tileName); ! vector<TileType*> generateTileArray(); ! protected: ! map<const char*, TileType*, ltstr> tileTypes; }; *************** *** 119,134 **** class Tile { ! public: ! Tile(); ! void saveTo(PACKFILE *file); ! void loadFrom(PACKFILE *file, TileRepository *tileRepository); ! void setType(TileType* tileType); ! TileType* getType() {return tileType;} ! int obstacle; ! protected: ! TileType* tileType; }; --- 124,141 ---- class Tile { ! public: ! Tile(); ! 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;} ! int obstacle; ! protected: ! TileType* tileType; }; *************** *** 137,144 **** class EntityP { ! public: ! EntityP(Object *ent) {this->ent = ent;} ! Object *ent; ! bool operator< (const EntityP& X) const; }; --- 144,151 ---- class EntityP { ! public: ! EntityP(Object *ent) {this->ent = ent;} ! Object *ent; ! bool operator< (const EntityP& X) const; }; *************** *** 148,169 **** class TiledMapLayer { ! public: ! TiledMapLayer(); ! ~TiledMapLayer(); ! // Layer functions ! void resizeTo(int w, int h, int dx = 0, int dy = 0); ! void saveTo(PACKFILE* file); ! void loadFrom(PACKFILE* file, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} ! Tile* getTile(Point tileCoords); ! private: ! int mapWidth; ! int mapHeight; ! Tile** tileMap; }; --- 155,178 ---- class TiledMapLayer { ! public: ! TiledMapLayer(); ! ~TiledMapLayer(); ! // Layer functions ! void resizeTo(int w, int h, int dx = 0, int dy = 0); ! void saveTo(PACKFILE* file); ! void saveTo(xmlTextWriterPtr writer); ! void loadFrom(PACKFILE* file, TileRepository *tileRepository); ! void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} ! Tile* getTile(Point tileCoords); ! private: ! int mapWidth; ! int mapHeight; ! Tile** tileMap; }; *************** *** 174,234 **** class TiledMap { ! public: ! TiledMap(); ! virtual ~TiledMap(); ! // Map functions ! void resizeTo(int w, int h, int dx = 0, int dy = 0); ! void saveTo(PACKFILE* file); ! int loadMap(const char* mapName); ! void loadFrom(PACKFILE* file, TileRepository *tileRepository); ! void loadFromOld(PACKFILE *file, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} ! // Tile and entity methods ! //Tile* getTile(Point tileCoords); ! TiledMapLayer* getLayer(int i); ! // Draw the map ! virtual void setCamera(Point cameraCoords, Rectangle screenRect, bool centerCamera = false, bool modify = true); ! virtual void draw(BITMAP *dest, bool drawObstacle = false) = 0; ! virtual void drawLayer(BITMAP *dest, bool drawObstacle, TiledMapLayer *layer, int opacity = 255) = 0; ! void drawEntities(BITMAP *dest); ! void drawAirborneEntities(BITMAP *dest); ! Object* addObject(int x, int y, const char* type); ! Object* registerObject(int tableRef); ! void updateObjects(); ! void removeReference(Object* obj); ! void addReference(Object* obj); ! // Coordinate space converters ! virtual Point screenToTile(Point screenCoords); ! virtual Point tileToScreen(Point tileCoords); ! virtual Point screenToMap(Point screenCoords) = 0; ! virtual Point mapToScreen(Point mapCoords) = 0; ! virtual Point mapToTile(Point mapCoords) = 0; ! virtual Point tileToMap(Point tileCoords) = 0; ! virtual Point getMapSize() = 0; ! // The layers ! TiledMapLayer *mapLayers[2]; ! int nrLayers; ! // Entity list ! list<Object*> objects; ! protected: ! //Tile** tileMap; ! int mapWidth, mapHeight; ! // Camera properties ! Point cameraCoords; ! Rectangle cameraScreenRect; }; --- 183,247 ---- class TiledMap { ! public: ! TiledMap(); ! virtual ~TiledMap(); ! // Map functions ! void resizeTo(int w, int h, int dx = 0, int dy = 0); ! void saveTo(PACKFILE* file); ! void saveTo(xmlTextWriterPtr writer); ! int loadMap(const char* filename); ! void loadFrom(PACKFILE* file, TileRepository *tileRepository); ! void loadFrom(xmlNodePtr reader, TileRepository *tileRepository); ! int getWidth() {return mapWidth;} ! int getHeight() {return mapHeight;} ! // Tile and entity methods ! //Tile* getTile(Point tileCoords); ! TiledMapLayer* getLayer(int i); ! // Draw the map ! virtual void setCamera(Point cameraCoords, Rectangle screenRect, ! bool centerCamera = false, bool modify = true); ! virtual void draw(BITMAP *dest, bool drawObstacle = false) = 0; ! virtual void drawLayer(BITMAP *dest, bool drawObstacle, ! TiledMapLayer *layer, int opacity = 255) = 0; ! void drawEntities(BITMAP *dest); ! void drawAirborneEntities(BITMAP *dest); ! Object* addObject(double x, double y, const char* type); ! Object* registerObject(int tableRef); ! void updateObjects(); ! void removeReference(Object* obj); ! void addReference(Object* obj); ! void removeObjects(); ! // Coordinate space converters ! virtual Point screenToTile(Point screenCoords); ! virtual Point tileToScreen(Point tileCoords); ! virtual Point screenToMap(Point screenCoords) = 0; ! virtual Point mapToScreen(Point mapCoords) = 0; ! virtual Point mapToTile(Point mapCoords) = 0; ! virtual Point tileToMap(Point tileCoords) = 0; ! virtual Point getMapSize() = 0; ! // The layers ! TiledMapLayer *mapLayers[2]; ! int nrLayers; ! // Entity list ! list<Object*> objects; ! protected: ! //Tile** tileMap; ! int mapWidth, mapHeight; ! // Camera properties ! Point cameraCoords; ! Rectangle cameraScreenRect; }; *************** *** 238,259 **** class SquareMap : public TiledMap { ! public: ! SquareMap(int tileSize); ! SquareMap(int tileWidth, int tileHeight); ! // Draw the map ! virtual void draw(BITMAP *dest, bool drawObstacle = false); ! virtual void drawLayer(BITMAP *dest, bool drawObstacle, TiledMapLayer *layer, int opacity = 255); ! // Coordinate space converters ! virtual Point screenToMap(Point screenCoords); ! virtual Point mapToScreen(Point mapCoords); ! virtual Point mapToTile(Point mapCoords); ! virtual Point tileToMap(Point tileCoords); ! virtual Point getMapSize(); ! protected: ! int tileWidth, tileHeight; }; --- 251,273 ---- class SquareMap : public TiledMap { ! public: ! SquareMap(int tileSize); ! SquareMap(int tileWidth, int tileHeight); ! // Draw the map ! virtual void draw(BITMAP *dest, bool drawObstacle = false); ! virtual void drawLayer(BITMAP *dest, bool drawObstacle, ! TiledMapLayer *layer, int opacity = 255); ! // Coordinate space converters ! virtual Point screenToMap(Point screenCoords); ! virtual Point mapToScreen(Point mapCoords); ! virtual Point mapToTile(Point mapCoords); ! virtual Point tileToMap(Point tileCoords); ! virtual Point getMapSize(); ! protected: ! int tileWidth, tileHeight; }; *************** *** 264,284 **** class IsometricMap : public TiledMap { ! public: ! IsometricMap(int tileStepX, int tileStepY); ! // Draw the map ! virtual void draw(BITMAP *dest, bool drawObstacle = false); ! // Coordinate space converters ! virtual Point screenToMap(Point screenCoords); ! virtual Point mapToScreen(Point mapCoords); ! virtual Point mapToTile(Point mapCoords); ! virtual Point tileToMap(Point tileCoords); ! virtual Point getMapSize(); ! protected: ! int tileGridSize; ! int tileStepX, tileStepY; }; --- 278,298 ---- class IsometricMap : public TiledMap { ! public: ! IsometricMap(int tileStepX, int tileStepY); ! // Draw the map ! virtual void draw(BITMAP *dest, bool drawObstacle = false); ! // Coordinate space converters ! virtual Point screenToMap(Point screenCoords); ! virtual Point mapToScreen(Point mapCoords); ! virtual Point mapToTile(Point mapCoords); ! virtual Point tileToMap(Point tileCoords); ! virtual Point getMapSize(); ! protected: ! int tileGridSize; ! int tileStepX, tileStepY; }; Index: tiled_map.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/tiled_map.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tiled_map.cpp 1 Jan 2004 16:04:36 -0000 1.7 --- tiled_map.cpp 13 Apr 2004 12:26:08 -0000 1.8 *************** *** 18,21 **** --- 18,23 ---- #include <map> #include <algorithm> + #include <libxml/xmlwriter.h> + #include <libxml/xmlreader.h> *************** *** 25,36 **** void *load_tiledmapdata(PACKFILE *f, long size) [...2218 lines suppressed...] ! ); } Point IsometricMap::tileToMap(Point tileCoords) { ! return Point( ! (tileCoords.x + 1) * tileGridSize, ! (tileCoords.y + 1) * tileGridSize, ! tileCoords.z ! ); } Point IsometricMap::getMapSize() { ! return Point( ! tileStepX * (mapWidth + mapHeight), ! tileStepY * (mapWidth + mapHeight) ! ); } */ Index: console.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/shared/console.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** console.cpp 13 Jan 2004 16:32:35 -0000 1.2 --- console.cpp 13 Apr 2004 12:26:08 -0000 1.3 *************** *** 77,81 **** while (i != logMessages.end() && posY > - text_height(font)) { ! textprintf(dest, font, 2, posY, makecol(200,200,200), (*i)); posY -= text_height(font) + 1; i++; --- 77,81 ---- while (i != logMessages.end() && posY > - text_height(font)) { ! textprintf_ex(dest, font, 2, posY, makecol(200,200,200), -1, (*i)); posY -= text_height(font) + 1; i++; *************** *** 133,136 **** --- 133,137 ---- set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(buf); + printf("\n"); exit(1); } |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:40:09
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15068/src Modified Files: canvas.cpp canvas.h rpg.cpp rpg.h script.cpp script.h sound.cpp Log Message: Commiting engine changes to our beloved BBRpg on SourceForge. Index: canvas.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** canvas.cpp 9 Dec 2003 21:23:06 -0000 1.3 --- canvas.cpp 13 Apr 2004 12:26:08 -0000 1.4 *************** *** 26,196 **** void Canvas::init() { ! curX = 0; ! curY = 0; ! set_clip(buffer, 0, 0, SCREEN_W - 1, SCREEN_H - 1); ! myFont = font; ! drawColor = makecol(255,255,255); ! alpha = 255; ! drawMode = DM_MASKED; } void Canvas::getCursor(int *x, int *y) { ! ASSERT(x && y); ! *x = curX; ! *y = curY; } void Canvas::setCursor(int x, int y) { ! curX = x; ! curY = y; } void Canvas::getClip(int *x1, int *y1, int *x2, int *y2) { ! ASSERT(x1 && y1 && x2 && y2); ! *x1 = buffer->cl; ! *y1 = buffer->ct; ! *x2 = buffer->cr; ! *y2 = buffer->cb; } void Canvas::setClip(int x1, int y1, int x2, int y2) { ! set_clip(buffer, x1, y1, x2, y2); } void Canvas::setColor(int color) { ! drawColor = color; } void Canvas::setDrawMode(int drawMode) { ! this->drawMode = drawMode; } void Canvas::setAlpha(int alpha) { ! this->alpha = alpha; } void Canvas::setFont(FONT *font) { ! if (font) myFont = font; } void Canvas::textSize(const char *text, int *w, int *h) { ! ASSERT(w && h); ! *w = text_length(myFont, text); ! *h = text_height(myFont); } void Canvas::drawText(const char *text) { ! ASSERT(text); ! int tm = text_mode(-1); // Text will be drawn masked ! textout(buffer, myFont, text, curX, curY, drawColor); ! curX += text_length(myFont, text); ! text_mode(tm); } void Canvas::drawBitmap(BITMAP *bmp, int dw, int dh, int sx, int sy, int sw, int sh) { ! /* ! console.log( ! CON_LOG | CON_CONSOLE, ! CON_DEBUG, ! "Processing draw_bitmap(bmp, %d, %d, %d, %d, %d, %d)", ! dw, dh, sx, sy, sw, sh ! ); ! */ ! ASSERT(bitmap); ! BITMAP *src = NULL; ! // Don't try to process invalid surfaces ! if (dw < 0 || dh < 0) return; ! if (sx != 0 || sy != 0 || sw != bmp->w || sh != bmp->h) ! { ! // The source bitmap needs to be adapted first ! src = create_bitmap(sw, sh); ! ASSERT(src); ! // Determine the point where we should start drawing ! int start_x = -sx % bmp->w; ! int start_y = -sy % bmp->h; ! if (start_x > 0) start_x -= bmp->w; ! if (start_y > 0) start_y -= bmp->h; ! int x = start_x; ! int y = start_y; ! // Create tiled pattern ! while (y < sh) { ! while (x < sw) { ! blit(bmp, src, 0, 0, x, y, bmp->w, bmp->h); ! x += bmp->w; ! } ! x = start_x; ! y += bmp->h; ! } ! bmp = src; ! } ! // Now we'll put this sprite on the screen ! switch (drawMode) { ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! } ! if ((drawMode == DM_TRANS && alpha < 255) || drawMode == DM_ALPHA || drawMode == DM_ADD) { ! if (sw == dw && sh == dh) { ! draw_trans_sprite(buffer, bmp, curX, curY); ! } ! else { ! BITMAP *stretch = create_bitmap(dw, dh); ! if (stretch) { ! stretch_sprite(stretch, bmp, 0, 0, dw, dh); ! draw_trans_sprite(buffer, stretch, curX, curY); ! destroy_bitmap(stretch); ! } ! } ! } ! else ! { ! if (sw == dw && sh == dh) { ! draw_sprite(buffer, bmp, curX, curY); ! } ! else { ! stretch_sprite(buffer, bmp, curX, curY, dw, dh); ! } ! } ! switch (drawMode) { ! case DM_TRANS: ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! if (src) destroy_bitmap(src); ! // And don't forget to move that cursor ! curX += dw; } void Canvas::drawViewport(int x, int y, int w, int h, int tx, int ty, TiledMap* map) { ! map->setCamera( ! Point(tx, ty), ! Rectangle(x, y, w, h), ! true, true ! ); ! map->draw(buffer); } --- 26,194 ---- void Canvas::init() { ! curX = 0; ! curY = 0; ! set_clip_rect(buffer, 0, 0, SCREEN_W - 1, SCREEN_H - 1); ! myFont = font; ! drawColor = makecol(255,255,255); ! alpha = 255; ! drawMode = DM_MASKED; } void Canvas::getCursor(int *x, int *y) { ! ASSERT(x && y); ! *x = curX; ! *y = curY; } void Canvas::setCursor(int x, int y) { ! curX = x; ! curY = y; } void Canvas::getClip(int *x1, int *y1, int *x2, int *y2) { ! ASSERT(x1 && y1 && x2 && y2); ! *x1 = buffer->cl; ! *y1 = buffer->ct; ! *x2 = buffer->cr; ! *y2 = buffer->cb; } void Canvas::setClip(int x1, int y1, int x2, int y2) { ! set_clip_rect(buffer, x1, y1, x2, y2); } void Canvas::setColor(int color) { ! drawColor = color; } void Canvas::setDrawMode(int drawMode) { ! this->drawMode = drawMode; } void Canvas::setAlpha(int alpha) { ! this->alpha = alpha; } void Canvas::setFont(FONT *font) { ! if (font) myFont = font; } void Canvas::textSize(const char *text, int *w, int *h) { ! ASSERT(w && h); ! *w = text_length(myFont, text); ! *h = text_height(myFont); } void Canvas::drawText(const char *text) { ! ASSERT(text); ! textout_ex(buffer, myFont, text, curX, curY, drawColor, -1); ! curX += text_length(myFont, text); } void Canvas::drawBitmap(BITMAP *bmp, int dw, int dh, int sx, int sy, int sw, int sh) { ! /* ! console.log( ! CON_LOG | CON_CONSOLE, ! CON_DEBUG, ! "Processing draw_bitmap(bmp, %d, %d, %d, %d, %d, %d)", ! dw, dh, sx, sy, sw, sh ! ); ! */ ! ASSERT(bitmap); ! BITMAP *src = NULL; ! // Don't try to process invalid surfaces ! if (dw < 0 || dh < 0) return; ! if (sx != 0 || sy != 0 || sw != bmp->w || sh != bmp->h) ! { ! // The source bitmap needs to be adapted first ! src = create_bitmap(sw, sh); ! ASSERT(src); ! // Determine the point where we should start drawing ! int start_x = -sx % bmp->w; ! int start_y = -sy % bmp->h; ! if (start_x > 0) start_x -= bmp->w; ! if (start_y > 0) start_y -= bmp->h; ! int x = start_x; ! int y = start_y; ! // Create tiled pattern ! while (y < sh) { ! while (x < sw) { ! blit(bmp, src, 0, 0, x, y, bmp->w, bmp->h); ! x += bmp->w; ! } ! x = start_x; ! y += bmp->h; ! } ! bmp = src; ! } ! // Now we'll put this sprite on the screen ! switch (drawMode) { ! case DM_ALPHA: ! set_alpha_blender(); ! break; ! case DM_TRANS: ! set_trans_blender(0,0,0,alpha); ! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); ! break; ! } ! if ((drawMode == DM_TRANS && alpha < 255) || drawMode == DM_ALPHA || drawMode == DM_ADD) { ! if (sw == dw && sh == dh) { ! draw_trans_sprite(buffer, bmp, curX, curY); ! } ! else { ! BITMAP *stretch = create_bitmap(dw, dh); ! if (stretch) { ! stretch_sprite(stretch, bmp, 0, 0, dw, dh); ! draw_trans_sprite(buffer, stretch, curX, curY); ! destroy_bitmap(stretch); ! } ! } ! } ! else ! { ! if (sw == dw && sh == dh) { ! draw_sprite(buffer, bmp, curX, curY); ! } ! else { ! stretch_sprite(buffer, bmp, curX, curY, dw, dh); ! } ! } ! switch (drawMode) { ! case DM_TRANS: ! drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); ! break; ! } ! if (src) destroy_bitmap(src); ! // And don't forget to move that cursor ! curX += dw; } void Canvas::drawViewport(int x, int y, int w, int h, int tx, int ty, TiledMap* map) { ! map->setCamera( ! Point(tx, ty), ! Rectangle(x, y, w, h), ! true, true ! ); ! map->draw(buffer); } Index: script.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** script.cpp 13 Jan 2004 16:32:35 -0000 1.14 --- script.cpp 13 Apr 2004 12:26:08 -0000 1.15 *************** *** 21,212 **** #include "canvas.h" #include "common.h" - #include <set> #include <vector> - using std::set; using std::vector; lua_State* L = NULL; [...2143 lines suppressed...] ! } ! else if (strcmp(index, "in_air") == 0) { ! obj->in_air = (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; } Index: canvas.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/canvas.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** canvas.h 9 Dec 2003 21:23:06 -0000 1.2 --- canvas.h 13 Apr 2004 12:26:08 -0000 1.3 *************** *** 18,45 **** class Canvas { ! public: ! void init(); ! void getCursor(int *x, int *y); ! void setCursor(int x, int y); ! void getClip(int *x1, int *y1, int *x2, int *y2); ! void setClip(int x1, int y1, int x2, int y2); ! void setColor(int color); ! void setDrawMode(int drawMode); ! int getDrawMode() {return drawMode;} ! void setAlpha(int alpha); ! int getAlpha() {return alpha;} ! void setFont(FONT* font); ! void textSize(const char *text, int *width, int *height); ! void bitmapSize(BITMAP *bmp, int *width, int *height); ! void drawText(const char *text); ! void drawBitmap(BITMAP *bmp, int dw, int dh, int sx, int sy, int sw, int sh); ! void drawViewport(int x, int y, int w, int h, int tx, int ty, TiledMap* map); ! private: ! int curX, curY; // The current cursor position ! int drawColor; // The currently used draw color ! int alpha; // The currently used opacity ! FONT* myFont; // The currently used font ! int drawMode; // The currently used drawmode }; --- 18,45 ---- class Canvas { ! public: ! void init(); ! void getCursor(int *x, int *y); ! void setCursor(int x, int y); ! void getClip(int *x1, int *y1, int *x2, int *y2); ! void setClip(int x1, int y1, int x2, int y2); ! void setColor(int color); ! void setDrawMode(int drawMode); ! int getDrawMode() {return drawMode;} ! void setAlpha(int alpha); ! int getAlpha() {return alpha;} ! void setFont(FONT* font); ! void textSize(const char *text, int *width, int *height); ! void bitmapSize(BITMAP *bmp, int *width, int *height); ! void drawText(const char *text); ! void drawBitmap(BITMAP *bmp,int dw,int dh,int sx,int sy,int sw,int sh); ! void drawViewport(int x,int y,int w,int h,int tx,int ty,TiledMap* map); ! private: ! int curX, curY; // The current cursor position ! int drawColor; // The currently used draw color ! int alpha; // The currently used opacity ! FONT* myFont; // The currently used font ! int drawMode; // The currently used drawmode }; Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** rpg.cpp 13 Jan 2004 16:32:35 -0000 1.9 --- rpg.cpp 13 Apr 2004 12:26:08 -0000 1.10 *************** *** 15,18 **** --- 15,19 ---- #include "shared/tiled_map.h" #include "shared/engine.h" + #include "shared/module.h" #include "script.h" #include "canvas.h" *************** *** 39,43 **** char filename[256]; DATAFILE *interface_graphics; ! DATAFILE *bitmap_data; FONT* engine_font; int gameClassInstance = 0; --- 40,44 ---- char filename[256]; DATAFILE *interface_graphics; ! Module *module; FONT* engine_font; int gameClassInstance = 0; *************** *** 47,51 **** Console console("rpg.log"); - //TiledMap *tiledMap = NULL; TileRepository *tileRepository; TileType *selectedTile = NULL; --- 48,51 ---- *************** *** 55,73 **** void main() { ! init_engine(); ! do { ! // Handle user input ! if (frames_to_do > 0) { ! handle_input(); ! frames_to_do--; ! // If less than 2 extra frames are waiting, take time to display current frame ! if (frames_to_do < 2) {draw_screen();} ! else if (frames_to_do > 10) {frames_to_do = frames_to_do % 10;} ! } ! } while (!game_end); ! exit_program(); } END_OF_MAIN(); --- 55,73 ---- void main() { ! init_engine(); ! do { ! // Handle user input ! if (frames_to_do > 0) { ! handle_input(); ! frames_to_do--; ! // If less than 2 extra frames are waiting, take time to display ! if (frames_to_do < 2) {draw_screen();} ! else if (frames_to_do > 10) {frames_to_do = frames_to_do % 10;} ! } ! } while (!game_end); ! exit_program(); } END_OF_MAIN(); *************** *** 76,215 **** void init_engine() { ! // Allegro initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initializing Allegro..."); ! allegro_init(); ! install_keyboard(); ! install_timer(); ! three_finger_flag = 0; ! set_display_switch_mode(SWITCH_BACKAMNESIA); ! //register_datafile_object(DAT_MAPDATA, load_tiledmapdata, destroy_tiledmapdata); ! set_config_file("rpg.cfg"); ! lps = get_config_int("Engine", "GameSpeed", 100); ! debug_mode = (get_config_int("Engine", "DebugMode", 0)) ? 1 : 0; ! debug_mode += (get_config_int("Engine", "DebugVerbose", 0)) ? 1 : 0; ! int driver = GFX_AUTODETECT_WINDOWED; ! if (get_config_int("Video", "Fullscreen", 0)) { ! driver = GFX_AUTODETECT_FULLSCREEN; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! bVSync = get_config_int("Video", "VSync", 0); ! ! sound_enabled = (get_config_int("Sound", "MusicEnabled", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "SfxEnabled", 1)) ? 1 : 0; ! music_vol = get_config_int("Sound", "MusicVolume", 255); ! sfx_vol = get_config_int("Sound", "SfxVolume", 255); ! music_format = (strcmp(get_config_string("Sound", "MusicFormat", "MIDI"), "MIDI") == 0) ? MUSIC_MIDI : MUSIC_OGG; ! console.enableLogfile = (get_config_int("Engine", "LogEnabled", 1)); ! // Screen initialisation ! int width, height, colordepth = 0; ! width = get_config_int("Video", "ResolutionWidth", 640); ! height = get_config_int("Video", "ResolutionHeight", 480); ! if (driver == GFX_AUTODETECT_FULLSCREEN) {colordepth = desktop_color_depth();} ! if (colordepth == 0) {colordepth = 16;} ! colordepth = get_config_int("Video", "ColorDepth", colordepth); ! bDoubleSize = get_config_int("Video", "DoubleSize", 0); ! if (bDoubleSize) { ! width = width * 2; ! height = height * 2; ! } ! console.log(CON_LOG, CON_ALWAYS, "Setting screen mode (%dx%dx%d)...", width, height, colordepth); ! set_color_depth(colordepth); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_LOG, CON_ALWAYS, "Failed, trying screen mode (%dx%dx15)...", width, height); ! set_color_depth(15); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_QUIT, CON_ALWAYS, "%s", allegro_error); ! } ! } ! set_window_title("Moonlight RPG engine"); ! text_mode(-1); ! textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(255,0,0), "LOADING..."); ! console.log(CON_LOG, CON_ALWAYS, "Creating screen buffer..."); ! if (bDoubleSize) { ! buffer = create_bitmap(SCREEN_W / 2, SCREEN_H / 2); ! } else { ! buffer = create_bitmap(SCREEN_W, SCREEN_H); ! } ! clear(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Creating tile repository..."); ! tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! interface_graphics = load_datafile("gui.dat"); ! if (!interface_graphics) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); ! } ! // Set font to use ! DATAFILE *temp = find_datafile_object(interface_graphics, "SmallFont"); ! if (temp) {engine_font = ((FONT *)temp->dat);} ! console.log(CON_LOG, CON_ALWAYS, "Loading data.dat..."); ! bitmap_data = load_datafile("data.dat"); ! if (!bitmap_data) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: data.dat"); ! } ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); ! init_sound(); ! } ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising Lua scripting environment..."); ! initScripting(); ! console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); ! LOCK_VARIABLE(frames_to_do); // Game speed handler ! LOCK_FUNCTION(handle_game_time); ! LOCK_VARIABLE(fps); // Frames per second counter ! LOCK_VARIABLE(fps_counter); ! LOCK_FUNCTION(handle_fps_counter); ! install_int_ex(handle_game_time, BPS_TO_TIMER(lps)); ! install_int_ex(handle_fps_counter, BPS_TO_TIMER(1)); ! console.log(CON_LOG, CON_ALWAYS, "Initialising canvas..."); ! canvas.init(); ! console.log(CON_LOG, CON_ALWAYS, "All finished, initializing game..."); ! const char* gameClass = get_config_string("Engine", "GameClass", "Game"); ! lua_pushstring(L, gameClass); lua_gettable(L, LUA_GLOBALSINDEX); ! if (!lua_isnil(L, -1)) { ! lua_call(L, 0, 1); ! if (lua_istable(L, -1)) { ! gameClassInstance = lua_ref(L, -1); ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, "Error while instaniating game class \"%s\"", gameClass); ! } ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, "Error: could not find game class \"%s\"", gameClass); ! } ! clear(screen); } --- 76,224 ---- void init_engine() { ! // Allegro initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initializing Allegro..."); ! allegro_init(); ! install_keyboard(); ! install_timer(); ! three_finger_flag = 0; ! set_display_switch_mode(SWITCH_BACKAMNESIA); ! //register_datafile_object( ! // DAT_MAPDATA, load_tiledmapdata, destroy_tiledmapdata); ! set_config_file("rpg.cfg"); ! lps = get_config_int("Engine", "GameSpeed", 100); ! debug_mode = (get_config_int("Engine", "DebugMode", 0)) ? 1 : 0; ! debug_mode += (get_config_int("Engine", "DebugVerbose", 0)) ? 1 : 0; ! int driver = GFX_AUTODETECT_WINDOWED; ! if (get_config_int("Video", "Fullscreen", 0)) { ! driver = GFX_AUTODETECT_FULLSCREEN; ! } ! set_color_conversion( ! (COLORCONV_TOTAL & ! ~( ! COLORCONV_32A_TO_8 | ! COLORCONV_32A_TO_15 | ! COLORCONV_32A_TO_16 | ! COLORCONV_32A_TO_24 ! )) ! ); ! bVSync = get_config_int("Video", "VSync", 0); ! sound_enabled = (get_config_int("Sound", "MusicEnabled", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "SfxEnabled", 1)) ? 1 : 0; ! music_vol = get_config_int("Sound", "MusicVolume", 255); ! sfx_vol = get_config_int("Sound", "SfxVolume", 255); ! music_format = (strcmp(get_config_string("Sound", "MusicFormat", "MIDI"), ! "MIDI") == 0) ? MUSIC_MIDI : MUSIC_OGG; ! console.enableLogfile = (get_config_int("Engine", "LogEnabled", 1)); ! // Screen initialisation ! int width, height, colordepth = 0; ! width = get_config_int("Video", "ResolutionWidth", 640); ! height = get_config_int("Video", "ResolutionHeight", 480); ! if (driver == GFX_AUTODETECT_FULLSCREEN) { ! colordepth = desktop_color_depth(); ! } ! if (colordepth == 0) { ! colordepth = 16; ! } ! colordepth = get_config_int("Video", "ColorDepth", colordepth); ! bDoubleSize = get_config_int("Video", "DoubleSize", 0); ! if (bDoubleSize) { ! width = width * 2; ! height = height * 2; ! } ! console.log(CON_LOG, CON_ALWAYS, ! "Setting screen mode (%dx%dx%d)...", width, height, colordepth); ! set_color_depth(colordepth); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_LOG, CON_ALWAYS, ! "Failed, trying screen mode (%dx%dx15)...", width, height); ! set_color_depth(15); ! if (set_gfx_mode(driver, width, height, 0, 0) < 0) { ! console.log(CON_QUIT, CON_ALWAYS, "%s", allegro_error); ! } ! } ! set_window_title("Moonlight RPG engine"); ! textprintf_centre_ex( ! screen, font, SCREEN_W/2, SCREEN_H/2, makecol(255,0,0), -1, ! "LOADING..."); ! console.log(CON_LOG, CON_ALWAYS, "Creating screen buffer..."); ! if (bDoubleSize) { ! buffer = create_bitmap(SCREEN_W / 2, SCREEN_H / 2); ! } else { ! buffer = create_bitmap(SCREEN_W, SCREEN_H); ! } ! clear(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Creating tile repository..."); ! tileRepository = new TileRepository(); ! console.log(CON_LOG, CON_ALWAYS, "Loading gui.dat..."); ! interface_graphics = load_datafile("gui.dat"); ! if (!interface_graphics) { ! console.log(CON_QUIT, CON_ALWAYS, "Error while loading: gui.dat"); ! } ! // Set font to use ! DATAFILE *temp = find_datafile_object(interface_graphics, "SmallFont"); ! if (temp) {engine_font = ((FONT *)temp->dat);} ! console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"..."); ! module = new Module("data"); ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); ! init_sound(); ! } ! // Lua initialisation ! console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment..."); ! initScripting(); ! console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); ! LOCK_VARIABLE(frames_to_do); // Game speed handler ! LOCK_FUNCTION(handle_game_time); ! LOCK_VARIABLE(fps); // Frames per second counter ! LOCK_VARIABLE(fps_counter); ! LOCK_FUNCTION(handle_fps_counter); ! install_int_ex(handle_game_time, BPS_TO_TIMER(lps)); ! install_int_ex(handle_fps_counter, BPS_TO_TIMER(1)); ! console.log(CON_LOG, CON_ALWAYS, "Initialising canvas..."); ! canvas.init(); ! console.log(CON_LOG, CON_ALWAYS, "All finished, initializing game..."); ! ! const char* gameClass = get_config_string("Engine", "GameClass", "Game"); ! lua_pushstring(L, gameClass); lua_gettable(L, LUA_GLOBALSINDEX); ! if (!lua_isnil(L, -1)) { ! lua_call(L, 0, 1); ! if (lua_istable(L, -1)) { ! gameClassInstance = lua_ref(L, -1); ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, ! "Error while instaniating game class \"%s\"", gameClass); ! } ! } ! else { ! console.log(CON_QUIT, CON_ALWAYS, ! "Error: could not find game class \"%s\"", gameClass); ! } ! clear(screen); } *************** *** 217,256 **** void handle_input() { ! if (keypressed()) { ! inkey = (readkey() >> 8); ! if (console.handleInput(inkey)) inkey = 0; ! } ! else { ! inkey = 0; ! } ! if (inkey > 0) ! { ! char *key_name = "anykey"; ! if (inkey == KEY_ESC) key_name = "esc"; ! if (inkey == KEY_TAB) key_name = "tab"; ! if (inkey == KEY_SPACE || inkey == KEY_ENTER) key_name = "action"; ! if (inkey == KEY_UP) key_name = "up"; ! if (inkey == KEY_LEFT) key_name = "left"; ! if (inkey == KEY_RIGHT) key_name = "right"; ! if (inkey == KEY_DOWN) key_name = "down"; ! if (inkey == KEY_LCONTROL || inkey == KEY_RCONTROL) key_name = "ctrl"; ! callMemberFunction(gameClassInstance, "event_keypress", "s", key_name); ! } ! update_objects(); ! callMemberFunction(gameClassInstance, "event_logic_update"); ! console.update(); #ifdef ENABLE_MUSIC ! if (sound_enabled && sound_counter == 0) { ! poll_sound(); ! sound_counter = 10; ! } ! sound_counter--; #endif } --- 226,265 ---- void handle_input() { ! if (keypressed()) { ! inkey = (readkey() >> 8); ! if (console.handleInput(inkey)) inkey = 0; ! } ! else { ! inkey = 0; ! } ! if (inkey > 0) ! { ! char *key_name = "anykey"; ! if (inkey == KEY_ESC) key_name = "esc"; ! if (inkey == KEY_TAB) key_name = "tab"; ! if (inkey == KEY_SPACE || inkey == KEY_ENTER) key_name = "action"; ! if (inkey == KEY_UP) key_name = "up"; ! if (inkey == KEY_LEFT) key_name = "left"; ! if (inkey == KEY_RIGHT) key_name = "right"; ! if (inkey == KEY_DOWN) key_name = "down"; ! if (inkey == KEY_LCONTROL || inkey == KEY_RCONTROL) key_name = "ctrl"; ! callMemberFunction(gameClassInstance, "event_keypress", "s", key_name); ! } ! update_objects(); ! callMemberFunction(gameClassInstance, "event_logic_update"); ! console.update(); #ifdef ENABLE_MUSIC ! if (sound_enabled && sound_counter == 0) { ! poll_sound(); ! sound_counter = 10; ! } ! sound_counter--; #endif } *************** *** 259,287 **** void draw_screen() { ! clear_bitmap(buffer); ! callMemberFunction(gameClassInstance, "event_render"); ! canvas.init(); ! if (debug_mode) { ! font = engine_font; ! textprintf_centre(buffer, font, buffer->w / 2 + 1, 12, makecol(0,0,0) , "%d fps", fps); ! textprintf_centre(buffer, font, buffer->w / 2, 11, makecol(128,128,150), "%d fps", fps); ! } ! console.draw(buffer); ! update_screen(); ! fps_counter++; } void update_screen() { ! if (bVSync) vsync(); ! if (bDoubleSize) { ! stretch_blit(buffer, screen, 0, 0, buffer->w, buffer->h, 0, 0, buffer->w * 2, buffer->h * 2); ! } else { ! blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h); ! } } --- 268,302 ---- void draw_screen() { ! clear_bitmap(buffer); ! callMemberFunction(gameClassInstance, "event_render"); ! canvas.init(); ! if (debug_mode) { ! font = engine_font; ! textprintf_centre_ex( ! buffer, font, buffer->w / 2 + 1, 12, makecol(0,0,0), -1, ! "%d fps", fps); ! textprintf_centre_ex( ! buffer, font, buffer->w / 2, 11, makecol(128,128,150), -1, ! "%d fps", fps); ! } ! console.draw(buffer); ! update_screen(); ! fps_counter++; } void update_screen() { ! if (bVSync) vsync(); ! if (bDoubleSize) { ! stretch_blit(buffer, screen, ! 0, 0, buffer->w, buffer->h, ! 0, 0, buffer->w * 2, buffer->h * 2); ! } else { ! blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h); ! } } *************** *** 289,325 **** void exit_program() { ! console.log(CON_LOG, CON_ALWAYS, "Game ended"); ! console.log(CON_LOG, CON_ALWAYS, "Deleting objects..."); ! list<TiledMap*>::iterator i; ! while (!maps.empty()) ! { ! i = maps.begin(); ! delete (*i); ! maps.erase(i); ! } ! console.log(CON_LOG, CON_ALWAYS, "Deleting tile repository..."); ! delete tileRepository; ! console.log(CON_LOG, CON_ALWAYS, "Removing timers..."); ! remove_int(handle_fps_counter); ! remove_int(handle_game_time); ! console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(interface_graphics); ! unload_datafile(bitmap_data); ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Deinitializing sound..."); ! exit_sound(); ! } ! console.log(CON_LOG, CON_ALWAYS, "Destroying screen buffer..."); ! destroy_bitmap(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Closing Lua scripting environment..."); ! exitScripting(); ! exit(0); } --- 304,342 ---- void exit_program() { ! console.log(CON_LOG, CON_ALWAYS, "Game ended"); ! console.log(CON_LOG, CON_ALWAYS, "Deleting objects..."); ! list<TiledMap*>::iterator i; ! while (!maps.empty()) ! { ! i = maps.begin(); ! delete (*i); ! maps.erase(i); ! } ! console.log(CON_LOG, CON_ALWAYS, "Deleting tile repository..."); ! delete tileRepository; ! console.log(CON_LOG, CON_ALWAYS, "Removing timers..."); ! remove_int(handle_fps_counter); ! remove_int(handle_game_time); ! console.log(CON_LOG, CON_ALWAYS, "Unloading datafiles..."); ! unload_datafile(interface_graphics); ! delete module; ! if (sound_enabled || sfx_enabled) { ! console.log(CON_LOG, CON_ALWAYS, "Deinitializing sound..."); ! exit_sound(); ! } ! console.log(CON_LOG, CON_ALWAYS, "Destroying screen buffer..."); ! destroy_bitmap(buffer); ! console.log(CON_LOG, CON_ALWAYS, "Closing scripting environment..."); ! exitScripting(); ! ! console.log(CON_LOG, CON_ALWAYS, "Shutdown complete, exiting..."); ! exit(0); } Index: sound.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sound.cpp 13 Jan 2004 16:32:35 -0000 1.9 --- sound.cpp 13 Apr 2004 12:26:08 -0000 1.10 *************** *** 33,41 **** // Currently playing OGG file struct { ! SAMPLE *sample; ! int voice; ! struct alogg_stream *stream; ! AUDIOSTREAM *ass; ! char filename[128]; } channels[CHANNELS]; --- 33,41 ---- // Currently playing OGG file struct { ! SAMPLE *sample; ! int voice; ! struct alogg_stream *stream; ! AUDIOSTREAM *ass; ! char filename[128]; } channels[CHANNELS]; *************** *** 45,80 **** void init_sound() { ! // To achieve the max possible volume ! set_volume_per_voice(0); ! // Initialize alogg ! int midi_driver = MIDI_NONE; ! int sound_driver = DIGI_NONE; ! if (music_format == MUSIC_MIDI) { ! midi_driver = MIDI_AUTODETECT; ! } ! if (sfx_enabled || (sound_enabled && music_format != MUSIC_MIDI)) { #ifdef ENABLE_MUSIC ! alogg_init(); #endif ! sound_driver = DIGI_AUTODETECT; ! } ! // Install sound driver ! if (install_sound(sound_driver, midi_driver, NULL) != 0) { ! console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); ! return; ! } #ifdef ENABLE_MUSIC ! // Initialize channels to NULL ! for (int i = 0; i < CHANNELS; i++) { ! channels[i].voice = 0; ! channels[i].sample = NULL; ! channels[i].stream = NULL; ! channels[i].ass = NULL; ! } #endif } --- 45,80 ---- void init_sound() { ! // To achieve the max possible volume ! set_volume_per_voice(0); ! // Initialize alogg ! int midi_driver = MIDI_NONE; ! int sound_driver = DIGI_NONE; ! if (sound_enabled && music_format == MUSIC_MIDI) { ! midi_driver = MIDI_AUTODETECT; ! } ! if (sfx_enabled || (sound_enabled && music_format != MUSIC_MIDI)) { #ifdef ENABLE_MUSIC ! alogg_init(); #endif ! sound_driver = DIGI_AUTODETECT; ! } ! // Install sound driver ! if (install_sound(sound_driver, midi_driver, NULL) != 0) { ! console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); ! return; ! } #ifdef ENABLE_MUSIC ! // Initialize channels to NULL ! for (int i = 0; i < CHANNELS; i++) { ! channels[i].voice = 0; ! channels[i].sample = NULL; ! channels[i].stream = NULL; ! channels[i].ass = NULL; ! } #endif } *************** *** 83,136 **** /* play_music(filename, channel) ! */ int l_play_music(lua_State *L) { ! char* filename; ! int channel; ! getLuaArguments(L, "si", &filename, &channel); ! error = NULL; ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! if (sound_enabled && error == NULL) { ! if (music_format == MUSIC_MIDI) { ! replace_extension(channels[channel].filename, get_filename(filename), "mid", 128); ! ! DATAFILE *found_object = find_datafile_object(bitmap_data, channels[channel].filename); ! if (found_object) { ! play_looped_midi((MIDI*)found_object->dat, 0, -1); ! } else { ! console.log(CON_QUIT, CON_ALWAYS, "Could not find MIDI file in datafile (%s)", channels[channel].filename); ! } ! } else { #ifdef ENABLE_MUSIC ! // Stop currently playing music ! stop_music(channel); ! ! if (!exists(filename)) {error = "file does not exist";} ! ! strncpy(channels[channel].filename, filename, 128); ! ! channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); ! if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", channels[channel].filename); ! alogg_exit(); ! exit(1); ! } ! channels[channel].ass = alogg_get_audio_stream(channels[channel].stream); ! voice_set_volume(channels[channel].ass->voice, music_vol); #endif ! } ! } ! ! if (error == NULL) { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing music file (%s)", filename); ! } ! else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing music file \"%s\" (%s)", filename, error); ! } ! ! return 0; } --- 83,138 ---- /* play_music(filename, channel) ! */ int l_play_music(lua_State *L) { ! char* filename; ! int channel; ! getLuaArguments(L, "si", &filename, &channel); ! error = NULL; ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! if (sound_enabled && error == NULL) { ! if (music_format == MUSIC_MIDI) { ! replace_extension(channels[channel].filename, get_filename(filename), "mid", 128); ! ! MIDI *midi = module->findMidi(channels[channel].filename); ! if (midi) { ! play_looped_midi(midi, 0, -1); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, ! "Could not find MIDI file in datafile (%s)", ! channels[channel].filename); ! } ! } else { #ifdef ENABLE_MUSIC ! // Stop currently playing music ! stop_music(channel); ! ! if (!exists(filename)) {error = "file does not exist";} ! ! strncpy(channels[channel].filename, filename, 128); ! ! channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); ! if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", channels[channel].filename); ! alogg_exit(); ! exit(1); ! } ! channels[channel].ass = alogg_get_audio_stream(channels[channel].stream); ! voice_set_volume(channels[channel].ass->voice, music_vol); #endif ! } ! } ! ! if (error == NULL) { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing music file (%s)", filename); ! } ! else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing music file \"%s\" (%s)", filename, error); ! } ! ! return 0; } *************** *** 139,173 **** /* adjust_channel(channel, volume, panning, speed) ! */ int l_adjust_channel(lua_State *L) { ! int channel, vol, pan, speed; ! getLuaArguments(L, "iiii", &channel, &vol, &pan, &speed); ! error = NULL; ! if (sound_enabled && music_format != MUSIC_MIDI) { ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!channels[channel].ass) {error = "no music on this channel to adjust";} ! else if (vol < 0 || vol > 255) {error = "illegal volume value";} ! else if (pan < 0 || pan > 255) {error = "illegal panning value";} ! else if (speed < 0) {error = "illegal speed value";} ! if (error == NULL) { ! voice_set_volume(channels[channel].ass->voice, int(vol * (float(music_vol) / 255.0f))); ! //console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Adjusted channel parameters (%d, %d, %d, %d)", channel, vol, pan, speed); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error adjusting channel parameters (%s)", error); ! } ! } ! return 0; } /* get_number_of_channels() ! */ int l_get_number_of_channels(lua_State *L) { ! return putLuaArguments(L, "i", CHANNELS); } --- 141,175 ---- /* adjust_channel(channel, volume, panning, speed) ! */ int l_adjust_channel(lua_State *L) { ! int channel, vol, pan, speed; ! getLuaArguments(L, "iiii", &channel, &vol, &pan, &speed); ! error = NULL; ! if (sound_enabled && music_format != MUSIC_MIDI) { ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!channels[channel].ass) {error = "no music on this channel to adjust";} ! else if (vol < 0 || vol > 255) {error = "illegal volume value";} ! else if (pan < 0 || pan > 255) {error = "illegal panning value";} ! else if (speed < 0) {error = "illegal speed value";} ! if (error == NULL) { ! voice_set_volume(channels[channel].ass->voice, int(vol * (float(music_vol) / 255.0f))); ! //console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Adjusted channel parameters (%d, %d, %d, %d)", channel, vol, pan, speed); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error adjusting channel parameters (%s)", error); ! } ! } ! return 0; } /* get_number_of_channels() ! */ int l_get_number_of_channels(lua_State *L) { ! return putLuaArguments(L, "i", CHANNELS); } *************** *** 175,233 **** void poll_sound() { ! if (music_format != MUSIC_MIDI) { ! for (int i = 0; i < CHANNELS; i++) { ! if (channels[i].stream) { ! int ret = alogg_update_streaming(channels[i].stream); ! if (ret == 0) { ! // Loop song ! stop_music(i); ! channels[i].stream = alogg_start_streaming(channels[i].filename, BLOCK_SIZE); ! if (!channels[i].stream) { ! fprintf(stderr,"Error opening %s\n", channels[i].filename); ! alogg_exit(); ! exit(1); ! } ! channels[i].ass = alogg_get_audio_stream(channels[i].stream); ! break; ! } ! } ! } ! } } void stop_music(int channel) { ! /* ! if (channels[channel].voice) { ! deallocate_voice(channels[channel].voice); ! destroy_sample(channels[channel].sample); ! channels[channel].voice = 0; ! channels[channel].sample = NULL; ! } ! */ ! if (music_format != MUSIC_MIDI && channels[channel].stream) { ! alogg_stop_streaming(channels[channel].stream); ! channels[channel].stream = NULL; ! channels[channel].ass = NULL; ! } } /* stop_music(channel) ! */ int l_stop_music(lua_State *L) { ! int channel; ! getLuaArguments(L, "i", &channel); ! error = NULL; ! if (channel < 0 || channel >= CHANNELS) {error = "invalid channel";} ! if (error == NULL) { ! stop_music(channel); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error stopping music (%s)", error); ! } ! return 0; } --- 177,235 ---- void poll_sound() { ! if (music_format != MUSIC_MIDI) { ! for (int i = 0; i < CHANNELS; i++) { ! if (channels[i].stream) { ! int ret = alogg_update_streaming(channels[i].stream); ! if (ret == 0) { ! // Loop song ! stop_music(i); ! channels[i].stream = alogg_start_streaming(channels[i].filename, BLOCK_SIZE); ! if (!channels[i].stream) { ! fprintf(stderr,"Error opening %s\n", channels[i].filename); ! alogg_exit(); ! exit(1); ! } ! channels[i].ass = alogg_get_audio_stream(channels[i].stream); ! break; ! } ! } ! } ! } } void stop_music(int channel) { ! /* ! if (channels[channel].voice) { ! deallocate_voice(channels[channel].voice); ! destroy_sample(channels[channel].sample); ! channels[channel].voice = 0; ! channels[channel].sample = NULL; ! } ! */ ! if (music_format != MUSIC_MIDI && channels[channel].stream) { ! alogg_stop_streaming(channels[channel].stream); ! channels[channel].stream = NULL; ! channels[channel].ass = NULL; ! } } /* stop_music(channel) ! */ int l_stop_music(lua_State *L) { ! int channel; ! getLuaArguments(L, "i", &channel); ! error = NULL; ! if (channel < 0 || channel >= CHANNELS) {error = "invalid channel";} ! if (error == NULL) { ! stop_music(channel); ! } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error stopping music (%s)", error); ! } ! return 0; } *************** *** 236,257 **** /* play_sample(filename) ! */ int l_play_sample(lua_State *L) { ! char* name; ! getLuaArguments(L, "s", &name); ! if (sfx_enabled) { ! DATAFILE *found_object = find_datafile_object(bitmap_data, name); ! if (found_object) { ! console.log(CON_LOG, CON_ALWAYS, "Playing sample: %s", name); ! play_sample((SAMPLE*)found_object->dat, sfx_vol, 128, 1000, 0); ! } else { ! return luaL_error(L, "Error: Cannot find requested sample (%s)!", name); ! } ! } ! return 0; } --- 238,260 ---- /* play_sample(filename) ! */ int l_play_sample(lua_State *L) { ! char* name; ! getLuaArguments(L, "s", &name); ! if (sfx_enabled) { ! SAMPLE *sample = module->findSample(name); ! if (sample) { ! console.log(CON_LOG, CON_ALWAYS, "Playing sample: %s", name); ! play_sample(sample, sfx_vol, 128, 1000, 0); ! } else { ! return luaL_error(L, ! "Error: Cannot find requested sample (%s)!", name); ! } ! } ! return 0; } *************** *** 259,269 **** { #ifdef ENABLE_MUSIC ! for (int i = 0; i < CHANNELS; i++) { ! stop_music(i); ! } ! if (sound_enabled && music_format != MUSIC_MIDI) { ! alogg_exit(); ! } #endif } --- 262,272 ---- { #ifdef ENABLE_MUSIC ! for (int i = 0; i < CHANNELS; i++) { ! stop_music(i); ! } ! if (sound_enabled && music_format != MUSIC_MIDI) { ! alogg_exit(); ! } #endif } Index: script.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/script.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** script.h 1 Jan 2004 17:10:55 -0000 1.6 --- script.h 13 Apr 2004 12:26:08 -0000 1.7 *************** *** 26,30 **** ! //=================== The engine to script interface ============================/ void initScripting(); --- 26,30 ---- ! //============ The engine to script interface ============================/ void initScripting(); *************** *** 33,37 **** void handleLuaError(int err, const char *string); ! int callMemberFunction(int tableRef, const char *function, const char *argfmt = NULL, ...); int callFunction(const char *function, const char *argfmt = NULL, ...); --- 33,38 ---- void handleLuaError(int err, const char *string); ! int callMemberFunction( ! int tableRef, const char *function, const char *argfmt = NULL, ...); int callFunction(const char *function, const char *argfmt = NULL, ...); *************** *** 40,44 **** ! //=================== The script to engine interface ============================/ int l_alert(lua_State *L); --- 41,45 ---- ! //============ The script to engine interface ============================/ int l_alert(lua_State *L); *************** *** 75,78 **** --- 76,80 ---- int l_map_to_screen(lua_State *L); int l_get_tile_at(lua_State *L); + int l_set_tile_at(lua_State *L); int l_walk_obj(lua_State *L); *************** *** 91,95 **** ! //=================== Tag methods ====================================================/ int object_gettable(lua_State *L); --- 93,97 ---- ! //======= Tag methods ====================================================/ int object_gettable(lua_State *L); Index: rpg.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** rpg.h 9 Dec 2003 01:42:46 -0000 1.5 --- rpg.h 13 Apr 2004 12:26:08 -0000 1.6 *************** *** 16,19 **** --- 16,20 ---- #include "shared/engine.h" #include "shared/console.h" + #include "shared/module.h" #include <map> #include <allegro.h> *************** *** 30,34 **** extern DATAFILE *interface_graphics; ! extern DATAFILE *bitmap_data; extern int gameClassInstance; --- 31,35 ---- extern DATAFILE *interface_graphics; ! extern Module *module; extern int gameClassInstance; |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:40:08
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15068 Modified Files: Makefile.in configure rpg.cfg Log Message: Commiting engine changes to our beloved BBRpg on SourceForge. Index: Makefile.in =================================================================== RCS file: /cvsroot/moeng/BBRpg/Makefile.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile.in 7 Feb 2004 19:03:23 -0000 1.8 --- Makefile.in 13 Apr 2004 12:26:07 -0000 1.9 *************** *** 26,30 **** .PHONY: default remake clean ! default: $(ENGINE_EXE) $(EDITOR_EXE) data.dat remake: clean default --- 26,30 ---- .PHONY: default remake clean ! default: $(ENGINE_EXE) $(EDITOR_EXE) remake: clean default *************** *** 41,73 **** $(CC) $(CPPFLAGS) -o $(EDITOR_EXE) $(COMMON_OBJS) $(EDITOR_OBJS) $(COMMON_LIBS) ! # data.dat updater, vraagt de lijst vernieuwde datafiles op, loopt ze langs, kijkt waar ze bij horen ! # voegt ze toe aan de bij de groep behorende variabele en update dan de juiste groepen (door te ! # testen op niet lege variables data.dat: $(DATA_LUA) $(DATA_BMP) $(DATA_FONT) $(DATA_MAP) $(DATA_SAMPS) $(DATA_MIDIS) ! @list='$?'; \ ! for file in $$list; do \ ! if echo "$(DATA_LUA)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DELUAS="$$DELUAS $$file"; \ ! fi; \ ! if echo "$(DATA_BMP)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DEBMPS="$$DEBMPS $$file"; \ ! fi; \ ! if echo "$(DATA_FONT)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DEFONTS="$$DEFONTS $$file"; \ ! fi; \ ! if echo "$(DATA_MAP)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DEMAPS="$$DEMAPS $$file"; \ ! fi; \ ! if echo "$(DATA_SAMPS)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DESAMPS="$$DESAMPS $$file"; \ ! fi; \ ! if echo "$(DATA_MIDIS)" | grep "$$file" > /dev/null 2>/dev/null ; then \ ! DEMIDIS="$$DEMIDIS $$file"; \ ! fi; \ ! done;\ ! if test -n "$$DELUAS" ; then dat -a -k -t LUA data.dat $$DELUAS; fi; \ ! if test -n "$$DEBMPS" ; then dat -a -k -t BMP data.dat $$DEBMPS; fi; \ ! if test -n "$$DEFONTS" ; then dat -a -k -t FONT data.dat $$DEFONTS; fi; \ ! if test -n "$$DEMAPS" ; then dat -a -k -t MAP data.dat $$DEMAPS; fi; \ ! if test -n "$$DESAMPS" ; then dat -a -k -t SAMP data.dat $$DESAMPS; fi; \ ! if test -n "$$DEMIDIS" ; then dat -a -k -t MIDI data.dat $$DEMIDIS; fi; \ --- 41,52 ---- $(CC) $(CPPFLAGS) -o $(EDITOR_EXE) $(COMMON_OBJS) $(EDITOR_OBJS) $(COMMON_LIBS) ! # Recreate data.dat data.dat: $(DATA_LUA) $(DATA_BMP) $(DATA_FONT) $(DATA_MAP) $(DATA_SAMPS) $(DATA_MIDIS) ! rm -vf data.dat ! dat -a -t BMP -c0 -k data.dat data/bitmaps/*.bmp ! dat -a -t BMP -c0 -k data.dat data/bitmaps/*.tga ! dat -a -t FONT -c0 -k data.dat data/bitmaps/font_*.pcx ! dat -a -t LUA -c0 -k data.dat data/scripts/*.lua ! dat -a -t MAP -c0 -k data.dat data/maps/*.map ! dat -a -t SAMP -c0 -k data.dat data/samples/*.wav ! if test -n "$$DATA_MIDIS"; then dat -a -t MIDI -c0 -k data.dat $$DEMIDIS; fi; Index: rpg.cfg =================================================================== RCS file: /cvsroot/moeng/BBRpg/rpg.cfg,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rpg.cfg 13 Jan 2004 16:32:34 -0000 1.7 --- rpg.cfg 13 Apr 2004 12:26:07 -0000 1.8 *************** *** 8,12 **** [Video] Fullscreen=0 ! DoubleSize=1 VSync=0 ResolutionWidth=320 --- 8,12 ---- [Video] Fullscreen=0 ! DoubleSize=0 VSync=0 ResolutionWidth=320 Index: configure =================================================================== RCS file: /cvsroot/moeng/BBRpg/configure,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** configure 13 Jan 2004 16:32:34 -0000 1.12 --- configure 13 Apr 2004 12:26:07 -0000 1.13 *************** *** 4,10 **** CC=g++ ! LIBS= LIBS_ENGINE= ! CPPFLAGS=-Wall # on windows set EXE_EXT to '.exe' EXE_EXT= --- 4,10 ---- CC=g++ ! LIBS="`pkg-config --libs libxml-2.0`" LIBS_ENGINE= ! CPPFLAGS="-Wall `pkg-config --cflags libxml-2.0`" # on windows set EXE_EXT to '.exe' EXE_EXT= *************** *** 97,107 **** echo "allegro-config --version" >>$LOGERR if allegro-config --version >>$LOG 2>>$LOGERR ; then ! LIBS="$LIBS `allegro-config --libs`" ! CPPFLAGS="$CPPFLAGS `allegro-config --cppflags`" ! echo "yes" else echo "no" echo "*** No allegro-config found. Please add the right directory to PATH or install allegro" ! echo "using -lalleg instead" LIBS="$LIBS -lalleg" fi --- 97,117 ---- echo "allegro-config --version" >>$LOGERR if allegro-config --version >>$LOG 2>>$LOGERR ; then ! allegro_version_major=`allegro-config --version | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` ! allegro_version_minor=`allegro-config --version | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` ! allegro_version_micro=`allegro-config --version | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` ! # version check ! if test "$allegro_version_major" -ge "4" -a "$allegro_version_minor" -ge "1" ; then ! LIBS="$LIBS `allegro-config --libs`" ! CPPFLAGS="$CPPFLAGS `allegro-config --cppflags`" ! echo "yes ($allegro_version_major.$allegro_version_minor.$allegro_version_micro)" ! else ! echo "found" ! echo "*** Allegro version to old. required: 4.1.0 or higher." ! exit 1; ! fi else echo "no" echo "*** No allegro-config found. Please add the right directory to PATH or install allegro" ! echo "Trying -lalleg instead" LIBS="$LIBS -lalleg" fi *************** *** 131,135 **** else echo "no" ! echo "*** Allegro not working" exit 1 fi --- 141,146 ---- else echo "no" ! echo "*** Compiling of Allegro program failed" ! echo "*** Please install Allegro. http://alleg.sourceforge.net/" exit 1 fi |
From: Bj?rn L. <b_l...@us...> - 2004-04-13 12:40:08
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15068/data/scripts Modified Files: BloodSplat.lua Cells.lua City.lua ConversationWindow.lua GuiTheme.lua Jail.lua JakesPlace.lua LanguageMenu.lua LeesPlace.lua RestPlace.lua Sewers.lua Log Message: Commiting engine changes to our beloved BBRpg on SourceForge. Index: City.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/City.lua,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** City.lua 13 Jan 2004 16:32:35 -0000 1.19 --- City.lua 13 Apr 2004 12:26:08 -0000 1.20 *************** *** 12,16 **** local obj; ! Map.init(self, "data/maps/city1.map") -- Spawn the walkie talkie. Needed by the addToInventory function. --- 12,16 ---- local obj; ! Map.init(self, "city1.map") -- Spawn the walkie talkie. Needed by the addToInventory function. Index: Cells.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Cells.lua,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Cells.lua 13 Jan 2004 16:32:35 -0000 1.16 --- Cells.lua 13 Apr 2004 12:26:08 -0000 1.17 *************** *** 12,16 **** local obj ! Map.init(self, "data/maps/cells.map") -- Dummy used for the cameratarget in the arena. --- 12,16 ---- local obj ! Map.init(self, "cells.map") -- Dummy used for the cameratarget in the arena. Index: Sewers.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Sewers.lua,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Sewers.lua 7 Feb 2004 18:30:01 -0000 1.18 --- Sewers.lua 13 Apr 2004 12:26:08 -0000 1.19 *************** *** 13,17 **** local obj; ! Map.init(self, "data/maps/sewers1.map") self:spawn(WallAndTube, 54, 47); --- 13,17 ---- local obj; ! Map.init(self, "sewers1.map") self:spawn(WallAndTube, 54, 47); Index: ConversationWindow.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/ConversationWindow.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConversationWindow.lua 13 Jan 2004 16:32:35 -0000 1.4 --- ConversationWindow.lua 13 Apr 2004 12:26:08 -0000 1.5 *************** *** 157,160 **** --- 157,164 ---- local length = string.len(current_string) + if (self.quickFinish) then + self.curr_char = length + end + if (self.curr_char < length) then self.curr_char = self.curr_char + 0.5 *************** *** 165,168 **** --- 169,173 ---- self.state = CB_READY else + self.quickFinish = self.defaultproperties.quickFinish self:set_state(CB_WAITING) end *************** *** 188,199 **** keyType = function(self, key) ! if (key == "action" and self.state == CB_WAITING) then ! if (self.continue) then ! -- Scroll up ! self.state = CB_SCROLLING ! else ! self.state = CB_READY end - return true end return false --- 193,209 ---- keyType = function(self, key) ! if (key == "action") then ! if (self.state == CB_WAITING) then ! if (self.continue) then ! -- Scroll up ! self.state = CB_SCROLLING ! else ! self.state = CB_READY ! end ! return true ! end ! if (self.state == CB_WRITING) then ! self.quickFinish = true end end return false *************** *** 282,285 **** --- 292,296 ---- height = 0, appear_time = 15, + quickFinish = true, }; } Index: Jail.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/Jail.lua,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Jail.lua 2 Jan 2004 04:49:53 -0000 1.7 --- Jail.lua 13 Apr 2004 12:26:08 -0000 1.8 *************** *** 12,16 **** local obj ! Map.init(self, "data/maps/jail.map") self:spawn(Table, 22, 16); --- 12,16 ---- local obj ! Map.init(self, "jail.map") self:spawn(Table, 22, 16); Index: RestPlace.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/RestPlace.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RestPlace.lua 13 Jan 2004 16:32:35 -0000 1.5 --- RestPlace.lua 13 Apr 2004 12:26:08 -0000 1.6 *************** *** 10,14 **** init = function(self) ! Map.init(self, "data/maps/restplace.map") -- Spawn portals --- 10,14 ---- init = function(self) ! Map.init(self, "restplace.map") -- Spawn portals Index: JakesPlace.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/JakesPlace.lua,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JakesPlace.lua 8 Feb 2004 14:53:59 -0000 1.7 --- JakesPlace.lua 13 Apr 2004 12:26:08 -0000 1.8 *************** *** 10,14 **** init = function(self) ! Map.init(self, "data/maps/jakesplace.map") -- Spawn portals --- 10,14 ---- init = function(self) ! Map.init(self, "jakesplace.map") -- Spawn portals Index: BloodSplat.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/BloodSplat.lua,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BloodSplat.lua 7 Dec 2003 02:17:16 -0000 1.1.1.1 --- BloodSplat.lua 13 Apr 2004 12:26:08 -0000 1.2 *************** *** 3,6 **** --- 3,10 ---- -- + import("Actor.lua") + import("AnimationFunctions.lua") + + BloodSplat = Actor:subclass { Index: LeesPlace.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/LeesPlace.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LeesPlace.lua 13 Jan 2004 16:32:35 -0000 1.4 --- LeesPlace.lua 13 Apr 2004 12:26:08 -0000 1.5 *************** *** 10,14 **** init = function(self) ! Map.init(self, "data/maps/leesplace.map") -- Spawn portals --- 10,14 ---- init = function(self) ! Map.init(self, "leesplace.map") -- Spawn portals Index: GuiTheme.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/GuiTheme.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuiTheme.lua 2 Jan 2004 02:49:56 -0000 1.6 --- GuiTheme.lua 13 Apr 2004 12:26:08 -0000 1.7 *************** *** 45,49 **** -- The actual box ! m_set_alpha(128) self:drawBoxEx( self.bg, --- 45,49 ---- -- The actual box ! m_set_alpha(192) self:drawBoxEx( self.bg, *************** *** 59,63 **** self.canvas:setDrawMode(DM_TRANS) ! local alpha = m_set_alpha(128) self:drawBoxEx( self.bg, --- 59,63 ---- self.canvas:setDrawMode(DM_TRANS) ! local alpha = m_set_alpha(192) self:drawBoxEx( self.bg, Index: LanguageMenu.lua =================================================================== RCS file: /cvsroot/moeng/BBRpg/data/scripts/LanguageMenu.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LanguageMenu.lua 3 Jan 2004 20:08:34 -0000 1.2 --- LanguageMenu.lua 13 Apr 2004 12:26:08 -0000 1.3 *************** *** 1,4 **** --- 1,7 ---- -- A menu to choose your language + import("GuiMenu.lua") + + LanguageMenu = GuiMenu:subclass { *************** *** 35,37 **** defaultproperties = { }; ! } \ No newline at end of file --- 38,40 ---- defaultproperties = { }; ! } |