Skip to content

Commit

Permalink
Optimization & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Aug 7, 2022
1 parent 04c9dbe commit 870fcb2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 34 deletions.
1 change: 0 additions & 1 deletion Installer/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ private void ScrollPage(byte page)
ProgressInstall.Hide();
ButtonFinish.Hide();
PageDone.Hide();
CheckOpenCC.Checked = false;
LabelPath.Text = "Install Directory: " + BoxDirectoryPath.Text;
LabelStatus.Text = "Installing Blitz3D TSS " + ProductVersion + "...";
LabelDir.Font = new System.Drawing.Font("Consolas", 9);
Expand Down
57 changes: 41 additions & 16 deletions Installer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bbruntime/bbgraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,12 @@ void bbLine(int x1, int y1, int x2, int y2)

void bbRect(int x, int y, int w, int h, int solid)
{
gx_canvas->rect(x, y, w, h, solid ? true : false);
gx_canvas->rect(x, y, w, h, solid);
}

void bbOval(int x, int y, int w, int h, int solid)
{
gx_canvas->oval(x, y, w, h, solid ? true : false);
gx_canvas->oval(x, y, w, h, solid);
}

/*
Expand Down
16 changes: 8 additions & 8 deletions bbruntime/bbsockets.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#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 @@ -465,7 +466,7 @@ void bbTCPTimeouts(int rt, int at) {
accept_timeout = at;
}

std::string exec(char* cmd) {
std::string exec(const char* cmd) {
FILE* pipe = _popen(cmd, "r");
if (!pipe) return "";
char buffer[128];
Expand Down Expand Up @@ -498,23 +499,21 @@ BBStr* bbParseDomainTXT(BBStr* txt, BBStr* name) {
std::string s2 = name->c_str();
std::string result = "";
int n, a;
if ((n = s1.find(s2+"=")) != std::string::npos)
if ((n = s1.find(s2 + "=")) != std::string::npos)
result = s1.substr(n);
if ((a = result.find(';')) != std::string::npos)
result = result.substr(s2.length()+1, a - s2.length()-1);
result = result.substr(s2.length()+1, a - s2.length() - 1);
*txt = result.c_str();
delete name;
return txt;
}

BBStr* bbGetDomainTXT(BBStr* domain) {
std::string cmd = "nslookup -qt=TXT ";
cmd += domain->c_str();
std::string result = exec((char*)cmd.data());
std::string result = exec(SFormat("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);
if (result[result.length() - 1] != ';') result += ';';
if (result[result.length() - 2] == '\"') result = result.substr(0, result.length() - 2);
if (result[result.length() - 1] != ';') result += ';';
*domain = result.c_str();
return domain;
}
Expand Down Expand Up @@ -563,6 +562,7 @@ int bbDownloadFile(BBStr* url, BBStr* file)
InternetCloseHandle(hSession);
hSession = NULL;
}

delete url, file;
std::ifstream fileStream(file->c_str(), std::ios::in);
int isOpen = fileStream.is_open();
Expand Down
20 changes: 13 additions & 7 deletions bbruntime_dll/bbruntime_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ static HINSTANCE hinst;
static std::map<const char*, void*> syms;
std::map<const char*, void*>::iterator sym_it;
static gxRuntime* gx_runtime;
static std::string funList[999]; //a huge array
static int funNum = 0;

/*
* If you using a single variant to handle function names, then you will get error
* sym is a pointer, backup function name is pointer too.
* So, variant of backup name's content will change by sym's content.
*
* How it works?
*/
//Allows userlibs to call DebugLog() and RuntimeError().
//******************************************************
Expand All @@ -55,13 +55,19 @@ __declspec(dllexport) void __cdecl BlitzRuntimeError(const char* msg)
}
//******************************************************

const char* getCharPtr(std::string str) {
char* cha = new char[str.size() + 1];
memcpy(cha, str.c_str(), str.size() + 1);
const char* p = cha;
return p;
}

static void rtSym(const char* sym, void* pc) {
syms[sym] = pc;
funList[funNum] = sym;
if (sym[0] == '%' || sym[0] == '$' || sym[0] == '#') funList[funNum] = funList[funNum].insert(1, "Blitz_");
else funList[funNum] = "Blitz_" + funList[funNum];
syms[funList[funNum].c_str()] = pc;
funNum++;
std::string symSpare = sym;
if (sym[0] == '%' || sym[0] == '$' || sym[0] == '#') symSpare = symSpare.insert(1, "Blitz_");
else symSpare = symSpare.insert(0, "Blitz_");
syms[getCharPtr(symSpare)] = pc;
}

static void killer() {
Expand Down

0 comments on commit 870fcb2

Please sign in to comment.