Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Mainloop Timer

 
Post new topic   Reply to topic Printable version
 View previous topic  Update the ASSS guides links Post :: Post Balls stuff  View next topic  
Author Message
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Sat Jun 26, 2010 4:38 pm    Post subject: Mainloop Timer Reply to topic Reply with quote

Why is it that everytime I try to loop over every player within a timer, it just ends up triggering a deadlock? If I remove the FOR_EACH_PLAYER loop, then it continues without a hitch. What exactly am I doing wrong and how else can I achieve this?

Edit: Nevermind, I typo'd playerdata -_-;

Code: Show/Hide

#include "asss.h"

local Imodman     *mm;
local Iarenaman   *aman;
local Imainloop   *mainloop;
local Iplayerdata *pd;

local int timer(void *arena_)
{
   Arena *arena = arena_;

   Player *p;
   Link *link;

   pd->Lock();
   FOR_EACH_PLAYER(p)
   {
      //crashes here
   }
   pd->Unlock();

   return 1;
}

EXPORT int MM_mymodule(int action, Imodman *mm_, Arena *arena)
{
   if (action == MM_LOAD)
   {
      mm = mm_;
      aman = mm->GetInterface(I_ARENAMAN, ALLARENAS);
      mainloop = mm->GetInterface(I_MAINLOOP, ALLARENAS);
      pd = mm->GetInterface(I_PLAYERDATA, ALLARENAS);

      if (!aman || !mainloop || !pd)
         return MM_FAIL;

      return MM_OK;
   }
   else if (action == MM_UNLOAD)
   {
      mainloop->ClearTimer(timer, NULL);
      mm->ReleaseInterface(pd);
      mm->ReleaseInterface(mainloop);
      mm->ReleaseInterface(aman);
      return MM_OK;
   }
   else if (action == MM_ATTACH)
   {
      mainloop->SetTimer(timer, 500, 100, arena, arena);
      return MM_OK;
   }
   else if (action == MM_DETACH)
   {
      mainloop->ClearTimer(timer, arena);
      return MM_OK;
   }
   return MM_FAIL;
}
Back to top
View users profile Send private message Add User to Ignore List Send email
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 71 page(s) served in previous 5 minutes.

phpBB Created this page in 0.082846 seconds : 26 queries executed (56.4%): GZIP compression disabled