Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tremulous: bucket system #107

Merged
merged 7 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,17 @@ is contained within the files as listed.
src/game/bg_lib.c BSD license
src/client/snd_adpcm.c Stichting Mathematisch Centrum license
src/jpeg-6/* JPEG license

assets/ui/main_menu_music/Finally_Heartbeat.ogg:
"Finally Heartbeat" by Avarthar licensed CC-BY-SA-3.0
based on "C'Mon" by Analog by Nature, licensed CC-BY-3.0
and samples from "Tremulous" game assets, licensed CC-BY-SA-3.0

assets/ui/main_menu_music/tremfusion_heartbeat.ogg:
by Vortexx licensed CC-BY-SA-2.5

assets/ui/main_menu_music/Black_mistUntiteled_3.ogg:
by AutumnLegends licensed CC-BY-NC-SA-3.0

assets/ui/main_menu_music/Granger_Foley_v1.ogg:
by Akane licensed CC-BY-SA-2.5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added assets/sound/ui/main_menu_music/heartbeat.wav
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/ui/main.menu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ focusColor WINDOW_FOCUSCOLOR// vim:ft=menu
onOpen
{
uiScript stopRefresh
playlooped "sound/ui/heartbeat.wav"
bucketPlayLooped "sound/ui/main_menu_music" ui_mainMenuSelectedMusic
}

onESC
Expand Down
9 changes: 9 additions & 0 deletions src/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,14 @@ void CG_LoadHudMenu( void )
cgDC.stopCinematic = &CG_StopCinematic;
cgDC.drawCinematic = &CG_DrawCinematic;
cgDC.runCinematicFrame = &CG_RunCinematicFrame;
cgDC.Bucket_Create_Bucket = BG_Bucket_Create_Bucket;
cgDC.Bucket_Delete_Bucket = BG_Bucket_Delete_Bucket;
cgDC.Bucket_Destroy_All_Buckets = BG_Bucket_Destroy_All_Buckets;
cgDC.Bucket_Add_Item_To_Bucket = BG_Bucket_Add_Item_To_Bucket;
cgDC.Bucket_Remove_Item_From_Bucket = BG_Bucket_Remove_Item_From_Bucket;
cgDC.Bucket_Select_A_Random_Item = BG_Bucket_Select_A_Random_Item;
cgDC.Bucket_Select_A_Specific_Item = BG_Bucket_Select_A_Specific_Item;
cgDC.FS_GetFileList = trap_FS_GetFileList;

Init_Display( &cgDC );

Expand Down Expand Up @@ -2047,6 +2055,7 @@ Called before every level change or subsystem restart
*/
void CG_Shutdown( void )
{
BG_Bucket_Destroy_All_Buckets( );
CG_UnregisterCommands( );
}

Expand Down
2 changes: 2 additions & 0 deletions src/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5057,6 +5057,8 @@ void CL_Shutdown(const char *finalmsg, bool disconnect, bool quit)
}
recursive = true;

Com_Bucket_Destroy_All_Buckets( );

noGameRestart = quit;

