Menu: Fix memory leak that'll when preparing some TCP streams. Fix a name display issue in the IRC log.
This commit is contained in:
parent
b3713ca0ab
commit
1fca666a5f
3 changed files with 43 additions and 33 deletions
|
@ -105,13 +105,15 @@ class func_door:CBaseTrigger
|
|||
virtual void(void) m_pMove = 0;
|
||||
};
|
||||
|
||||
void func_door::Use(void)
|
||||
void
|
||||
func_door::Use(void)
|
||||
{
|
||||
eActivator.gflags &= ~GF_USE_RELEASED;
|
||||
Trigger();
|
||||
}
|
||||
|
||||
void func_door::Arrived(void)
|
||||
void
|
||||
func_door::Arrived(void)
|
||||
{
|
||||
m_iState = DOORSTATE_RAISED;
|
||||
|
||||
|
@ -134,7 +136,8 @@ void func_door::Arrived(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door::Returned(void)
|
||||
void
|
||||
func_door::Returned(void)
|
||||
{
|
||||
if (m_strSndStop) {
|
||||
sound(this, CHAN_VOICE, m_strSndStop, 1.0f, ATTN_NORM);
|
||||
|
@ -158,7 +161,8 @@ void func_door::Returned(void)
|
|||
m_iState = DOORSTATE_LOWERED;
|
||||
}
|
||||
|
||||
void func_door::MoveBack(void)
|
||||
void
|
||||
func_door::MoveBack(void)
|
||||
{
|
||||
if (m_strSndMove) {
|
||||
sound(this, CHAN_VOICE, m_strSndMove, 1.0f, ATTN_NORM);
|
||||
|
@ -174,7 +178,8 @@ void func_door::MoveBack(void)
|
|||
MoveToDestination(m_vecPos1, Returned);
|
||||
}
|
||||
|
||||
void func_door::MoveAway(void)
|
||||
void
|
||||
func_door::MoveAway(void)
|
||||
{
|
||||
if (m_iState == DOORSTATE_UP) {
|
||||
return;
|
||||
|
@ -197,7 +202,8 @@ void func_door::MoveAway(void)
|
|||
MoveToDestination(m_vecPos2, Arrived);
|
||||
}
|
||||
|
||||
void func_door::Trigger(void)
|
||||
void
|
||||
func_door::Trigger(void)
|
||||
{
|
||||
if (m_flNextTrigger > time) {
|
||||
if (!(spawnflags & SF_MOV_TOGGLE)) {
|
||||
|
@ -223,7 +229,8 @@ void func_door::Trigger(void)
|
|||
MoveAway();
|
||||
}
|
||||
|
||||
void func_door::Touch(void)
|
||||
void
|
||||
func_door::Touch(void)
|
||||
{
|
||||
if (spawnflags & SF_MOV_TOGGLE) {
|
||||
return;
|
||||
|
@ -241,7 +248,8 @@ void func_door::Touch(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door::Blocked(void)
|
||||
void
|
||||
func_door::Blocked(void)
|
||||
{
|
||||
if (m_iDamage) {
|
||||
Damage_Apply(other, this, m_iDamage, 0, DMG_CRUSH);
|
||||
|
@ -256,7 +264,8 @@ void func_door::Blocked(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door::SetMovementDirection(void)
|
||||
void
|
||||
func_door::SetMovementDirection(void)
|
||||
{
|
||||
if (angles == [0,-1,0]) {
|
||||
m_vecMoveDir = [0,0,1];
|
||||
|
@ -268,7 +277,8 @@ void func_door::SetMovementDirection(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door::MoveToDestination_End(void)
|
||||
void
|
||||
func_door::MoveToDestination_End(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
|
@ -276,7 +286,8 @@ void func_door::MoveToDestination_End(void)
|
|||
m_pMove();
|
||||
}
|
||||
|
||||
void func_door::MoveToDestination(vector vecDest, void(void) func)
|
||||
void
|
||||
func_door::MoveToDestination(vector vecDest, void(void) func)
|
||||
{
|
||||
vector vecDifference;
|
||||
float flTravel;
|
||||
|
@ -311,7 +322,8 @@ void func_door::MoveToDestination(vector vecDest, void(void) func)
|
|||
velocity = (vecDifference * (1.0f / fTravelTime));
|
||||
}
|
||||
|
||||
void func_door::Respawn(void)
|
||||
void
|
||||
func_door::Respawn(void)
|
||||
{
|
||||
/* reset */
|
||||
m_vecPos1 = [0,0,0];
|
||||
|
@ -373,7 +385,8 @@ void func_door::Respawn(void)
|
|||
SetAngles([0,0,0]);
|
||||
}
|
||||
|
||||
void func_door::func_door(void)
|
||||
void
|
||||
func_door::func_door(void)
|
||||
{
|
||||
int x;
|
||||
|
||||
|
@ -430,7 +443,8 @@ void func_door::func_door(void)
|
|||
precache_sound(m_strSndStop);
|
||||
}
|
||||
|
||||
void func_water(void)
|
||||
void
|
||||
func_water(void)
|
||||
{
|
||||
spawnfunc_func_door();
|
||||
self.classname = "func_water";
|
||||
|
|
|
@ -54,20 +54,10 @@ cr_print(string buffer)
|
|||
cr_lbHistory.InsertWrapped(buffer);
|
||||
}
|
||||
|
||||
/* tempstrings and fwrite == not a good idea. we need to manually copy all
|
||||
* the chars. sigh.
|
||||
* for static strings however, we can just use TCP_Send as is. */
|
||||
void
|
||||
irc_send(string msg)
|
||||
{
|
||||
string out;
|
||||
|
||||
out = (string)memalloc(strlen(msg));
|
||||
|
||||
for (float i = 0; i < strlen(msg); i++)
|
||||
out[i] = str2chr(msg, i);
|
||||
|
||||
TCP_Send(&tcp_irc, out);
|
||||
TCP_Send(&tcp_irc, msg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -244,11 +234,12 @@ cr_makeconnection(void)
|
|||
i = TCP_Connect(&tcp_irc, "tcp://irc.frag-net.com:6667");
|
||||
|
||||
g_ircroom.m_strChannel = sprintf("#%s", cvar_string("game"));
|
||||
TCP_Send(&tcp_irc, "USER guest fn irc.won.net :Player\n");
|
||||
irc_send("USER guest fn irc.won.net :Player\n");
|
||||
|
||||
/* attempt to force our nickname to be the same as in-game.
|
||||
* we'll probably have to keep track of event 433 though. */
|
||||
irc_send(sprintf("NICK %s\n", cvar_string("name")));
|
||||
g_ircroom.m_strNick = cvar_string("name");
|
||||
irc_send(sprintf("NICK %s\n", g_ircroom.m_strNick));
|
||||
}
|
||||
|
||||
/* when ENTER is pressed on the message box */
|
||||
|
|
|
@ -90,25 +90,29 @@ TCP_Receive(tcpinfo_t *in)
|
|||
void
|
||||
TCP_Frame(tcpinfo_t *in)
|
||||
{
|
||||
string data;
|
||||
string out;
|
||||
|
||||
/* not even open */
|
||||
if (in.m_iState == STATE_DISCONNECTED)
|
||||
return;
|
||||
|
||||
data = in.m_strBuffer[0];
|
||||
|
||||
/* got nothing worth sending */
|
||||
if (data == "" || in.m_iBufferLines <= 0)
|
||||
if (in.m_strBuffer[0] == "" || in.m_iBufferLines <= 0)
|
||||
return;
|
||||
|
||||
/* if the send was unsuccessful, try next frame */
|
||||
if (fwrite(in.m_fSocket, (void *)data, strlen(data)) <= 0) {
|
||||
out = (string)memalloc(strlen(in.m_strBuffer[0]));
|
||||
|
||||
for (float i = 0; i < strlen(in.m_strBuffer[0]); i++)
|
||||
out[i] = str2chr(in.m_strBuffer[0], i);
|
||||
|
||||
if (fwrite(in.m_fSocket, (void *)out, strlen(in.m_strBuffer[0])) <= 0) {
|
||||
dprint("^1TCP_Frame^7: Unsuccessful frame\n");
|
||||
memfree(out);
|
||||
return;
|
||||
}
|
||||
|
||||
print(sprintf("^1TCP_Frame^7: Sent %s", data));
|
||||
print(sprintf("^1TCP_Frame^7: Sent %s", in.m_strBuffer[0]));
|
||||
|
||||
/* at least one successful write went through */
|
||||
in.m_iState = STATE_CONNECTED;
|
||||
|
@ -119,6 +123,7 @@ TCP_Frame(tcpinfo_t *in)
|
|||
}
|
||||
|
||||
in.m_iBufferLines--;
|
||||
memfree(out);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue