Raised This Month: $51 Target: $400
 12% 

Removing entity causing freeze?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-30-2008 , 01:08   Removing entity causing freeze?
Reply With Quote #1

Is there a circumstance under which removing an entity could cause a server to freeze? I have a plugin that's freezing my server a small fraction of the time and I can't pin down the problem.

(I'm using EF_RemoveEntity from fakemeta_stocks.inc)
Prajch is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-30-2008 , 01:35   Re: Removing entity causing freeze?
Reply With Quote #2

It would help with your code.

You can try :
PHP Code:
set_pev(entitypev_flagsFL_KILLME)
dllfunc(DLLFunc_Thinkentity
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-30-2008 at 11:40.
ConnorMcLeod is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-30-2008 , 02:06   Re: Removing entity causing freeze?
Reply With Quote #3

Well it's a fairly big section of code... I'll try what you suggested and see if it helps, thanks.
Prajch is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 09-30-2008 , 08:36   Re: Removing entity causing freeze?
Reply With Quote #4

usually removing should not freeze the server. removing entitys can just fuck up the map if you remove every single spawn withotu creating enw ones or bombzones etc if your server is a ordinary shooting server.
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-30-2008 , 15:55   Re: Removing entity causing freeze?
Reply With Quote #5

I'm starting to think that RemoveEntity isn't the problem... Here's a section of the code that I think contains what is causing the freeze.

PHP Code:
     if(elapsedTime >= fuseTime && bombExists[ownerID])
     {
          static 
Float:damageFloat:radius
          damage 
get_pcvar_float(cvar_damage)
          
radius get_pcvar_float(cvar_radius)
 
          new 
0
 
          
while(32)
          {
               
EF_FindEntityInSphere(ibombOriginradius)
 
               static 
Float:origin[3], Float:distance
               pev
(ipev_originorigin)
               
distance get_distance_f(bombOriginorigin)
 
               if(
is_user_alive(i) && distance <= radius)
               {
                    static 
Float:health
                    pev
(ipev_healthhealth)
                    
health health damage * (1.0 distance radius)      //distance-dependent damage
 
                    
if(health >= 1.0)
                    {
                         
set_pev(ipev_healthhealth)
                    }
                    else
                    {
                         
//create a cherry bomb death message
                         
message_begin(MSG_ALLdeathMsgid)
                         
write_byte(ownerID)
                         
write_byte(i)
                         
write_byte(0)
                         
write_string("cherry bomb")
                         
message_end()
 
                         
user_silentkill(i)
                         
////////////////////////////////////////////////////////////////
                         //Update the victim's scoreboard to cancel the loss of a frag.//
                         //user_silentkill() doesn't update it immediately.            //
                         //If it isn't delayed, the message gets overridden.           //
                         ////////////////////////////////////////////////////////////////
                         
static fragsdeathsteam
                         frags 
get_user_frags(i)
                         
deaths get_pdata_int(iOFFSET_CSDEATHS)
                         
team get_pdata_int(iOFFSET_TEAM)
 
                         
set_pev(ipev_fragsfloat(frags)) //update frags
 
                         
static arg[3]
                         
arg[0] = frags
                         arg
[1] = deaths
                         arg
[2] = team
                         set_task
(0.1"scoreUpdate"iarg3)
                         
////////////////////////////////////////////////////////
                         //Give the killer a frag, unless it was self-inflicted//
                         ////////////////////////////////////////////////////////
                         
if(!= ownerID)
                         {
                              
frags get_user_frags(ownerID) + 1
                              deaths 
get_pdata_int(ownerIDOFFSET_CSDEATHS)
                              
team get_pdata_int(ownerIDOFFSET_TEAM)
 
                              
set_pev(ownerIDpev_fragsfloat(frags)) //update frags
 
                              
arg[0] = frags
                              arg
[1] = deaths
                              arg
[2] = team
                              set_task
(0.1"scoreUpdate"ownerIDarg3)
                         }
                    }
               }
          }
          
//create the explosion visuals and sounds
          
EF_MessageBegin(MSG_PVSSVC_TEMPENTITYbombOrigin0)
          
write_byte(TE_EXPLOSION)
          
EF_WriteCoord(bombOrigin[0] + 10.0)
          
EF_WriteCoord(bombOrigin[1])
          
EF_WriteCoord(bombOrigin[2] + 5.0)
          
write_short(explosionIndex)
          
write_byte(10)               //scale in 0.1's
          
write_byte(45)               //framerate
          
write_byte(TE_EXPLFLAG_NOSOUND)     //flags
          
message_end()
 
          
emit_sound(bombCHAN_BODYexplosionSound0.7ATTN_NORM0200)
          
emit_sound(bombCHAN_WEAPONexplosionSound20.6ATTN_NORM0175)
 
          
EF_RemoveEntity(bomb)
          
bombExists[ownerID] = false //owner no longer has a bomb deployed
     

Prajch is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-30-2008 , 16:01   Re: Removing entity causing freeze?
Reply With Quote #6

If that code from above is called on a forward try to return SUPERCEDE, to handle the nextthink of ent. But i think that while(i < 32) is creating an infinite loop.
Alka is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 09-30-2008 , 16:06   Re: Removing entity causing freeze?
Reply With Quote #7

Hmm you know, you're probably right! I never thought about the case where it wouldn't be able to find enough entities around it to go beyond 32. I'll try that tonight.

By the way it is called on a forward. Why do you say it should return FMRES_SUPERCEDE?

[edit] Also does FindEntityInSphere return 0 on failure only, or is it possible that it could return 0 when hitting worldspawn?
Prajch is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 10-01-2008 , 00:17   Re: Removing entity causing freeze?
Reply With Quote #8

[edit] Also does FindEntityInSphere return 0 on failure only, or is it possible that it could return 0 when hitting worldspawn?

while(ent = FindEnitityInSphear

;) I'm not tying it out you seem smart enough ... but as far as Iknow, it loops for ever and while true (while there is an entity) blah..
Styles is offline
Send a message via AIM to Styles
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 10-01-2008 , 04:04   Re: Removing entity causing freeze?
Reply With Quote #9

Quote:
Originally Posted by styles View Post
[edit] Also does FindEntityInSphere return 0 on failure only, or is it possible that it could return 0 when hitting worldspawn?

while(ent = FindEnitityInSphear

;) I'm not tying it out you seem smart enough ... but as far as Iknow, it loops for ever and while true (while there is an entity) blah..
[edit] Nevermind, misunderstood your code. That's a pretty good idea.

Last edited by Prajch; 10-01-2008 at 04:11.
Prajch is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode