Revert "sstring; crash?"

This reverts commit a30438b0c54b41a1edd0fb98612f6ac723189e80.
This commit is contained in:
nullifiedcat 2016-12-23 13:58:47 +03:00
parent ec815bede5
commit 5d26fd1de2
6 changed files with 8 additions and 34 deletions

View File

@ -22,7 +22,6 @@
#include "trace.h"
#include "cvwrapper.h"
#include "netvars.h"
#include "sstring.h"
#include "prediction.h"
#include "sdk.h"

View File

@ -16,7 +16,7 @@ FILE* hConVarsFile = 0;
void BeginConVars() {
passwd* pwd = getpwuid(getuid());
char* user = pwd->pw_name;
hConVarsFile = fopen((const char*)strfmt("/home/%s/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg/cat_defaults.cfg", user), "w");
hConVarsFile = fopen(strfmt("/home/%s/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg/cat_defaults.cfg", user), "w");
SetCVarInterface(interfaces::cvar);
}
@ -741,13 +741,13 @@ void EndPrediction() {
interfaces::gvars->frametime = oldFrametime;
}*/
sstring strfmt(const char* fmt, ...) {
sstring result(1024);
char* strfmt(const char* fmt, ...) {
char buf[1024];
va_list list;
va_start(list, fmt);
vsprintf(result, fmt, list);
vsprintf(buf, fmt, list);
va_end(list);
return result;
return buf;
}
const char* powerups[] = {

View File

@ -16,7 +16,6 @@ class CUserCmd;
class CCommand;
struct player_info_s;
class Vector;
class sstring;
#define PI 3.14159265358979323846f
#define RADPI 57.295779513082f
@ -70,7 +69,7 @@ bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity);
bool IsVectorVisible(Vector a, Vector b);
relation GetRelation(CachedEntity* ent); // TODO new relations
bool IsSentryBuster(CachedEntity* ent);
sstring strfmt(const char* fmt, ...);
char* strfmt(const char* fmt, ...);
// TODO move that to weaponid.h
bool IsAmbassador(CachedEntity* ent);

View File

@ -14,14 +14,13 @@
#include "interfaces.h"
#include "sdk.h"
#include "sstring.h"
FILE* logging::handle = 0;
void logging::Initialize() {
passwd* pwd = getpwuid(getuid());
char* user = pwd->pw_name;
logging::handle = fopen((const char*)strfmt("/tmp/cathook-%s.log", user), "w");
logging::handle = fopen(strfmt("/tmp/cathook-%s.log", user), "w");
}
void logging::Info(const char* fmt, ...) {

View File

@ -8,14 +8,13 @@
#include "sharedobj.h"
#include "logging.h"
#include "helpers.h"
#include "sstring.h"
#include <unistd.h>
#include <link.h>
#include <dlfcn.h>
const char* path_from_proc_maps(const char* name) {
FILE* proc_maps = fopen((const char*)strfmt("/proc/%i/maps", getpid()), "r");
FILE* proc_maps = fopen(strfmt("/proc/%i/maps", getpid()), "r");
if (!proc_maps) return (const char*)0;
char* buffer = new char[512];
while (fgets(buffer, 512, proc_maps)) {

View File

@ -1,22 +0,0 @@
/*
* sstring.h
*
* Created on: Dec 23, 2016
* Author: nullifiedcat
*/
#ifndef SSTRING_H_
#define SSTRING_H_
class sstring {
public:
inline sstring() { length = 0; p_String = 0; };
inline sstring(int length) { this->length = length; p_String = new char[length]; }
inline ~sstring() { delete [] p_String; }
inline operator const char*() const { return p_String; };
inline operator char*() const { return (char*)p_String; }
const char* p_String;
int length;
};
#endif /* SSTRING_H_ */