Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-09 15:22:44 +0000
committerStijn Buys <ingar@osirion.org>2013-11-09 15:22:44 +0000
commit977a9a68d2465818a331643399a9ecc998d0cbb3 (patch)
tree5e19904a95119ebc22cfffedcf4bd7b2094e4e31 /src/core/reputation.cc
parentd0b6e591fbaf3db5fc9898e75913e57a3c32169a (diff)
Bumped network protocol to version 27,
send player reputation and stats from server to client, send entity faction to clients, improved list_entity.
Diffstat (limited to 'src/core/reputation.cc')
-rw-r--r--src/core/reputation.cc34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/core/reputation.cc b/src/core/reputation.cc
index 013fd9e..b3eee43 100644
--- a/src/core/reputation.cc
+++ b/src/core/reputation.cc
@@ -5,11 +5,13 @@
*/
#include "core/reputation.h"
+#include "core/application.h"
namespace core {
Reputation::Reputation()
{
+ reputation_dirty = false;
}
Reputation::~Reputation()
@@ -24,6 +26,8 @@ void Reputation::clear()
(*it) = 0;
}
reputation_factionreps.clear();
+
+ reputation_dirty = false;
}
void Reputation::assign(const Reputation &other)
@@ -78,26 +82,52 @@ void Reputation::set_reputation(const std::string &label, const float reputation
{
for (FactionReps::const_iterator it = reputation_factionreps.begin(); it != reputation_factionreps.end(); ++it) {
if (((*it)->faction() && (label.compare((*it)->faction()->label()) == 0)) || ((*it)->label().compare(label) == 0)) {
- (*it)->set_reputation(reputation);
+ if ((*it)->reputation() != reputation) {
+ (*it)->set_reputation(reputation);
+ reputation_dirty = true;
+ }
return;
}
}
FactionRep *factionrep = new FactionRep(label, reputation);
reputation_factionreps.push_back(factionrep);
+ reputation_dirty = true;
}
void Reputation::set_reputation(const Info *faction, const float reputation)
{
for (FactionReps::const_iterator it = reputation_factionreps.begin(); it != reputation_factionreps.end(); ++it) {
if ((!(*it)->faction() && ((*it)->label().compare(faction->label()) == 0)) || ((*it)->faction() == faction)) {
- (*it)->set_reputation(reputation);
+ if ((*it)->reputation() != reputation) {
+ (*it)->set_reputation(reputation);
+ reputation_dirty = true;
+ }
return;
}
}
FactionRep *factionrep = new FactionRep(faction, reputation);
reputation_factionreps.push_back(factionrep);
+ reputation_dirty = true;
+}
+
+void Reputation::receive_server_update(std::istream &is)
+{
+ unsigned long id;
+ float reputation;
+
+ while ((is >> id) && ( is >> reputation)) {
+ // this is client side and has to create info records as required
+ set_reputation(game()->request_info(id), reputation);
+ }
+}
+
+void Reputation::serialize_server_update(std::ostream & os) const
+{
+ for (FactionReps::const_iterator it = reputation_factionreps.begin(); it != reputation_factionreps.end(); ++it) {
+ os << (*it)->faction()->id() << " " << roundf((*it)->reputation()) << " ";
+ }
}
} // namespace core \ No newline at end of file