Skip to content

Commit

Permalink
Update to C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Aug 14, 2022
1 parent 870fcb2 commit 3dbfd11
Show file tree
Hide file tree
Showing 106 changed files with 496 additions and 5,207 deletions.
432 changes: 216 additions & 216 deletions MultiLang/English.cpp

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion MultiLang/MultiLang.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="MultiLang.h" />
<ClInclude Include="sformat.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="English.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions MultiLang/MultiLang.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<ClInclude Include="MultiLang.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="sformat.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="English.cpp">
Expand Down
432 changes: 216 additions & 216 deletions MultiLang/SimplifiedChinese.cpp

Large diffs are not rendered by default.

95 changes: 0 additions & 95 deletions MultiLang/sformat.h

This file was deleted.

4 changes: 2 additions & 2 deletions _release/help/commands/2d_commands/GetUserLanguage.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>

<body>
<h1>GetUserLanguage</h1>
<h1>GetUserLanguageStrict</h1>
<h1>Parameters</h1>
<table>
<tr>
Expand All @@ -18,7 +18,7 @@ <h1>Description</h1>
<table>
<tr>
<td>
Get display language of current user.
Get display language of current user (for example, en-US).
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion bblaunch/bblaunch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<AssemblerOutput>NoListing</AssemblerOutput>
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Midl>
Expand Down
7 changes: 3 additions & 4 deletions bbruntime/basic.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "std.h"
#include "bbsys.h"
#include "../MultiLang/MultiLang.h"
#include "../MultiLang/sformat.h"
#include "bbruntime.h"

//how many strings allocated
Expand Down Expand Up @@ -477,9 +476,9 @@ float _bbFPow(float x, float y) {
}

void bbRuntimeStats() {
gx_runtime->debugLog(SFormat(MultiLang::stats_strings, stringCnt).c_str());
gx_runtime->debugLog(SFormat(MultiLang::stats_objects, objCnt).c_str());
gx_runtime->debugLog(SFormat(MultiLang::stats_unreleased, unrelObjCnt).c_str());
gx_runtime->debugLog(std::format(MultiLang::stats_strings, stringCnt).c_str());
gx_runtime->debugLog(std::format(MultiLang::stats_objects, objCnt).c_str());
gx_runtime->debugLog(std::format(MultiLang::stats_unreleased, unrelObjCnt).c_str());
}