if (disconnect) CL_Disconnect(true);
Expand Down
41 changes: 40 additions & 1 deletion src/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,7 @@ int BG_SlotsForInventory( int stats[ ] )
{
slot = BG_Upgrade( i )->slots;

// this check should never be true
// this check should never be qtrue
if( slots & slot )
{
Com_Printf( S_COLOR_YELLOW "WARNING: held item %d conflicts with "
Expand Down Expand Up @@ -3971,3 +3971,42 @@ char *G_CopyString( const char *str )
memcpy( cp, str, size );
return cp;
}

/*
==============================================================
Bucket Selection System
==============================================================
*/

unsigned int BG_Bucket_Create_Bucket(void) {
Q_Bucket_Create_Bucket(BG_Alloc, BG_Free);
}

void BG_Bucket_Delete_Bucket(unsigned int bucket_handle) {
Q_Bucket_Delete_Bucket(bucket_handle);
}

void BG_Bucket_Destroy_All_Buckets(void) {
Q_Bucket_Destroy_All_Buckets(BG_Alloc, BG_Free);
}

void BG_Bucket_Add_Item_To_Bucket(
unsigned int bucket_handle, void* item) {
Q_Bucket_Add_Item_To_Bucket(bucket_handle, item, BG_Alloc, BG_Free);
}

void BG_Bucket_Remove_Item_From_Bucket(
unsigned int bucket_handle, void* item) {
Q_Bucket_Remove_Item_From_Bucket(
bucket_handle, item, BG_Alloc, BG_Free);
}

void* BG_Bucket_Select_A_Random_Item(unsigned int bucket_handle) {
Q_Bucket_Select_A_Random_Item(bucket_handle);
}

void BG_Bucket_Select_A_Specific_Item(unsigned int bucket_handle, void* item) {
Q_Bucket_Select_A_Specific_Item(bucket_handle, item);
}
21 changes: 21 additions & 0 deletions src/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,27 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *

qboolean BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime );

/*
==============================================================
Bucket Selection System
==============================================================
*/

unsigned int BG_Bucket_Create_Bucket(void);
void BG_Bucket_Delete_Bucket(unsigned int bucket_handle);
void BG_Bucket_Destroy_All_Buckets(void);
void BG_Bucket_Add_Item_To_Bucket(
unsigned int bucket_handle, void* item);
void BG_Bucket_Remove_Item_From_Bucket(
unsigned int bucket_handle, void* item);
void* BG_Bucket_Select_A_Random_Item(unsigned int bucket_handle);
void BG_Bucket_Select_A_Specific_Item(
unsigned int bucket_handle, void* item);
//==============================================================


#define ARENAS_PER_TIER 4
#define MAX_ARENAS 1024
#define MAX_ARENAS_TEXT 8192
Expand Down
2 changes: 2 additions & 0 deletions src/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ void G_ShutdownGame( int restart )
G_FreePlayerModel( );
G_ShutdownMapRotations( );

BG_Bucket_Destroy_All_Buckets( );

level.restarted = qfalse;
level.surrenderTeam = TEAM_NONE;
trap_SetConfigstring( CS_WINNER, "" );
Expand Down
43 changes: 43 additions & 0 deletions src/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3660,3 +3660,46 @@ int QDECL Com_strCompare( const void *a, const void *b )
const char **pb = (const char **)b;
return strcmp( *pa, *pb );
}

/*
==============================================================
Bucket Selection System
==============================================================
*/

static void *Z_PlaceHolderAlloc(int size) {
Z_Malloc(size);
}

unsigned int Com_Bucket_Create_Bucket(void) {
Q_Bucket_Create_Bucket(Z_PlaceHolderAlloc, Z_Free);
}

void Com_Bucket_Delete_Bucket(unsigned int bucket_handle) {
Q_Bucket_Delete_Bucket(bucket_handle);
}

void Com_Bucket_Destroy_All_Buckets(void) {
Q_Bucket_Destroy_All_Buckets(Z_PlaceHolderAlloc, Z_Free);
}

void Com_Bucket_Add_Item_To_Bucket(
unsigned int bucket_handle, void* item) {
Q_Bucket_Add_Item_To_Bucket(bucket_handle, item, Z_PlaceHolderAlloc, Z_Free);
}

void Com_Bucket_Remove_Item_From_Bucket(
unsigned int bucket_handle, void* item) {
Q_Bucket_Remove_Item_From_Bucket(
bucket_handle, item, Z_PlaceHolderAlloc, Z_Free);
}

void* Com_Bucket_Select_A_Random_Item(unsigned int bucket_handle) {
Q_Bucket_Select_A_Random_Item(bucket_handle);
}

void Com_Bucket_Select_A_Specific_Item(unsigned int bucket_handle, void* item) {
Q_Bucket_Select_A_Specific_Item(bucket_handle, item);
}
Loading