Redid lots of destruction stuff.

This commit is contained in:
David Anderson 2004-03-15 20:27:53 +00:00
parent 439550c2ac
commit ee947b1673
2 changed files with 44 additions and 31 deletions

View File

@ -34,10 +34,6 @@
#define VERSION "0.15"
#include <string>
using namespace std;
plugin_info_t Plugin_info = {
META_INTERFACE_VERSION, // ifvers
@ -378,6 +374,7 @@ public:
writeangle = 0.0;
writecoord = 0.0;
writeentity = 0;
writestring = NULL;
}
argStack* arg()
@ -393,6 +390,13 @@ public:
return next;
}
~argStack()
{
if (writestring != NULL) {
delete [] writestring;
}
}
void put(int arg_type, int i)
{
argtype = arg_type;
@ -436,7 +440,9 @@ public:
switch (argtype)
{
case arg_string:
writestring.append((char *)sz);
delete [] writestring;
writestring = new char[strlen(sz)+1];
strcpy(writestring, sz);
break;
}
}
@ -464,7 +470,7 @@ public:
WRITE_COORD(writecoord);
break;
case arg_string:
WRITE_STRING(writestring.c_str());
WRITE_STRING(writestring);
break;
case arg_entity:
WRITE_ENTITY(writeentity);
@ -515,7 +521,7 @@ public:
switch (argtype)
{
case arg_string:
return (writestring.length());
return strlen(writestring);
break;
}
return 0;
@ -526,7 +532,7 @@ public:
switch (argtype)
{
case arg_string:
return writestring.c_str();
return (const char*)writestring;
break;
}
@ -720,6 +726,20 @@ public:
}
}
void destroy()
{
argStack *p;
while (next != NULL) {
p = next->link();
delete next;
next = p;
}
if (p != NULL) {
delete p;
p = NULL;
}
}
private:
int argtype;
int writebyte;
@ -728,7 +748,7 @@ private:
int writelong;
float writeangle;
float writecoord;
std::string writestring;
char *writestring;
int writeentity;
argStack *next;
};
@ -808,16 +828,9 @@ public:
void Destroy()
{
argStack *p;
p = CHeadArg->link();
while (p) {
argStack *n = p->link();
delete p;
p = n;
}
argcount = 0;
CHeadArg->destroy();
delete CHeadArg;
CHeadArg = NULL;
}
bool Set(int n, int arg_type, int data)

View File

@ -42,12 +42,8 @@
#include <limits.h>
#include "engine.h"
extern "C" void destroy(MessageInfo* p) {
delete p;
}
GlobalInfo GlInfo;
MessageInfo *msgd;
MessageInfo *msgd = NULL;
bool isMsgHooked[MAX_MESSAGES];
int inHookProcess;
edict_t *valid_ent(int ent);
@ -268,16 +264,20 @@ static cell AMX_NATIVE_CALL get_msg_arg_string(AMX *amx, cell *params)
int argn = params[1];
int iLen = 0;
char *szValue = '\0';
char *szRetr;
if (inHookProcess && msgd!=NULL) {
if (argn <= msgd->args() && argn > 0) {
iLen = msgd->RetArg_Strlen(argn);
szValue = new char[iLen+1];
strcpy(szValue, msgd->RetArg_String(argn));
if (strlen(szValue)) {
return SET_AMXSTRING(amx, params[2], szValue, params[3]);
} else {
return SET_AMXSTRING(amx, params[2], "", params[3]);
szRetr = (char *)msgd->RetArg_String(argn);
if (szRetr != NULL) {
strcpy(szValue, szRetr);
if (strlen(szValue)) {
return SET_AMXSTRING(amx, params[2], szValue, params[3]);
} else {
return SET_AMXSTRING(amx, params[2], "", params[3]);
}
}
} else {
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
@ -2943,7 +2943,7 @@ void MessageEnd(void) {
msgd->SendMsg();
RETURN_META(MRES_SUPERCEDE);
}
destroy(msgd);
delete msgd;
msgd = NULL;
}
@ -3106,7 +3106,7 @@ void ServerDeactivate() {
}
if (msgd != NULL) {
destroy(msgd);
delete msgd;
msgd = NULL;
}