<commit_before>////////////////////////////////////////
//
//             OpenLieroX
//
// code under LGPL, based on JasonBs work,
// enhanced by <NAME> and <NAME>
//
//
/////////////////////////////////////////


// Client class - Game routines
// Created 21/7/02
// <NAME>


#include "LieroX.h"
#include "Clipboard.h"
#include "AuxLib.h"
#include "MathLib.h"
#include "CClient.h"
#include "CServer.h"
#include "CServerConnection.h"
#include "CBonus.h"
#include "console.h"
#include "GfxPrimitives.h"
#include "DeprecatedGUI/Graphics.h"
#include "StringUtils.h"
#include "CWorm.h"
#include "Entity.h"
#include "Protocol.h"
#include "Physics.h"
#include "CClient.h"
#include "CClientNetEngine.h"
#include "ProfileSystem.h"
#include "Debug.h"


CClient		*cClient = NULL;


///////////////////
// Simulation
void CClient::Simulation(void)
{
	short i;
    CWorm *w;

	// Don't simulate if the physics engine is not ready
	if (!PhysicsEngine::Get()->isInitialised())  {
		printf("WARNING: trying to simulate with non-initialized physics engine!\n");
		return;
	}


	// If we're in a menu & a local game, don't do simulation
	if (tLX->iGameType == GME_LOCAL)  {
		if( bGameOver || bGameMenu || bViewportMgr ) {

			// Clear the input of the local worms
			clearLocalWormInputs();
		}
	}

    // We stop a few seconds after the actual game over
    if(bGameOver && tLX->fCurTime - fGameOverTime > GAMEOVER_WAIT)
        return;
    if((bGameMenu || bViewportMgr) && tLX->iGameType == GME_LOCAL)
        return;


	// TODO: does it work also, if we
	// 1. simulate all worms
	// 2. check collisions with bonuses
	// (at the moment, we are doing these 2 things at once in the loop, I want to have 2 loops)
	// TODO: make it working
	// TODO: create a function simulateWorms() in PhysicsEngine which does all worms-simulation

	// Player simulation
	w = cRemoteWorms;
	for(i = 0; i < MAX_WORMS; i++, w++) {
		if(!w->isUsed())
			continue;

		if(w->getAlive()) {

			// Simulate the worm
			// TODO: move this to a simulateWorms() in PhysicsEngine
			PhysicsEngine::Get()->simulateWorm( w, cRemoteWorms, w->getLocal() );

			if(bGameOver)
				// TODO: why continue and not break?
                continue;


			// Check if this worm picked up a bonus

			CBonus *b = cBonuses;
			if (tGameInfo.bBonusesOn)  {
				for(short n = 0; n < MAX_BONUSES; n++, b++) {
					if(!b->getUsed())
						continue;

					if(w->CheckBonusCollision(b)) {
						if(w->getLocal() || (iNumWorms > 0 && cLocalWorms[0]->getID() == 0 && tLXOptions->tGameInfo.bServerSideHealth)) {

							if( w->GiveBonus(b) ) {

								// Pickup noise
								PlaySoundSample(sfxGame.smpPickup);

								DestroyBonus(n, w->getLocal(), w->getID());

								bShouldRepaintInfo = true;
							}
						}
					}
				}
			}
		}

        if(bGameOver)
			// TODO: why continue and not break?
            continue;


		// TODO: move this to physics as it should also be FPS independent
		// Is this worm shooting?
		if(w->getAlive()) {

			// Shoot
			if(w->getWormState()->bShoot) {
				// This handles only client-side weapons, like jetpack and for beam drawing
				// It doesn't process the shot itself.
				// The shot-info will be sent to the server which sends it back and
				// we handle it in CClient::ProcessShot in the end.
				PlayerShoot(w);
			}

			// If the worm is using a weapon with a laser sight, spawn a laser sight
			if (w->getCurWeapon()->Weapon)
				if(w->getCurWeapon()->Weapon->LaserSight)
					LaserSight(w);

		}


		// In a game of tag, increment the tagged worms time
		if(iGameType == GMT_TAG && w->getTagIT())  {
			w->incrementTagTime(tLX->fRealDeltaTime);

			// Log
			log_worm_t *l = GetLogWorm(w->getID());
			if (l)
				l->fTagTime += tLX->fRealDeltaTime;
		}
	}

	// Entities
	// only some gfx effects, therefore it doesn't belong to PhysicsEngine
	SimulateEntities(tLX->fDeltaTime, cMap);

	// Weather
	// TODO: if this will be implemented once, this should be moved to the PhysicsEngine
	//cWeather.Simulate(tLX->fDeltaTime, cMap);

	// Projectiles
	PhysicsEngine::Get()->simulateProjectiles(cProjectiles.begin());

	// Bonuses
	PhysicsEngine::Get()->simulateBonuses(cBonuses, MAX_BONUSES);

}<commit_msg>dont do entities simulation in dedicated mode<commit_after>////////////////////////////////////////
//
//             OpenLieroX
//
// code under LGPL, based on JasonBs work,
// enhanced by <NAME> and <NAME>
//
//
/////////////////////////////////////////


