Skip to content

Commit

Permalink
Implemented coach feature (Request: coach QW-Group#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcsabina committed Mar 13, 2020
1 parent d2cdf19 commit 63fbc5d
Show file tree
Hide file tree
Showing 31 changed files with 193 additions and 56 deletions.
Empty file modified configure
100755 → 100644
Empty file.
7 changes: 7 additions & 0 deletions include/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ char *g_himself( gedict_t * ed );

gedict_t *find_client( gedict_t *start );
gedict_t *find_plr( gedict_t *start );
gedict_t *find_plr_same_team( gedict_t *start, char *team );
gedict_t *find_spc( gedict_t *start );
gedict_t *find_plrghst( gedict_t *start, int *from );
gedict_t *find_plrspc( gedict_t *start, int *from );
Expand Down Expand Up @@ -762,6 +763,11 @@ qbool CA_can_fire( gedict_t *p );

int capt_num(gedict_t *p);

// coach.c

int coach_num(gedict_t *p);
qbool is_coach(gedict_t *p);

// maps.c

void StuffMaps( gedict_t *p );
Expand Down Expand Up @@ -875,6 +881,7 @@ extern float framechecks; // if timedemo/uptime bugs are tolerated
extern float k_attendees; // stores number of players on server - used in 'ready' checking
extern float k_captains; // number of captains
extern float k_captainturn; // which captain comes in line to pick
extern float k_coaches; // number of coaches
extern float k_checkx;
extern float k_force; // used in forcing matchstart
extern float k_maxspeed; // used to store server maxspeed to allow switching by admins
Expand Down
2 changes: 2 additions & 0 deletions include/progs.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ typedef enum
{
etNone = 0,
etCaptain,
etCoach,
etAdmin
} electType_t;

Expand Down Expand Up @@ -897,6 +898,7 @@ typedef struct gedict_s {
int k_admin; // if player is an admin, flags
float k_adm_lasttime; // store time of last attempt getting admin rights
int k_captain; // if player is team captain
int k_coach; // if player is team coach
float k_flag; // flagvalue to customise settings such as sounds/autoscreenshot
float k_msgcount; // NOT_SURE: last time mod printed a message to client?
float k_picked; // NOT_SURE:
Expand Down
2 changes: 2 additions & 0 deletions makevm.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ cd VM
@if errorlevel 1 goto quit
%CC% %CFLAGS% %INCFLAGS% %SRC%\captain.c
@if errorlevel 1 goto quit
%CC% %CFLAGS% %INCFLAGS% %SRC%\coach.c
@if errorlevel 1 goto quit
%CC% %CFLAGS% %INCFLAGS% %SRC%\commands.c
@if errorlevel 1 goto quit
%CC% %CFLAGS% %INCFLAGS% %SRC%\logs.c
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ktx_sources = [
'src/bot_world.c',
'src/buttons.c',
'src/captain.c',
'src/coach.c',
'src/clan_arena.c',
'src/client.c',
'src/combat.c',
Expand Down
3 changes: 3 additions & 0 deletions qwprogs_71.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
<File
RelativePath="src\captain.c">
</File>
<File
RelativePath="src\coach.c">
</File>
<File
RelativePath="src\client.c">
<FileConfiguration
Expand Down
4 changes: 4 additions & 0 deletions qwprogs_80.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@
RelativePath="src\captain.c"
>
</File>
<File
RelativePath="src\coach.c"
>
</File>
<File
RelativePath="src\client.c"
>
Expand Down
4 changes: 4 additions & 0 deletions qwprogs_90.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@
RelativePath="src\captain.c"
>
</File>
<File
RelativePath="src\coach.c"
>
</File>
<File
RelativePath=".\src\clan_arena.c"
>
Expand Down
1 change: 1 addition & 0 deletions qwprogs_vc2010.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;QWPROGS_EXPORTS</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="src\captain.c" />
<ClCompile Include="src\coach.c" />
<ClCompile Include="src\clan_arena.c" />
<ClCompile Include="src\client.c">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
Expand Down
1 change: 1 addition & 0 deletions qwprogs_vc2015.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile Include="src\captain.c" />
<ClCompile Include="src\coach.c" />
<ClCompile Include="src\clan_arena.c" />
<ClCompile Include="src\client.c">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
Expand Down
1 change: 1 addition & 0 deletions qwprogs_vc2015.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ClCompile Include="src\admin.c" />
<ClCompile Include="src\buttons.c" />
<ClCompile Include="src\captain.c" />
<ClCompile Include="src\coach.c" />
<ClCompile Include="src\client.c" />
<ClCompile Include="src\combat.c" />
<ClCompile Include="src\commands.c" />
Expand Down
1 change: 1 addition & 0 deletions qwprogs_vc2017.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile Include="src\captain.c" />
<ClCompile Include="src\coach.c" />
<ClCompile Include="src\clan_arena.c" />
<ClCompile Include="src\client.c">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
Expand Down
1 change: 1 addition & 0 deletions resources/example-configs/ktx/ktx.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ set k_lockmap 0 // prevent players from changing map (0
set k_vp_break 51 // vote percentage for breaking
set k_vp_admin 51 // vote percentage for admin election
set k_vp_captain 51 // vote percentage for captain election
set k_vp_coach 51 // vote percentage for coach election
set k_vp_map 51 // vote percentage for map change
set k_vp_pickup 51 // vote percentage for pickup
set k_vp_rpickup 51 // vote percentage for random pickup
Expand Down
Empty file modified resources/example-configs/port1
100755 → 100644
Empty file.
Empty file modified resources/example-configs/port2
100755 → 100644
Empty file.
Empty file modified resources/example-configs/port3
100755 → 100644
Empty file.
Empty file modified resources/example-configs/portffa
100755 → 100644
Empty file.
Empty file modified resources/example-configs/servers
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion src/Makefile.dl.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SOURCES=native_lib.c buttons.c client.c combat.c doors.c g_cmd.c g_main.c \
g_mem.c g_spawn.c g_syscalls.c g_utils.c items.c mathlib.c misc.c \
plats.c player.c q_shared.c server.c spectate.c subs.c triggers.c \
weapons.c world.c clan_arena.c \
admin.c captain.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
admin.c captain.c coach.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
g_userinfo.c grapple.c runes.c ctf.c arena.c hoonymode.c race.c \
sp_ai.c sp_boss.c sp_client.c sp_demon.c sp_dog.c sp_enforcer.c sp_fish.c sp_hknight.c sp_knight.c \
sp_monsters.c sp_ogre.c sp_oldone.c sp_shalrath.c sp_shambler.c sp_soldier.c sp_tarbaby.c sp_wizard.c sp_zombie.c \
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.dl32.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SOURCES=native_lib.c buttons.c client.c combat.c doors.c g_cmd.c g_main.c \
g_mem.c g_spawn.c g_syscalls.c g_utils.c items.c mathlib.c misc.c \
plats.c player.c q_shared.c server.c spectate.c subs.c triggers.c \
weapons.c world.c clan_arena.c \
admin.c captain.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
admin.c captain.c coach.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
g_userinfo.c grapple.c runes.c ctf.c arena.c hoonymode.c race.c \
sp_ai.c sp_boss.c sp_client.c sp_demon.c sp_dog.c sp_enforcer.c sp_fish.c sp_hknight.c sp_knight.c \
sp_monsters.c sp_ogre.c sp_oldone.c sp_shalrath.c sp_shambler.c sp_soldier.c sp_tarbaby.c sp_wizard.c sp_zombie.c \
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.vm.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endif
SOURCES=g_main.c bg_lib.c buttons.c client.c combat.c doors.c g_cmd.c \
g_mem.c g_spawn.c g_utils.c items.c mathlib.c misc.c plats.c player.c \
q_shared.c server.c spectate.c subs.c triggers.c weapons.c world.c clan_arena.c \
admin.c captain.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
admin.c captain.c coach.c commands.c globals.c logs.c maps.c match.c motd.c vip.c vote.c \
g_userinfo.c grapple.c runes.c ctf.c arena.c hoonymode.c race.c \
sp_ai.c sp_boss.c sp_client.c sp_demon.c sp_dog.c sp_enforcer.c sp_fish.c sp_hknight.c sp_knight.c \
sp_monsters.c sp_ogre.c sp_oldone.c sp_shalrath.c sp_shambler.c sp_soldier.c sp_tarbaby.c sp_wizard.c sp_zombie.c \
Expand Down
15 changes: 11 additions & 4 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void CheckAll();
void PlayerStats();
void ExitCaptain();
void CheckFinishCaptain();
void ExitCoach();
void MakeMOTD();
void ImpulseCommands();
void StartDie ();
Expand Down Expand Up @@ -87,16 +88,16 @@ qbool CheckRate (gedict_t *p, char *newrate)
{
if ( player_rate > maxrate )
{
G_sprint(p, 2, "\nYour òáôå setting is too high for this server.\n"
"Rate set to %d\n", (int)maxrate);
G_sprint(p, 2, "\nYour %s setting is too high for this server.\n"
"Rate set to %d\n", redtext("rate"), (int)maxrate);
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "rate %d\n", (int)maxrate );
ret = true;
}

if ( player_rate < minrate )
{
G_sprint(p, 2, "\nYour òáôå setting is too low for this server.\n"
"Rate set to %d\n", (int)minrate);
G_sprint(p, 2, "\nYour %s setting is too low for this server.\n"
"Rate set to %d\n", redtext("rate"), (int)minrate);
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "rate %d\n", (int)minrate );
ret = true;
}
Expand Down Expand Up @@ -2325,6 +2326,12 @@ void ClientDisconnect()
if( k_captains == 2 )
CheckFinishCaptain();

if( coach_num( self ) ) {
G_bprint(2, "A %s has left\n", redtext("coach"));

ExitCoach();
}

if( cvar( "k_idletime" ) > 0 )
IdlebotCheck();

Expand Down
Loading

0 comments on commit 63fbc5d

Please sign in to comment.