Code: Show/Hide ... local void SSSC_GoalAction(Arena *arena, Player *p, int bid, int x, int y) { chat->SendArenaMessage(arena, "SSSC_game - Goal detected"); } // The entry point: EXPORT int MM_sssc_game(int action, Imodman *mm_, Arena *arena) { int rv = MM_FAIL; // return value if (action == MM_LOAD) { mm = mm_; ball = mm->GetInterface(I_BALLS, ALLARENAS); game = mm->GetInterface(I_GAME, ALLARENAS); stats = mm->GetInterface(I_STATS, ALLARENAS); pd = mm->GetInterface(I_PLAYERDATA, ALLARENAS); chat = mm->GetInterface(I_GAME, ALLARENAS); if (!ball || !game || !stats || !pd || !chat) { // release interfaces if loading failed mm->ReleaseInterface(ball); mm->ReleaseInterface(game); mm->ReleaseInterface(stats); mm->ReleaseInterface(pd); mm->ReleaseInterface(chat); rv = MM_FAIL; } else { // callbacks mm->RegCallback(CB_GOAL, SSSC_GoalAction, ALLARENAS); rv = MM_OK; } } ... |
Code: Show/Hide [Soccer] DisableWallPass=1 DisableBallKilling=0 BallBounce=1 AllowBombs=1 AllowGuns=1 PassDelay=10 Mode=1 BallBlankDelay=200 UseFlagger=0 BallLocation=1 BallCount=1 SendTime=200 Reward=0 CapturePoints=-1 CatchMinimum=1 CatchPoints=1 WinBy=1 |
Code: Show/Hide else if (action == MM_ATTACH)
{ rv = MM_OK; } else if (action == MM_DETACH) { rv = MM_OK; } |
Code: Show/Hide #include "balls.h" local Iballs *ball; |
Code: Show/Hide void PGoal(Player *p, byte *pkt, int len) { Arena *arena = p->arena; ArenaBallData *abd = P_ARENA_DATA(arena, abdkey); MyBallData *pbd = P_ARENA_DATA(arena, pbdkey); int bid; struct C2SGoal *g = (struct C2SGoal*)pkt; struct BallData *bd; if (len != sizeof(struct C2SGoal)) { logm->LogP(L_MALICIOUS, "balls", p, "bad size for goal packet"); return; } if (!arena || p->status != S_PLAYING) { logm->LogP(L_WARN, "balls", p, "goal packet from bad arena or status"); return; } LOCK_STATUS(arena); bid = g->ballid; if (bid < 0 || bid >= abd->ballcount) { logm->LogP(L_MALICIOUS, "balls", p, "sent a goal for a nonexistent ball"); UNLOCK_STATUS(arena); return; } bd = abd->balls + bid; /* we use this as a flag to check for dupilicated goals */ if (bd->carrier == NULL) { UNLOCK_STATUS(arena); return; } if (bd->state != BALL_ONMAP) { logm->LogP(L_WARN, "balls", p, "state sync problem: sent goal for carried ball"); UNLOCK_STATUS(arena); return; } if (p != bd->carrier) { logm->LogP(L_MALICIOUS, "balls", p, "sent goal for ball he didn't fire"); UNLOCK_STATUS(arena); return; } /* do callbacks before spawning */ DO_CBS(CB_GOAL, arena, GoalFunc, (arena, p, g->ballid, g->x, g->y)); |
Icebird wrote: |
I never used MM_ATTACH/DETACH in my own modules. However the first two (sssc_shields & sssc_spawn) worked without it. I added Hakaku's code for MM_ATTACH/DETACH to sssc_game. It is listed in ?lsmod -a but it doesn't work. |
Icebird wrote: |
I logged it and I see the log message in the asss console so the "error" probably is in balls.c. Unfortuantely I don't know how to debug the dll (using Dev-C++). |
Code: Show/Hide #include "asss.h" #define SSSC_VERBOSE 1 // Interfaces local Imodman *mm; local Iballs *ball; local Igame *game; local Istats *stats; local Iplayerdata *pd; local Ichat *chat; local Ilogman *lm; // This function is called when a goal is scored local void SSSC_GoalAction(Arena *arena, Player *p, int bid, int x, int y) { Player *player; Link *link; if (SSSC_VERBOSE) chat->SendArenaMessage(arena, "SSSC_game - Goal detected"); pd->Lock(); FOR_EACH_PLAYER(player) { if (SSSC_VERBOSE) chat->SendMessage(player, "SSSC_game - Preparing for restart"); // warp the player back to the spawn if (p->status == S_PLAYING) { Target t; t.type = T_PLAYER; t.u.p = player; if (SSSC_VERBOSE) chat->SendMessage(player, "SSSC_game - Warping you back to spawn"); // if (x < 0 || y < 0) // { // if (SSSC_VERBOSE) chat->SendArenaMessage(player->arena, "SSSC_spawn - Invalid warp coordinates for %s [%i,%i]", player->name, aw->x, aw->y); // continue; // } // game->WarpTo(&t, aw->x, aw->y); game->ShipReset(&t); } // reset his points } pd->Unlock(); stats->SendUpdates(NULL); } // The entry point: EXPORT int MM_sssc_game(int action, Imodman *mm_, Arena *arena) { int rv = MM_FAIL; // return value if (action == MM_LOAD) { mm = mm_; ball = mm->GetInterface(I_BALLS, ALLARENAS); game = mm->GetInterface(I_GAME, ALLARENAS); stats = mm->GetInterface(I_STATS, ALLARENAS); pd = mm->GetInterface(I_PLAYERDATA, ALLARENAS); chat = mm->GetInterface(I_GAME, ALLARENAS); lm = mm->GetInterface(I_LOGMAN, ALLARENAS); if (!ball || !game || !stats || !pd || !chat || !lm) { // release interfaces if loading failed mm->ReleaseInterface(ball); mm->ReleaseInterface(game); mm->ReleaseInterface(stats); mm->ReleaseInterface(pd); mm->ReleaseInterface(chat); mm->ReleaseInterface(lm); rv = MM_FAIL; } else { // callbacks mm->RegCallback(CB_GOAL, SSSC_GoalAction, ALLARENAS); lm->Log(L_INFO, "<SSSC_game> registered CB_GOAL"); // timers // times are in centiseconds // commands rv = MM_OK; } } else if (action == MM_UNLOAD) { // clear timers // unregister callbacks mm->UnregCallback(CB_GOAL, SSSC_GoalAction, ALLARENAS); // free allocated data // release interfaces mm->ReleaseInterface(ball); mm->ReleaseInterface(game); mm->ReleaseInterface(stats); mm->ReleaseInterface(pd); mm->ReleaseInterface(chat); mm->ReleaseInterface(lm); rv = MM_OK; } else if (action == MM_ATTACH) { rv = MM_OK; } else if (action == MM_DETACH) { rv = MM_OK; } return rv; } |
Code: Show/Hide chat = mm->GetInterface(I_GAME, ALLARENAS); |