forked from teamnwah/openmw-tes3coop
[Server] Iterate only through updated players on each frame
parent
4ab338bbb1
commit
8f5d31cb03
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by koncord on 02.01.18.
|
||||
//
|
||||
|
||||
#include "BaseMgr.hpp"
|
||||
#include "Player.hpp"
|
||||
|
||||
BaseMgr::BaseMgr(Player *player) : player(player), changed(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BaseMgr::update()
|
||||
{
|
||||
if (!changed)
|
||||
return;
|
||||
changed = false;
|
||||
|
||||
processUpdate();
|
||||
}
|
||||
|
||||
void BaseMgr::setChanged()
|
||||
{
|
||||
changed = true;
|
||||
player->addToUpdateQueue();
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by koncord on 02.01.18.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
class Player;
|
||||
|
||||
class BaseMgr
|
||||
{
|
||||
public:
|
||||
explicit BaseMgr(Player *player);
|
||||
void update();
|
||||
protected:
|
||||
bool isChanged() const { return changed; };
|
||||
void setChanged();
|
||||
virtual void processUpdate() = 0;
|
||||
Player *player;
|
||||
private:
|
||||
bool changed;
|
||||
};
|
Loading…
Reference in New Issue