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
hs_antiwarp

 
Post new topic   Reply to topic Printable version
 View previous topic  hs_listnewb Post :: Post PATCH: TCP Billing on Windows  View next topic  
Author Message
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Aug 16, 2004 12:14 am    Post subject: hs_antiwarp Reply to topic Reply with quote

Removes antiwarp from players in the "noanti" region.

It will first try to disable the client's antiwarp.

If anti remains on, it will deprize it.

Code: Show/Hide

#include "../asss.h"

struct adata
{
   int on;
};

struct pdata
{
   time_t last;
   int count;
};

/* global data */
local int adkey;
local int pdkey;

local Iplayerdata *pd;
local Ilogman *lm;
local Inet *net;
local Imapdata *mapdata;
local Iarenaman *aman;
local Igame *game;


local void DoChecksum(struct S2CWeapons *pkt)
{
   int i;
   u8 ck = 0;
   pkt->checksum = 0;
   for (i = 0; i < sizeof(struct S2CWeapons) - sizeof(struct ExtraPosData); i++)
      ck ^= ((unsigned char*)pkt)[i];
   pkt->checksum = ck;
}

local void Pppk(Player *p, byte *p2, int len)
{
   struct C2SPosition *pos = (struct C2SPosition *)p2;
   Arena *arena = p->arena;
   struct adata *ad = P_ARENA_DATA(arena, adkey);

   if (len < 22)
      return;

   /* handle common errors */
   if (!arena || !ad->on) return;

   if (p->p_ship == SHIP_SPEC)
      return;

   if (pos->status & STATUS_ANTIWARP && mapdata->InRegion(arena, "noanti", pos->x>>4, pos->y>>4))
   {
      struct pdata *data = PPDATA(p, pdkey);

      //lm->LogP(L_DRIVEL, "hs_antiwarp", p, "removing anti.");
      if (data->last + 50 < current_ticks())
      {
         if (data->count < 4)
         {
            data->count++;

            struct S2CWeapons wpn = {
               S2C_WEAPON, pos->rotation, pos->time & 0xFFFF, pos->x, pos->yspeed,
               p->pid, pos->xspeed, 0, pos->status & ~STATUS_ANTIWARP, 0, pos->y, pos->bounty
            };

            DoChecksum(&wpn);
            net->SendToArena(arena, NULL, (byte*)&wpn, sizeof(struct S2CWeapons) -
                  sizeof(struct ExtraPosData), NET_PRI_P4);
         }
         else
         {
            Target t;
            t.type = T_PLAYER;
            t.u.p = p;
            game->GivePrize(&t, -20, 1);

            data->count = 0;
         }

         //update last time
         data->last = current_ticks();
      }
   }
}

EXPORT int MM_hs_antiwarp(int action, Imodman *mm, Arena *arena)
{
   if (action == MM_LOAD)
   {
      pd = mm->GetInterface(I_PLAYERDATA, ALLARENAS);
      lm = mm->GetInterface(I_LOGMAN, ALLARENAS);
      net = mm->GetInterface(I_NET, ALLARENAS);
      mapdata = mm->GetInterface(I_MAPDATA, ALLARENAS);
      aman = mm->GetInterface(I_ARENAMAN, ALLARENAS);
      game = mm->GetInterface(I_GAME, ALLARENAS);

      if (!pd || !lm || !net || !mapdata || !aman || !game) return MM_FAIL;

      adkey = aman->AllocateArenaData(sizeof(struct adata));
      if (adkey == -1) return MM_FAIL;

      pdkey = pd->AllocatePlayerData(sizeof(struct pdata));
      if (pdkey == -1) return MM_FAIL;

      net->AddPacket(C2S_POSITION, Pppk);

      return MM_OK;
   }
   else if (action == MM_UNLOAD)
   {
      net->RemovePacket(C2S_POSITION, Pppk);
      aman->FreeArenaData(adkey);
      pd->FreePlayerData(pdkey);

      mm->ReleaseInterface(pd);
      mm->ReleaseInterface(lm);
      mm->ReleaseInterface(net);
      mm->ReleaseInterface(mapdata);
      mm->ReleaseInterface(aman);
      mm->ReleaseInterface(game);
      return MM_OK;
   }
   else if (action == MM_ATTACH)
   {
      struct adata *ad = P_ARENA_DATA(arena, adkey);
      ad->on = 1;
      return MM_OK;
   }
   else if (action == MM_DETACH)
   {
      struct adata *ad = P_ARENA_DATA(arena, adkey);
      ad->on = 0;
      return MM_OK;
   }
   return MM_FAIL;
}

_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me




hs_antiwarp.c - 2.98 KB
File downloaded or viewed 41 time(s)
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects 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: 726 page(s) served in previous 5 minutes.

phpBB Created this page in 0.414033 seconds : 28 queries executed (89.2%): GZIP compression disabled