void bbMav() {
Expand Down
14 changes: 7 additions & 7 deletions bbruntime/bbblitz3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ int bbCameraProject(Camera* c, float x, float y, float z) {
float nr = c->getFrustumNear();
float nr_w = c->getFrustumWidth();
float nr_h = c->getFrustumHeight();
projected = Vector((v.x / nr_w + .5f) * vp_w, (.5f - v.y / nr_h) * vp_h, nr);
::projected = Vector((v.x / nr_w + .5f) * vp_w, (.5f - v.y / nr_h) * vp_h, nr);
return 1;
}
if(v.z > 0) {
Expand All @@ -1022,26 +1022,26 @@ int bbCameraProject(Camera* c, float x, float y, float z) {
float nr = c->getFrustumNear();
float nr_w = c->getFrustumWidth();
float nr_h = c->getFrustumHeight();
projected = Vector(
::projected = Vector(
(v.x * nr / v.z / nr_w + .5f) * vp_w,
(.5f - v.y * nr / v.z / nr_h) * vp_h, nr);
return 1;
}
}
projected = Vector();
::projected = Vector();
return 0;
}

float bbProjectedX() {
return projected.x;
return ::projected.x;
}

float bbProjectedY() {
return projected.y;
return ::projected.y;
}

float bbProjectedZ() {
return projected.z;
return ::projected.z;
}

static Object* doPick(const Line& l, float radius) {
Expand Down Expand Up @@ -2059,7 +2059,7 @@ void blitz3d_open() {
gx_scene = gx_graphics->createScene(0);
if(!gx_scene) RTEX(MultiLang::unable_create_gxscene_instance);
world = new World();
projected = Vector();
::projected = Vector();
picked.collision = Collision();
picked.with = 0; picked.coords = Vector();
Texture::clearFilters();
Expand Down
10 changes: 8 additions & 2 deletions bbruntime/bbruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "bbruntime.h"
#include "../gxruntime/gxutf8.h"
#include "../MultiLang/MultiLang.h"
#include "../MultiLang/sformat.h"
#include <codecvt>

std::string* ErrorMessagePool::memoryAccessViolation = 0;
Expand Down Expand Up @@ -55,6 +54,12 @@ BBStr* bbGetUserLanguage() {
return new BBStr(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(buf));
}

BBStr* bbGetLocaleInfo() {
char szLangName[10];
GetLocaleInfoA(GetSystemDefaultLCID(), LOCALE_SABBREVLANGNAME, szLangName, sizeof(szLangName) / sizeof(szLangName[0]));
return new BBStr(szLangName);
}

int bbExecFile(BBStr* f) {
std::string t = *f;
delete f;
Expand Down Expand Up @@ -219,6 +224,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc)) {
rtSym("SetEnv$env_var$value", bbSetEnv);
rtSym("DisableClose", bbDisableClose);
rtSym("$GetUserLanguage", bbGetUserLanguage);
rtSym("$GetLocaleInfo", bbGetLocaleInfo);

rtSym("%CreateTimer%hertz", bbCreateTimer);
rtSym("%WaitTimer%timer", bbWaitTimer);
Expand Down Expand Up @@ -247,7 +253,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc)) {

//start up error
static void sue(const char* t) {
std::string p = SFormat(MultiLang::startup_error, t);
std::string p = std::format(MultiLang::startup_error, t);
gx_runtime->debugError(p.c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion bbruntime/bbruntime.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<ExceptionHandling>Async</ExceptionHandling>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>..\freetype\include;</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>
Expand Down
3 changes: 1 addition & 2 deletions bbruntime/bbsockets.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "std.h"
#include "bbsockets.h"
#include <wininet.h>
#include "../MultiLang/sformat.h"
#include "../MultiLang/MultiLang.h"

#pragma comment (lib, "wininet.lib")
Expand Down Expand Up @@ -509,7 +508,7 @@ BBStr* bbParseDomainTXT(BBStr* txt, BBStr* name) {
}

BBStr* bbGetDomainTXT(BBStr* domain) {
std::string result = exec(SFormat("nslookup -qt=TXT {0}", domain->c_str()).data());
std::string result = exec(std::format("nslookup -qt=TXT {0}", domain->c_str()).data());
result = clearTabLeft(result);
if (result[0] == '\"') result = result.substr(1);
if (result[result.length() - 2] == '\"') result = result.substr(0, result.length() - 2);
Expand Down
6 changes: 3 additions & 3 deletions bbruntime/bbstring.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "std.h"
#include "bbsys.h"
#include "../gxruntime/gxutf8.h"
#include "../bbruntime/bbgraphics.h"
#include <time.h>
#include "../MultiLang/MultiLang.h"
#include "../MultiLang/sformat.h"

#define CHKPOS(x) if( (x)<0 ) RTEX( SFormat(MultiLang::string_parameter_positive, __func__).c_str() );
#define CHKOFF(x) if( (x)<=0 ) RTEX( SFormat(MultiLang::string_parameter_greater, __func__ ).c_str() );
#define CHKPOS(x) if( (x)<0 ) RTEX( std::format(MultiLang::string_parameter_positive, __func__).c_str() );
#define CHKOFF(x) if( (x)<=0 ) RTEX( std::format(MultiLang::string_parameter_greater, __func__ ).c_str() );

BBStr* bbString(BBStr* s, int n) {
BBStr* t = new BBStr();
Expand Down
3 changes: 1 addition & 2 deletions bbruntime_dll/bbruntime_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "../gxruntime/gxutf8.h"

#include "../MultiLang/MultiLang.h"
#include "../MultiLang/sformat.h"
#include "../bbruntime/bbsys.h"

class DummyDebugger : public Debugger {
Expand Down Expand Up @@ -235,7 +234,7 @@ static int findSym(const std::string& t) {
it = runtime_syms.find(t);
if(it != runtime_syms.end()) return it->second;

std::string err = SFormat(MultiLang::cant_find_symbol, t);
std::string err = std::format(MultiLang::cant_find_symbol, t);
MessageBox(0, err.c_str(), 0, 0);
ExitProcess(0);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion bbruntime_dll/bbruntime_dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<OpenMPSupport>false</OpenMPSupport>
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>..\freetype\include;</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
Expand Down
2 changes: 1 addition & 1 deletion blitz/blitz.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<AssemblerOutput>NoListing</AssemblerOutput>
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>..\freetype\include;</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
Expand Down
2 changes: 1 addition & 1 deletion blitz3d/blitz3d.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<AssemblerOutput>NoListing</AssemblerOutput>
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>..\freetype\include;</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
Expand Down
2 changes: 1 addition & 1 deletion blitzide/blitzide.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<AssemblerOutput>NoListing</AssemblerOutput>
<MinimalRebuild>false</MinimalRebuild>
<CallingConvention>StdCall</CallingConvention>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>..\freetype\include;</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
Expand Down
4 changes: 2 additions & 2 deletions blitzide/libs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool isMediaFile(const std::string& f) {
return false;
#endif

static char* exts[] = {
static const char* exts[] = {
"bmp","jpg","png","tga","iff","pcx",
"wav","mid","mp3","mod","s3m","xm","it","rmi","sgt",
"x","3ds",0
Expand All @@ -113,7 +113,7 @@ bool isMediaFile(const std::string& f) {
int i = f.rfind('.');
if(i == std::string::npos || i + 1 == f.size()) return false;
std::string ext = f.substr(i + 1);
char** p = exts;
const char** p = exts;
while(const char* e = *p++) {
std::string t(e);
if(i + t.size() + 1 != f.size()) continue;
Expand Down
Loading

0 comments on commit 3dbfd11

Please sign in to comment.