the re variable contains a structure which houses pointers to the rendering API. These values are initialize in the GetRefAPI function, as follows:
refexport_t re;
re.api_version = API_VERSION;
re.BeginRegistration = R_BeginRegistration;
re.RegisterModel = R_RegisterModelShort;
re.RegisterSkin = R_RegisterSkin;
re.RegisterFont = R_RegisterFont;
re.RegisterPic = Draw_FindPic;
re.SetSky = R_SetSky;
re.EndRegistration = R_EndRegistration;
re.RenderFrame = R_RenderFrame;
re.DrawModelDirect = R_DrawModelDirect;
re.DrawGetPicSize = Draw_GetPicSize;
re.DrawPic = Draw_Pic;
re.DrawNormPic = Draw_NormPic;
re.DrawStretchPic = Draw_StretchPic;
re.DrawChar = Draw_Char;
re.DrawPropChar = Draw_PropChar;
re.DrawPropString = Draw_PropString;
re.DrawPropLength = Draw_PropLength;
re.DrawTileClear = Draw_TileClear;
re.DrawFill = Draw_Fill;
re.DrawColor = Draw_Color;
re.DrawFadeScreen = Draw_FadeScreen;
re.AnimAppend = Anim_Append;
re.AnimChange = Anim_Change;
re.AnimRun = Anim_Run;
re.DrawStretchRaw = Draw_StretchRaw;
re.Init = R_Init;
re.Shutdown = R_Shutdown;
re.CinematicSetPalette = R_SetPalette;
re.BeginFrame = R_BeginFrame;
re.EndFrame = GLimp_EndFrame;
re.AppActivate = GLimp_AppActivate;
First, make sure that ufo was compiled with debugging enabled. You can do this using the debug target:
bash$ make debug
Next, open a vt, yes a text vt. Change to the ufoai_source/linux directory and start emacs
Start gdb within emacs using the M-x gdb command, and select the ufo executable as your target, for instance
gdb ~/projects/ufoai/ufo
Set a breakpoint at the first function in the main(), like this:
(gdb) b sys_linux.c:298
And use the run command:
(gdb) run
Now you're cooking!
The init process looks something like this:
\-- main | \-- Qcommon_Init | | \-- COM_InitArgv | | \-- Swap_Init | | \-- Cbuf_Init | | | \-- SZ_Init | | \-- Cmd_Init | | \-- Cvar_Init | | \-- Key_Init | | \-- Cbuf_AddEarlyCommands | | \-- Cbuf_Execute | | \-- FS_InitFilesystem | | \-- Sys_Init | | \-- NET_Init | | \-- Netchan_Init | | \-- SV_Init | | | \-- SV_InitOperatorCommands | | | \-- SZ_Init | | \-- CL_Init | | | \-- Con_Init | | | \-- S_Init | | | | \-- SNDDMA_Init | | | \-- VID_Init | | | | \-- VID_CheckChanges | | | \-- V_Init | | | \-- SCR_Init | | | | \-- SCR_TouchPics | | | \-- CDAudio_Init | | | \-- CL_InitLocal | | | | \-- Sys_Milliseconds | | | | \-- Con_CheckResize | | | | | \-- Con_ClearNotify | | | | \-- Com_InitInventory | | | | \-- CL_InitInput | | | | \-- MN_ResetMenus | | | | \-- CL_ResetParticles | | | | \-- CL_ResetTeams | | | | \-- CL_ResetCampaign | | | | \-- CL_ResetSequences | | | \-- IN_Init | | | \-- FS_ExecAutoexec | | \-- Com_ParseScripts
void normpath(char *path) |
qcommon/files.c |
path is a pointer to a zero terminated
string. |
char **FS_ListFiles( char *findname, int *numfiles, unsigned musthave, unsigned canthave ) |
qcommon/files.c |
returns a pointer to an array of string pointers. Each of these string pointers points to a file matching findname. The musthave and canthave argument describe file attributes. |
|
|
The UFOAI scripting system is really cool. By manipulating the scripts in the ufos directory you can customize the game to do just about anything (ok, it won't make coffee). This document explains how it works.
UFOAI TD1 reads every file in the ufos directory that ends in .ufo (i.e., matches the pattern “ufos/*ufo”).
The scripts define a set of objects. Some objects are more complicated than others. Some objects reference other objects. Every object has a type and a name. There are a limited number of object types:
menu
actors
names
team
item
equipment
mission
campaign
inventory
particle
object_type object_name
{
object_type object_value
object_type object_name
{
object_type object_value
}
}Valid object types are:
|
menu |
|
|
|
|
|
zone |
|
|
|
|
|
invis |
true/false |
|
|
pic |
|
|
|
|
|
image |
path/file |
|
|
|
pos |
“x y” position of upper left corner |
|
|
|
texl |
“x y” |
|
|
|
texh |
“x y” |
|
|
|
click |
{cmd “mn_push singleplayer” } |
|
|
|
out |
{ *button_singleplayer texl "0 0" *button_singleplayer texh "256 64" |
|
|
|
in |
{ *button_singleplayer texl "0 64" *button_singleplayer texh "256 128" } |
|
|
string |
|
|
|
|
|
string |
“*cvar ver” |
|
|
|
pos |
“x y” position of upper left corner |
|
|
func |
|
|
|
|
|
cmd |
“command string” |
|
actors |
|
|
|
|
|
gender |
{ list of models } |
|
|
names |
|
|
|
|
|
gender |
{ list of names } |
|
|
team |
|
|
|
|
|
actors_name |
||
|
item |
|
|
|
|
|
name |
“name” |
|
|
|
model |
path |
|
|
|
type |
??? seems to be one of rifle, ammo, pistol rpg, or biggun |
|
|
|
category |
??? seems to be 0 or 1. All category 1 objects seem to be weapons, while category 0 seem to be ammo |
|
|
|
shape |
“s t x y” |
|
|
|
center |
“s t f” |
|
|
|
scale |
f |
|
|
|
ammo |
x |
|
|
|
reload |
x |
|
|
|
price |
x |
|
|
|
buytype |
??? 0 |
|
|
|
primary |
an unnamed object, with member objects as follows: |
|
|
|
|
name |
“name” |
|
|
|
projtl |
particle_name |
|
|
|
impact |
??? |
|
|
|
firesnd |
path/filename |
|
|
|
speed |
x |
|
|
|
spread |
“x y” |
|
|
|
crouch |
f |
|
|
|
range |
x |
|
|
|
shots |
x |
|
|
|
ammo |
x |
|
|
|
rof |
x |
|
|
|
time |
x |
|
|
|
damaage |
“x y” |
|
|
secondary |
another unnamed object, with member objects same as primary |
|
|
equipment |
|
|
|
|
|
item_name |
quantity |
|
|
mission |
|
|
|
|
|
text |
“description of mission” |
|
|
|
map |
map_file |
|
|
|
music |
music_file |
|
|
|
pos |
“x y” ??? |
|
|
|
aliens |
x |
|
|
|
civilians |
number of civilians to spawn |
|
|
|
alien_equip |
equipment_name |
|
|
|
recruits |
x |
|
|
|
$win |
x |
|
|
|
$alien |
x |
|
|
|
$civilian |
x |
|
|
campaign |
|
|
|
|
|
team |
team_name (must be defined by a team object) |
|
|
|
soldiers |
num |
|
|
|
equipment |
equipment_name |
|
|
|
market |
market_name |
|
|
|
credits |
x |
|
|
|
mission_name |
“mission_name” |
|
|
inventory |
|
|
|
|
|
shape |
“x x x x” |
|
|
|
single |
true or false |
|
|
|
in |
x |
|
|
|
out |
x |
|
Buttons:
A simple backgroung image can be place using a pic like this:
{
image menu/main_ul
pos "0 0"
}
A button is defined using a more complicate pic object type, like this:
pic button_singleplayer
{
image menu/main_buttons1
pos "640 170"
texl "0 0"
texh "256 64"
click { cmd "mn_push singleplayer" }
out { *button_singleplayer texl "0 0" *button_singleplayer texh "256 64" }
in { *button_singleplayer texl "0 64" *button_singleplayer texh "256 128" }
}
Special Functions:
The init function is automatically executed when a menu is pushed to the screen.