Removed std::string

This commit is contained in:
David Anderson 2004-06-29 06:56:31 +00:00
parent 47dd28bd63
commit 743767610a
3 changed files with 20 additions and 11 deletions

View File

@ -1,7 +1,6 @@
#ifndef _ENGINE_INCLUDE_H #ifndef _ENGINE_INCLUDE_H
#define _ENGINE_INCLUDE_H #define _ENGINE_INCLUDE_H
#include <string>
#include <extdll.h> #include <extdll.h>
#include <string.h> #include <string.h>
#include <meta_api.h> #include <meta_api.h>

View File

@ -1,7 +1,5 @@
#include "engine.h" #include "engine.h"
using namespace std;
CVector<argMsg*> Msg; CVector<argMsg*> Msg;
int msgHooks[256] = {0}; int msgHooks[256] = {0};
int msgBlocks[256] = {0}; int msgBlocks[256] = {0};
@ -22,7 +20,11 @@ void argMsg::Reset()
{ {
iData = 0; iData = 0;
fData = 0.0; fData = 0.0;
cData.assign(""); if (cData)
{
delete [] cData;
cData = NULL;
}
type = 0; type = 0;
} }
@ -49,7 +51,7 @@ void argMsg::Send()
WRITE_COORD(fData); WRITE_COORD(fData);
break; break;
case arg_string: case arg_string:
WRITE_STRING(cData.c_str()); WRITE_STRING(cData);
break; break;
case arg_entity: case arg_entity:
WRITE_ENTITY(iData); WRITE_ENTITY(iData);
@ -236,11 +238,15 @@ void WriteString(const char *sz)
} else if (inhook) { } else if (inhook) {
if (++msgCount > Msg.size()) { if (++msgCount > Msg.size()) {
argMsg *p = new argMsg(); argMsg *p = new argMsg();
p->cData.assign(sz); p->cData = new char[strlen(sz)+1];
strcpy(p->cData, sz);
p->cData[strlen(sz)] = 0;
p->type = arg_string; p->type = arg_string;
Msg.push_back(p); Msg.push_back(p);
} else { } else {
Msg[msgCount-1]->cData.assign(sz); Msg[msgCount-1]->cData = new char[strlen(sz)+1];
strcpy(Msg[msgCount-1]->cData, sz);
Msg[msgCount-1]->cData[strlen(sz)] = 0;
Msg[msgCount-1]->type = arg_string; Msg[msgCount-1]->type = arg_string;
} }
RETURN_META(MRES_SUPERCEDE); RETURN_META(MRES_SUPERCEDE);
@ -417,9 +423,9 @@ static cell AMX_NATIVE_CALL get_msg_arg_string(AMX *amx, cell *params)
return 0; return 0;
} }
const char *szVal = Msg[argn]->cData.c_str(); const char *szVal = Msg[argn]->cData;
return MF_SetAmxString(amx, params[2], szVal, params[3]); return MF_SetAmxString(amx, params[2], szVal?szVal:"", params[3]);
} }
static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params)
@ -434,7 +440,11 @@ static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params)
char *szVal = MF_GetAmxString(amx, params[2], 0, &iLen); char *szVal = MF_GetAmxString(amx, params[2], 0, &iLen);
Msg[argn]->cData.assign(szVal); if (Msg[argn]->cData)
delete [] Msg[argn]->cData;
Msg[argn]->cData = new char[strlen(szVal)+1];
strcpy(Msg[argn]->cData, szVal);
Msg[argn]->cData[strlen(szVal)] = 0;
return 1; return 1;
} }

View File

@ -36,7 +36,7 @@ public:
int type; int type;
REAL fData; REAL fData;
std::string cData; char *cData;
int iData; int iData;
}; };