runtime/lib: C++ify
This commit is contained in:
@@ -34,9 +34,6 @@ add_library(${PROJECT_NAME} STATIC
|
||||
# "multiplay_setup.hpp"
|
||||
# "multiplay_setup.rc"
|
||||
"resource.hpp"
|
||||
"runtime.cpp"
|
||||
"std.cpp"
|
||||
"std.hpp"
|
||||
# "userlib.cpp"
|
||||
# "userlib.hpp"
|
||||
"userlibs.cpp"
|
||||
@@ -44,13 +41,12 @@ add_library(${PROJECT_NAME} STATIC
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
stdutil
|
||||
runtime_gfx
|
||||
ddraw
|
||||
dsound
|
||||
dxguid
|
||||
mswsock
|
||||
stdutil
|
||||
runtime_gfx
|
||||
ddraw
|
||||
dsound
|
||||
dxguid
|
||||
wsock32
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
||||
+16
-14
@@ -1,5 +1,7 @@
|
||||
#include "bbsys.hpp"
|
||||
#include "std.hpp"
|
||||
#include <map>
|
||||
|
||||
#include <stdutil.hpp>
|
||||
|
||||
//how many strings allocated
|
||||
static int stringCnt;
|
||||
@@ -29,8 +31,8 @@ static BBStr usedStrs, freeStrs;
|
||||
static int next_handle;
|
||||
|
||||
//object<->handle maps
|
||||
static map<int, BBObj*> handle_map;
|
||||
static map<BBObj*, int> object_map;
|
||||
static std::map<int, BBObj*> handle_map;
|
||||
static std::map<BBObj*, int> object_map;
|
||||
|
||||
static BBType _bbIntType(BBTYPE_INT);
|
||||
static BBType _bbFltType(BBTYPE_FLT);
|
||||
@@ -99,41 +101,41 @@ BBStr::BBStr()
|
||||
++stringCnt;
|
||||
}
|
||||
|
||||
BBStr::BBStr(const char* s) : string(s)
|
||||
BBStr::BBStr(const char* s) : std::string(s)
|
||||
{
|
||||
++stringCnt;
|
||||
}
|
||||
|
||||
BBStr::BBStr(const char* s, int n) : string(s, n)
|
||||
BBStr::BBStr(const char* s, int n) : std::string(s, n)
|
||||
{
|
||||
++stringCnt;
|
||||
}
|
||||
|
||||
BBStr::BBStr(const BBStr& s) : string(s)
|
||||
BBStr::BBStr(const BBStr& s) : std::string(s)
|
||||
{
|
||||
++stringCnt;
|
||||
}
|
||||
|
||||
BBStr::BBStr(const string& s) : string(s)
|
||||
BBStr::BBStr(const std::string& s) : std::string(s)
|
||||
{
|
||||
++stringCnt;
|
||||
}
|
||||
|
||||
BBStr& BBStr::operator=(const char* s)
|
||||
{
|
||||
string::operator=(s);
|
||||
std::string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BBStr& BBStr::operator=(const BBStr& s)
|
||||
{
|
||||
string::operator=(s);
|
||||
std::string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BBStr& BBStr::operator=(const string& s)
|
||||
BBStr& BBStr::operator=(const std::string& s)
|
||||
{
|
||||
string::operator=(s);
|
||||
std::string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -338,7 +340,7 @@ void _bbObjDelete(BBObj* obj)
|
||||
break;
|
||||
}
|
||||
}
|
||||
map<BBObj*, int>::iterator it = object_map.find(obj);
|
||||
std::map<BBObj*, int>::iterator it = object_map.find(obj);
|
||||
if (it != object_map.end()) {
|
||||
handle_map.erase(it->second);
|
||||
object_map.erase(it);
|
||||
@@ -514,7 +516,7 @@ int _bbObjToHandle(BBObj* obj)
|
||||
{
|
||||
if (!obj || !obj->fields)
|
||||
return 0;
|
||||
map<BBObj*, int>::const_iterator it = object_map.find(obj);
|
||||
std::map<BBObj*, int>::const_iterator it = object_map.find(obj);
|
||||
if (it != object_map.end())
|
||||
return it->second;
|
||||
++next_handle;
|
||||
@@ -525,7 +527,7 @@ int _bbObjToHandle(BBObj* obj)
|
||||
|
||||
BBObj* _bbObjFromHandle(int handle, BBObjType* type)
|
||||
{
|
||||
map<int, BBObj*>::const_iterator it = handle_map.find(handle);
|
||||
std::map<int, BBObj*>::const_iterator it = handle_map.find(handle);
|
||||
if (it == handle_map.end())
|
||||
return 0;
|
||||
BBObj* obj = it->second;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef BASIC_H
|
||||
#define BASIC_H
|
||||
|
||||
#pragma once
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@@ -155,5 +152,3 @@ float _bbFMod(float x, float y);
|
||||
float _bbFPow(float x, float y);
|
||||
|
||||
void bbRuntimeStats();
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
enum {
|
||||
BBTYPE_END = 0,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
#include "bbaudio.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxchannel.hpp>
|
||||
#include <gxsound.hpp>
|
||||
|
||||
gxAudio* gx_audio;
|
||||
|
||||
#ifdef _DEBUG
|
||||
static inline void debugSound(gxSound* s)
|
||||
{
|
||||
if (debug) {
|
||||
@@ -11,17 +13,20 @@ static inline void debugSound(gxSound* s)
|
||||
ThrowRuntimeException("Sound does not exist");
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define debugSound
|
||||
#endif
|
||||
|
||||
static gxSound* loadSound(BBStr* f, bool use_3d)
|
||||
{
|
||||
string t = *f;
|
||||
std::string t = *f;
|
||||
delete f;
|
||||
return gx_audio ? gx_audio->loadSound(t, use_3d) : 0;
|
||||
}
|
||||
|
||||
static gxChannel* playMusic(BBStr* f, bool use_3d)
|
||||
{
|
||||
string t = *f;
|
||||
std::string t = *f;
|
||||
delete f;
|
||||
return gx_audio ? gx_audio->playFile(t, use_3d) : 0;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#ifndef BBAUDIO_H
|
||||
#define BBAUDIO_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
#include "gxaudio.hpp"
|
||||
|
||||
#include <gxaudio.hpp>
|
||||
|
||||
extern gxAudio* gx_audio;
|
||||
|
||||
@@ -23,5 +21,3 @@ void bbChannelPitch(gxChannel* channel, int pitch);
|
||||
void bbChannelVolume(gxChannel* channel, float volume);
|
||||
void bbChannelPan(gxChannel* channel, float pan);
|
||||
int bbChannelPlaying(gxChannel* channel);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#include "bbbank.hpp"
|
||||
#include <set>
|
||||
#include "bbstream.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
struct bbBank {
|
||||
char* data;
|
||||
@@ -36,8 +35,9 @@ struct bbBank {
|
||||
}
|
||||
};
|
||||
|
||||
static set<bbBank*> bank_set;
|
||||
static std::set<bbBank*> bank_set;
|
||||
|
||||
#ifdef _DEBUG
|
||||
static inline void debugBank(bbBank* b)
|
||||
{
|
||||
if (debug) {
|
||||
@@ -54,6 +54,9 @@ static inline void debugBank(bbBank* b, int offset)
|
||||
ThrowRuntimeException("Offset out of range");
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define debugBank
|
||||
#endif
|
||||
|
||||
bbBank* bbCreateBank(int size)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
|
||||
#ifndef BBBANK_H
|
||||
#define BBBANK_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
|
||||
#endif
|
||||
+24
-25
@@ -1,26 +1,25 @@
|
||||
|
||||
#include "std.hpp"
|
||||
|
||||
#include "../blitz3d/blitz3d.hpp"
|
||||
#include "../blitz3d/brush.hpp"
|
||||
#include "../blitz3d/camera.hpp"
|
||||
#include "../blitz3d/meshmodel.hpp"
|
||||
#include "../blitz3d/sprite.hpp"
|
||||
#include "../blitz3d/texture.hpp"
|
||||
#include "../blitz3d/world.hpp"
|
||||
#include "bbblitz3d.hpp"
|
||||
#include "bbgraphics.hpp"
|
||||
//#include "../blitz3d/loader_x.hpp"
|
||||
#include <set>
|
||||
#include "../blitz3d/animator.hpp"
|
||||
#include "../blitz3d/brush.hpp"
|
||||
#include "../blitz3d/cachedtexture.hpp"
|
||||
#include "../blitz3d/camera.hpp"
|
||||
#include "../blitz3d/listener.hpp"
|
||||
#include "../blitz3d/loader_3ds.hpp"
|
||||
#include "../blitz3d/loader_b3d.hpp"
|
||||
#include "../blitz3d/md2model.hpp"
|
||||
#include "../blitz3d/meshmodel.hpp"
|
||||
#include "../blitz3d/meshutil.hpp"
|
||||
#include "../blitz3d/pivot.hpp"
|
||||
#include "../blitz3d/planemodel.hpp"
|
||||
#include "../blitz3d/q3bspmodel.hpp"
|
||||
#include "../blitz3d/sprite.hpp"
|
||||
#include "../blitz3d/terrain.hpp"
|
||||
#include "../blitz3d/texture.hpp"
|
||||
#include "../blitz3d/world.hpp"
|
||||
#include "bbgraphics.hpp"
|
||||
|
||||
#include <stdutil.hpp>
|
||||
|
||||
gxScene* gx_scene;
|
||||
extern gxFileSystem* gx_filesys;
|
||||
@@ -28,9 +27,9 @@ extern gxFileSystem* gx_filesys;
|
||||
static int tri_count;
|
||||
static World* world;
|
||||
|
||||
static set<Brush*> brush_set;
|
||||
static set<Texture*> texture_set;
|
||||
static set<Entity*> entity_set;
|
||||
static std::set<Brush*> brush_set;
|
||||
static std::set<Texture*> texture_set;
|
||||
static std::set<Entity*> entity_set;
|
||||
|
||||
static Listener* listener;
|
||||
|
||||
@@ -53,7 +52,7 @@ extern float stats3d[10];
|
||||
static Loader_3DS loader_3ds;
|
||||
static Loader_B3D loader_b3d;
|
||||
|
||||
static map<string, Transform> loader_mat_map;
|
||||
static std::map<std::string, Transform> loader_mat_map;
|
||||
|
||||
#ifdef _DEBUG
|
||||
static inline void debug3d()
|
||||
@@ -192,13 +191,13 @@ static inline void debugVertex(Surface* s, int n, int t)
|
||||
}
|
||||
#endif
|
||||
|
||||
static Entity* loadEntity(string t, int hint)
|
||||
static Entity* loadEntity(std::string t, int hint)
|
||||
{
|
||||
t = tolower(t);
|
||||
int n = t.rfind(".");
|
||||
if (n == string::npos)
|
||||
if (n == std::string::npos)
|
||||
return 0;
|
||||
string ext = t.substr(n + 1);
|
||||
std::string ext = t.substr(n + 1);
|
||||
MeshLoader* l;
|
||||
|
||||
if (ext == "x") {
|
||||
@@ -213,9 +212,9 @@ static Entity* loadEntity(string t, int hint)
|
||||
|
||||
const Transform& conv = loader_mat_map[ext];
|
||||
|
||||
CachedTextureFactory::setPath(filenamepath(t));
|
||||
CachedTexture::setPath(filenamepath(t));
|
||||
Entity* e = l->load(t, conv, hint);
|
||||
CachedTextureFactory::setPath("");
|
||||
CachedTexture::setPath("");
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -267,7 +266,7 @@ static void erase(Entity* e)
|
||||
#endif
|
||||
}
|
||||
|
||||
static Entity* findChild(Entity* e, const string& t)
|
||||
static Entity* findChild(Entity* e, const std::string& t)
|
||||
{
|
||||
if (e->getName() == t)
|
||||
return e;
|
||||
@@ -586,7 +585,7 @@ BBStr* bbTextureName(Texture* t)
|
||||
#ifdef _DEBUG
|
||||
debugTexture(t);
|
||||
#endif
|
||||
CachedTextureFactory* c = t->getCachedTexture();
|
||||
CachedTexture* c = t->getCachedTexture();
|
||||
return c ? new BBStr(c->getName().c_str()) : new BBStr("");
|
||||
}
|
||||
|
||||
@@ -1722,10 +1721,10 @@ Entity* bbLoadBSP(BBStr* file, float gam, Entity* p)
|
||||
#ifdef _DEBUG
|
||||
debugParent(p);
|
||||
#endif
|
||||
CachedTextureFactory::setPath(filenamepath(*file));
|
||||
CachedTexture::setPath(filenamepath(*file));
|
||||
Q3BSPModel* t = new Q3BSPModel(*file, gam);
|
||||
delete file;
|
||||
CachedTextureFactory::setPath("");
|
||||
CachedTexture::setPath("");
|
||||
|
||||
if (!t->isValid()) {
|
||||
delete t;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
|
||||
#ifndef BBBLITZ3D_H
|
||||
#define BBBLITZ3D_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
#include "gxscene.hpp"
|
||||
#include <gxscene.hpp>
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
|
||||
#include "bbfilesystem.hpp"
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include "bbstream.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
gxFileSystem* gx_filesys;
|
||||
|
||||
struct bbFile : public bbStream {
|
||||
filebuf* buf;
|
||||
bbFile(filebuf* f) : buf(f) {}
|
||||
std::filebuf* buf;
|
||||
bbFile(std::filebuf* f) : buf(f) {}
|
||||
~bbFile()
|
||||
{
|
||||
delete buf;
|
||||
@@ -31,7 +30,7 @@ struct bbFile : public bbStream {
|
||||
}
|
||||
};
|
||||
|
||||
static set<bbFile*> file_set;
|
||||
static std::set<bbFile*> file_set;
|
||||
|
||||
static inline void debugFile(bbFile* f)
|
||||
{
|
||||
@@ -51,9 +50,9 @@ static inline void debugDir(gxDir* d)
|
||||
|
||||
static bbFile* open(BBStr* file_path, int flags)
|
||||
{
|
||||
string t = *file_path;
|
||||
filebuf* buf = new filebuf();
|
||||
if (buf->open(t.c_str(), flags | ios_base::binary)) {
|
||||
std::string t = *file_path;
|
||||
std::filebuf* buf = new std::filebuf();
|
||||
if (buf->open(t.c_str(), flags | std::ios_base::binary)) {
|
||||
bbFile* file = new bbFile(buf);
|
||||
file_set.insert(file);
|
||||
return file;
|
||||
@@ -64,17 +63,17 @@ static bbFile* open(BBStr* file_path, int flags)
|
||||
|
||||
bbFile* bbReadFile(BBStr* f)
|
||||
{
|
||||
return open(f, ios_base::in);
|
||||
return open(f, std::ios_base::in);
|
||||
}
|
||||
|
||||
bbFile* bbWriteFile(BBStr* f)
|
||||
{
|
||||
return open(f, ios_base::out | ios_base::trunc);
|
||||
return open(f, std::ios_base::out | std::ios_base::trunc);
|
||||
}
|
||||
|
||||
bbFile* bbOpenFile(BBStr* f)
|
||||
{
|
||||
return open(f, ios_base::in | ios_base::out);
|
||||
return open(f, std::ios_base::in | std::ios_base::out);
|
||||
}
|
||||
|
||||
void bbCloseFile(bbFile* f)
|
||||
@@ -86,17 +85,17 @@ void bbCloseFile(bbFile* f)
|
||||
|
||||
int bbFilePos(bbFile* f)
|
||||
{
|
||||
return f->buf->pubseekoff(0, ios_base::cur);
|
||||
return f->buf->pubseekoff(0, std::ios_base::cur);
|
||||
}
|
||||
|
||||
int bbSeekFile(bbFile* f, int pos)
|
||||
{
|
||||
return f->buf->pubseekoff(pos, ios_base::beg);
|
||||
return f->buf->pubseekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
|
||||
gxDir* bbReadDir(BBStr* d)
|
||||
{
|
||||
string t = *d;
|
||||
std::string t = *d;
|
||||
delete d;
|
||||
return gx_filesys->openDir(t, 0);
|
||||
}
|
||||
@@ -137,7 +136,7 @@ void bbDeleteDir(BBStr* d)
|
||||
|
||||
int bbFileType(BBStr* f)
|
||||
{
|
||||
string t = *f;
|
||||
std::string t = *f;
|
||||
delete f;
|
||||
int n = gx_filesys->getFileType(t);
|
||||
return n == gxFileSystem::FILE_TYPE_FILE ? 1 : (n == gxFileSystem::FILE_TYPE_DIR ? 2 : 0);
|
||||
@@ -145,14 +144,14 @@ int bbFileType(BBStr* f)
|
||||
|
||||
int bbFileSize(BBStr* f)
|
||||
{
|
||||
string t = *f;
|
||||
std::string t = *f;
|
||||
delete f;
|
||||
return gx_filesys->getFileSize(t);
|
||||
}
|
||||
|
||||
void bbCopyFile(BBStr* f, BBStr* to)
|
||||
{
|
||||
string src = *f, dest = *to;
|
||||
std::string src = *f, dest = *to;
|
||||
delete f;
|
||||
delete to;
|
||||
gx_filesys->copyFile(src, dest);
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
|
||||
#ifndef BBFILESYSTEM_H
|
||||
#define BBFILESYSTEM_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
#include "gxfilesystem.hpp"
|
||||
|
||||
#include <gxfilesystem.hpp>
|
||||
|
||||
extern gxFileSystem* gx_filesys;
|
||||
|
||||
#endif
|
||||
+30
-29
@@ -1,7 +1,8 @@
|
||||
|
||||
#include "bbgraphics.hpp"
|
||||
#include "bbinput.hpp"
|
||||
#include "std.hpp"
|
||||
#include <fstream>
|
||||
|
||||
#include <gxmovie.hpp>
|
||||
|
||||
gxGraphics* gx_graphics;
|
||||
gxCanvas* gx_canvas;
|
||||
@@ -12,14 +13,14 @@ struct GfxMode {
|
||||
|
||||
class bbImage {
|
||||
public:
|
||||
bbImage(const vector<gxCanvas*>& f) : frames(f) {}
|
||||
bbImage(const std::vector<gxCanvas*>& f) : frames(f) {}
|
||||
~bbImage()
|
||||
{
|
||||
for (int k = 0; k < frames.size(); ++k) {
|
||||
gx_graphics->freeCanvas(frames[k]);
|
||||
}
|
||||
}
|
||||
const vector<gxCanvas*>& getFrames() const
|
||||
const std::vector<gxCanvas*>& getFrames() const
|
||||
{
|
||||
return frames;
|
||||
}
|
||||
@@ -30,7 +31,7 @@ class bbImage {
|
||||
}
|
||||
|
||||
private:
|
||||
vector<gxCanvas*> frames;
|
||||
std::vector<gxCanvas*> frames;
|
||||
};
|
||||
|
||||
//degrees to radians
|
||||
@@ -41,7 +42,7 @@ static int gx_driver; //current graphics driver
|
||||
static bool filter;
|
||||
static bool auto_dirty;
|
||||
static bool auto_midhandle;
|
||||
static set<bbImage*> image_set;
|
||||
static std::set<bbImage*> image_set;
|
||||
static int curs_x, curs_y;
|
||||
static gxCanvas* p_canvas;
|
||||
|
||||
@@ -49,7 +50,7 @@ static gxFont* curr_font;
|
||||
static unsigned curr_color;
|
||||
static unsigned curr_clsColor;
|
||||
|
||||
static vector<GfxMode> gfx_modes;
|
||||
static std::vector<GfxMode> gfx_modes;
|
||||
|
||||
#ifdef _DEBUG
|
||||
static inline void debugImage(bbImage* i, int frame = 0)
|
||||
@@ -234,9 +235,9 @@ static gxCanvas* tformCanvas(gxCanvas* c, float m[2][2], int x_handle, int y_han
|
||||
return t;
|
||||
}
|
||||
|
||||
static bool saveCanvas(gxCanvas* c, const string& f)
|
||||
static bool saveCanvas(gxCanvas* c, const std::string& f)
|
||||
{
|
||||
ofstream out(f.c_str(), ios::binary);
|
||||
std::ofstream out(f.c_str(), std::ios::binary);
|
||||
if (!out.good())
|
||||
return false;
|
||||
|
||||
@@ -286,7 +287,7 @@ int bbCountGfxDrivers()
|
||||
BBStr* bbGfxDriverName(int n)
|
||||
{
|
||||
debugDriver(n);
|
||||
string t;
|
||||
std::string t;
|
||||
int caps;
|
||||
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
||||
return new BBStr(t);
|
||||
@@ -351,7 +352,7 @@ int bbGfxModeExists(int w, int h, int d)
|
||||
int bbGfxDriver3D(int n)
|
||||
{
|
||||
debugDriver(n);
|
||||
string t;
|
||||
std::string t;
|
||||
int caps;
|
||||
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
||||
return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0;
|
||||
@@ -441,7 +442,7 @@ gxCanvas* bbGraphicsBuffer()
|
||||
int bbLoadBuffer(gxCanvas* c, BBStr* str)
|
||||
{
|
||||
debugCanvas(c);
|
||||
string s = *str;
|
||||
std::string s = *str;
|
||||
delete str;
|
||||
gxCanvas* t = gx_graphics->loadCanvas(s, 0);
|
||||
if (!t)
|
||||
@@ -463,7 +464,7 @@ int bbLoadBuffer(gxCanvas* c, BBStr* str)
|
||||
int bbSaveBuffer(gxCanvas* c, BBStr* str)
|
||||
{
|
||||
debugCanvas(c);
|
||||
string t = *str;
|
||||
std::string t = *str;
|
||||
delete str;
|
||||
return saveCanvas(c, t) ? 1 : 0;
|
||||
}
|
||||
@@ -827,7 +828,7 @@ int bbFontHeight()
|
||||
|
||||
int bbStringWidth(BBStr* str)
|
||||
{
|
||||
string t = *str;
|
||||
std::string t = *str;
|
||||
delete str;
|
||||
return curr_font->getWidth(t);
|
||||
}
|
||||
@@ -879,7 +880,7 @@ void bbCloseMovie(gxMovie* movie)
|
||||
|
||||
bbImage* bbLoadImage(BBStr* s)
|
||||
{
|
||||
string t = *s;
|
||||
std::string t = *s;
|
||||
delete s;
|
||||
gxCanvas* c = gx_graphics->loadCanvas(t, 0);
|
||||
if (!c)
|
||||
@@ -888,7 +889,7 @@ bbImage* bbLoadImage(BBStr* s)
|
||||
c->backup();
|
||||
if (auto_midhandle)
|
||||
c->setHandle(c->getWidth() / 2, c->getHeight() / 2);
|
||||
vector<gxCanvas*> frames;
|
||||
std::vector<gxCanvas*> frames;
|
||||
frames.push_back(c);
|
||||
bbImage* i = new bbImage(frames);
|
||||
image_set.insert(i);
|
||||
@@ -897,7 +898,7 @@ bbImage* bbLoadImage(BBStr* s)
|
||||
|
||||
bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
||||
{
|
||||
string t = *s;
|
||||
std::string t = *s;
|
||||
delete s;
|
||||
|
||||
if (cnt < 1)
|
||||
@@ -918,7 +919,7 @@ bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
||||
}
|
||||
|
||||
//x,y of first frame...
|
||||
vector<gxCanvas*> frames;
|
||||
std::vector<gxCanvas*> frames;
|
||||
int src_x = first % fpr * w, src_y = first / fpr * h;
|
||||
|
||||
for (int k = 0; k < cnt; ++k) {
|
||||
@@ -950,8 +951,8 @@ bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
||||
bbImage* bbCopyImage(bbImage* i)
|
||||
{
|
||||
debugImage(i);
|
||||
vector<gxCanvas*> frames;
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
std::vector<gxCanvas*> frames;
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
for (int k = 0; k < f.size(); ++k) {
|
||||
gxCanvas* t = f[k];
|
||||
gxCanvas* c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0);
|
||||
@@ -978,7 +979,7 @@ bbImage* bbCopyImage(bbImage* i)
|
||||
|
||||
bbImage* bbCreateImage(int w, int h, int n)
|
||||
{
|
||||
vector<gxCanvas*> frames;
|
||||
std::vector<gxCanvas*> frames;
|
||||
for (int k = 0; k < n; ++k) {
|
||||
gxCanvas* c = gx_graphics->createCanvas(w, h, 0);
|
||||
if (!c) {
|
||||
@@ -1001,7 +1002,7 @@ void bbFreeImage(bbImage* i)
|
||||
{
|
||||
if (!image_set.erase(i))
|
||||
return;
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
for (int k = 0; k < f.size(); ++k) {
|
||||
if (f[k] == gx_canvas) {
|
||||
bbSetBuffer(gx_graphics->getFrontCanvas());
|
||||
@@ -1014,7 +1015,7 @@ void bbFreeImage(bbImage* i)
|
||||
int bbSaveImage(bbImage* i, BBStr* str, int n)
|
||||
{
|
||||
debugImage(i, n);
|
||||
string t = *str;
|
||||
std::string t = *str;
|
||||
delete str;
|
||||
gxCanvas* c = i->getFrames()[n];
|
||||
return saveCanvas(c, t) ? 1 : 0;
|
||||
@@ -1110,7 +1111,7 @@ void bbMaskImage(bbImage* i, int r, int g, int b)
|
||||
{
|
||||
debugImage(i);
|
||||
unsigned argb = (r << 16) | (g << 8) | b;
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
for (int k = 0; k < f.size(); ++k)
|
||||
f[k]->setMask(argb);
|
||||
}
|
||||
@@ -1118,7 +1119,7 @@ void bbMaskImage(bbImage* i, int r, int g, int b)
|
||||
void bbHandleImage(bbImage* i, int x, int y)
|
||||
{
|
||||
debugImage(i);
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
for (int k = 0; k < f.size(); ++k)
|
||||
f[k]->setHandle(x, y);
|
||||
}
|
||||
@@ -1126,7 +1127,7 @@ void bbHandleImage(bbImage* i, int x, int y)
|
||||
void bbMidHandle(bbImage* i)
|
||||
{
|
||||
debugImage(i);
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
for (int k = 0; k < f.size(); ++k)
|
||||
f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2);
|
||||
}
|
||||
@@ -1206,7 +1207,7 @@ int bbImageRectCollide(bbImage* i, int x, int y, int f, int x2, int y2, int w2,
|
||||
void bbTFormImage(bbImage* i, float a, float b, float c, float d)
|
||||
{
|
||||
debugImage(i);
|
||||
const vector<gxCanvas*>& f = i->getFrames();
|
||||
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||
int k;
|
||||
for (k = 0; k < f.size(); ++k) {
|
||||
if (f[k] == gx_canvas) {
|
||||
@@ -1319,7 +1320,7 @@ void bbPrint(BBStr* str)
|
||||
BBStr* bbInput(BBStr* prompt)
|
||||
{
|
||||
gxCanvas* c = startPrinting();
|
||||
string t = *prompt;
|
||||
std::string t = *prompt;
|
||||
delete prompt;
|
||||
|
||||
//get temp canvas
|
||||
@@ -1340,7 +1341,7 @@ BBStr* bbInput(BBStr* prompt)
|
||||
p_canvas->setColor(curr_color);
|
||||
p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true);
|
||||
|
||||
string str;
|
||||
std::string str;
|
||||
bool go = true;
|
||||
int curs = 0, last_key = 0, last_time, rep_delay;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
#ifndef BBGRAPHICS_H
|
||||
#define BBGRAPHICS_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
#include "gxgraphics.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxcanvas.hpp>
|
||||
#include <gxscene.hpp>
|
||||
#include <gxfont.hpp>
|
||||
|
||||
extern gxGraphics* gx_graphics;
|
||||
extern gxCanvas* gx_canvas;
|
||||
@@ -115,5 +116,3 @@ void bbWrite(BBStr* str);
|
||||
void bbPrint(BBStr* str);
|
||||
BBStr* bbInput(BBStr* prompt);
|
||||
void bbLocate(int x, int y);
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,13 @@
|
||||
|
||||
#include "bbsys.hpp"
|
||||
#include "std.hpp"
|
||||
#include <vector>
|
||||
|
||||
#include <gxinput.hpp>
|
||||
#include <gxdevice.hpp>
|
||||
|
||||
gxInput* gx_input;
|
||||
gxDevice* gx_mouse;
|
||||
gxDevice* gx_keyboard;
|
||||
vector<gxDevice*> gx_joysticks;
|
||||
std::vector<gxDevice*> gx_joysticks;
|
||||
|
||||
static int mouse_x, mouse_y, mouse_z;
|
||||
static const float JLT = -1.0f / 3.0f;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
#ifndef BBINPUT_H
|
||||
#define BBINPUT_H
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include "bbsys.hpp"
|
||||
#include "gxinput.hpp"
|
||||
|
||||
#include <gxinput.hpp>
|
||||
#include <gxdevice.hpp>
|
||||
|
||||
extern gxInput* gx_input;
|
||||
extern gxDevice* gx_mouse;
|
||||
@@ -51,5 +49,3 @@ int bbJoyZDir(int port);
|
||||
int bbJoyUDir(int port);
|
||||
int bbJoyVDir(int port);
|
||||
void bbFlushJoy();
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "bbmath.hpp"
|
||||
#include "std.hpp"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
static int rnd_state;
|
||||
static const int RND_A = 48271;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#ifndef BBMATH_H
|
||||
#define BBMATH_H
|
||||
#pragma once
|
||||
|
||||
float bbSin(float n);
|
||||
float bbCos(float n);
|
||||
@@ -20,5 +18,3 @@ float bbLog(float n);
|
||||
float bbLog10(float n);
|
||||
float bbRnd(float from, float to);
|
||||
void bbSeedRnd(int seed);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#include "bbruntime.hpp"
|
||||
#include "bbsys.hpp"
|
||||
#include "std.hpp"
|
||||
#include <string>
|
||||
|
||||
#include <gxtimer.hpp>
|
||||
|
||||
void bbEnd()
|
||||
{
|
||||
@@ -23,7 +24,7 @@ void bbAppTitle(BBStr* ti, BBStr* cp)
|
||||
|
||||
void bbRuntimeError(BBStr* str)
|
||||
{
|
||||
string t = *str;
|
||||
std::string t = *str;
|
||||
delete str;
|
||||
if (t.size() > 255)
|
||||
t[255] = 0;
|
||||
@@ -34,7 +35,7 @@ void bbRuntimeError(BBStr* str)
|
||||
|
||||
int bbExecFile(BBStr* f)
|
||||
{
|
||||
string t = *f;
|
||||
std::string t = *f;
|
||||
delete f;
|
||||
int n = gx_runtime->execute(t);
|
||||
if (!gx_runtime->idle())
|
||||
@@ -60,7 +61,7 @@ BBStr* bbCommandLine()
|
||||
|
||||
BBStr* bbSystemProperty(BBStr* p)
|
||||
{
|
||||
string t = gx_runtime->systemProperty(*p);
|
||||
std::string t = gx_runtime->systemProperty(*p);
|
||||
delete p;
|
||||
return new BBStr(t);
|
||||
}
|
||||
@@ -75,7 +76,7 @@ BBStr* bbGetEnv(BBStr* env_var)
|
||||
|
||||
void bbSetEnv(BBStr* env_var, BBStr* val)
|
||||
{
|
||||
string t = *env_var + "=" + *val;
|
||||
std::string t = *env_var + "=" + *val;
|
||||
_putenv(t.c_str());
|
||||
delete env_var;
|
||||
delete val;
|
||||
@@ -204,7 +205,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc))
|
||||
//start up error
|
||||
static void sue(const char* t)
|
||||
{
|
||||
string p = string("Startup Error: ") + t;
|
||||
std::string p = std::string("Startup Error: ") + t;
|
||||
gx_runtime->debugInfo(p.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
|
||||
Platform neutral runtime library.
|
||||
@@ -7,15 +6,11 @@ To be statically linked with an appropriate gxruntime driver.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BBRUNTIME_H
|
||||
#define BBRUNTIME_H
|
||||
|
||||
#include "gxruntime.hpp"
|
||||
#pragma once
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
void bbruntime_link(void (*rtSym)(const char* sym, void* pc));
|
||||
|
||||
const char* bbruntime_run(gxRuntime* runtime, void (*pc)(), bool debug);
|
||||
|
||||
void bbruntime_panic(const char* err);
|
||||
|
||||
#endif
|
||||
|
||||
+22
-14
@@ -1,7 +1,9 @@
|
||||
|
||||
#include "bbsockets.hpp"
|
||||
#include <set>
|
||||
|
||||
#include <stdutil.hpp>
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include "std.hpp"
|
||||
|
||||
static bool socks_ok;
|
||||
static WSADATA wsadata;
|
||||
@@ -22,9 +24,9 @@ class UDPStream;
|
||||
class TCPStream;
|
||||
class TCPServer;
|
||||
|
||||
static set<UDPStream*> udp_set;
|
||||
static set<TCPStream*> tcp_set;
|
||||
static set<TCPServer*> server_set;
|
||||
static std::set<UDPStream*> udp_set;
|
||||
static std::set<TCPStream*> tcp_set;
|
||||
static std::set<TCPServer*> server_set;
|
||||
|
||||
class UDPStream : public bbStream {
|
||||
public:
|
||||
@@ -44,10 +46,10 @@ class UDPStream : public bbStream {
|
||||
int getMsgPort();
|
||||
|
||||
private:
|
||||
SOCKET sock;
|
||||
vector<char> in_buf, out_buf;
|
||||
sockaddr_in addr, in_addr, out_addr;
|
||||
int in_get, e;
|
||||
SOCKET sock;
|
||||
std::vector<char> in_buf, out_buf;
|
||||
sockaddr_in addr, in_addr, out_addr;
|
||||
int in_get, e;
|
||||
};
|
||||
|
||||
UDPStream::UDPStream(SOCKET s) : sock(s), in_get(0), e(0)
|
||||
@@ -199,9 +201,9 @@ class TCPServer {
|
||||
void remove(TCPStream* s);
|
||||
|
||||
private:
|
||||
int e;
|
||||
SOCKET sock;
|
||||
set<TCPStream*> accepted_set;
|
||||
int e;
|
||||
SOCKET sock;
|
||||
std::set<TCPStream*> accepted_set;
|
||||
};
|
||||
|
||||
TCPStream::TCPStream(SOCKET s, TCPServer* t) : sock(s), server(t), e(0)
|
||||
@@ -348,6 +350,7 @@ void TCPServer::remove(TCPStream* s)
|
||||
accepted_set.erase(s);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
static inline void debugUDPStream(UDPStream* p)
|
||||
{
|
||||
if (debug && !udp_set.count(p)) {
|
||||
@@ -368,8 +371,13 @@ static inline void debugTCPServer(TCPServer* p)
|
||||
ThrowRuntimeException("TCP Server does not exist");
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define debugUPDStream
|
||||
#define debugTCPStream
|
||||
#define debugTCPServer
|
||||
#endif
|
||||
|
||||
static vector<int> host_ips;
|
||||
static std::vector<int> host_ips;
|
||||
|
||||
int bbCountHostIPs(BBStr* host)
|
||||
{
|
||||
@@ -467,7 +475,7 @@ BBStr* bbDottedIP(int ip)
|
||||
+ itoa(ip & 255));
|
||||
}
|
||||
|
||||
static int findHostIP(const string& t)
|
||||
static int findHostIP(const std::string& t)
|
||||
{
|
||||
int ip = inet_addr(t.c_str());
|
||||
if (ip != INADDR_NONE)
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
|
||||
#ifndef BBSOCKETS_H
|
||||
#define BBSOCKETS_H
|
||||
|
||||
#pragma once
|
||||
#include "bbstream.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
|
||||
#include "bbstream.hpp"
|
||||
#include "std.hpp"
|
||||
#include <set>
|
||||
|
||||
static set<bbStream*> stream_set;
|
||||
static std::set<bbStream*> stream_set;
|
||||
|
||||
#ifdef _DEBUG
|
||||
void debugStream(bbStream* s)
|
||||
{
|
||||
if (stream_set.count(s))
|
||||
return;
|
||||
ThrowRuntimeException("Stream does not exist");
|
||||
}
|
||||
#else
|
||||
#define debugStream
|
||||
#endif
|
||||
|
||||
bbStream::bbStream()
|
||||
{
|
||||
@@ -80,7 +83,7 @@ BBStr* bbReadString(bbStream* s)
|
||||
if (s->read((char*)&len, 4)) {
|
||||
char* buff = new char[len];
|
||||
if (s->read(buff, len)) {
|
||||
*str = string(buff, len);
|
||||
*str = std::string(buff, len);
|
||||
}
|
||||
delete[] buff;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef BBSTREAM_H
|
||||
#define BBSTREAM_H
|
||||
|
||||
#pragma once
|
||||
#include "bbsys.hpp"
|
||||
|
||||
class bbStream {
|
||||
@@ -25,5 +22,3 @@ class bbStream {
|
||||
};
|
||||
|
||||
void debugStream(bbStream* s);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#include "bbsys.hpp"
|
||||
|
||||
#include <time.h>
|
||||
#include "bbsys.hpp"
|
||||
|
||||
#define CHKPOS(x) \
|
||||
if ((x) < 0) \
|
||||
@@ -39,7 +38,7 @@ BBStr* bbRight(BBStr* s, int n)
|
||||
BBStr* bbReplace(BBStr* s, BBStr* from, BBStr* to)
|
||||
{
|
||||
int n = 0, from_sz = from->size(), to_sz = to->size();
|
||||
while (n < s->size() && (n = s->find(*from, n)) != string::npos) {
|
||||
while (n < s->size() && (n = s->find(*from, n)) != std::string::npos) {
|
||||
s->replace(n, from_sz, *to);
|
||||
n += to_sz;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ int bbInstr(BBStr* s, BBStr* t, int from)
|
||||
int n = s->find(*t, from);
|
||||
delete s;
|
||||
delete t;
|
||||
return n == string::npos ? 0 : n + 1;
|
||||
return n == std::string::npos ? 0 : n + 1;
|
||||
}
|
||||
|
||||
BBStr* bbMid(BBStr* s, int o, int n)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
|
||||
#ifndef BBSTRING_H
|
||||
#define BBSTRING_H
|
||||
|
||||
#include "basic.h"
|
||||
#pragma once
|
||||
#include "basic.hpp"
|
||||
|
||||
BBStr* bbString(BBStr* s, int n);
|
||||
BBStr* bbLeft(BBStr* s, int n);
|
||||
@@ -22,5 +19,3 @@ BBStr* bbHex(int n);
|
||||
BBStr* bbBin(int n);
|
||||
BBStr* bbCurrentDate();
|
||||
BBStr* bbCurrentTime();
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "bbsys.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
bool debug;
|
||||
gxRuntime* gx_runtime;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#ifndef BBSYS_H
|
||||
#define BBSYS_H
|
||||
|
||||
#pragma once
|
||||
#include "basic.hpp"
|
||||
#include "gxruntime.hpp"
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
extern bool debug;
|
||||
extern gxRuntime* gx_runtime;
|
||||
@@ -18,5 +16,3 @@ struct bbEx {
|
||||
};
|
||||
|
||||
#define ThrowRuntimeException(_X_) throw bbEx(_X_);
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
#include "std.hpp"
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
#ifndef STD_H
|
||||
#define STD_H
|
||||
|
||||
//#ifndef _WINSOCKAPI_
|
||||
//#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
|
||||
//#endif
|
||||
#include <windows.h>
|
||||
//#include <winsock2.h>
|
||||
|
||||
#include "../stdutil/stdutil.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
#include "userlibs.hpp"
|
||||
#include "bbsys.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static vector<HMODULE> _mods;
|
||||
static std::vector<HMODULE> _mods;
|
||||
|
||||
struct Str {
|
||||
char* p;
|
||||
@@ -27,7 +25,7 @@ static void procNotFound()
|
||||
|
||||
void _bbLoadLibs(char* p)
|
||||
{
|
||||
string home;
|
||||
std::string home;
|
||||
|
||||
if (const char* t = getenv("blitzpath"))
|
||||
home = t;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
|
||||
#ifndef USERLIBS_H
|
||||
#define USERLIBS_H
|
||||
|
||||
#pragma once
|
||||
#include "basic.hpp"
|
||||
|
||||
void _bbLoadLibs(char* p);
|
||||
|
||||
const char* _bbStrToCStr(BBStr* str);
|
||||
BBStr* _bbCStrToStr(const char* str);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user