StatSet.addStat()/updateStat() need to know if they were called from syncStat() so that our ServerStatSet subclass that does sneaky badge-related stuff in msoy can do the right thing with regards to badge updating.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@733 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -77,13 +77,13 @@ public class StatSet extends DSet<Stat>
|
|||||||
if (stat != null) {
|
if (stat != null) {
|
||||||
wasModified = stat.isModified();
|
wasModified = stat.isModified();
|
||||||
modifier.modify(stat);
|
modifier.modify(stat);
|
||||||
updateStat(stat);
|
updateStat(stat, true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@SuppressWarnings("unchecked") T nstat = (T)modifier.getType().newStat();
|
@SuppressWarnings("unchecked") T nstat = (T)modifier.getType().newStat();
|
||||||
stat = nstat;
|
stat = nstat;
|
||||||
modifier.modify(stat);
|
modifier.modify(stat);
|
||||||
addStat(stat);
|
addStat(stat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
stat.setModified(wasModified);
|
stat.setModified(wasModified);
|
||||||
@@ -102,9 +102,9 @@ public class StatSet extends DSet<Stat>
|
|||||||
if (stat == null) {
|
if (stat == null) {
|
||||||
stat = (IntStat)type.newStat();
|
stat = (IntStat)type.newStat();
|
||||||
stat.setValue(value);
|
stat.setValue(value);
|
||||||
addStat(stat);
|
addStat(stat, false);
|
||||||
} else if (stat.setValue(value)) {
|
} else if (stat.setValue(value)) {
|
||||||
updateStat(stat);
|
updateStat(stat, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ public class StatSet extends DSet<Stat>
|
|||||||
if (stat == null) {
|
if (stat == null) {
|
||||||
stat = (IntStat)type.newStat();
|
stat = (IntStat)type.newStat();
|
||||||
stat.increment(delta);
|
stat.increment(delta);
|
||||||
addStat(stat);
|
addStat(stat, false);
|
||||||
} else if (stat.increment(delta)) {
|
} else if (stat.increment(delta)) {
|
||||||
updateStat(stat);
|
updateStat(stat, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +152,10 @@ public class StatSet extends DSet<Stat>
|
|||||||
if (stat == null) {
|
if (stat == null) {
|
||||||
stat = (IntArrayStat)type.newStat();
|
stat = (IntArrayStat)type.newStat();
|
||||||
stat.appendValue(value);
|
stat.appendValue(value);
|
||||||
addStat(stat);
|
addStat(stat, false);
|
||||||
} else {
|
} else {
|
||||||
stat.appendValue(value);
|
stat.appendValue(value);
|
||||||
updateStat(stat);
|
updateStat(stat, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,9 +172,9 @@ public class StatSet extends DSet<Stat>
|
|||||||
@SuppressWarnings("unchecked") SetStat<T> nstat = (SetStat<T>)type.newStat();
|
@SuppressWarnings("unchecked") SetStat<T> nstat = (SetStat<T>)type.newStat();
|
||||||
stat = nstat;
|
stat = nstat;
|
||||||
stat.add(value);
|
stat.add(value);
|
||||||
addStat(stat);
|
addStat(stat, false);
|
||||||
} else if (stat.add(value)) {
|
} else if (stat.add(value)) {
|
||||||
updateStat(stat);
|
updateStat(stat, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,9 +190,9 @@ public class StatSet extends DSet<Stat>
|
|||||||
if (stat == null) {
|
if (stat == null) {
|
||||||
stat = (StringMapStat)type.newStat();
|
stat = (StringMapStat)type.newStat();
|
||||||
stat.increment(value, amount);
|
stat.increment(value, amount);
|
||||||
addStat(stat);
|
addStat(stat, false);
|
||||||
} else if (stat.increment(value, amount)) {
|
} else if (stat.increment(value, amount)) {
|
||||||
updateStat(stat);
|
updateStat(stat, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +274,14 @@ public class StatSet extends DSet<Stat>
|
|||||||
add(stat);
|
add(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addStat (Stat stat)
|
/**
|
||||||
|
* Adds the specified Stat to the set.
|
||||||
|
*
|
||||||
|
* @param syncingWithRepo should be set to true only when called from {@link #syncStat},
|
||||||
|
* which itself is called only when a stat modification has been made to the database,
|
||||||
|
* and the in-memory StatSet needs to be updated as a result.
|
||||||
|
*/
|
||||||
|
protected void addStat (Stat stat, boolean syncingWithRepo)
|
||||||
{
|
{
|
||||||
if (_container != null) {
|
if (_container != null) {
|
||||||
_container.addToStats(stat);
|
_container.addToStats(stat);
|
||||||
@@ -283,7 +290,14 @@ public class StatSet extends DSet<Stat>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateStat (Stat stat)
|
/**
|
||||||
|
* Updates the specified Stat in the set.
|
||||||
|
*
|
||||||
|
* @param syncingWithRepo should be set to true only when called from {@link #syncStat},
|
||||||
|
* which itself is called only when a stat modification has been made to the database,
|
||||||
|
* and the in-memory StatSet needs to be updated as a result.
|
||||||
|
*/
|
||||||
|
protected void updateStat (Stat stat, boolean syncingWithRepo)
|
||||||
{
|
{
|
||||||
if (_container != null) {
|
if (_container != null) {
|
||||||
_container.updateStats(stat);
|
_container.updateStats(stat);
|
||||||
|
|||||||
Reference in New Issue
Block a user