From 4c2698210a06d6e4479d4e2ac7fcfb8ea21213d2 Mon Sep 17 00:00:00 2001 From: Dino <8dino2@gmail.com> Date: Mon, 4 Sep 2023 17:36:53 -0400 Subject: [PATCH] A few more adds/fixes --- actionlite/g_local.h | 11 +++++- actionlite/g_svcmds.cpp | 87 +++++++++++++++++++++++++++++++++++++++++ actionlite/p_client.cpp | 16 ++++---- 3 files changed, 106 insertions(+), 8 deletions(-) diff --git a/actionlite/g_local.h b/actionlite/g_local.h index 25e6c1c..058a45f 100644 --- a/actionlite/g_local.h +++ b/actionlite/g_local.h @@ -1938,6 +1938,11 @@ extern gitem_t itemlist[IT_TOTAL]; #define ENHANCED_BANDAGE_TIME 10 #define BLEED_TIME 10 // 10 = 1 second is time for losing 1 health at slowest bleed rate +// edict->client->pers.spec_flags +#define SPECFL_KILLFEED 0x00000001 +#define SPECFL_SPECHUD 0x00000002 +#define SPECFL_SPECHUD_NEW 0x00000004 + // Firing styles (where shots originate from) #define ACTION_FIRING_CENTER 0 #define ACTION_FIRING_CLASSIC 1 @@ -1949,6 +1954,7 @@ extern gitem_t itemlist[IT_TOTAL]; #define CROUCHING_VIEWHEIGHT 8 #define STANDING_VIEWHEIGHT 22 +extern team_t teams[TEAM_TOP]; int32_t gameSettings; // Round based, deathmatch, etc? extern cvar_t *allitem; @@ -2458,6 +2464,9 @@ void player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage // void ServerCommand(); bool SV_FilterPacket(const char *from); +// ACTION +bool Ban_TeamKiller (edict_t * ent, int rounds); +void UnBan_TeamKillers (void); // // p_view.c @@ -2853,7 +2862,7 @@ struct client_persistant_t int32_t hc_mode; int32_t id; // id command on or off int32_t irvision; // ir on or off (only matters if player has ir device, currently bandolier) - + int32_t spec_flags; int32_t firing_style; // Action Add End }; diff --git a/actionlite/g_svcmds.cpp b/actionlite/g_svcmds.cpp index 17e7402..7f848c8 100644 --- a/actionlite/g_svcmds.cpp +++ b/actionlite/g_svcmds.cpp @@ -300,3 +300,90 @@ void ServerCommand() else gi.LocClient_Print(nullptr, PRINT_HIGH, "Unknown server command \"{}\"\n", cmd); } + +/* +========================== +Kick a client entity +========================== +*/ +void Kick_Client (edict_t * ent) +{ + if (!ent || !ent->client || !ent->client->pers.connected) + return; + + int clientId = ent->client - game.clients; + char *kick_msg; + + // We used to kick on names, but people got crafty and figured + // out that putting in a space after their name let them get + // around the stupid 'kick' function. So now we kick by number. + + snprintf(kick_msg, sizeof(kick_msg), "kick %d\n", clientId); + gi.AddCommandString(kick_msg); +} + + +/* +========================== +Ban a client for N rounds +========================== +*/ +bool Ban_TeamKiller (edict_t * ent, int rounds) +{ + int i = 0; + + if (!ent || !ent->client || !ent->client->pers.ip[0]) + { + gi.Com_Print("Unable to determine client ip address for edict\n"); + return false; + } + + for (i = 0; i < numipfilters; i++) + { + if (ipfilters[i].compare == 0xffffffff) + break; // free spot + } + + if (i == numipfilters) + { + if (numipfilters == MAX_IPFILTERS) + { + gi.Com_Print("IP filter list is full\n"); + return false; + } + numipfilters++; + } + if (!StringToFilter(ent->client->pers.ip, &ipfilters[i], rounds)) + { + ipfilters[i].compare = 0xffffffff; + return false; + } + + return true; +} + +void UnBan_TeamKillers (void) +{ + // We don't directly unban them all - we subtract 1 from temp_ban_games, + // and unban them if it's 0. + + int i, j; + + for (i = 0; i < numipfilters; i++) + { + if (ipfilters[i].temp_ban_games > 0) + { + if (!--ipfilters[i].temp_ban_games) + { + // re-pack the filters + for (j = i + 1; j < numipfilters; j++) + ipfilters[j - 1] = ipfilters[j]; + numipfilters--; + gi.Com_Print ("Unbanned teamkiller/vote kickked.\n"); + + // since we removed the current we have to re-process the new current + i--; + } + } + } +} \ No newline at end of file diff --git a/actionlite/p_client.cpp b/actionlite/p_client.cpp index 76b6c05..029fbd7 100644 --- a/actionlite/p_client.cpp +++ b/actionlite/p_client.cpp @@ -66,7 +66,7 @@ void Add_Frag(edict_t * ent, int mod) ent->client->resp.gunstats[mod].kills++; } // Grenade splash, kicks and punch damage - if (mod > 0 && ((mod.id == MOD_HG_SPLASH) || (mod.id == MOD_KICK) || (mod.id == MOD_PUNCH))) { + if (mod.id > 0 && ((mod.id == MOD_HG_SPLASH) || (mod.id == MOD_KICK) || (mod.id == MOD_PUNCH))) { ent->client->resp.gunstats[mod].kills++; } @@ -436,7 +436,9 @@ void CL_FixUpGender(edict_t *ent, const char *userinfo) if (!ent->client) return; - Q_strlcpy(sk, gi.Info_ValueForKey(userinfo, "skin"), sizeof(sk)); + gi.Info_ValueForKey(userinfo, "skin", sk, sizeof(sk)); + + //Q_strlcpy(sk, gi.Info_ValueForKey(userinfo, "skin"), sizeof(sk)); if ((p = strchr(sk, '/')) != NULL) *p = 0; if (Q_strcasecmp(sk, "male") == 0 || @@ -476,7 +478,7 @@ void ClientObituary(edict_t *self, edict_t *inflictor, edict_t *attacker, mod_t self->client->resp.ctf_capstreak = 0; friendlyFire = meansOfDeath & MOD_FRIENDLY_FIRE; - mod = meansOfDeath & ~MOD_FRIENDLY_FIRE; + //mod = meansOfDeath & ~MOD_FRIENDLY_FIRE; loc = locOfDeath; // useful for location based hits // Reki: Print killfeed to spectators who ask for easily parsable stuff @@ -495,10 +497,10 @@ void ClientObituary(edict_t *self, edict_t *inflictor, edict_t *attacker, mod_t if (attacker == world || !attacker->client) sprintf(death_msg, "--KF %i %s, MOD %i\n", - self->client->resp.team, self->client->pers.netname, mod); + self->client->resp.team, self->client->pers.netname, mod.id); else sprintf(death_msg, "--KF %i %s, MOD %i, %i %s\n", - attacker->client->resp.team, attacker->client->pers.netname, mod, self->client->resp.team, self->client->pers.netname); + attacker->client->resp.team, attacker->client->pers.netname, mod.id, self->client->resp.team, self->client->pers.netname); gi.LocClient_Print(other, PRINT_MEDIUM, "%s", death_msg); } // @@ -610,7 +612,7 @@ void ClientObituary(edict_t *self, edict_t *inflictor, edict_t *attacker, mod_t } else { - sprintf( death_msg, "%s %s\n", self->client->pers.netname, message ); + sprintf( death_msg, message ); PrintDeathMessage(death_msg, self ); if (!teamplay->value || team_round_going || !ff_afterround->value) { @@ -1237,7 +1239,7 @@ void TossClientWeapon(edict_t * self) // drop->think = G_FreeEdict; // } // RAFAEL -} +//} /* ==================