Skip to content

Commit

Permalink
Finished adding serverside stuff!?
Browse files Browse the repository at this point in the history
  • Loading branch information
videoP committed Jan 11, 2014
1 parent 6c739c8 commit e41a31a
Show file tree
Hide file tree
Showing 24 changed files with 1,482 additions and 242 deletions.
2 changes: 1 addition & 1 deletion code/game/g_local.h
Expand Up @@ -32,7 +32,7 @@ This file is part of Jedi Academy.
//==================================================================

// the "gameversion" client command will print this plus compile date
#define GAMEVERSION "japro"
#define GAMEVERSION "OpenJK"

#define BODY_QUEUE_SIZE 8

Expand Down
1 change: 1 addition & 0 deletions codemp/cgame/cg_local.h
Expand Up @@ -670,6 +670,7 @@ typedef struct score_s {
int defendCount;
int assistCount;
int captures;
int deaths; //JAPRO - Scoreboard Deaths
qboolean perfect;
int team;
} score_t;
Expand Down
2 changes: 1 addition & 1 deletion codemp/game/bg_misc.c
Expand Up @@ -1749,7 +1749,7 @@ qboolean BG_CanUseFPNow(int gametype, playerState_t *ps, int time, forcePowers_t
break;
}
}
#else
#elif defined _CGAME
if (ps->duelInProgress) // consider duel types.
{
switch ( cg_dueltypes[ps->clientNum]) {
Expand Down
27 changes: 26 additions & 1 deletion codemp/game/bg_pmove.c
Expand Up @@ -6680,9 +6680,17 @@ static qboolean PM_DoChargedWeapons( qboolean vehicleRocketLock, bgEntity_t *veh
if ( (pm->cmd.buttons & BUTTON_ALT_ATTACK)
&& pm->ps->ammo[weaponData[pm->ps->weapon].ammoIndex] >= weaponData[pm->ps->weapon].altEnergyPerShot )
{
#ifdef _GAME
if (!(g_tweakWeapons.integer & ROCKET_MORTAR)) {
PM_RocketLock(2048,qfalse);
charging = qtrue;
}
altFire = qtrue;
#else
PM_RocketLock(2048,qfalse);
charging = qtrue;
altFire = qtrue;
#endif
}
break;

Expand Down Expand Up @@ -8230,6 +8238,11 @@ if (pm->ps->duelInProgress)

if ( pm->cmd.buttons & BUTTON_ALT_ATTACK )
{
#ifdef _GAME
if (pm->ps->weapon == WP_ROCKET_LAUNCHER && g_tweakWeapons.integer & ROCKET_MORTAR)
amount = 1;//JAPRO mortar meh
else
#endif
amount = weaponData[pm->ps->weapon].altEnergyPerShot;
}
else
Expand Down Expand Up @@ -8281,7 +8294,14 @@ if (pm->ps->duelInProgress)
{ //do not fire melee events at all when on vehicle
PM_AddEvent( EV_ALT_FIRE );
}
addTime = weaponData[pm->ps->weapon].altFireTime;
#ifdef _GAME
if (pm->ps->weapon == WP_STUN_BATON && g_tweakWeapons.integer & STUN_SHOCKLANCE)
addTime = 1500;
else if (pm->ps->weapon == WP_ROCKET_LAUNCHER && g_tweakWeapons.integer & ROCKET_MORTAR)
addTime = 3000;
else
#endif
addTime = weaponData[pm->ps->weapon].altFireTime;
}
}
else {
Expand All @@ -8290,6 +8310,11 @@ if (pm->ps->duelInProgress)
{ //do not fire melee events at all when on vehicle
PM_AddEvent( EV_FIRE_WEAPON );
}
#ifdef _GAME
if (pm->ps->weapon == WP_STUN_BATON && g_tweakWeapons.integer & STUN_LG)
addTime = 50;
else
#endif
addTime = weaponData[pm->ps->weapon].fireTime;
if ( pm->gametype == GT_SIEGE && pm->ps->weapon == WP_DET_PACK )
{ // were far too spammy before? So says Rick.
Expand Down
6 changes: 6 additions & 0 deletions codemp/game/bg_saber.c
Expand Up @@ -3,6 +3,12 @@
#include "bg_local.h"
#include "w_saber.h"

//JAPRO - Serverside - Fullforce Duels - Start
#ifdef _CGAME
extern int cg_dueltypes[MAX_CLIENTS];
#endif
//JAPRO - Serverside - Fullforce Duels - End

extern qboolean BG_SabersOff( playerState_t *ps );
saberInfo_t *BG_MySaber( int clientNum, int saberNum );

Expand Down
1 change: 1 addition & 0 deletions codemp/game/g_ICARUScb.c
Expand Up @@ -1948,6 +1948,7 @@ static void Q3_SetOrigin( int entID, vec3_t origin )
ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;

ent->client->ps.eFlags ^= EF_TELEPORT_BIT;
G_ResetTrail( ent );//unlagged

// G_KillBox (ent);
}
Expand Down
96 changes: 84 additions & 12 deletions codemp/game/g_active.c
Expand Up @@ -677,6 +677,46 @@ static void SV_PMTrace( trace_t *results, const vec3_t start, const vec3_t mins,
trap->Trace( results, start, mins, maxs, end, passEntityNum, contentMask, qfalse, 0, 10 );
}

int SpectatorFind(gentity_t *self) // loda japro fixme - add unlagged (could this be exploited?)
{
int i;

for ( i = 0; i < level.numConnectedClients; i ++ )
{
gentity_t *ent = &g_entities[level.sortedClients[i]];
float dist;
vec3_t angles;

if ( ent == self ) {
continue;
}

if (ent->client->sess.sessionTeam == TEAM_SPECTATOR)
continue;

VectorSubtract( ent->client->ps.origin, self->client->ps.origin, angles );
dist = VectorLengthSquared ( angles );
vectoangles ( angles, angles );

// Out of range
if ( dist > 4096*4096 ) {
continue;
}

// Not in our FOV
if ( !InFieldOfVision ( self->client->ps.viewangles, 30, angles ) ) {
continue;
}

// Not in line of sight?
//break;

// Return the first guy that fits the requirements
return level.sortedClients[i];
}
return -1;
}

/*
=================
SpectatorThink
Expand All @@ -685,6 +725,7 @@ SpectatorThink
void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
pmove_t pmove;
gclient_t *client;
int match;

client = ent->client;

Expand Down Expand Up @@ -734,10 +775,19 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {

if (client->tempSpectate < level.time)
{
// attack button cycles through spectators
if ( (client->buttons & BUTTON_ATTACK) && !(client->oldbuttons & BUTTON_ATTACK) )
Cmd_FollowCycle_f( ent, 1 );

if ( client->sess.spectatorState == SPECTATOR_FOLLOW && (client->buttons & BUTTON_ATTACK) && !(client->oldbuttons & BUTTON_ATTACK) )
Cmd_FollowCycle_f( ent, 1 ); // Clicked while following a guy -> go to next guy
else if ( (client->buttons & BUTTON_ATTACK) && !(client->oldbuttons & BUTTON_ATTACK) ) {
G_TimeShiftAllClients( ent->client->pers.cmd.serverTime, ent );
match = SpectatorFind(ent);
G_UnTimeShiftAllClients( ent );
if (match == -1) // Clicked while not following a guy -> Follow guy you are aiming at.
Cmd_FollowCycle_f( ent, 1 );
else {
client->sess.spectatorClient = match;
client->sess.spectatorState = SPECTATOR_FOLLOW;
}
}
else if ( client->sess.spectatorState == SPECTATOR_FOLLOW && (client->buttons & BUTTON_ALT_ATTACK) && !(client->oldbuttons & BUTTON_ALT_ATTACK) )
Cmd_FollowCycle_f( ent, -1 );

Expand Down Expand Up @@ -3873,6 +3923,7 @@ while a slow client may have multiple ClientEndFrame between ClientThink.
void ClientEndFrame( gentity_t *ent ) {
int i;
qboolean isNPC = qfalse;
int frames; //japro smoothclients

if (ent->s.eType == ET_NPC)
{
Expand All @@ -3891,14 +3942,6 @@ void ClientEndFrame( gentity_t *ent ) {
}
}

// save network bandwidth
#if 0
if ( !g_synchronousClients->integer && (ent->client->ps.pm_type == PM_NORMAL || ent->client->ps.pm_type == PM_JETPACK || ent->client->ps.pm_type == PM_FLOAT) ) {
// FIXME: this must change eventually for non-sync demo recording
VectorClear( ent->client->ps.viewangles );
}
#endif

//
// If the end of unit layout is displayed, don't give
// the player any normal movement attributes
Expand Down Expand Up @@ -3945,6 +3988,35 @@ void ClientEndFrame( gentity_t *ent ) {

SendPendingPredictableEvents( &ent->client->ps );

//unlagged - smooth clients #1 - loda
// mark as not missing updates initially
ent->client->ps.eFlags &= ~EF_CONNECTION;

// see how many frames the client has missed
frames = level.framenum - ent->client->lastUpdateFrame - 1;

// don't extrapolate more than two frames
if ( frames > 2 ) {
frames = 2;

// if they missed more than two in a row, show the phone jack
if (g_lagIcon.integer)
ent->client->ps.eFlags |= EF_CONNECTION;
ent->s.eFlags |= EF_CONNECTION;
}

// did the client miss any frames?
if ( frames > 0 && g_smoothClients.integer && VectorLength(ent->client->ps.velocity) >= 90 && !(ent->r.svFlags & SVF_BOT)) { // loda - sad hack fix this
// yep, missed one or more, so extrapolate the player's movement
//G_PredictPlayerMove( ent, (float)frames / sv_fps.integer );
G_PredictPlayerStepSlideMove( ent, (float)frames / sv_fps.integer );
// save network bandwidth
SnapVector( ent->s.pos.trBase );
}
//unlagged - smooth clients #1 - loda


G_StoreTrail( ent );
// set the bit for the reachability area the client is currently in
// i = trap->AAS_PointReachabilityAreaIndex( ent->client->ps.origin );
// ent->client->areabits[i >> 3] |= 1 << (i & 7);
Expand Down
2 changes: 2 additions & 0 deletions codemp/game/g_client.c
Expand Up @@ -3300,6 +3300,8 @@ void ClientSpawn(gentity_t *ent) {

// clear everything but the persistant data

G_ResetTrail( ent );//unlagged

saved = client->pers;
savedSess = client->sess;
savedPing = client->ps.ping;
Expand Down

0 comments on commit e41a31a

Please sign in to comment.