The data will always be sent to the client in one update, so there's no worry of wasted bandwidth.
Is it better for server performance / memory to store all the variables and access them like this:
Code: Select all
// Init stat data on zone entry
SFSObject statData = new SFSObject();
statData.putInt("level", userLevel);
statData.putInt("magic", userMagic);
... Multiple more data values
UserVariable stats = new SFSUserVariable("stats", statData);
// Battle loop
// Accessing data during battle
if ( user.getVariable("s").getSFSObjectValue().getInt("magic") > 50 )
{
... Use spell
}
// Update data at end of battle
SFSObject stats = user.getVariable("stats").getSFSObjectValue();
int newLevel = 10;
stats.putInt("level", newLevel); // Update level
UserVariable newStats = new SFSUserVariable("stats", sfsoObject);
user.setVariable(newStats);
Or is it better to use multiple separate UserVariables like this:
Code: Select all
// Init stat data on zone entry
UserVariable level = new SFSUserVariable("level", 9);
UserVariable magic = new SFSUserVariable("magic", 50);
... Multiple more data values
// Battle loop
// Accessing data during battle
if ( user.getVariable("magic").getIntValue() > 50 )
{
... Use spell
}
// Update data at end of battle
int newLevel = 10;
UserVariable level = new SFSUserVariable("level", newLevel);
user.setVariable(level);
I am less familiar with how Java will handle each case and what goes on behind the curtains.