// Client class - Game routines
// Created 21/7/02
// <NAME>


#include "LieroX.h"
#include "Clipboard.h"
#include "AuxLib.h"
#include "MathLib.h"
#include "CClient.h"
#include "CServer.h"
#include "CServerConnection.h"
#include "CBonus.h"
#include "console.h"
#include "GfxPrimitives.h"
#include "DeprecatedGUI/Graphics.h"
#include "StringUtils.h"
#include "CWorm.h"
#include "Entity.h"
#include "Protocol.h"
#include "Physics.h"
#include "CClient.h"
#include "CClientNetEngine.h"
#include "ProfileSystem.h"
#include "Debug.h"


CClient		*cClient = NULL;


///////////////////
// Simulation
void CClient::Simulation(void)
{
	short i;
    CWorm *w;

	// Don't simulate if the physics engine is not ready
	if (!PhysicsEngine::Get()->isInitialised())  {
		printf("WARNING: trying to simulate with non-initialized physics engine!\n");
		return;
	}


	// If we're in a menu & a local game, don't do simulation
	if (tLX->iGameType == GME_LOCAL)  {
		if( bGameOver || bGameMenu || bViewportMgr ) {

			// Clear the input of the local worms
			clearLocalWormInputs();
		}
	}

    // We stop a few seconds after the actual game over
    if(bGameOver && tLX->fCurTime - fGameOverTime > GAMEOVER_WAIT)
        return;
    if((bGameMenu || bViewportMgr) && tLX->iGameType == GME_LOCAL)
        return;


	// TODO: does it work also, if we
	// 1. simulate all worms
	// 2. check collisions with bonuses
	// (at the moment, we are doing these 2 things at once in the loop, I want to have 2 loops)
	// TODO: make it working
	// TODO: create a function simulateWorms() in PhysicsEngine which does all worms-simulation

	// Player simulation
	w = cRemoteWorms;
	for(i = 0; i < MAX_WORMS; i++, w++) {
		if(!w->isUsed())
			continue;

		if(w->getAlive()) {

			// Simulate the worm
			// TODO: move this to a simulateWorms() in PhysicsEngine
			PhysicsEngine::Get()->simulateWorm( w, cRemoteWorms, w->getLocal() );

			if(bGameOver)
				// TODO: why continue and not break?
                continue;


			// Check if this worm picked up a bonus

			CBonus *b = cBonuses;
			if (tGameInfo.bBonusesOn)  {
				for(short n = 0; n < MAX_BONUSES; n++, b++) {
					if(!b->getUsed())
						continue;

					if(w->CheckBonusCollision(b)) {
						if(w->getLocal() || (iNumWorms > 0 && cLocalWorms[0]->getID() == 0 && tLXOptions->tGameInfo.bServerSideHealth)) {

							if( w->GiveBonus(b) ) {

								// Pickup noise
								PlaySoundSample(sfxGame.smpPickup);

								DestroyBonus(n, w->getLocal(), w->getID());

								bShouldRepaintInfo = true;
							}
						}
					}
				}
			}
		}

        if(bGameOver)
			// TODO: why continue and not break?
            continue;


		// TODO: move this to physics as it should also be FPS independent
		// Is this worm shooting?
		if(w->getAlive()) {

			// Shoot
			if(w->getWormState()->bShoot) {
				// This handles only client-side weapons, like jetpack and for beam drawing
				// It doesn't process the shot itself.
				// The shot-info will be sent to the server which sends it back and
				// we handle it in CClient::ProcessShot in the end.
				PlayerShoot(w);
			}

			// If the worm is using a weapon with a laser sight, spawn a laser sight
			if (w->getCurWeapon()->Weapon)
				if(w->getCurWeapon()->Weapon->LaserSight)
					LaserSight(w);

		}


		// In a game of tag, increment the tagged worms time
		if(iGameType == GMT_TAG && w->getTagIT())  {
			w->incrementTagTime(tLX->fRealDeltaTime);

			// Log
			log_worm_t *l = GetLogWorm(w->getID());
			if (l)
				l->fTagTime += tLX->fRealDeltaTime;
		}
	}

	// Entities
	// only some gfx effects, therefore it doesn't belong to PhysicsEngine
	if(!bDedicated)
		SimulateEntities(tLX->fDeltaTime, cMap);

	// Weather
	// TODO: if this will be implemented once, this should be moved to the PhysicsEngine
	//cWeather.Simulate(tLX->fDeltaTime, cMap);

	// Projectiles
	PhysicsEngine::Get()->simulateProjectiles(cProjectiles.begin());

	// Bonuses
	PhysicsEngine::Get()->simulateBonuses(cBonuses, MAX_BONUSES);

}
{'fraction_non_alphanumeric': 0.1568650699549443, 'fraction_numerical': 0.003319895660422101, 'mean_word_length': 2.683406113537118, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '787136', 'n_tokens_mistral': 3320, 'n_tokens_neox': 2847, 'n_words': 817}