Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-10 17:13:41 +0000
committerStijn Buys <ingar@osirion.org>2013-11-10 17:13:41 +0000
commit5f0958c121a246d445507313984358ff8a6df3fa (patch)
tree34f0b53f0e7de9bee09ad8bcafa4228654365ae5 /src/core
parent82f0ac05f5da2d89c4a544ca22ff47e116e6dd97 (diff)
Adjust reputation on NPC kills,
refresh reputation window if required.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/netconnection.cc1
-rw-r--r--src/core/reputation.cc13
-rw-r--r--src/core/reputation.h24
3 files changed, 34 insertions, 4 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index b1a4e77..f87f66e 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -817,6 +817,7 @@ void NetConnection::parse_incoming_message(const std::string & message)
} else if (command.compare("rep") == 0) {
connection()->localplayer()->reputation().receive_server_update(msgstream);
+ connection()->localplayer()->reputation().set_timestamp(game()->timestamp());
} else if (command.compare("inf") == 0) {
diff --git a/src/core/reputation.cc b/src/core/reputation.cc
index b3eee43..ea276a7 100644
--- a/src/core/reputation.cc
+++ b/src/core/reputation.cc
@@ -43,6 +43,19 @@ void Reputation::assign(const Reputation &other)
}
+void Reputation::set_dirty(const bool dirty)
+{
+ reputation_dirty = dirty;
+ if (reputation_dirty) {
+ reputation_timestamp = game()->timestamp();
+ }
+}
+
+void Reputation::set_timestamp(const unsigned long timestamp)
+{
+ reputation_timestamp = timestamp;
+}
+
const Info *Reputation::find(const Info *faction) const
{
for (FactionReps::const_iterator it = reputation_factionreps.begin(); it != reputation_factionreps.end(); ++it) {
diff --git a/src/core/reputation.h b/src/core/reputation.h
index d20a210..af6b426 100644
--- a/src/core/reputation.h
+++ b/src/core/reputation.h
@@ -87,15 +87,24 @@ public:
void set_reputation(const Info *faction, const float reputation);
- inline void set_dirty(const bool dirty = true)
- {
- reputation_dirty = dirty;
- }
+ void set_dirty(const bool dirty = true);
+
+ void set_timestamp(const unsigned long timestamp);
void clear();
void assign(const Reputation &other);
+ inline FactionReps::const_iterator factionreps_begin() const
+ {
+ return reputation_factionreps.begin();
+ }
+
+ inline FactionReps::const_iterator factionreps_end() const
+ {
+ return reputation_factionreps.end();
+ }
+
inline FactionReps & factionreps()
{
return reputation_factionreps;
@@ -106,6 +115,11 @@ public:
return reputation_dirty;
}
+ inline const unsigned long timestamp() const
+ {
+ return reputation_timestamp;
+ }
+
/* ---- deserializers -------------------------------------- */
/// receive a server-to-client update from a stream
@@ -120,6 +134,8 @@ private:
FactionReps reputation_factionreps;
bool reputation_dirty;
+
+ unsigned long reputation_timestamp;
};
} // namespace core