268
hands o
f
widgets
as possi
b
full-
b
lo
w
through
Dep
e
the user
requires
speciali
z
inconve
n
missing
It c
a
most di
f
the dedi
c
tions ca
n
On
t
game, i
s
found t
o
Howeve
r
and co
m
f
the team to
and controls
b
le (e.g., col
o
w
n impleme
n
the actual ga
m
e
nding on ho
interface an
d
background
z
ation of its
o
n
ient (e.g., w
i
shortcuts, or
a
n now be un
d
ff
icult to get
r
c
ation of a n
u
n
be a wise d
e
t
he impleme
n
s
free to use
i
o
be excelle
n
r
, using a dif
f
m
munication,
b
Figure 16.2
.
make the to
o
for tuning ca
n
o
r pickers, r
a
n
tation can g
o
m
e’s executa
b
w sophistica
t
d
controls fo
r
and experie
n
o
wn. If not c
o
i
dgets not be
h
m
issing und
o
d
erstood why
r
ight. It can i
n
u
mber of me
m
e
cision here.
n
tation side,
t
i
ts own prog
r
n
t for rapidly
f
erent langua
g
b
ut solutions
.
UnrealEd is
e
o
l tune virtua
l
n
all be cust
o
a
nge-limited
v
o
as far as p
r
b
le, such as i
n
t
ed a team w
a
r
a successfu
l
n
ce in devel
o
o
nsidered we
l
h
aving in a s
t
o
or redo).
this method,
n
volve a hug
e
m
bers of the
t
t
he editor ap
p
r
amming lan
g
developing
g
e than the g
a
exist [Bahna
s
e
mbedded in t
h
16.
G
l
ly any value
o
mized to be
a
v
alue sliders
,
r
oviding inst
a
n
Unreal and
a
nts to get wi
l
editor can
b
o
ping user i
n
l
l, the result
m
t
andard way,
while being
e
amount of
p
t
eam. Going
w
p
lication, be
i
g
uage. .NET
desktop con
t
a
me can com
p
s
si 08].
h
e same game’
s
G
ameTuning
deemed tun
a
a
s suitable to
,
or curve ed
a
ntaneous li
v
CryEngine.
i
th this, impl
e
b
e a difficult
t
n
terfaces, w
h
m
ost probabl
y
bad interfac
e
most sophist
i
p
rogrammer
w
w
ith third-p
a
i
ng separate
f
languages h
a
t
rol-rich app
l
p
licate data
e
s
executable.
Infrastructu
r
a
ble. The
the data
itors). A
v
e tuning
e
menting
t
ask that
h
ich is a
y
will be
e
layout,
i
cated, is
w
ork and
a
rty solu-
f
rom the
a
ve been
l
ications.
e
xchange
r
e
16.5DataExchange 269
Some implementations, such as the Unreal editor shown in Figure 16.2, in-
volve the editor directly within the actual game’s executable. This simplifies the
task of data exchange and provides access to the game’s most up-to-date render-
ing features and data structures. But on the other hand, such approaches can
complicate the game’s code by involving the editor’s code in many of the game’s
internal aspects and forcing it to handle situations that are not faced when launch-
ing the game in standalone mode.
Another important issue is stability. By binding the editor to the game code
itself, the editor inherits the same level of instability as the game (which can be
high during game production), causing grief and lost work to the entire team.
Thus, it is advisable to implement the editor as a separate application running in
its own address space and using its own codebase. It can be made so that even if
the game or visualization tool crashes, then it would still be possible to save data
so that no work is lost.
16.5DataExchange
As has been shown in the previous section, the tuning tool might have to com-
municate with a separate visualization tool (be it the game, a DCC tool, or some
other application). In this case, a method for exchanging tuning data between the
two ends must be established. We discuss the possible approaches in this section.
DirectValueAccess
Direct value access is the most straightforward possibility. When the tuning tool
shares the same address space as the visualization tool, direct access to the tuned
values becomes possible. Sharing the address space means the tuning tool is ei-
ther implemented in the game executable (such as in Unreal) or is loaded as a
dynamic-link library (DLL).
InterprocessCommunication
When the tuning tool is implemented as a separate application, it can communi-
cate with the game process through interprocess communication methods. This
first requires writing a game-side module to handle the communication and exe-
cute the tuning commands. Second, a protocol must be devised to identify tuna-
ble values and serialize them between the game and the tuning tool. As is shown
in Section 16.6, this can be a complicated task when the tuned data structure is
complex or the game does not offer proper identification of the objects living in
its world.
270 16.GameTuningInfrastructure
CrossPlatformCommunication
If an interprocess communication system has been put in place, then it is relative-
ly easy to extend it to handle cross-platform communication. With this feature,
the tuning tool can be run on the development platform (e.g., PC) and tuning can
occur live inside the game running on the target platform (e.g., PlayStation 3).
All major console SDKs provide some means to communicate programmatically
with the console from a PC. Implementing this method is the only way for dedi-
cated editors to support on-console tuning.
16.6SchemaandExposure
Historically, a lot of games have relied on configuration files (usually of type
.INI) to expose tunable values to users. As discussed earlier, such a method is
not convenient for games that have a large launch overhead. This is even more
problematic if the result of tuning can only be seen after going to a certain loca-
tion in the game or performing a lengthy series of steps to get to it.
Exposing data for tuning involves identifying variables to expose, their types,
their value limits, and other possible tuning-related information and user inter-
face options. In this section, we discuss some possibilities available in this area.
MarkingTunableVariables
A very simple method is to give tunable variables a special declaration in the
C++ code. For example, variables can be wrapped in a preprocessor define that
would expand to register the variable with a tuning service, similar to the method
given by Jensen [2001].
This works fine with global variables but needs more thought to be extended
to handle instance variables (e.g., the object registers its tunables explicitly upon
instantiation). The registration can include the additional tuning information
mentioned previously.
Reflection
If C++ had code reflection capabilities, then the task of exposing tunables would
have been much simpler. This lack of reflection has strongly influenced some
engines to extend their systems with an accompanying reflected language in their
engines [Sweeny 1998]. The presence of reflection information simplifies matters
a lot and makes for uniform tuning code.
The .NET languages are a good role model in this area. The great news is
that C++/CLI has become a well-developed solution that can remedy such a situ-
16.7DataStorage 271
ation elegantly. For example, any class can become reflected if declared as a
CLR type; and the rest of the class can be left untouched in frequent cases. This
reflection can be easily turned off for the final game executable if the dependen-
cy on .NET is to be avoided in the final product. The tuning tool can then read
the structure of the tuned object and deal directly with its members.
ExplicitDefinition
Another alternative is to define the properties of tunable game objects in a sepa-
rate place outside the game code and rely on a tool to generate data definition and
access information for both the editor and the game to use. For example, a data
schema can be written once and then passed to a code generation utility to gener-
ate a C++ class for in-game use, along with an accompanying reflection infor-
mation class usable by the tuning tool. The code generation utility can go all the
way to even implementing the necessary serialization code between the native
object and its tuning service proxy.
16.7DataStorage
Once the tunable values are exposed and under convenient control, the question
becomes how to store value changes in such a way that subsequent game sessions
remember those changes and how to properly share such changes with the rest of
the team. This section gives advice about several aspects of data storage.
TextorBinary
Text file storage is highly recommended. First, the tunable values are usually not
overwhelmingly dense, which drops the necessity of storing them in a binary
format. Second, such a human readable format allows for easy differencing to see
a history of changes that went through a file. This is a valuable feature for de-
bugging.
If loading efficiency is to be maximized, a text-to-binary conversion process
can optionally be supported for the release version of the game. Interestingly,
some games actually prefer to ship those files in a human readable format for
players to tweak and modify.
DivideandConquer
Another production-related piece of advice is to avoid storing tuned data in single
monolithic configuration files. Such a setup prevents parallel work when multiple
272 16.GameTuningInfrastructure
team members are involved in tuning different areas of the game because they
are forced to wait for each other to release the file and continue working. Al-
though it is usually possible to merge changes from different versions of the file
and thus restore the capability of parallel work, it is not a good idea to involve
yet an additional step in the workflow of game tuning. Thus, it is advisable that
tunable values be stored in different files in accordance with logical sectioning,
thus reducing the possibility of conflicts and the need to resolve such conflicts.
SupportingStructureChanges
When writing tuned data to a file, it is possible to fall into the trap of writing
them in a serial manner and assuming an implicit ordering that matches the inter-
nal structure holding this data in memory. It is a trap because this could compro-
mise all tuned data if any changes occurred to the internal data structure, and the
team then has to write version-aware code to deal with files not written using the
new data structure layout.
An alternative is to name tuned data as it is written to file as illustrated by
Listing 16.2. This way, regardless of where that field falls in the internal data
structure layout, it can still be loaded correctly, without having to consider any
changes that might occur later in time.
FileFormat
There are well-known formats that can be used for storing tuned data. Those in-
clude the
.INI file format (sectioned name-value pairs) and the more expressive
XML format. Adopting a well-known format can save development time by us-
ing libraries that are already available for reading and writing such file formats.
[weapon]
name = "Tachyon Gun"
sustainTime = 10
chargeRate = 6
[upgrade]
name = "Heat Dispenser"
effect = sustainTime
value = +5
[upgrade]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.32.1