Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <davidebeatrici@gmail.com>2019-10-11 22:58:39 +0300
committerDavide Beatrici <davidebeatrici@gmail.com>2019-10-11 22:58:39 +0300
commit5e247f258c0a2fbdabb74361890cad1ccac68407 (patch)
tree663d9e3b1ff2860a920a2cf481fa5c447c658391 /plugins
parentd40fbe8c3b98873501cc39b58f4ffc5c09cfeae4 (diff)
plugins: replace MSVC string functions with C++ ones
Diffstat (limited to 'plugins')
-rw-r--r--plugins/blacklight/blacklight.cpp20
-rw-r--r--plugins/gw/gw.cpp9
-rw-r--r--plugins/lol/lol.cpp21
3 files changed, 25 insertions, 25 deletions
diff --git a/plugins/blacklight/blacklight.cpp b/plugins/blacklight/blacklight.cpp
index 5e704cc7e..f7ef3d343 100644
--- a/plugins/blacklight/blacklight.cpp
+++ b/plugins/blacklight/blacklight.cpp
@@ -59,7 +59,7 @@ static procptr_t camtopptr = camfrontptr + 0xC;
static procptr_t camptr = camfrontptr + 0x18;
static procptr_t hostipportptr;
-static char prev_hostipport[22];
+static std::string prev_hostipport;
static char state = 0; // 1 if connected to a server, 0 if not
@@ -88,7 +88,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
float cam[3], camtop[3], camfront[3];
bool ok;
- char hostipport[sizeof(prev_hostipport)];
+ char hostipport[22];
ok = peekProc(camfrontptr, camfront, 12) &&
peekProc(camtopptr, camtop, 12) &&
@@ -99,16 +99,17 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
return false;
hostipport[sizeof(hostipport) - 1] = '\0';
- if (strcmp(hostipport, prev_hostipport) != 0) {
+ if (hostipport != prev_hostipport) {
context.clear();
state = 0;
- strcpy_s(prev_hostipport, sizeof(prev_hostipport), hostipport);
+ prev_hostipport = hostipport;
if (strcmp(hostipport, "") != 0 && strcmp(hostipport, "bot") != 0) {
- char buffer[50];
- sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s\"}", hostipport);
- context.assign(buffer);
+ std::ostringstream contextstream;
+ contextstream << "{\"ipport\": \"" << hostipport << "\"}";
+ context = contextstream.str();
+
state = 1;
}
}
@@ -131,15 +132,14 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
return false;
if (refreshPointers()) { // unlink plugin if this fails
-
- *prev_hostipport = '\0';
+ prev_hostipport.clear();
float avatar_pos[3], avatar_front[3], avatar_top[3];
float camera_pos[3], camera_front[3], camera_top[3];
std::string context;
std::wstring identity;
if (fetch(avatar_pos, avatar_front, avatar_top, camera_pos, camera_front, camera_top, context, identity)) {
- *prev_hostipport = '\0'; // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
+ prev_hostipport.clear(); // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
return true;
}
}
diff --git a/plugins/gw/gw.cpp b/plugins/gw/gw.cpp
index cbb938c75..fc504a9b2 100644
--- a/plugins/gw/gw.cpp
+++ b/plugins/gw/gw.cpp
@@ -159,15 +159,14 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
calcout(pos, front, cam, camfront, avatar_pos, avatar_front, camera_pos, camera_front);
if (areaid != prev_areaid || location != prev_location) {
- context.clear();
-
prev_areaid = areaid;
prev_location = location;
- char buffer[50];
- sprintf_s(buffer, sizeof(buffer), "{\"instance\": \"%d:%d\"}", areaid, static_cast<int>(location));
- context.assign(buffer);
+ std::ostringstream contextstream;
+ contextstream << "{\"instance\": \"" << areaid << ":" << static_cast<int>(location) << "\"}";
+ context = contextstream.str();
}
+
return true;
}
diff --git a/plugins/lol/lol.cpp b/plugins/lol/lol.cpp
index 6402cc2ff..3f79c6474 100644
--- a/plugins/lol/lol.cpp
+++ b/plugins/lol/lol.cpp
@@ -67,7 +67,7 @@ static procptr_t gameptr = 0xE22E90;
static procptr_t hostipptr = 0xAF69D18;
static procptr_t hostportptr = hostipptr + 0x1C;
-static char prev_hostip[16]; // These should never change while the game is running, but just in case...
+static std::string prev_hostip; // These should never change while the game is running, but just in case...
static int prev_hostport;
static bool calcout(float *pos, float *cam, float *opos, float *ocam) {
@@ -128,18 +128,19 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
calcout(ipos, cam, avatar_pos, camera_pos); //calculate proper position values
- if (strcmp(hostip, prev_hostip) != 0 || hostport != prev_hostport) {
- context.clear();
-
- strcpy_s(prev_hostip, sizeof(prev_hostip), hostip);
+ if (hostip != prev_hostip || hostport != prev_hostport) {
+ prev_hostip = hostip;
prev_hostport = hostport;
if (strcmp(hostip, "") != 0) {
- char buffer[50];
- sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s:%d\"}", hostip, hostport);
- context.assign(buffer);
+ std::ostringstream contextstream;
+ contextstream << "{\"ipport\": \"" << hostip << ":" << hostport << "\"}";
+ context = contextstream.str();
+ } else {
+ context.clear();
}
}
+
return true;
}
@@ -148,7 +149,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
return false;
if (refreshPointers()) { // unlink plugin if this fails
- *prev_hostip = '\0';
+ prev_hostip.clear();
prev_hostport = 0;
float avatar_pos[3], avatar_front[3], avatar_top[3];
@@ -157,7 +158,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
std::wstring identity;
if (fetch(avatar_pos, avatar_front, avatar_top, camera_pos, camera_front, camera_top, context, identity)) {
- *prev_hostip = '\0'; // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
+ prev_hostip.clear(); // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
prev_hostport = 0;
return true;
}