diff --git a/Runtime/lib/CMakeLists.txt b/Runtime/lib/CMakeLists.txt index 802d9de..965af38 100644 --- a/Runtime/lib/CMakeLists.txt +++ b/Runtime/lib/CMakeLists.txt @@ -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} diff --git a/Runtime/lib/basic.cpp b/Runtime/lib/basic.cpp index fdf3516..39b3dc7 100644 --- a/Runtime/lib/basic.cpp +++ b/Runtime/lib/basic.cpp @@ -1,5 +1,7 @@ #include "bbsys.hpp" -#include "std.hpp" +#include + +#include //how many strings allocated static int stringCnt; @@ -29,8 +31,8 @@ static BBStr usedStrs, freeStrs; static int next_handle; //object<->handle maps -static map handle_map; -static map object_map; +static std::map handle_map; +static std::map 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::iterator it = object_map.find(obj); + std::map::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::const_iterator it = object_map.find(obj); + std::map::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::const_iterator it = handle_map.find(handle); + std::map::const_iterator it = handle_map.find(handle); if (it == handle_map.end()) return 0; BBObj* obj = it->second; @@ -723,4 +725,4 @@ void basic_link(void (*rtSym)(const char* sym, void* pc)) rtSym("_bbFMod", _bbFMod); rtSym("_bbFPow", _bbFPow); rtSym("RuntimeStats", bbRuntimeStats); -} \ No newline at end of file +} diff --git a/Runtime/lib/basic.hpp b/Runtime/lib/basic.hpp index 484400e..a2d27a1 100644 --- a/Runtime/lib/basic.hpp +++ b/Runtime/lib/basic.hpp @@ -1,7 +1,4 @@ - -#ifndef BASIC_H -#define BASIC_H - +#pragma once #include #include @@ -155,5 +152,3 @@ float _bbFMod(float x, float y); float _bbFPow(float x, float y); void bbRuntimeStats(); - -#endif \ No newline at end of file diff --git a/Runtime/lib/bb_basic.hpp b/Runtime/lib/bb_basic.hpp index 1d7f312..9465b82 100644 --- a/Runtime/lib/bb_basic.hpp +++ b/Runtime/lib/bb_basic.hpp @@ -1,3 +1,4 @@ +#pragma once enum { BBTYPE_END = 0, diff --git a/Runtime/lib/bbaudio.cpp b/Runtime/lib/bbaudio.cpp index d7baf0f..920bacc 100644 --- a/Runtime/lib/bbaudio.cpp +++ b/Runtime/lib/bbaudio.cpp @@ -1,9 +1,11 @@ - #include "bbaudio.hpp" -#include "std.hpp" + +#include +#include 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; } diff --git a/Runtime/lib/bbaudio.hpp b/Runtime/lib/bbaudio.hpp index 998e1f0..a34d352 100644 --- a/Runtime/lib/bbaudio.hpp +++ b/Runtime/lib/bbaudio.hpp @@ -1,9 +1,7 @@ - -#ifndef BBAUDIO_H -#define BBAUDIO_H - +#pragma once #include "bbsys.hpp" -#include "gxaudio.hpp" + +#include 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 diff --git a/Runtime/lib/bbbank.cpp b/Runtime/lib/bbbank.cpp index ed366d1..b5a5273 100644 --- a/Runtime/lib/bbbank.cpp +++ b/Runtime/lib/bbbank.cpp @@ -1,7 +1,6 @@ - #include "bbbank.hpp" +#include #include "bbstream.hpp" -#include "std.hpp" struct bbBank { char* data; @@ -36,8 +35,9 @@ struct bbBank { } }; -static set bank_set; +static std::set 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) { diff --git a/Runtime/lib/bbbank.hpp b/Runtime/lib/bbbank.hpp index 63f9d08..493042e 100644 --- a/Runtime/lib/bbbank.hpp +++ b/Runtime/lib/bbbank.hpp @@ -1,7 +1,2 @@ - -#ifndef BBBANK_H -#define BBBANK_H - +#pragma once #include "bbsys.hpp" - -#endif \ No newline at end of file diff --git a/Runtime/lib/bbblitz3d.cpp b/Runtime/lib/bbblitz3d.cpp index aab384d..8bd01b8 100644 --- a/Runtime/lib/bbblitz3d.cpp +++ b/Runtime/lib/bbblitz3d.cpp @@ -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 +#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 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_set; -static set texture_set; -static set entity_set; +static std::set brush_set; +static std::set texture_set; +static std::set 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 loader_mat_map; +static std::map 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; diff --git a/Runtime/lib/bbblitz3d.hpp b/Runtime/lib/bbblitz3d.hpp index 5706d21..ed7466e 100644 --- a/Runtime/lib/bbblitz3d.hpp +++ b/Runtime/lib/bbblitz3d.hpp @@ -1,10 +1,5 @@ - -#ifndef BBBLITZ3D_H -#define BBBLITZ3D_H - +#pragma once #include "bbsys.hpp" -#include "gxscene.hpp" +#include extern gxScene* gx_scene; - -#endif diff --git a/Runtime/lib/bbfilesystem.cpp b/Runtime/lib/bbfilesystem.cpp index 9ce4057..fa212b3 100644 --- a/Runtime/lib/bbfilesystem.cpp +++ b/Runtime/lib/bbfilesystem.cpp @@ -1,14 +1,13 @@ - #include "bbfilesystem.hpp" #include +#include #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 file_set; +static std::set 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); diff --git a/Runtime/lib/bbfilesystem.hpp b/Runtime/lib/bbfilesystem.hpp index d197abb..7a438a7 100644 --- a/Runtime/lib/bbfilesystem.hpp +++ b/Runtime/lib/bbfilesystem.hpp @@ -1,10 +1,6 @@ - -#ifndef BBFILESYSTEM_H -#define BBFILESYSTEM_H - +#pragma once #include "bbsys.hpp" -#include "gxfilesystem.hpp" + +#include extern gxFileSystem* gx_filesys; - -#endif \ No newline at end of file diff --git a/Runtime/lib/bbgraphics.cpp b/Runtime/lib/bbgraphics.cpp index 8ac421b..77387b7 100644 --- a/Runtime/lib/bbgraphics.cpp +++ b/Runtime/lib/bbgraphics.cpp @@ -1,7 +1,8 @@ - #include "bbgraphics.hpp" #include "bbinput.hpp" -#include "std.hpp" +#include + +#include gxGraphics* gx_graphics; gxCanvas* gx_canvas; @@ -12,14 +13,14 @@ struct GfxMode { class bbImage { public: - bbImage(const vector& f) : frames(f) {} + bbImage(const std::vector& f) : frames(f) {} ~bbImage() { for (int k = 0; k < frames.size(); ++k) { gx_graphics->freeCanvas(frames[k]); } } - const vector& getFrames() const + const std::vector& getFrames() const { return frames; } @@ -30,7 +31,7 @@ class bbImage { } private: - vector frames; + std::vector 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 image_set; +static std::set 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 gfx_modes; +static std::vector 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 frames; + std::vector 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 frames; + std::vector 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 frames; - const vector& f = i->getFrames(); + std::vector frames; + const std::vector& 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 frames; + std::vector 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& f = i->getFrames(); + const std::vector& 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& f = i->getFrames(); + const std::vector& 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& f = i->getFrames(); + const std::vector& 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& f = i->getFrames(); + const std::vector& 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& f = i->getFrames(); + const std::vector& 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; diff --git a/Runtime/lib/bbgraphics.hpp b/Runtime/lib/bbgraphics.hpp index eacaf88..13bda26 100644 --- a/Runtime/lib/bbgraphics.hpp +++ b/Runtime/lib/bbgraphics.hpp @@ -1,9 +1,10 @@ - -#ifndef BBGRAPHICS_H -#define BBGRAPHICS_H - +#pragma once #include "bbsys.hpp" -#include "gxgraphics.hpp" + +#include +#include +#include +#include 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 \ No newline at end of file diff --git a/Runtime/lib/bbinput.cpp b/Runtime/lib/bbinput.cpp index e838030..e6bc70e 100644 --- a/Runtime/lib/bbinput.cpp +++ b/Runtime/lib/bbinput.cpp @@ -1,11 +1,13 @@ - #include "bbsys.hpp" -#include "std.hpp" +#include + +#include +#include gxInput* gx_input; gxDevice* gx_mouse; gxDevice* gx_keyboard; -vector gx_joysticks; +std::vector gx_joysticks; static int mouse_x, mouse_y, mouse_z; static const float JLT = -1.0f / 3.0f; diff --git a/Runtime/lib/bbinput.hpp b/Runtime/lib/bbinput.hpp index e8841db..a83f917 100644 --- a/Runtime/lib/bbinput.hpp +++ b/Runtime/lib/bbinput.hpp @@ -1,11 +1,9 @@ - -#ifndef BBINPUT_H -#define BBINPUT_H - +#pragma once #include - #include "bbsys.hpp" -#include "gxinput.hpp" + +#include +#include 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 \ No newline at end of file diff --git a/Runtime/lib/bbmath.cpp b/Runtime/lib/bbmath.cpp index 9268451..9eacea5 100644 --- a/Runtime/lib/bbmath.cpp +++ b/Runtime/lib/bbmath.cpp @@ -1,6 +1,6 @@ - #include "bbmath.hpp" -#include "std.hpp" +#include +#include static int rnd_state; static const int RND_A = 48271; diff --git a/Runtime/lib/bbmath.hpp b/Runtime/lib/bbmath.hpp index 29a29a3..ecb7de1 100644 --- a/Runtime/lib/bbmath.hpp +++ b/Runtime/lib/bbmath.hpp @@ -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 \ No newline at end of file diff --git a/Runtime/lib/bbruntime.cpp b/Runtime/lib/bbruntime.cpp index f50cfe5..63ea70b 100644 --- a/Runtime/lib/bbruntime.cpp +++ b/Runtime/lib/bbruntime.cpp @@ -1,7 +1,8 @@ - #include "bbruntime.hpp" #include "bbsys.hpp" -#include "std.hpp" +#include + +#include 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()); } diff --git a/Runtime/lib/bbruntime.hpp b/Runtime/lib/bbruntime.hpp index fe4dce2..fdda39f 100644 --- a/Runtime/lib/bbruntime.hpp +++ b/Runtime/lib/bbruntime.hpp @@ -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 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 diff --git a/Runtime/lib/bbsockets.cpp b/Runtime/lib/bbsockets.cpp index 842fe6a..1bee61c 100644 --- a/Runtime/lib/bbsockets.cpp +++ b/Runtime/lib/bbsockets.cpp @@ -1,7 +1,9 @@ - #include "bbsockets.hpp" +#include + +#include + #include -#include "std.hpp" static bool socks_ok; static WSADATA wsadata; @@ -22,9 +24,9 @@ class UDPStream; class TCPStream; class TCPServer; -static set udp_set; -static set tcp_set; -static set server_set; +static std::set udp_set; +static std::set tcp_set; +static std::set server_set; class UDPStream : public bbStream { public: @@ -44,10 +46,10 @@ class UDPStream : public bbStream { int getMsgPort(); private: - SOCKET sock; - vector in_buf, out_buf; - sockaddr_in addr, in_addr, out_addr; - int in_get, e; + SOCKET sock; + std::vector 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 accepted_set; + int e; + SOCKET sock; + std::set 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 host_ips; +static std::vector 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) diff --git a/Runtime/lib/bbsockets.hpp b/Runtime/lib/bbsockets.hpp index 83ca54a..60498b9 100644 --- a/Runtime/lib/bbsockets.hpp +++ b/Runtime/lib/bbsockets.hpp @@ -1,7 +1,2 @@ - -#ifndef BBSOCKETS_H -#define BBSOCKETS_H - +#pragma once #include "bbstream.hpp" - -#endif diff --git a/Runtime/lib/bbstream.cpp b/Runtime/lib/bbstream.cpp index 04ad25a..a9beb40 100644 --- a/Runtime/lib/bbstream.cpp +++ b/Runtime/lib/bbstream.cpp @@ -1,15 +1,18 @@ - #include "bbstream.hpp" -#include "std.hpp" +#include -static set stream_set; +static std::set 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; } diff --git a/Runtime/lib/bbstream.hpp b/Runtime/lib/bbstream.hpp index 617a944..9452064 100644 --- a/Runtime/lib/bbstream.hpp +++ b/Runtime/lib/bbstream.hpp @@ -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 \ No newline at end of file diff --git a/Runtime/lib/bbstring.cpp b/Runtime/lib/bbstring.cpp index 9ec8079..f916e28 100644 --- a/Runtime/lib/bbstring.cpp +++ b/Runtime/lib/bbstring.cpp @@ -1,7 +1,6 @@ - +#include "bbsys.hpp" #include -#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) diff --git a/Runtime/lib/bbstring.hpp b/Runtime/lib/bbstring.hpp index bb9a01a..9b1783f 100644 --- a/Runtime/lib/bbstring.hpp +++ b/Runtime/lib/bbstring.hpp @@ -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 \ No newline at end of file diff --git a/Runtime/lib/bbsys.cpp b/Runtime/lib/bbsys.cpp index 519323b..e34f59d 100644 --- a/Runtime/lib/bbsys.cpp +++ b/Runtime/lib/bbsys.cpp @@ -1,6 +1,6 @@ - #include "bbsys.hpp" -#include "std.hpp" + +#include bool debug; gxRuntime* gx_runtime; diff --git a/Runtime/lib/bbsys.hpp b/Runtime/lib/bbsys.hpp index 454459c..28d03eb 100644 --- a/Runtime/lib/bbsys.hpp +++ b/Runtime/lib/bbsys.hpp @@ -1,9 +1,7 @@ - -#ifndef BBSYS_H -#define BBSYS_H - +#pragma once #include "basic.hpp" -#include "gxruntime.hpp" + +#include extern bool debug; extern gxRuntime* gx_runtime; @@ -18,5 +16,3 @@ struct bbEx { }; #define ThrowRuntimeException(_X_) throw bbEx(_X_); - -#endif \ No newline at end of file diff --git a/Runtime/lib/runtime.cpp b/Runtime/lib/runtime.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Runtime/lib/std.cpp b/Runtime/lib/std.cpp deleted file mode 100644 index d5f561b..0000000 --- a/Runtime/lib/std.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "std.hpp" diff --git a/Runtime/lib/std.hpp b/Runtime/lib/std.hpp deleted file mode 100644 index 1af16a9..0000000 --- a/Runtime/lib/std.hpp +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef STD_H -#define STD_H - -//#ifndef _WINSOCKAPI_ -//#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */ -//#endif -#include -//#include - -#include "../stdutil/stdutil.hpp" - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; - -#endif diff --git a/Runtime/lib/userlibs.cpp b/Runtime/lib/userlibs.cpp index 8c27559..49a2204 100644 --- a/Runtime/lib/userlibs.cpp +++ b/Runtime/lib/userlibs.cpp @@ -1,11 +1,9 @@ - #include "userlibs.hpp" #include "bbsys.hpp" -#include "std.hpp" #include -static vector _mods; +static std::vector _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; diff --git a/Runtime/lib/userlibs.hpp b/Runtime/lib/userlibs.hpp index 61ce2f7..081e7c8 100644 --- a/Runtime/lib/userlibs.hpp +++ b/Runtime/lib/userlibs.hpp @@ -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