-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "SpectatorComponent.h" | ||
|
||
SpectatorComponent::SpectatorComponent(Entity& entity, ClientComponent& r_ClientComponent) | ||
: SpectatorComponentBase(entity, r_ClientComponent) | ||
{} | ||
|
||
void SpectatorComponent::HandlePrepareNetCode() { | ||
gclient_t* cl = entity.oldEnt->client; | ||
|
||
if (!cl | ||
|| cl->sess.spectatorState != SPECTATOR_FOLLOW | ||
|| cl->sess.spectatorClient < 0 | ||
|| cl->sess.spectatorClient >= level.maxclients | ||
|| level.clients[cl->sess.spectatorClient].pers.connected != CON_CONNECTED) { | ||
return; | ||
} | ||
|
||
// Save | ||
int score = cl->ps.persistant[PERS_SCORE]; | ||
int ping = cl->ps.ping; | ||
|
||
// Copy | ||
cl->ps = level.clients[cl->sess.spectatorClient].ps; | ||
|
||
// Restore | ||
cl->ps.persistant[PERS_SCORE] = score; | ||
cl->ps.ping = ping; | ||
|
||
cl->ps.pm_flags |= PMF_FOLLOW; | ||
cl->ps.pm_flags &= ~PMF_QUEUED; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef SPECTATOR_COMPONENT_H_ | ||
#define SPECTATOR_COMPONENT_H_ | ||
|
||
#include "../backend/CBSEBackend.h" | ||
#include "../backend/CBSEComponents.h" | ||
|
||
class SpectatorComponent: public SpectatorComponentBase { | ||
public: | ||
// ///////////////////// // | ||
// Autogenerated Members // | ||
// ///////////////////// // | ||
|
||
/** | ||
* @brief Default constructor of the SpectatorComponent. | ||
* @param entity The entity that owns the component instance. | ||
* @param r_ClientComponent A ClientComponent instance that this component depends on. | ||
* @note This method is an interface for autogenerated code, do not modify its signature. | ||
*/ | ||
SpectatorComponent(Entity& entity, ClientComponent& r_ClientComponent); | ||
|
||
/** | ||
* @brief Handle the PrepareNetCode message. | ||
* @note This method is an interface for autogenerated code, do not modify its signature. | ||
*/ | ||
void HandlePrepareNetCode(); | ||
|
||
// ///////////////////// // | ||
|
||
private: | ||
|
||
}; | ||
|
||
#endif // SPECTATOR_COMPONENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters