[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src action/action_spellcast.c clone/c...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src action/action_spellcast.c clone/c... |
Date: |
Thu, 09 Oct 2003 16:54:36 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/10/09 16:54:36
Modified files:
src/action : action_spellcast.c
src/clone : ccl.c ccl_player.c ccl_spell.c
Log message:
Cleanup
Patches:
Index: stratagus/src/action/action_spellcast.c
diff -u stratagus/src/action/action_spellcast.c:1.33
stratagus/src/action/action_spellcast.c:1.34
--- stratagus/src/action/action_spellcast.c:1.33 Mon Sep 29 13:04:12 2003
+++ stratagus/src/action/action_spellcast.c Thu Oct 9 16:54:35 2003
@@ -10,7 +10,7 @@
//
/address@hidden action_spellcast.c - The spell cast action. */
//
-// (c) Copyright 2000-2002 by Vladi Belperchinov-Shabanski
+// (c) Copyright 2000-2003 by Vladi Belperchinov-Shabanski
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_spellcast.c,v 1.33 2003/09/29 17:04:12 n0body Exp $
+// $Id: action_spellcast.c,v 1.34 2003/10/09 20:54:35 jsalmon3 Exp $
/*
** This is inherited from action_attack.c, actually spell casting will
@@ -67,7 +67,7 @@
**
** @param unit Unit, for that spell cast/attack animation is played.
*/
-global void AnimateActionSpellCast(Unit * unit)
+global void AnimateActionSpellCast(Unit* unit)
{
int flags;
@@ -100,7 +100,7 @@
// Unit can't move
err = 1;
- if( unit->Type->Animations && unit->Type->Animations->Move ) {
+ if (unit->Type->Animations && unit->Type->Animations->Move) {
err = DoActionMove(unit);
if (!unit->Reset) {
return;
@@ -111,45 +111,45 @@
// FIXME: use return codes from pathfinder
goal = unit->Orders[0].Goal;
- if (goal && MapDistanceBetweenUnits(unit, goal)
- <= unit->Orders[0].RangeX) {
+ if (goal && MapDistanceBetweenUnits(unit, goal) <=
+ unit->Orders[0].RangeX) {
// there is goal and it is in range
unit->State = 0;
- if( !unit->Type->Building ) {
+ if (!unit->Type->Building) {
// FIXME: buildings could have directions
UnitHeadingFromDeltaXY(unit,
- goal->X+(goal->Type->TileWidth-1)/2-unit->X,
- goal->Y+(goal->Type->TileHeight-1)/2-unit->Y);
+ goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
+ goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
}
unit->SubAction++; // cast the spell
return;
} else if (!goal && MapDistanceToUnit(unit->Orders[0].X,
- unit->Orders[0].Y,unit) <= unit->Orders[0].RangeX) {
+ unit->Orders[0].Y, unit) <= unit->Orders[0].RangeX) {
// there is no goal and target spot is in range
unit->State = 0;
- if( !unit->Type->Building ) {
+ if (!unit->Type->Building) {
// FIXME: buildings could have directions
UnitHeadingFromDeltaXY(unit,
- unit->Orders[0].X
- +((SpellType*)unit->Orders[0].Arg1)->Range-unit->X,
- unit->Orders[0].Y
- +((SpellType*)unit->Orders[0].Arg1)->Range-unit->Y);
+ unit->Orders[0].X +
+ ((SpellType*)unit->Orders[0].Arg1)->Range - unit->X,
+ unit->Orders[0].Y +
+ ((SpellType*)unit->Orders[0].Arg1)->Range - unit->Y);
}
unit->SubAction++; // cast the spell
return;
} else if (err) {
// goal/spot out of range -- move to target
- unit->Orders[0].Action=UnitActionStill;
- unit->State=unit->SubAction=0;
+ unit->Orders[0].Action = UnitActionStill;
+ unit->State = unit->SubAction = 0;
- if( unit->Orders[0].Goal ) { // Release references
+ if (unit->Orders[0].Goal) { // Release references
RefsDebugCheck(!unit->Orders[0].Goal->Refs);
if (!--unit->Orders[0].Goal->Refs) {
RefsDebugCheck(!unit->Orders[0].Goal->Destroyed);
ReleaseUnit(unit->Orders[0].Goal);
}
- unit->Orders[0].Goal=NoUnitP;
+ unit->Orders[0].Goal = NoUnitP;
}
}
DebugCheck(unit->Type->Vanishes || unit->Destroyed);
@@ -160,116 +160,115 @@
**
** @param unit Unit, for that the spell cast is handled.
*/
-global void HandleActionSpellCast(Unit * unit)
+global void HandleActionSpellCast(Unit* unit)
{
int flags;
- const SpellType *spell;
+ const SpellType* spell;
DebugLevel3Fn("%d %d,%d+%d+%d\n" _C_
UnitNumber(unit) _C_ unit->Orders[0].X _C_ unit->Orders[0].Y _C_
unit->Orders[0].RangeX _C_ unit->Orders[0].RangeY);
switch (unit->SubAction) {
-
- case 0: // first entry.
- //
- // Check if we can cast the spell.
- //
- spell = unit->Orders[0].Arg1;
- if( !CanCastSpell(unit,spell,unit->Orders[0].Goal,
- unit->Orders[0].X,unit->Orders[0].Y) ) {
-
+ case 0: // first entry.
//
- // Notify player about this problem
+ // Check if we can cast the spell.
//
- if (unit->Mana < spell->ManaCost) {
- NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
+ spell = unit->Orders[0].Arg1;
+ if (!CanCastSpell(unit,spell, unit->Orders[0].Goal,
+ unit->Orders[0].X, unit->Orders[0].Y)) {
+
+ //
+ // Notify player about this problem
+ //
+ if (unit->Mana < spell->ManaCost) {
+ NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
"%s: not enough mana for spell: %s",
unit->Type->Name, spell->Name);
- } else {
- NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
+ } else {
+ NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
"%s: can't cast spell: %s",
unit->Type->Name, spell->Name);
- }
+ }
- if( unit->Player->Ai ) {
- DebugLevel0Fn("FIXME: need we an AI callback?\n");
- }
- unit->Orders[0].Action = UnitActionStill;
- unit->SubAction = 0;
- unit->Wait = 1;
- if (unit->Orders[0].Goal) {
- RefsDebugCheck(!unit->Orders[0].Goal->Refs);
- if (!--unit->Orders[0].Goal->Refs) {
- RefsDebugCheck(!unit->Orders[0].Goal->Destroyed);
- ReleaseUnit(unit->Orders[0].Goal);
+ if (unit->Player->Ai) {
+ DebugLevel0Fn("FIXME: need we an AI callback?\n");
+ }
+ unit->Orders[0].Action = UnitActionStill;
+ unit->SubAction = 0;
+ unit->Wait = 1;
+ if (unit->Orders[0].Goal) {
+ RefsDebugCheck(!unit->Orders[0].Goal->Refs);
+ if (!--unit->Orders[0].Goal->Refs) {
+ RefsDebugCheck(!unit->Orders[0].Goal->Destroyed);
+ ReleaseUnit(unit->Orders[0].Goal);
+ }
+ unit->Orders[0].Goal = NoUnitP;
}
- unit->Orders[0].Goal=NoUnitP;
+ return;
}
- return;
- }
- // FIXME FIXME FIXME: Check if already in range and skip straight to
2(casting)
- NewResetPath(unit);
- unit->Value=0; // repeat spell on next pass? (defaults to `no')
- unit->SubAction=1;
- // FALL THROUGH
- case 1: // Move to the target.
- // FIXME: crashes with huge ranges.
- if( (spell = unit->Orders[0].Arg1)->Range != INFINITE_RANGE ) {
- SpellMoveToTarget(unit);
- break;
- } else {
- unit->SubAction=2;
- }
- // FALL THROUGH
- case 2: // Cast spell on the target.
- // FIXME: should use AnimateActionSpellCast here
- if (unit->Type->Animations && unit->Type->Animations->Attack ) {
- flags=UnitShowAnimation(unit, unit->Type->Animations->Attack);
- if( flags&AnimationMissile ) {
+ // FIXME FIXME FIXME: Check if already in range and skip straight
to 2(casting)
+ NewResetPath(unit);
+ unit->Value = 0; // repeat spell on next pass? (defaults
to `no')
+ unit->SubAction = 1;
+ // FALL THROUGH
+ case 1: // Move to the target.
+ // FIXME: crashes with huge ranges.
+ if ((spell = unit->Orders[0].Arg1)->Range != INFINITE_RANGE) {
+ SpellMoveToTarget(unit);
+ break;
+ } else {
+ unit->SubAction = 2;
+ }
+ // FALL THROUGH
+ case 2: // Cast spell on the target.
+ // FIXME: should use AnimateActionSpellCast here
+ if (unit->Type->Animations && unit->Type->Animations->Attack) {
+ flags = UnitShowAnimation(unit, unit->Type->Animations->Attack);
+ if (flags & AnimationMissile) {
+ // FIXME: what todo, if unit/goal is removed?
+ if (unit->Orders[0].Goal &&
+ unit->Orders[0].Goal->Orders[0].Action ==
UnitActionDie) {
+ unit->Value = 0;
+ } else {
+ spell = unit->Orders[0].Arg1;
+ unit->Value = SpellCast(unit, spell,
unit->Orders[0].Goal,
+ unit->Orders[0].X, unit->Orders[0].Y);
+ }
+ }
+ if (!(flags & AnimationReset)) { // end of animation
+ return;
+ }
+ } else {
// FIXME: what todo, if unit/goal is removed?
- if (unit->Orders[0].Goal
- &&
unit->Orders[0].Goal->Orders[0].Action==UnitActionDie) {
+ if (unit->Orders[0].Goal &&
+ unit->Orders[0].Goal->Orders[0].Action ==
UnitActionDie) {
unit->Value = 0;
} else {
spell = unit->Orders[0].Arg1;
- unit->Value = SpellCast(unit,spell,unit->Orders[0].Goal,
- unit->Orders[0].X,unit->Orders[0].Y);
- }
- }
- if ( !(flags&AnimationReset) ) { // end of animation
- return;
- }
- } else {
- // FIXME: what todo, if unit/goal is removed?
- if (unit->Orders[0].Goal
- && unit->Orders[0].Goal->Orders[0].Action==UnitActionDie) {
- unit->Value = 0;
- } else {
- spell = unit->Orders[0].Arg1;
- unit->Value = SpellCast(unit,spell,unit->Orders[0].Goal,
+ unit->Value = SpellCast(unit, spell, unit->Orders[0].Goal,
unit->Orders[0].X,unit->Orders[0].Y);
+ }
}
- }
- if (!unit->Value) {
- unit->Orders[0].Action = UnitActionStill;
- unit->SubAction = 0;
- unit->Wait = 1;
- if (unit->Orders[0].Goal) {
- RefsDebugCheck(!unit->Orders[0].Goal->Refs);
- if (!--unit->Orders[0].Goal->Refs) {
- if (unit->Orders[0].Goal->Destroyed) {
- ReleaseUnit(unit->Orders[0].Goal);
+ if (!unit->Value) {
+ unit->Orders[0].Action = UnitActionStill;
+ unit->SubAction = 0;
+ unit->Wait = 1;
+ if (unit->Orders[0].Goal) {
+ RefsDebugCheck(!unit->Orders[0].Goal->Refs);
+ if (!--unit->Orders[0].Goal->Refs) {
+ if (unit->Orders[0].Goal->Destroyed) {
+ ReleaseUnit(unit->Orders[0].Goal);
+ }
}
+ unit->Orders[0].Goal = NoUnitP;
}
- unit->Orders[0].Goal=NoUnitP;
}
- }
- break;
+ break;
- default:
- unit->SubAction = 0; // Reset path, than move to target
- break;
+ default:
+ unit->SubAction = 0; // Reset path, than move to
target
+ break;
}
}
Index: stratagus/src/clone/ccl.c
diff -u stratagus/src/clone/ccl.c:1.113 stratagus/src/clone/ccl.c:1.114
--- stratagus/src/clone/ccl.c:1.113 Tue Oct 7 06:40:36 2003
+++ stratagus/src/clone/ccl.c Thu Oct 9 16:54:35 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl.c,v 1.113 2003/10/07 10:40:36 martinxyz Exp $
+// $Id: ccl.c,v 1.114 2003/10/09 20:54:35 jsalmon3 Exp $
//@{
@@ -80,7 +80,7 @@
global char* GameName; /// Game Preferences
global int CclInConfigFile; /// True while config file parsing
-global char* Tips[MAX_TIPS+1]; /// Array of tips
+global char* Tips[MAX_TIPS + 1]; /// Array of tips
global int ShowTips; /// Show tips at start of level
global int CurrentTip; /// Current tip to display
@@ -89,102 +89,108 @@
----------------------------------------------------------------------------*/
/**
- * Convert a SCM to a string, SCM must be a symbol or string, else 0
- * is returned
- *
- * @param scm the SCM to convert to string
- *
- * @return a string representing the SCM or 0 in case the conversion
- * failed, caller must free() the returned value
- */
+** Convert a SCM to a string, SCM must be a symbol or string, else 0
+** is returned
+**
+** @param scm the SCM to convert to string
+**
+** @return a string representing the SCM or 0 in case the conversion
+** failed, caller must free() the returned value
+*/
global char* CclConvertToString(SCM scm)
{
#ifdef USE_GUILE
- if (gh_string_p(scm))
- return gh_scm2newstr(scm, NULL);
- else if (gh_symbol_p(scm))
- return gh_symbol2newstr(scm, NULL);
- else
- return 0;
+ if (gh_string_p(scm)) {
+ return gh_scm2newstr(scm, NULL);
+ } else if (gh_symbol_p(scm)) {
+ return gh_symbol2newstr(scm, NULL);
+ } else {
+ return 0;
+ }
#else
- char* str = try_get_c_string(scm);
- if (str)
- return strdup(str);
- else
- return 0;
+ char* str;
+
+ str = try_get_c_string(scm);
+ if (str) {
+ return strdup(str);
+ } else {
+ return 0;
+ }
#endif
}
/**
- * Return the type of a smob
- *
- * @param smob
- *
- * @return type id of the smob
- */
+** Return the type of a smob
+**
+** @param smob
+**
+** @return type id of the smob
+*/
global ccl_smob_type_t CclGetSmobType(SCM smob)
{
#ifdef USE_GUILE
- if (SCM_NIMP (smob))
- return (ccl_smob_type_t)SCM_CAR (smob);
- else
- return 0;
+ if (SCM_NIMP(smob)) {
+ return (ccl_smob_type_t)SCM_CAR(smob);
+ } else {
+ return 0;
+ }
#else
- return TYPE(smob);
+ return TYPE(smob);
#endif
}
/**
- * Return the pointer that is stored in a smob
- *
- * @param smob the smob that contains the pointer
- *
- * @return pointer that was inside the smob
- */
+** Return the pointer that is stored in a smob
+**
+** @param smob the smob that contains the pointer
+**
+** @return pointer that was inside the smob
+*/
global void* CclGetSmobData(SCM smob)
{
#ifdef USE_GUILE
- return (void*)SCM_SMOB_DATA(smob);
+ return (void*)SCM_SMOB_DATA(smob);
#else
- return smob->storage_as.cons.cdr;
+ return smob->storage_as.cons.cdr;
#endif
}
/**
- * Store a pointer inside a SMOB, aka convert a pointer to a SCM
- *
- * @param tag The type of the pointer/smob
- * @param ptr the pointer that should be converted to a SCM
- */
+** Store a pointer inside a SMOB, aka convert a pointer to a SCM
+**
+** @param tag The type of the pointer/smob
+** @param ptr the pointer that should be converted to a SCM
+*/
global SCM CclMakeSmobObj(ccl_smob_type_t tag, void* ptr)
{
#ifdef USE_GUILE
- SCM_RETURN_NEWSMOB (tag, ptr);
+ SCM_RETURN_NEWSMOB(tag, ptr);
#else
- SCM value = cons(NIL,NIL);
+ SCM value;
- value->type = tag;
- value->storage_as.cons.cdr = (SCM)ptr;
+ value = cons(NIL, NIL);
+ value->type = tag;
+ value->storage_as.cons.cdr = (SCM)ptr;
- return value;
+ return value;
#endif
}
/**
- * Create a tag for a new type.
- *
- * @param name
- *
- * @return The newly generated SMOB type
- */
+** Create a tag for a new type.
+**
+** @param name
+**
+** @return The newly generated SMOB type
+*/
global ccl_smob_type_t CclMakeSmobType(const char* name)
{
- ccl_smob_type_t new_type;
+ ccl_smob_type_t new_type;
#ifdef USE_GUILE
- new_type = scm_make_smob_type ((char*)name, 0);
+ new_type = scm_make_smob_type((char*)name, 0);
#else
- new_type = allocate_user_tc();
+ new_type = allocate_user_tc();
#endif
return new_type;
@@ -201,8 +207,9 @@
scm_gc_protect_object(obj);
#else
SCM var;
- var=gh_symbol2scm("*ccl-protect*");
- setvar(var,cons(obj,symbol_value(var,NIL)),NIL);
+
+ var = gh_symbol2scm("*ccl-protect*");
+ setvar(var, cons(obj, symbol_value(var, NIL)), NIL);
#endif
}
@@ -216,23 +223,24 @@
#ifdef USE_GUILE
scm_gc_unprotect_object(obj);
#else
- // Remove obj from the list *ccl-protect*
SCM sym;
SCM old_lst;
SCM new_lst;
+ // Remove obj from the list *ccl-protect*
sym = gh_symbol2scm("*ccl-protect*");
old_lst = symbol_value(sym, NIL);
new_lst = NIL;
// FIXME: Doesn't handle nested protect/unprotects
- while( !gh_null_p(old_lst) ) {
- SCM el = gh_car(old_lst);
-
- if (el != obj)
- new_lst = cons(el, new_lst);
-
- old_lst = gh_cdr(old_lst);
+ while (!gh_null_p(old_lst)) {
+ SCM el;
+
+ el = gh_car(old_lst);
+ if (el != obj) {
+ new_lst = cons(el, new_lst);
+ }
+ old_lst = gh_cdr(old_lst);
}
setvar(sym, new_lst, NIL);
@@ -273,17 +281,17 @@
{
SCM old;
- old=NIL;
- if( GameName ) {
- old=gh_str02scm(GameName);
+ old = NIL;
+ if (GameName) {
+ old = gh_str02scm(GameName);
}
- if( !gh_null_p(gamename) ) {
- if( GameName ) {
+ if (!gh_null_p(gamename)) {
+ if (GameName) {
free(GameName);
- GameName=NULL;
+ GameName = NULL;
}
- GameName=gh_scm2newstr(gamename,NULL);
+ GameName = gh_scm2newstr(gamename, NULL);
}
return old;
}
@@ -293,7 +301,7 @@
*/
local SCM CclSetGameCycle(SCM cycle)
{
- GameCycle=gh_scm2int(cycle);
+ GameCycle = gh_scm2int(cycle);
return SCM_UNSPECIFIED;
}
@@ -302,10 +310,10 @@
*/
local SCM CclSetGamePaused(SCM paused)
{
- if( gh_boolean_p(paused) ) {
- GamePaused=gh_scm2bool(paused);
+ if (gh_boolean_p(paused)) {
+ GamePaused = gh_scm2bool(paused);
} else {
- GamePaused=gh_scm2int(paused);
+ GamePaused = gh_scm2int(paused);
}
return SCM_UNSPECIFIED;
}
@@ -315,7 +323,7 @@
*/
local SCM CclSetVideoSyncSpeed(SCM speed)
{
- VideoSyncSpeed=gh_scm2int(speed);
+ VideoSyncSpeed = gh_scm2int(speed);
return SCM_UNSPECIFIED;
}
@@ -326,9 +334,9 @@
{
char* str;
- str=gh_scm2newstr(name, 0);
- strncpy(LocalPlayerName,str,sizeof(LocalPlayerName)-1);
- LocalPlayerName[sizeof(LocalPlayerName)-1]='\0';
+ str = gh_scm2newstr(name, 0);
+ strncpy(LocalPlayerName, str, sizeof(LocalPlayerName) - 1);
+ LocalPlayerName[sizeof(LocalPlayerName) - 1] = '\0';
return SCM_UNSPECIFIED;
}
@@ -342,8 +350,8 @@
{
int old;
- old=ShowTips;
- ShowTips=gh_scm2bool(flag);
+ old = ShowTips;
+ ShowTips = gh_scm2bool(flag);
return gh_bool2scm(old);
}
@@ -358,8 +366,8 @@
{
int old;
- old=CurrentTip;
- CurrentTip=gh_scm2int(tip);
+ old = CurrentTip;
+ CurrentTip = gh_scm2int(tip);
if (CurrentTip >= MAX_TIPS || Tips[CurrentTip] == NULL) {
CurrentTip = 0;
}
@@ -379,12 +387,12 @@
{
int i;
- for( i=0; i<MAX_TIPS; i++ ) {
- if( Tips[i] && !strcmp(get_c_string(tip),Tips[i]) ) {
+ for (i = 0; i < MAX_TIPS; ++i) {
+ if (Tips[i] && !strcmp(get_c_string(tip), Tips[i])) {
break;
}
- if( Tips[i]==NULL ) {
- Tips[i]=gh_scm2newstr(tip,NULL);
+ if (Tips[i] == NULL) {
+ Tips[i] = gh_scm2newstr(tip, NULL);
break;
}
}
@@ -398,17 +406,17 @@
** @param resource Name of resource.
** @param speed Speed factor of harvesting resource.
*/
-local SCM CclSetSpeedResourcesHarvest(SCM resource,SCM speed)
+local SCM CclSetSpeedResourcesHarvest(SCM resource, SCM speed)
{
int i;
- for( i=0; i<MaxCosts; ++i ) {
- if( gh_eq_p(resource,gh_symbol2scm(DefaultResourceNames[i])) ) {
- SpeedResourcesHarvest[i]=gh_scm2int(speed);
+ for (i = 0; i < MaxCosts; ++i) {
+ if (gh_eq_p(resource, gh_symbol2scm(DefaultResourceNames[i]))) {
+ SpeedResourcesHarvest[i] = gh_scm2int(speed);
return SCM_UNSPECIFIED;
}
}
- errl("Resource not found",resource);
+ errl("Resource not found", resource);
return SCM_UNSPECIFIED;
}
@@ -418,18 +426,18 @@
** @param resource Name of resource.
** @param speed Speed factor of returning resource.
*/
-local SCM CclSetSpeedResourcesReturn(SCM resource,SCM speed)
+local SCM CclSetSpeedResourcesReturn(SCM resource, SCM speed)
{
int i;
- for( i=0; i<MaxCosts; ++i ) {
- if( gh_eq_p(resource,gh_symbol2scm(DefaultResourceNames[i])) ) {
- SpeedResourcesReturn[i]=gh_scm2int(speed);
+ for (i = 0; i < MaxCosts; ++i) {
+ if (gh_eq_p(resource, gh_symbol2scm(DefaultResourceNames[i]))) {
+ SpeedResourcesReturn[i] = gh_scm2int(speed);
break;
}
}
- if( i==MaxCosts ) {
- errl("Resource not found",resource);
+ if (i == MaxCosts) {
+ errl("Resource not found", resource);
}
return speed;
}
@@ -439,7 +447,7 @@
*/
local SCM CclSetSpeedBuild(SCM speed)
{
- SpeedBuild=gh_scm2int(speed);
+ SpeedBuild = gh_scm2int(speed);
return speed;
}
@@ -449,7 +457,7 @@
*/
local SCM CclSetSpeedTrain(SCM speed)
{
- SpeedTrain=gh_scm2int(speed);
+ SpeedTrain = gh_scm2int(speed);
return speed;
}
@@ -459,7 +467,7 @@
*/
local SCM CclSetSpeedUpgrade(SCM speed)
{
- SpeedUpgrade=gh_scm2int(speed);
+ SpeedUpgrade = gh_scm2int(speed);
return speed;
}
@@ -469,7 +477,7 @@
*/
local SCM CclSetSpeedResearch(SCM speed)
{
- SpeedResearch=gh_scm2int(speed);
+ SpeedResearch = gh_scm2int(speed);
return speed;
}
@@ -482,12 +490,12 @@
int i;
int s;
- s=gh_scm2int(speed);
- for( i=0; i<MaxCosts; ++i ) {
- SpeedResourcesHarvest[i]=s;
- SpeedResourcesReturn[i]=s;
+ s = gh_scm2int(speed);
+ for (i = 0; i < MaxCosts; ++i) {
+ SpeedResourcesHarvest[i] = s;
+ SpeedResourcesReturn[i] = s;
}
- SpeedBuild=SpeedTrain=SpeedUpgrade=SpeedResearch=s;
+ SpeedBuild = SpeedTrain = SpeedUpgrade = SpeedResearch = s;
return speed;
}
@@ -499,9 +507,9 @@
{
int i;
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
- DefaultResources[i]=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
+ DefaultResources[i] = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -513,9 +521,9 @@
{
int i;
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
- DefaultResourcesLow[i]=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
+ DefaultResourcesLow[i] = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -527,9 +535,9 @@
{
int i;
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
- DefaultResourcesMedium[i]=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
+ DefaultResourcesMedium[i] = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -541,9 +549,9 @@
{
int i;
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
- DefaultResourcesHigh[i]=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
+ DefaultResourcesHigh[i] = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -555,9 +563,9 @@
{
int i;
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
- DefaultIncomes[i]=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
+ DefaultIncomes[i] = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -569,13 +577,13 @@
{
int i;
- for( i=0; i<MaxCosts; ++i ) {
+ for (i = 0; i < MaxCosts; ++i) {
free(DefaultActions[i]);
- DefaultActions[i]=NULL;
+ DefaultActions[i] = NULL;
}
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
DefaultActions[i] = gh_scm2newstr(gh_car(list), 0);
- list=gh_cdr(list);
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -587,13 +595,13 @@
{
int i;
- for( i=0; i<MaxCosts; ++i ) {
+ for (i = 0; i < MaxCosts; ++i) {
free(DefaultResourceNames[i]);
- DefaultResourceNames[i]=NULL;
+ DefaultResourceNames[i] = NULL;
}
- for( i=0; i<MaxCosts && !gh_null_p(list); ++i ) {
+ for (i = 0; i < MaxCosts && !gh_null_p(list); ++i) {
DefaultResourceNames[i] = gh_scm2newstr(gh_car(list), 0);
- list=gh_cdr(list);
+ list = gh_cdr(list);
}
return SCM_UNSPECIFIED;
}
@@ -610,35 +618,34 @@
int i;
static char buf[80];
- i=0;
- slot=UnitSlotFree;
- while( slot ) { // count the free slots
+ i = 0;
+ slot = UnitSlotFree;
+ while (slot) { // count the free slots
++i;
- slot=(void*)*slot;
+ slot = (void*)*slot;
}
- freeslots=i;
+ freeslots = i;
//
// Look how many slots are used
//
- destroyed=nullrefs=0;
- for( slot=UnitSlots; slot<UnitSlots+MAX_UNIT_SLOTS; ++slot ) {
- if( *slot
- && (*slot<(Unit*)UnitSlots
- || *slot>(Unit*)(UnitSlots+MAX_UNIT_SLOTS)) ) {
- if( (*slot)->Destroyed ) {
+ destroyed = nullrefs = 0;
+ for (slot = UnitSlots; slot < UnitSlots + MAX_UNIT_SLOTS; ++slot) {
+ if (*slot && (*slot < (Unit*)UnitSlots ||
+ *slot > (Unit*)(UnitSlots + MAX_UNIT_SLOTS))) {
+ if ((*slot)->Destroyed) {
++destroyed;
- } else if( !(*slot)->Refs ) {
+ } else if (!(*slot)->Refs) {
++nullrefs;
}
}
}
- sprintf(buf,"%d free, %d(%d) used, %d, destroyed, %d null"
- ,freeslots,MAX_UNIT_SLOTS-1-freeslots,NumUnits,destroyed,nullrefs);
+ sprintf(buf, "%d free, %d(%d) used, %d, destroyed, %d null",
+ freeslots, MAX_UNIT_SLOTS - 1 - freeslots, NumUnits, destroyed,
nullrefs);
SetStatusLine(buf);
- fprintf(stderr,"%d free, %d(%d) used, %d destroyed, %d null\n"
- ,freeslots,MAX_UNIT_SLOTS-1-freeslots,NumUnits,destroyed,nullrefs);
+ fprintf(stderr, "%d free, %d(%d) used, %d destroyed, %d null\n",
+ freeslots, MAX_UNIT_SLOTS - 1 - freeslots, NumUnits, destroyed,
nullrefs);
return gh_int2scm(destroyed);
}
@@ -663,13 +670,13 @@
const char* cp;
char* buf;
- cp=getenv("HOME");
- buf=alloca(strlen(cp)+strlen(GameName)+sizeof(STRATAGUS_HOME_PATH)+3);
- strcpy(buf,cp);
- strcat(buf,"/");
- strcat(buf,STRATAGUS_HOME_PATH);
- strcat(buf,"/");
- strcat(buf,GameName);
+ cp = getenv("HOME");
+ buf = alloca(strlen(cp) + strlen(GameName) + sizeof(STRATAGUS_HOME_PATH) +
3);
+ strcpy(buf, cp);
+ strcat(buf, "/");
+ strcat(buf, STRATAGUS_HOME_PATH);
+ strcat(buf, "/");
+ strcat(buf, GameName);
return gh_str02scm(buf);
}
@@ -698,8 +705,8 @@
char* name;
char buffer[1024];
- name=gh_scm2newstr(file,NULL);
- LoadPud(LibraryFileName(name,buffer),&TheMap);
+ name = gh_scm2newstr(file, NULL);
+ LoadPud(LibraryFileName(name, buffer), &TheMap);
free(name);
// FIXME: LoadPud should return an error
@@ -718,13 +725,13 @@
char* name;
char buffer[1024];
- name=gh_scm2newstr(file,NULL);
- if( strcasestr(name,".pud") ) {
- LoadPud(LibraryFileName(name,buffer),&TheMap);
- } else if( strcasestr(name,".scm") ) {
- LoadScm(LibraryFileName(name,buffer),&TheMap);
- } else if( strcasestr(name,".chk") ) {
- LoadChk(LibraryFileName(name,buffer),&TheMap);
+ name = gh_scm2newstr(file, NULL);
+ if (strcasestr(name, ".pud")) {
+ LoadPud(LibraryFileName(name, buffer), &TheMap);
+ } else if (strcasestr(name, ".scm")) {
+ LoadScm(LibraryFileName(name, buffer), &TheMap);
+ } else if (strcasestr(name, ".chk")) {
+ LoadChk(LibraryFileName(name, buffer), &TheMap);
}
free(name);
@@ -738,17 +745,17 @@
** @param width Map width.
** @param height Map height.
*/
-local SCM CclDefineMap(SCM width,SCM height)
+local SCM CclDefineMap(SCM width, SCM height)
{
- TheMap.Width=gh_scm2int(width);
- TheMap.Height=gh_scm2int(height);
+ TheMap.Width = gh_scm2int(width);
+ TheMap.Height = gh_scm2int(height);
- TheMap.Fields=calloc(TheMap.Width*TheMap.Height,sizeof(*TheMap.Fields));
- TheMap.Visible[0]=calloc(TheMap.Width*TheMap.Height/8,1);
+ TheMap.Fields = calloc(TheMap.Width * TheMap.Height,
sizeof(*TheMap.Fields));
+ TheMap.Visible[0] = calloc(TheMap.Width * TheMap.Height / 8, 1);
InitUnitCache();
// FIXME: this should be CreateMap or InitMap?
- // MapX=MapY=0;
+ // MapX = MapY = 0;
return SCM_UNSPECIFIED;
}
@@ -768,16 +775,17 @@
#ifndef USE_GUILE
int retval;
#endif
- strncpy(msg,command,sizeof(msg));
+
+ strncpy(msg, command, sizeof(msg));
// FIXME: cheat protection
#ifdef USE_GUILE
gh_eval_str(msg);
#else
- retval = repl_c_string(msg,0,0,sizeof(msg));
+ retval = repl_c_string(msg, 0, 0, sizeof(msg));
DebugLevel3("\n%d=%s\n" _C_ retval _C_ msg);
#endif
- SetMessage("%s",msg);
+ SetMessage("%s", msg);
}
/*............................................................................
@@ -790,13 +798,13 @@
global void InitCcl(void)
{
#ifdef USE_GUILE
- scm_init_guile();
+ scm_init_guile();
- gh_eval_str("(display \"Guile: Enabling debugging...\\n\")"
- "(debug-enable 'debug)"
- "(debug-enable 'backtrace)"
- "(read-enable 'positions)"
- "(define *scheme* 'guile)");
+ gh_eval_str("(display \"Guile: Enabling debugging...\\n\")"
+ "(debug-enable 'debug)"
+ "(debug-enable 'backtrace)"
+ "(read-enable 'positions)"
+ "(define *scheme* 'guile)");
#else
char* sargv[5];
char* buf;
@@ -806,40 +814,40 @@
sargv[1] = "-v1";
sargv[2] = "-g0";
sargv[3] = "-h800000:10";
- buf=malloc(strlen(StratagusLibPath)+4);
- sprintf(buf,"-l%s",StratagusLibPath);
+ buf = malloc(strlen(StratagusLibPath) + 4);
+ sprintf(buf, "-l%s", StratagusLibPath);
sargv[4] = buf; // never freed
- siod_init(5,sargv);
- repl_c_string(msg, 0,0,sizeof(msg));
+ siod_init(5, sargv);
+ repl_c_string(msg, 0, 0, sizeof(msg));
#endif
- gh_new_procedure0_0("library-path",CclStratagusLibraryPath);
- gh_new_procedure0_0("game-cycle",CclGameCycle);
- gh_new_procedure1_0("set-game-name!",CclSetGameName);
- gh_new_procedure1_0("set-game-cycle!",CclSetGameCycle);
- gh_new_procedure1_0("set-game-paused!",CclSetGamePaused);
- gh_new_procedure1_0("set-video-sync-speed!",CclSetVideoSyncSpeed);
- gh_new_procedure1_0("set-local-player-name!",CclSetLocalPlayerName);
-
- gh_new_procedure1_0("set-show-tips!",CclSetShowTips);
- gh_new_procedure1_0("set-current-tip!",CclSetCurrentTip);
- gh_new_procedure1_0("add-tip",CclAddTip);
-
-
gh_new_procedure2_0("set-speed-resources-harvest!",CclSetSpeedResourcesHarvest);
-
gh_new_procedure2_0("set-speed-resources-return!",CclSetSpeedResourcesReturn);
- gh_new_procedure1_0("set-speed-build!",CclSetSpeedBuild);
- gh_new_procedure1_0("set-speed-train!",CclSetSpeedTrain);
- gh_new_procedure1_0("set-speed-upgrade!",CclSetSpeedUpgrade);
- gh_new_procedure1_0("set-speed-research!",CclSetSpeedResearch);
- gh_new_procedure1_0("set-speeds!",CclSetSpeeds);
-
- gh_new_procedureN("define-default-resources",CclDefineDefaultResources);
-
gh_new_procedureN("define-default-resources-low",CclDefineDefaultResourcesLow);
-
gh_new_procedureN("define-default-resources-medium",CclDefineDefaultResourcesMedium);
-
gh_new_procedureN("define-default-resources-high",CclDefineDefaultResourcesHigh);
- gh_new_procedureN("define-default-incomes",CclDefineDefaultIncomes);
- gh_new_procedureN("define-default-actions",CclDefineDefaultActions);
-
gh_new_procedureN("define-default-resource-names",CclDefineDefaultResourceNames);
+ gh_new_procedure0_0("library-path", CclStratagusLibraryPath);
+ gh_new_procedure0_0("game-cycle", CclGameCycle);
+ gh_new_procedure1_0("set-game-name!", CclSetGameName);
+ gh_new_procedure1_0("set-game-cycle!", CclSetGameCycle);
+ gh_new_procedure1_0("set-game-paused!", CclSetGamePaused);
+ gh_new_procedure1_0("set-video-sync-speed!", CclSetVideoSyncSpeed);
+ gh_new_procedure1_0("set-local-player-name!", CclSetLocalPlayerName);
+
+ gh_new_procedure1_0("set-show-tips!", CclSetShowTips);
+ gh_new_procedure1_0("set-current-tip!", CclSetCurrentTip);
+ gh_new_procedure1_0("add-tip", CclAddTip);
+
+ gh_new_procedure2_0("set-speed-resources-harvest!",
CclSetSpeedResourcesHarvest);
+ gh_new_procedure2_0("set-speed-resources-return!",
CclSetSpeedResourcesReturn);
+ gh_new_procedure1_0("set-speed-build!", CclSetSpeedBuild);
+ gh_new_procedure1_0("set-speed-train!", CclSetSpeedTrain);
+ gh_new_procedure1_0("set-speed-upgrade!", CclSetSpeedUpgrade);
+ gh_new_procedure1_0("set-speed-research!", CclSetSpeedResearch);
+ gh_new_procedure1_0("set-speeds!", CclSetSpeeds);
+
+ gh_new_procedureN("define-default-resources", CclDefineDefaultResources);
+ gh_new_procedureN("define-default-resources-low",
CclDefineDefaultResourcesLow);
+ gh_new_procedureN("define-default-resources-medium",
CclDefineDefaultResourcesMedium);
+ gh_new_procedureN("define-default-resources-high",
CclDefineDefaultResourcesHigh);
+ gh_new_procedureN("define-default-incomes", CclDefineDefaultIncomes);
+ gh_new_procedureN("define-default-actions", CclDefineDefaultActions);
+ gh_new_procedureN("define-default-resource-names",
CclDefineDefaultResourceNames);
IconCclRegister();
MissileCclRegister();
@@ -863,89 +871,89 @@
TriggerCclRegister();
CreditsCclRegister();
ObjectivesCclRegister();
- SpellCclRegister();
+ SpellCclRegister();
EditorCclRegister();
- gh_new_procedure1_0("load-pud",CclLoadPud);
- gh_new_procedure1_0("load-map",CclLoadMap);
- gh_new_procedure2_0("define-map",CclDefineMap);
-
- gh_new_procedure0_0("units",CclUnits);
-
- gh_new_procedure0_0("with-sound",CclWithSound);
- gh_new_procedure0_0("get-stratagus-home-path",CclGetStratagusHomePath);
- gh_new_procedure0_0("get-stratagus-library-path"
- ,CclGetStratagusLibraryPath);
+ gh_new_procedure1_0("load-pud", CclLoadPud);
+ gh_new_procedure1_0("load-map", CclLoadMap);
+ gh_new_procedure2_0("define-map", CclDefineMap);
+
+ gh_new_procedure0_0("units", CclUnits);
+
+ gh_new_procedure0_0("with-sound", CclWithSound);
+ gh_new_procedure0_0("get-stratagus-home-path", CclGetStratagusHomePath);
+ gh_new_procedure0_0("get-stratagus-library-path",
+ CclGetStratagusLibraryPath);
//
// Make some sombols for the compile options/features.
//
#ifdef USE_THREAD
- gh_define("stratagus-feature-thread",SCM_BOOL_T);
+ gh_define("stratagus-feature-thread", SCM_BOOL_T);
#endif
#ifdef DEBUG
- gh_define("stratagus-feature-debug",SCM_BOOL_T);
+ gh_define("stratagus-feature-debug", SCM_BOOL_T);
#endif
#ifdef DEBUG_FLAGS
- gh_define("stratagus-feature-debug-flags",SCM_BOOL_T);
+ gh_define("stratagus-feature-debug-flags", SCM_BOOL_T);
#endif
#ifdef USE_ZLIB
- gh_define("stratagus-feature-zlib",SCM_BOOL_T);
+ gh_define("stratagus-feature-zlib", SCM_BOOL_T);
#endif
#ifdef USE_BZ2LIB
- gh_define("stratagus-feature-bz2lib",SCM_BOOL_T);
+ gh_define("stratagus-feature-bz2lib", SCM_BOOL_T);
#endif
#ifdef USE_ZZIPLIB
- gh_define("stratagus-feature-zziplib",SCM_BOOL_T);
+ gh_define("stratagus-feature-zziplib", SCM_BOOL_T);
#endif
#ifdef USE_SDL
- gh_define("stratagus-feature-sdl",SCM_BOOL_T);
+ gh_define("stratagus-feature-sdl", SCM_BOOL_T);
#endif
#ifdef USE_SDLA
- gh_define("stratagus-feature-sdl-audio",SCM_BOOL_T);
+ gh_define("stratagus-feature-sdl-audio", SCM_BOOL_T);
#endif
#ifdef USE_SDLCD
- gh_define("stratagus-feature-sdl-cd",SCM_BOOL_T);
+ gh_define("stratagus-feature-sdl-cd", SCM_BOOL_T);
#endif
#ifdef USE_X11
- gh_define("stratagus-feature-x11",SCM_BOOL_T);
+ gh_define("stratagus-feature-x11", SCM_BOOL_T);
#endif
#ifdef USE_SVGALIB
- gh_define("stratagus-feature-svgalib",SCM_BOOL_T);
+ gh_define("stratagus-feature-svgalib", SCM_BOOL_T);
#endif
#ifdef WITH_SOUND
- gh_define("stratagus-feature-with-sound",SCM_BOOL_T);
+ gh_define("stratagus-feature-with-sound", SCM_BOOL_T);
#endif
#ifdef UNIT_ON_MAP
- gh_define("stratagus-feature-unit-on-map",SCM_BOOL_T);
+ gh_define("stratagus-feature-unit-on-map", SCM_BOOL_T);
#endif
#ifdef UNITS_ON_MAP
- gh_define("stratagus-feature-units-on-map",SCM_BOOL_T);
+ gh_define("stratagus-feature-units-on-map", SCM_BOOL_T);
#endif
#ifdef NEW_MAPDRAW
- gh_define("stratagus-feature-new-mapdraw",SCM_BOOL_T);
+ gh_define("stratagus-feature-new-mapdraw", SCM_BOOL_T);
#endif
#ifdef HIERARCHIC_PATHFINDER
- gh_define("stratagus-feature-hierarchic-pathfinder",SCM_BOOL_T);
+ gh_define("stratagus-feature-hierarchic-pathfinder", SCM_BOOL_T);
#endif
#ifdef SLOW_INPUT
- gh_define("stratagus-feature-slow-input",SCM_BOOL_T);
+ gh_define("stratagus-feature-slow-input", SCM_BOOL_T);
#endif
#ifdef USE_FLAC
- gh_define("stratagus-feature-flac",SCM_BOOL_T);
+ gh_define("stratagus-feature-flac", SCM_BOOL_T);
#endif
#ifdef USE_OGG
- gh_define("stratagus-feature-ogg",SCM_BOOL_T);
+ gh_define("stratagus-feature-ogg", SCM_BOOL_T);
#endif
#ifdef USE_MAD
- gh_define("stratagus-feature-mp3",SCM_BOOL_T);
+ gh_define("stratagus-feature-mp3", SCM_BOOL_T);
#endif
#ifdef USE_LIBCDA
- gh_define("stratagus-feature-libcda",SCM_BOOL_T);
+ gh_define("stratagus-feature-libcda", SCM_BOOL_T);
#endif
- gh_define("*ccl-protect*",NIL);
+ gh_define("*ccl-protect*", NIL);
print_welcome();
}
@@ -959,15 +967,15 @@
char buf[1024];
#ifdef USE_WIN32
- strcpy(buf,"preferences1.ccl");
+ strcpy(buf, "preferences1.ccl");
#else
- sprintf(buf,"%s/%s/preferences1.ccl",getenv("HOME"),STRATAGUS_HOME_PATH);
+ sprintf(buf, "%s/%s/preferences1.ccl", getenv("HOME"),
STRATAGUS_HOME_PATH);
#endif
- fd=fopen(buf,"r");
- if( fd ) {
+ fd = fopen(buf, "r");
+ if (fd) {
fclose(fd);
- vload(buf,0,1);
+ vload(buf, 0, 1);
}
}
@@ -980,15 +988,16 @@
char buf[1024];
#ifdef USE_WIN32
- sprintf(buf,"%s/preferences2.ccl",GameName);
+ sprintf(buf, "%s/preferences2.ccl", GameName);
#else
-
sprintf(buf,"%s/%s/%s/preferences2.ccl",getenv("HOME"),STRATAGUS_HOME_PATH,GameName);
+ sprintf(buf, "%s/%s/%s/preferences2.ccl", getenv("HOME"),
+ STRATAGUS_HOME_PATH, GameName);
#endif
- fd=fopen(buf,"r");
- if( fd ) {
+ fd = fopen(buf, "r");
+ if (fd) {
fclose(fd);
- vload(buf,0,1);
+ vload(buf, 0, 1);
}
}
@@ -1006,22 +1015,22 @@
//
#ifdef USE_WIN32
- strcpy(buf,"preferences1.ccl");
+ strcpy(buf, "preferences1.ccl");
#else
- sprintf(buf,"%s/%s",getenv("HOME"),STRATAGUS_HOME_PATH);
- mkdir(buf,0777);
- strcat(buf,"/preferences1.ccl");
+ sprintf(buf, "%s/%s", getenv("HOME"), STRATAGUS_HOME_PATH);
+ mkdir(buf, 0777);
+ strcat(buf, "/preferences1.ccl");
#endif
- fd=fopen(buf,"w");
- if( !fd ) {
+ fd = fopen(buf, "w");
+ if (!fd) {
return;
}
- fprintf(fd,";;; -----------------------------------------\n");
- fprintf(fd,";;; $Id: ccl.c,v 1.113 2003/10/07 10:40:36 martinxyz Exp $\n");
+ fprintf(fd, ";;; -----------------------------------------\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.114 2003/10/09 20:54:35 jsalmon3 Exp $\n");
- fprintf(fd,"(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
+ fprintf(fd, "(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
fclose(fd);
@@ -1032,60 +1041,61 @@
//
#ifdef USE_WIN32
- sprintf(buf,"%s/preferences2.ccl",GameName);
+ sprintf(buf, "%s/preferences2.ccl", GameName);
#else
-
sprintf(buf,"%s/%s/%s/preferences2.ccl",getenv("HOME"),STRATAGUS_HOME_PATH,GameName);
+ sprintf(buf, "%s/%s/%s/preferences2.ccl", getenv("HOME"),
+ STRATAGUS_HOME_PATH, GameName);
#endif
- fd=fopen(buf,"w");
- if( !fd ) {
+ fd = fopen(buf, "w");
+ if (!fd) {
return;
}
- fprintf(fd,";;; -----------------------------------------\n");
- fprintf(fd,";;; $Id: ccl.c,v 1.113 2003/10/07 10:40:36 martinxyz Exp $\n");
+ fprintf(fd, ";;; -----------------------------------------\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.114 2003/10/09 20:54:35 jsalmon3 Exp $\n");
// Global options
- if( OriginalFogOfWar ) {
- fprintf(fd,"(original-fog-of-war)\n");
+ if (OriginalFogOfWar) {
+ fprintf(fd, "(original-fog-of-war)\n");
} else {
- fprintf(fd,"(alpha-fog-of-war)\n");
+ fprintf(fd, "(alpha-fog-of-war)\n");
}
- fprintf(fd,"(set-video-fullscreen! #%c)\n", VideoFullScreen ? 't' : 'f');
+ fprintf(fd, "(set-video-fullscreen! #%c)\n", VideoFullScreen ? 't' : 'f');
#if 0
// FIXME: Uncomment when this is configurable in the menus
- fprintf(fd,"(set-contrast! %d)\n", TheUI.Contrast);
- fprintf(fd,"(set-brightness! %d)\n", TheUI.Brightness);
- fprintf(fd,"(set-saturation! %d)\n", TheUI.Saturation);
+ fprintf(fd, "(set-contrast! %d)\n", TheUI.Contrast);
+ fprintf(fd, "(set-brightness! %d)\n", TheUI.Brightness);
+ fprintf(fd, "(set-saturation! %d)\n", TheUI.Saturation);
#endif
- fprintf(fd,"(set-local-player-name! \"%s\")\n", LocalPlayerName);
+ fprintf(fd, "(set-local-player-name! \"%s\")\n", LocalPlayerName);
// Game options
- fprintf(fd,"(set-show-tips! #%c)\n", ShowTips ? 't' : 'f');
- fprintf(fd,"(set-current-tip! %d)\n", CurrentTip);
+ fprintf(fd, "(set-show-tips! #%c)\n", ShowTips ? 't' : 'f');
+ fprintf(fd, "(set-current-tip! %d)\n", CurrentTip);
- fprintf(fd,"(set-fog-of-war! #%c)\n", !TheMap.NoFogOfWar ? 't' : 'f');
- fprintf(fd,"(set-show-command-key! #%c)\n", ShowCommandKey ? 't' : 'f');
+ fprintf(fd, "(set-fog-of-war! #%c)\n", !TheMap.NoFogOfWar ? 't' : 'f');
+ fprintf(fd, "(set-show-command-key! #%c)\n", ShowCommandKey ? 't' : 'f');
// Speeds
- fprintf(fd,"(set-video-sync-speed! %d)\n", VideoSyncSpeed);
- fprintf(fd,"(set-mouse-scroll-speed! %d)\n", SpeedMouseScroll);
- fprintf(fd,"(set-key-scroll-speed! %d)\n", SpeedKeyScroll);
+ fprintf(fd, "(set-video-sync-speed! %d)\n", VideoSyncSpeed);
+ fprintf(fd, "(set-mouse-scroll-speed! %d)\n", SpeedMouseScroll);
+ fprintf(fd, "(set-key-scroll-speed! %d)\n", SpeedKeyScroll);
// Sound options
- if( !SoundOff ) {
- fprintf(fd,"(sound-on)\n");
+ if (!SoundOff) {
+ fprintf(fd, "(sound-on)\n");
} else {
- fprintf(fd,"(sound-off)\n");
+ fprintf(fd, "(sound-off)\n");
}
#ifdef WITH_SOUND
- fprintf(fd,"(set-sound-volume! %d)\n", GlobalVolume);
- if( !MusicOff ) {
- fprintf(fd,"(music-on)\n");
+ fprintf(fd, "(set-sound-volume! %d)\n", GlobalVolume);
+ if (!MusicOff) {
+ fprintf(fd, "(music-on)\n");
} else {
- fprintf(fd,"(music-off)\n");
+ fprintf(fd, "(music-off)\n");
}
- fprintf(fd,"(set-music-volume! %d)\n", MusicVolume);
+ fprintf(fd, "(set-music-volume! %d)\n", MusicVolume);
#ifdef USE_CDAUDIO
buf[0] = '\0';
switch (CDMode) {
@@ -1106,7 +1116,7 @@
break;
}
if (buf[0]) {
- fprintf(fd,"(set-cd-mode! '%s)\n", buf);
+ fprintf(fd, "(set-cd-mode! '%s)\n", buf);
}
#endif
#endif
@@ -1126,17 +1136,17 @@
//
// Load and evaluate configuration file
//
- CclInConfigFile=1;
- file=LibraryFileName(CclStartFile,buf);
- ShowLoadProgress("Script %s\n",file);
+ CclInConfigFile = 1;
+ file = LibraryFileName(CclStartFile, buf);
+ ShowLoadProgress("Script %s\n", file);
LoadPreferences1();
- if( (s=strrchr(file,'.')) && s[1]=='C' ) {
- fast_load(gh_str02scm(file),NIL);
+ if ((s = strrchr(file, '.')) && s[1] == 'C') {
+ fast_load(gh_str02scm(file), NIL);
} else {
- vload(file,0,1);
+ vload(file, 0, 1);
}
LoadPreferences2();
- CclInConfigFile=0;
+ CclInConfigFile = 0;
user_gc(SCM_BOOL_F); // Cleanup memory after load
}
@@ -1152,24 +1162,24 @@
SCM list;
extern SCM oblistvar;
- CLprintf(file,"\n;;; -----------------------------------------\n");
- CLprintf(file,";;; MODULE: CCL $Id: ccl.c,v 1.113 2003/10/07 10:40:36
martinxyz Exp $\n\n");
+ CLprintf(file, "\n;;; -----------------------------------------\n");
+ CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.114 2003/10/09 20:54:35
jsalmon3 Exp $\n\n");
- for(list = oblistvar; gh_list_p(list); list = gh_cdr(list) ) {
+ for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
SCM sym;
- sym=gh_car(list);
- if(symbol_boundp(sym, NIL)) {
+ sym = gh_car(list);
+ if (symbol_boundp(sym, NIL)) {
SCM value;
- CLprintf(file,";;(define %s\n",get_c_string(sym));
+ CLprintf(file, ";;(define %s\n", get_c_string(sym));
value = symbol_value(sym, NIL);
- CLprintf(file,";;");
- lprin1CL(value,file);
- CLprintf(file,"\n");
+ CLprintf(file, ";;");
+ lprin1CL(value, file);
+ CLprintf(file, "\n");
#ifdef DEBUG
} else {
- CLprintf(file,";;%s unbound\n",get_c_string(sym));
+ CLprintf(file, ";;%s unbound\n", get_c_string(sym));
#endif
}
}
Index: stratagus/src/clone/ccl_player.c
diff -u stratagus/src/clone/ccl_player.c:1.40
stratagus/src/clone/ccl_player.c:1.41
--- stratagus/src/clone/ccl_player.c:1.40 Tue Oct 7 20:06:40 2003
+++ stratagus/src/clone/ccl_player.c Thu Oct 9 16:54:36 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_player.c,v 1.40 2003/10/08 00:06:40 jsalmon3 Exp $
+// $Id: ccl_player.c,v 1.41 2003/10/09 20:54:36 jsalmon3 Exp $
//@{
@@ -95,196 +95,193 @@
//
// Parse the list: (still everything could be changed!)
//
- while( !gh_null_p(list) ) {
-
- value=gh_car(list);
- list=gh_cdr(list);
-
- if( gh_eq_p(value,gh_symbol2scm("name")) ) {
- player->Name=gh_scm2newstr(gh_car(list),NULL);
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("type")) ) {
- value=gh_car(list);
- list=gh_cdr(list);
- if( gh_eq_p(value,gh_symbol2scm("neutral")) ) {
- player->Type=PlayerNeutral;
- } else if( gh_eq_p(value,gh_symbol2scm("nobody")) ) {
- player->Type=PlayerNobody;
- } else if( gh_eq_p(value,gh_symbol2scm("computer")) ) {
- player->Type=PlayerComputer;
- } else if( gh_eq_p(value,gh_symbol2scm("person")) ) {
- player->Type=PlayerPerson;
- } else if( gh_eq_p(value,gh_symbol2scm("rescue-passive")) ) {
- player->Type=PlayerRescuePassive;
- } else if( gh_eq_p(value,gh_symbol2scm("rescue-active")) ) {
- player->Type=PlayerRescueActive;
+ while (!gh_null_p(list)) {
+ value = gh_car(list);
+ list = gh_cdr(list);
+
+ if (gh_eq_p(value, gh_symbol2scm("name"))) {
+ player->Name = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("type"))) {
+ value = gh_car(list);
+ list = gh_cdr(list);
+ if (gh_eq_p(value, gh_symbol2scm("neutral"))) {
+ player->Type = PlayerNeutral;
+ } else if (gh_eq_p(value, gh_symbol2scm("nobody"))) {
+ player->Type = PlayerNobody;
+ } else if (gh_eq_p(value, gh_symbol2scm("computer"))) {
+ player->Type = PlayerComputer;
+ } else if (gh_eq_p(value, gh_symbol2scm("person"))) {
+ player->Type = PlayerPerson;
+ } else if (gh_eq_p(value, gh_symbol2scm("rescue-passive"))) {
+ player->Type = PlayerRescuePassive;
+ } else if (gh_eq_p(value, gh_symbol2scm("rescue-active"))) {
+ player->Type = PlayerRescueActive;
} else {
// FIXME: this leaves a half initialized player
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
- } else if( gh_eq_p(value,gh_symbol2scm("race")) ) {
- str=gh_scm2newstr(gh_car(list),NULL);
- for( i=0; i<PlayerRaces.Count; ++i ) {
- if( !strcmp(str,PlayerRaces.Name[i]) ) {
- player->RaceName=PlayerRaces.Name[i];
- player->Race=i;
+ } else if (gh_eq_p(value, gh_symbol2scm("race"))) {
+ str = gh_scm2newstr(gh_car(list),NULL);
+ for (i = 0; i < PlayerRaces.Count; ++i) {
+ if (!strcmp(str, PlayerRaces.Name[i])) {
+ player->RaceName = PlayerRaces.Name[i];
+ player->Race = i;
break;
}
}
free(str);
- if( i==PlayerRaces.Count ) {
+ if (i == PlayerRaces.Count) {
// FIXME: this leaves a half initialized player
- errl("Unsupported race",gh_car(list));
+ errl("Unsupported race", gh_car(list));
}
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("ai")) ) {
- player->AiNum=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("team")) ) {
- player->Team=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("enemy")) ) {
- str=gh_scm2newstr(gh_car(list),NULL);
- list=gh_cdr(list);
- for( i=0; i<PlayerMax && *str; ++i,++str ) {
- if( *str=='-' || *str=='_' || *str==' ' ) {
- player->Enemy&=~(1<<i);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("ai"))) {
+ player->AiNum = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("team"))) {
+ player->Team = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("enemy"))) {
+ str = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
+ for (i = 0; i < PlayerMax && *str; ++i, ++str) {
+ if (*str == '-' || *str == '_' || *str == ' ') {
+ player->Enemy &= ~(1 << i);
} else {
- player->Enemy|=(1<<i);
+ player->Enemy |= (1 << i);
}
}
- } else if( gh_eq_p(value,gh_symbol2scm("allied")) ) {
- str=gh_scm2newstr(gh_car(list),NULL);
- list=gh_cdr(list);
- for( i=0; i<PlayerMax && *str; ++i,++str ) {
- if( *str=='-' || *str=='_' || *str==' ' ) {
- player->Allied&=~(1<<i);
+ } else if (gh_eq_p(value, gh_symbol2scm("allied"))) {
+ str = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
+ for (i = 0; i < PlayerMax && *str; ++i, ++str) {
+ if (*str == '-' || *str == '_' || *str == ' ') {
+ player->Allied &= ~(1 << i);
} else {
- player->Allied|=(1<<i);
+ player->Allied |= (1 << i);
}
}
- } else if( gh_eq_p(value,gh_symbol2scm("shared-vision")) ) {
- str=gh_scm2newstr(gh_car(list),NULL);
- list=gh_cdr(list);
- for( i=0; i<PlayerMax && *str; ++i,++str ) {
- if( *str=='-' || *str=='_' || *str==' ' ) {
- player->SharedVision&=~(1<<i);
+ } else if (gh_eq_p(value, gh_symbol2scm("shared-vision"))) {
+ str = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
+ for (i = 0; i < PlayerMax && *str; ++i, ++str) {
+ if (*str == '-' || *str == '_' || *str == ' ') {
+ player->SharedVision &= ~(1 << i);
} else {
- player->SharedVision|=(1<<i);
+ player->SharedVision |= (1 << i);
}
}
- } else if( gh_eq_p(value,gh_symbol2scm("start")) ) {
- value=gh_car(list);
- list=gh_cdr(list);
- player->StartX=gh_scm2int(gh_car(value));
- player->StartY=gh_scm2int(gh_cadr(value));
- } else if( gh_eq_p(value,gh_symbol2scm("resources")) ) {
- sublist=gh_car(list);
- list=gh_cdr(list);
- while( !gh_null_p(sublist) ) {
-
- value=gh_car(sublist);
- sublist=gh_cdr(sublist);
-
- for( i=0; i<MaxCosts; ++i ) {
- if(
gh_eq_p(value,gh_symbol2scm((char*)DefaultResourceNames[i])) ) {
- player->Resources[i]=gh_scm2int(gh_car(sublist));
+ } else if (gh_eq_p(value, gh_symbol2scm("start"))) {
+ value = gh_car(list);
+ list = gh_cdr(list);
+ player->StartX = gh_scm2int(gh_car(value));
+ player->StartY = gh_scm2int(gh_cadr(value));
+ } else if (gh_eq_p(value, gh_symbol2scm("resources"))) {
+ sublist = gh_car(list);
+ list = gh_cdr(list);
+ while (!gh_null_p(sublist)) {
+ value = gh_car(sublist);
+ sublist = gh_cdr(sublist);
+
+ for (i = 0; i < MaxCosts; ++i) {
+ if (gh_eq_p(value,
gh_symbol2scm((char*)DefaultResourceNames[i]))) {
+ player->Resources[i] = gh_scm2int(gh_car(sublist));
break;
}
}
- if( i==MaxCosts ) {
+ if (i == MaxCosts) {
// FIXME: this leaves a half initialized player
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
- sublist=gh_cdr(sublist);
+ sublist = gh_cdr(sublist);
}
- } else if( gh_eq_p(value,gh_symbol2scm("incomes")) ) {
- sublist=gh_car(list);
- list=gh_cdr(list);
- while( !gh_null_p(sublist) ) {
-
- value=gh_car(sublist);
- sublist=gh_cdr(sublist);
-
- for( i=0; i<MaxCosts; ++i ) {
- if(
gh_eq_p(value,gh_symbol2scm((char*)DefaultResourceNames[i])) ) {
- player->Incomes[i]=gh_scm2int(gh_car(sublist));
+ } else if (gh_eq_p(value, gh_symbol2scm("incomes"))) {
+ sublist = gh_car(list);
+ list = gh_cdr(list);
+ while (!gh_null_p(sublist)) {
+ value = gh_car(sublist);
+ sublist = gh_cdr(sublist);
+
+ for (i = 0; i < MaxCosts; ++i) {
+ if (gh_eq_p(value,
gh_symbol2scm((char*)DefaultResourceNames[i]))) {
+ player->Incomes[i] = gh_scm2int(gh_car(sublist));
break;
}
}
- if( i==MaxCosts ) {
+ if (i == MaxCosts) {
// FIXME: this leaves a half initialized player
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
- sublist=gh_cdr(sublist);
+ sublist = gh_cdr(sublist);
}
- } else if( gh_eq_p(value,gh_symbol2scm("ai-enabled")) ) {
- player->AiEnabled=1;
- } else if( gh_eq_p(value,gh_symbol2scm("ai-disabled")) ) {
- player->AiEnabled=0;
- } else if( gh_eq_p(value,gh_symbol2scm("food")) ) {
- player->Food=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("food-unit-limit")) ) {
- player->FoodUnitLimit=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("building-limit")) ) {
- player->BuildingLimit=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-unit-limit")) ) {
- player->TotalUnitLimit=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("score")) ) {
- player->Score=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-units")) ) {
- player->TotalUnits=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-buildings")) ) {
- player->TotalBuildings=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-razings")) ) {
- player->TotalRazings=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-kills")) ) {
- player->TotalKills=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if( gh_eq_p(value,gh_symbol2scm("total-resources")) ) {
- sublist=gh_car(list);
- list=gh_cdr(list);
- i=gh_length(sublist);
- if( i!=MaxCosts ) {
- fprintf(stderr,"Wrong number of total-resources %d\n",i);
- }
- i=0;
- while( !gh_null_p(sublist) ) {
- if( i<MaxCosts ) {
- player->TotalResources[i]=gh_scm2int(gh_car(sublist));
+ } else if (gh_eq_p(value, gh_symbol2scm("ai-enabled"))) {
+ player->AiEnabled = 1;
+ } else if (gh_eq_p(value, gh_symbol2scm("ai-disabled"))) {
+ player->AiEnabled = 0;
+ } else if (gh_eq_p(value, gh_symbol2scm("food"))) {
+ player->Food = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("food-unit-limit"))) {
+ player->FoodUnitLimit = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("building-limit"))) {
+ player->BuildingLimit = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-unit-limit"))) {
+ player->TotalUnitLimit = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("score"))) {
+ player->Score = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-units"))) {
+ player->TotalUnits = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-buildings"))) {
+ player->TotalBuildings = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-razings"))) {
+ player->TotalRazings = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-kills"))) {
+ player->TotalKills = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("total-resources"))) {
+ sublist = gh_car(list);
+ list = gh_cdr(list);
+ i = gh_length(sublist);
+ if (i != MaxCosts) {
+ fprintf(stderr, "Wrong number of total-resources %d\n", i);
+ }
+ i = 0;
+ while (!gh_null_p(sublist)) {
+ if (i < MaxCosts) {
+ player->TotalResources[i] = gh_scm2int(gh_car(sublist));
}
- sublist=gh_cdr(sublist);
+ sublist = gh_cdr(sublist);
++i;
}
- player->TotalUnits=gh_scm2int(gh_car(list));
- } else if( gh_eq_p(value,gh_symbol2scm("timers")) ) {
- sublist=gh_car(list);
- list=gh_cdr(list);
- i=gh_length(sublist);
- if( i!=UpgradeMax ) {
- fprintf(stderr,"Wrong upgrade timer length %d\n",i);
- }
-
- i=0;
- while( !gh_null_p(sublist) ) {
- if( i<UpgradeMax ) {
- player->UpgradeTimers.Upgrades[i]=
- gh_scm2int(gh_car(sublist));
+ player->TotalUnits = gh_scm2int(gh_car(list));
+ } else if (gh_eq_p(value, gh_symbol2scm("timers"))) {
+ sublist = gh_car(list);
+ list = gh_cdr(list);
+ i = gh_length(sublist);
+ if (i != UpgradeMax) {
+ fprintf(stderr, "Wrong upgrade timer length %d\n", i);
+ }
+
+ i = 0;
+ while (!gh_null_p(sublist)) {
+ if (i < UpgradeMax) {
+ player->UpgradeTimers.Upgrades[i] =
+ gh_scm2int(gh_car(sublist));
}
- sublist=gh_cdr(sublist);
+ sublist = gh_cdr(sublist);
++i;
}
} else {
// FIXME: this leaves a half initialized player
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
}
@@ -306,15 +303,15 @@
int oldp;
int newp;
- n=SelectUnits(gh_scm2int(gh_car(pos1)), gh_scm2int(gh_cadr(pos1)),
- gh_scm2int(gh_car(pos2)), gh_scm2int(gh_cadr(pos2)), table);
- oldp=gh_scm2int(oldplayer);
- newp=gh_scm2int(newplayer);
- while( n ) {
- if( table[n-1]->Player->Player == oldp ) {
- ChangeUnitOwner(table[n-1],&Players[newp]);
+ n = SelectUnits(gh_scm2int(gh_car(pos1)), gh_scm2int(gh_cadr(pos1)),
+ gh_scm2int(gh_car(pos2)), gh_scm2int(gh_cadr(pos2)), table);
+ oldp = gh_scm2int(oldplayer);
+ newp = gh_scm2int(newplayer);
+ while (n) {
+ if (table[n - 1]->Player->Player == oldp) {
+ ChangeUnitOwner(table[n - 1], &Players[newp]);
}
- n--;
+ --n;
}
return SCM_UNSPECIFIED;
}
@@ -326,7 +323,7 @@
*/
local SCM CclGetThisPlayer(void)
{
- return gh_int2scm(ThisPlayer-Players);
+ return gh_int2scm(ThisPlayer - Players);
}
/**
@@ -336,7 +333,7 @@
*/
local SCM CclSetThisPlayer(SCM plynr)
{
- ThisPlayer=&Players[gh_scm2int(plynr)];
+ ThisPlayer = &Players[gh_scm2int(plynr)];
return plynr;
}
@@ -350,8 +347,8 @@
{
int i;
- for( i=0; i<PlayerMax; ++i ) {
- Players[i].FoodUnitLimit=gh_scm2int(limit);
+ for (i = 0; i < PlayerMax; ++i) {
+ Players[i].FoodUnitLimit = gh_scm2int(limit);
}
return limit;
@@ -366,8 +363,8 @@
{
int i;
- for( i=0; i<PlayerMax; ++i ) {
- Players[i].BuildingLimit=gh_scm2int(limit);
+ for (i = 0; i < PlayerMax; ++i) {
+ Players[i].BuildingLimit = gh_scm2int(limit);
}
return limit;
@@ -382,8 +379,8 @@
{
int i;
- for( i=0; i<PlayerMax; ++i ) {
- Players[i].TotalUnitLimit=gh_scm2int(limit);
+ for (i = 0; i < PlayerMax; ++i) {
+ Players[i].TotalUnitLimit = gh_scm2int(limit);
}
return limit;
@@ -400,46 +397,46 @@
**
** @todo FIXME: should return old state.
*/
-local SCM CclSetDiplomacy(SCM player,SCM state,SCM opponent)
+local SCM CclSetDiplomacy(SCM player, SCM state, SCM opponent)
{
int plynr;
#if 0
Player* base;
- base=CclGetPlayer(player);
- plynr=gh_scm2int(opponent);
+ base = CclGetPlayer(player);
+ plynr = gh_scm2int(opponent);
- if( gh_eq_p(state,gh_symbol2scm("allied")) ) {
- base->Enemy&=~(1<<plynr);
- base->Allied|=1<<plynr;
- } else if( gh_eq_p(state,gh_symbol2scm("neutral")) ) {
- base->Enemy&=~(1<<plynr);
- base->Allied&=~(1<<plynr);
- } else if( gh_eq_p(state,gh_symbol2scm("crazy")) ) {
- base->Enemy|=1<<plynr;
- base->Allied|=1<<plynr;
- } else if( gh_eq_p(state,gh_symbol2scm("enemy")) ) {
- base->Enemy|=1<<plynr;
- base->Allied&=~(1<<plynr);
+ if (gh_eq_p(state, gh_symbol2scm("allied"))) {
+ base->Enemy &= ~(1 << plynr);
+ base->Allied |= 1 << plynr;
+ } else if (gh_eq_p(state, gh_symbol2scm("neutral"))) {
+ base->Enemy &= ~(1 << plynr);
+ base->Allied &= ~(1 << plynr);
+ } else if (gh_eq_p(state, gh_symbol2scm("crazy"))) {
+ base->Enemy |= 1 << plynr;
+ base->Allied |= 1 << plynr;
+ } else if (gh_eq_p(state, gh_symbol2scm("enemy"))) {
+ base->Enemy |= 1 << plynr;
+ base->Allied &= ~(1 << plynr);
}
#else
int base;
- base=gh_scm2int(player);
- plynr=gh_scm2int(opponent);
+ base = gh_scm2int(player);
+ plynr = gh_scm2int(opponent);
// FIXME: must send over network!!
- if( gh_eq_p(state,gh_symbol2scm("allied")) ) {
- SendCommandDiplomacy(base,DiplomacyAllied,plynr);
- } else if( gh_eq_p(state,gh_symbol2scm("neutral")) ) {
- SendCommandDiplomacy(base,DiplomacyNeutral,plynr);
- } else if( gh_eq_p(state,gh_symbol2scm("crazy")) ) {
- SendCommandDiplomacy(base,DiplomacyCrazy,plynr);
- } else if( gh_eq_p(state,gh_symbol2scm("enemy")) ) {
- SendCommandDiplomacy(base,DiplomacyEnemy,plynr);
+ if (gh_eq_p(state, gh_symbol2scm("allied"))) {
+ SendCommandDiplomacy(base, DiplomacyAllied, plynr);
+ } else if (gh_eq_p(state, gh_symbol2scm("neutral"))) {
+ SendCommandDiplomacy(base, DiplomacyNeutral, plynr);
+ } else if (gh_eq_p(state, gh_symbol2scm("crazy"))) {
+ SendCommandDiplomacy(base, DiplomacyCrazy, plynr);
+ } else if (gh_eq_p(state, gh_symbol2scm("enemy"))) {
+ SendCommandDiplomacy(base, DiplomacyEnemy, plynr);
}
#endif
@@ -454,9 +451,9 @@
** @param state To which state this should be changed.
** @param player Player number to change.
*/
-local SCM CclDiplomacy(SCM state,SCM player)
+local SCM CclDiplomacy(SCM state, SCM player)
{
- return CclSetDiplomacy(gh_int2scm(ThisPlayer->Player),state,player);
+ return CclSetDiplomacy(gh_int2scm(ThisPlayer->Player), state, player);
}
/**
@@ -470,17 +467,17 @@
**
** @todo FIXME: should return old state.
*/
-local SCM CclSetSharedVision(SCM player,SCM state,SCM opponent)
+local SCM CclSetSharedVision(SCM player, SCM state, SCM opponent)
{
int plynr;
int base;
int shared;
- base=gh_scm2int(player);
- shared=gh_scm2bool(state);
- plynr=gh_scm2int(opponent);
+ base = gh_scm2int(player);
+ shared = gh_scm2bool(state);
+ plynr = gh_scm2int(opponent);
- SendCommandSharedVision(base,shared,plynr);
+ SendCommandSharedVision(base, shared, plynr);
// FIXME: we can return the old state
return SCM_UNSPECIFIED;
@@ -492,9 +489,9 @@
** @param state To which state this should be changed.
** @param player Player number to change.
*/
-local SCM CclSharedVision(SCM state,SCM player)
+local SCM CclSharedVision(SCM state, SCM player)
{
- return CclSetSharedVision(gh_int2scm(ThisPlayer->Player),state,player);
+ return CclSetSharedVision(gh_int2scm(ThisPlayer->Player), state, player);
}
/**
@@ -508,39 +505,39 @@
SCM value;
int i;
- PlayerRaces.Count=0;
- while( !gh_null_p(list) ) {
- value=gh_car(list);
- list=gh_cdr(list);
-
- if( gh_eq_p(value,gh_symbol2scm("race")) ) {
- sublist=gh_car(list);
- list=gh_cdr(list);
- i=PlayerRaces.Count++;
- PlayerRaces.Race[i]=0;
- PlayerRaces.Name[i]=NULL;
- PlayerRaces.Display[i]=NULL;
- PlayerRaces.Visible[i]=0;
- while( !gh_null_p(sublist) ) {
- value=gh_car(sublist);
- sublist=gh_cdr(sublist);
- if( gh_eq_p(value,gh_symbol2scm("race")) ) {
- PlayerRaces.Race[i]=gh_scm2int(gh_car(sublist));
- sublist=gh_cdr(sublist);
- } else if( gh_eq_p(value,gh_symbol2scm("name")) ) {
- PlayerRaces.Name[i]=gh_scm2newstr(gh_car(sublist),NULL);
- sublist=gh_cdr(sublist);
- } else if( gh_eq_p(value,gh_symbol2scm("display")) ) {
- PlayerRaces.Display[i]=gh_scm2newstr(gh_car(sublist),NULL);
- sublist=gh_cdr(sublist);
- } else if( gh_eq_p(value,gh_symbol2scm("visible")) ) {
- PlayerRaces.Visible[i]=1;
+ PlayerRaces.Count = 0;
+ while (!gh_null_p(list)) {
+ value = gh_car(list);
+ list = gh_cdr(list);
+
+ if (gh_eq_p(value, gh_symbol2scm("race"))) {
+ sublist = gh_car(list);
+ list = gh_cdr(list);
+ i = PlayerRaces.Count++;
+ PlayerRaces.Race[i] = 0;
+ PlayerRaces.Name[i] = NULL;
+ PlayerRaces.Display[i] = NULL;
+ PlayerRaces.Visible[i] = 0;
+ while (!gh_null_p(sublist)) {
+ value = gh_car(sublist);
+ sublist = gh_cdr(sublist);
+ if (gh_eq_p(value, gh_symbol2scm("race"))) {
+ PlayerRaces.Race[i] = gh_scm2int(gh_car(sublist));
+ sublist = gh_cdr(sublist);
+ } else if (gh_eq_p(value, gh_symbol2scm("name"))) {
+ PlayerRaces.Name[i] = gh_scm2newstr(gh_car(sublist), NULL);
+ sublist = gh_cdr(sublist);
+ } else if (gh_eq_p(value, gh_symbol2scm("display"))) {
+ PlayerRaces.Display[i] = gh_scm2newstr(gh_car(sublist),
NULL);
+ sublist = gh_cdr(sublist);
+ } else if (gh_eq_p(value, gh_symbol2scm("visible"))) {
+ PlayerRaces.Visible[i] = 1;
} else {
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
}
} else {
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
}
@@ -567,26 +564,26 @@
**
** @return Player resource
*/
-local SCM CclGetPlayerResource(SCM player,SCM resource)
+local SCM CclGetPlayerResource(SCM player, SCM resource)
{
int i;
Player* plyr;
char* res;
SCM ret;
- plyr=CclGetPlayer(player);
- res=gh_scm2newstr(resource,NULL);
+ plyr = CclGetPlayer(player);
+ res = gh_scm2newstr(resource, NULL);
- for( i=0; i<MaxCosts; ++i ) {
- if( !strcmp(res,DefaultResourceNames[i]) ) {
+ for (i = 0; i < MaxCosts; ++i) {
+ if (!strcmp(res, DefaultResourceNames[i])) {
break;
}
}
- if( i==MaxCosts ) {
+ if (i == MaxCosts) {
// FIXME: this leaves a half initialized player
- errl("Invalid resource",resource);
+ errl("Invalid resource", resource);
}
- ret=gh_int2scm(plyr->Resources[i]);
+ ret = gh_int2scm(plyr->Resources[i]);
free(res);
return ret;
}
@@ -602,23 +599,23 @@
Player* player;
SCM value;
- player=CclGetPlayer(gh_car(list));
- list=gh_cdr(list);
- while( !gh_null_p(list) ) {
- value=gh_car(list);
- list=gh_cdr(list);
- for( i=0; i<MaxCosts; ++i ) {
- if( gh_eq_p(value,gh_symbol2scm((char*)DefaultResourceNames[i])) ) {
+ player = CclGetPlayer(gh_car(list));
+ list = gh_cdr(list);
+ while (!gh_null_p(list)) {
+ value = gh_car(list);
+ list = gh_cdr(list);
+ for (i = 0; i < MaxCosts; ++i) {
+ if (gh_eq_p(value, gh_symbol2scm((char*)DefaultResourceNames[i]))) {
break;
}
}
- if( i==MaxCosts ) {
+ if (i == MaxCosts) {
// FIXME: this leaves a half initialized player
- errl("Unsupported tag",value);
+ errl("Unsupported tag", value);
}
- value=gh_car(list);
- list=gh_cdr(list);
- player->Resources[i]=gh_scm2int(value);
+ value = gh_car(list);
+ list = gh_cdr(list);
+ player->Resources[i] = gh_scm2int(value);
}
return SCM_UNSPECIFIED;
}
@@ -630,30 +627,30 @@
*/
global void PlayerCclRegister(void)
{
- gh_new_procedureN("player",CclPlayer);
- gh_new_procedure4_0("change-units-owner",CclChangeUnitsOwner);
- gh_new_procedure0_0("get-this-player",CclGetThisPlayer);
- gh_new_procedure1_0("set-this-player!",CclSetThisPlayer);
+ gh_new_procedureN("player", CclPlayer);
+ gh_new_procedure4_0("change-units-owner", CclChangeUnitsOwner);
+ gh_new_procedure0_0("get-this-player", CclGetThisPlayer);
+ gh_new_procedure1_0("set-this-player!", CclSetThisPlayer);
gh_new_procedure1_0("set-all-players-food-unit-limit!",
- CclSetAllPlayersFoodUnitLimit);
+ CclSetAllPlayersFoodUnitLimit);
gh_new_procedure1_0("set-all-players-building-limit!",
- CclSetAllPlayersBuildingLimit);
+ CclSetAllPlayersBuildingLimit);
gh_new_procedure1_0("set-all-players-total-unit-limit!",
- CclSetAllPlayersTotalUnitLimit);
+ CclSetAllPlayersTotalUnitLimit);
- gh_new_procedure3_0("set-diplomacy!",CclSetDiplomacy);
- gh_new_procedure2_0("diplomacy",CclDiplomacy);
- gh_new_procedure3_0("set-shared-vision!",CclSetSharedVision);
- gh_new_procedure2_0("shared-vision",CclSharedVision);
+ gh_new_procedure3_0("set-diplomacy!", CclSetDiplomacy);
+ gh_new_procedure2_0("diplomacy", CclDiplomacy);
+ gh_new_procedure3_0("set-shared-vision!", CclSetSharedVision);
+ gh_new_procedure2_0("shared-vision", CclSharedVision);
- gh_new_procedureN("define-race-names",CclDefineRaceNames);
+ gh_new_procedureN("define-race-names", CclDefineRaceNames);
- gh_new_procedure0_0("new-colors",CclNewPlayerColors);
+ gh_new_procedure0_0("new-colors", CclNewPlayerColors);
// player member access functions
- gh_new_procedure2_0("get-player-resource",CclGetPlayerResource);
- gh_new_procedureN("set-player-resource!",CclSetPlayerResource);
+ gh_new_procedure2_0("get-player-resource", CclGetPlayerResource);
+ gh_new_procedureN("set-player-resource!", CclSetPlayerResource);
}
//@}
Index: stratagus/src/clone/ccl_spell.c
diff -u stratagus/src/clone/ccl_spell.c:1.14
stratagus/src/clone/ccl_spell.c:1.15
--- stratagus/src/clone/ccl_spell.c:1.14 Thu Oct 9 07:31:45 2003
+++ stratagus/src/clone/ccl_spell.c Thu Oct 9 16:54:36 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_spell.c,v 1.14 2003/10/09 11:31:45 n0body Exp $
+// $Id: ccl_spell.c,v 1.15 2003/10/09 20:54:36 jsalmon3 Exp $
//@{
/*----------------------------------------------------------------------------
@@ -56,24 +56,22 @@
** @param list SCM list object, with somthing like
(action-type params).
** @param spellaction Pointer to spellactopm.
*/
-local void CclSpellAction(SCM list, SpellActionType *spellaction)
+local void CclSpellAction(SCM list, SpellActionType* spellaction)
{
char* str;
- SCM value = list;
+ SCM value;
+
+ DebugCheck(spellaction == NULL);
- DebugCheck (spellaction == NULL);
-
- value = gh_car(value);
-
- value=gh_car(list);
- list=gh_cdr(list);
+ value = gh_car(list);
+ list = gh_cdr(list);
memset(spellaction, 0, sizeof(*spellaction));
- if (gh_eq_p(value,gh_symbol2scm("area-bombardment"))) {
- spellaction->CastFunction=CastAreaBombardment;
+ if (gh_eq_p(value, gh_symbol2scm("area-bombardment"))) {
+ spellaction->CastFunction = CastAreaBombardment;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("fields"))) {
spellaction->Data.AreaBombardment.Fields =
gh_scm2int(gh_car(list));
list = gh_cdr(list);
@@ -90,27 +88,27 @@
spellaction->Data.AreaBombardment.StartOffsetY =
gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported area-bombardment tag",value);
+ errl("Unsupported area-bombardment tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("flame-shield"))) {
- spellaction->CastFunction=CastFlameShield;
+ } else if (gh_eq_p(value, gh_symbol2scm("flame-shield"))) {
+ spellaction->CastFunction = CastFlameShield;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("duration"))) {
spellaction->Data.FlameShield.TTL = gh_scm2int(gh_car(list));
list = gh_cdr(list);
/// FIXME:damage, missiles, rotation speed?
} else {
- errl("Unsupported flame-shield tag",value);
+ errl("Unsupported flame-shield tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("fireball"))) {
- spellaction->CastFunction=CastFireball;
+ } else if (gh_eq_p(value, gh_symbol2scm("fireball"))) {
+ spellaction->CastFunction = CastFireball;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("damage"))) {
spellaction->Data.Fireball.Damage = gh_scm2int(gh_car(list));
list = gh_cdr(list);
@@ -118,14 +116,14 @@
spellaction->Data.Fireball.TTL = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported fireball tag",value);
+ errl("Unsupported fireball tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("runes"))) {
- spellaction->CastFunction=CastRunes;
+ } else if (gh_eq_p(value, gh_symbol2scm("runes"))) {
+ spellaction->CastFunction = CastRunes;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("damage"))) {
spellaction->Data.Fireball.Damage = gh_scm2int(gh_car(list));
list = gh_cdr(list);
@@ -133,31 +131,31 @@
spellaction->Data.Fireball.TTL = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported runes tag",value);
+ errl("Unsupported runes tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("whirlwind"))) {
- spellaction->CastFunction=CastWhirlwind;
+ } else if (gh_eq_p(value, gh_symbol2scm("whirlwind"))) {
+ spellaction->CastFunction = CastWhirlwind;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("duration"))) {
spellaction->Data.Whirlwind.TTL = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported runes tag",value);
+ errl("Unsupported runes tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("adjust-buffs"))) {
- spellaction->CastFunction=CastAdjustBuffs;
- spellaction->Data.AdjustBuffs.HasteTicks=BUFF_NOT_AFFECTED;
- spellaction->Data.AdjustBuffs.SlowTicks=BUFF_NOT_AFFECTED;
- spellaction->Data.AdjustBuffs.BloodlustTicks=BUFF_NOT_AFFECTED;
- spellaction->Data.AdjustBuffs.InvisibilityTicks=BUFF_NOT_AFFECTED;
- spellaction->Data.AdjustBuffs.InvincibilityTicks=BUFF_NOT_AFFECTED;
+ } else if (gh_eq_p(value, gh_symbol2scm("adjust-buffs"))) {
+ spellaction->CastFunction = CastAdjustBuffs;
+ spellaction->Data.AdjustBuffs.HasteTicks = BUFF_NOT_AFFECTED;
+ spellaction->Data.AdjustBuffs.SlowTicks = BUFF_NOT_AFFECTED;
+ spellaction->Data.AdjustBuffs.BloodlustTicks = BUFF_NOT_AFFECTED;
+ spellaction->Data.AdjustBuffs.InvisibilityTicks = BUFF_NOT_AFFECTED;
+ spellaction->Data.AdjustBuffs.InvincibilityTicks = BUFF_NOT_AFFECTED;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("haste-ticks"))) {
spellaction->Data.AdjustBuffs.HasteTicks =
gh_scm2int(gh_car(list));
list = gh_cdr(list);
@@ -174,16 +172,16 @@
spellaction->Data.AdjustBuffs.InvincibilityTicks =
gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported adjust-buffs tag",value);
+ errl("Unsupported adjust-buffs tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("summon"))) {
- spellaction->CastFunction=CastSummon;
+ } else if (gh_eq_p(value, gh_symbol2scm("summon"))) {
+ spellaction->CastFunction = CastSummon;
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("unit-type"))) {
- str = gh_scm2newstr(gh_car(list),0);
+ str = gh_scm2newstr(gh_car(list), 0);
spellaction->Data.Summon.UnitType = UnitTypeByIdent(str);
if (!spellaction->Data.Summon.UnitType) {
spellaction->Data.Summon.UnitType = 0;
@@ -197,16 +195,16 @@
} else if (gh_eq_p(value, gh_symbol2scm("require-corpse"))) {
spellaction->Data.Summon.RequireCorpse = 1;
} else {
- errl("Unsupported summon tag",value);
+ errl("Unsupported summon tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("spawn-portal"))) {
- spellaction->CastFunction=CastSpawnPortal;
+ } else if (gh_eq_p(value, gh_symbol2scm("spawn-portal"))) {
+ spellaction->CastFunction = CastSpawnPortal;
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("portal-type"))) {
- str = gh_scm2newstr(gh_car(list),0);
+ str = gh_scm2newstr(gh_car(list), 0);
spellaction->Data.SpawnPortal.PortalType = UnitTypeByIdent(str);
if (!spellaction->Data.SpawnPortal.PortalType) {
spellaction->Data.SpawnPortal.PortalType = 0;
@@ -215,11 +213,11 @@
free(str);
list = gh_cdr(list);
} else {
- errl("Unsupported spawn-portal tag",value);
+ errl("Unsupported spawn-portal tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("polymorph"))) {
- spellaction->CastFunction=CastPolymorph;
+ } else if (gh_eq_p(value, gh_symbol2scm("polymorph"))) {
+ spellaction->CastFunction = CastPolymorph;
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
@@ -234,14 +232,14 @@
list = gh_cdr(list);
//FIXME : temp polymorphs? hard to do.
} else {
- errl("Unsupported polymorph tag",value);
+ errl("Unsupported polymorph tag", value);
}
}
- } else if (gh_eq_p(value,gh_symbol2scm("adjust-vitals"))) {
- spellaction->CastFunction=CastAdjustVitals;
+ } else if (gh_eq_p(value, gh_symbol2scm("adjust-vitals"))) {
+ spellaction->CastFunction = CastAdjustVitals;
while (!gh_null_p(list)) {
value = gh_car(list);
- list=gh_cdr(list);
+ list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("hit-points"))) {
spellaction->Data.AdjustVitals.HP = gh_scm2int(gh_car(list));
list = gh_cdr(list);
@@ -252,7 +250,7 @@
spellaction->Data.AdjustVitals.MaxMultiCast =
gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else {
- errl("Unsupported adjust-vitals tag",value);
+ errl("Unsupported adjust-vitals tag", value);
}
}
} else {
@@ -271,14 +269,14 @@
*/
local char Scm2Condition(SCM value)
{
- if (gh_eq_p(value,gh_symbol2scm("true"))) {
+ if (gh_eq_p(value, gh_symbol2scm("true"))) {
return CONDITION_TRUE;
- } else if (gh_eq_p(value,gh_symbol2scm("false"))) {
+ } else if (gh_eq_p(value, gh_symbol2scm("false"))) {
return CONDITION_FALSE;
- } else if (gh_eq_p(value,gh_symbol2scm("only"))) {
+ } else if (gh_eq_p(value, gh_symbol2scm("only"))) {
return CONDITION_ONLY;
} else {
- errl("Bad condition result",value);
+ errl("Bad condition result", value);
return -1;
}
}
@@ -300,77 +298,77 @@
//
// Set everything to 0:
- memset(condition,0,sizeof(ConditionInfo));
+ memset(condition, 0, sizeof(ConditionInfo));
// Flags are defaulted to 0(CONDITION_TRUE)
// Initialize min/max stuff to values with no effect.
- condition->MinHpPercent=-10;
- condition->MaxHpPercent=1000;
- condition->MinManaPercent=-10;
- condition->MaxManaPercent=1000;
+ condition->MinHpPercent = -10;
+ condition->MaxHpPercent = 1000;
+ condition->MinManaPercent = -10;
+ condition->MaxManaPercent = 1000;
// Buffs too.
- condition->MaxHasteTicks=0xFFFFFFF;
- condition->MaxSlowTicks=0xFFFFFFF;
- condition->MaxBloodlustTicks=0xFFFFFFF;
- condition->MaxInvisibilityTicks=0xFFFFFFF;
- condition->MaxInvincibilityTicks=0xFFFFFFF;
+ condition->MaxHasteTicks = 0xFFFFFFF;
+ condition->MaxSlowTicks = 0xFFFFFFF;
+ condition->MaxBloodlustTicks = 0xFFFFFFF;
+ condition->MaxInvisibilityTicks = 0xFFFFFFF;
+ condition->MaxInvincibilityTicks = 0xFFFFFFF;
// Now parse the list and set values.
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
- if (gh_eq_p(value,gh_symbol2scm("undead"))) {
- condition->Undead=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("organic"))) {
- condition->Organic=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("volatile"))) {
- condition->Volatile=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("hero"))) {
- condition->Hero=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("coward"))) {
- condition->Coward=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("alliance"))) {
- condition->Alliance=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("building"))) {
- condition->Building=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("self"))) {
- condition->TargetSelf=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("min-hp-percent"))) {
- condition->MinHpPercent=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-hp-percent"))) {
- condition->MaxHpPercent=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("min-mana-percent"))) {
- condition->MinManaPercent=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-mana-percent"))) {
- condition->MaxManaPercent=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-slow-ticks"))) {
- condition->MaxSlowTicks=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-haste-ticks"))) {
- condition->MaxHasteTicks=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-bloodlust-ticks"))) {
- condition->MaxBloodlustTicks=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-invisibility-ticks"))) {
- condition->MaxInvisibilityTicks=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("max-invincibility-ticks"))) {
- condition->MaxInvincibilityTicks=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
+ if (gh_eq_p(value, gh_symbol2scm("undead"))) {
+ condition->Undead = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("organic"))) {
+ condition->Organic = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("volatile"))) {
+ condition->Volatile = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("hero"))) {
+ condition->Hero = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("coward"))) {
+ condition->Coward = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("alliance"))) {
+ condition->Alliance = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("building"))) {
+ condition->Building = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("self"))) {
+ condition->TargetSelf = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("min-hp-percent"))) {
+ condition->MinHpPercent = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-hp-percent"))) {
+ condition->MaxHpPercent = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("min-mana-percent"))) {
+ condition->MinManaPercent = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-mana-percent"))) {
+ condition->MaxManaPercent = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-slow-ticks"))) {
+ condition->MaxSlowTicks = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-haste-ticks"))) {
+ condition->MaxHasteTicks = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-bloodlust-ticks"))) {
+ condition->MaxBloodlustTicks = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-invisibility-ticks"))) {
+ condition->MaxInvisibilityTicks = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("max-invincibility-ticks"))) {
+ condition->MaxInvincibilityTicks = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
} else {
- errl("Unsuported condition tag",value);
+ errl("Unsuported condition tag", value);
}
}
}
@@ -393,20 +391,20 @@
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
- if (gh_eq_p(value,gh_symbol2scm("range"))) {
- autocast->Range=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("combat"))) {
- autocast->Combat=Scm2Condition(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("condition"))) {
+ if (gh_eq_p(value, gh_symbol2scm("range"))) {
+ autocast->Range = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("combat"))) {
+ autocast->Combat = Scm2Condition(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("condition"))) {
if (!autocast->Condition) {
-
autocast->Condition=(ConditionInfo*)malloc(sizeof(ConditionInfo));
+ autocast->Condition =
(ConditionInfo*)malloc(sizeof(ConditionInfo));
}
- CclSpellCondition(gh_car(list),autocast->Condition);
- list=gh_cdr(list);
+ CclSpellCondition(gh_car(list), autocast->Condition);
+ list = gh_cdr(list);
} else {
- errl("Unsupported autocast tag",value);
+ errl("Unsupported autocast tag", value);
}
}
}
@@ -418,9 +416,9 @@
*/
local SCM CclDefineSpell(SCM list)
{
- char *identname;
- char *str;
- SpellType *spell;
+ char* identname;
+ char* str;
+ SpellType* spell;
SCM value;
identname = gh_scm2newstr(gh_car(list), NULL);
@@ -430,96 +428,96 @@
DebugLevel0Fn("Redefining spell-type `%s'\n" _C_ identname);
free(identname);
} else {
- SpellTypeTable =
realloc(SpellTypeTable,(1+SpellTypeCount)*sizeof(SpellType));
+ SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) *
sizeof(SpellType));
spell = &SpellTypeTable[SpellTypeCount++];
- memset(spell,0,sizeof(SpellType));
- spell->Ident=SpellTypeCount-1;
- spell->IdentName=identname;
+ memset(spell, 0, sizeof(SpellType));
+ spell->Ident = SpellTypeCount - 1;
+ spell->IdentName = identname;
spell->DependencyId = -1;
}
while (!gh_null_p(list)) {
value = gh_car(list);
list = gh_cdr(list);
- if (gh_eq_p(value,gh_symbol2scm("showname"))) {
+ if (gh_eq_p(value, gh_symbol2scm("showname"))) {
if (spell->Name) {
free(spell->Name);
}
- spell->Name=gh_scm2newstr(gh_car(list), NULL);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("manacost"))) {
- spell->ManaCost=gh_scm2int(gh_car(list));
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("range"))) {
- if (gh_eq_p(gh_car(list),gh_symbol2scm("infinite"))) {
- spell->Range=INFINITE_RANGE;
- } else {
- spell->Range=gh_scm2int(gh_car(list));
- }
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("target"))) {
- value=gh_car(list);
- if (gh_eq_p(value,gh_symbol2scm("self"))) {
- spell->Target=TargetSelf;
- } else if (gh_eq_p(value,gh_symbol2scm("unit"))) {
- spell->Target=TargetUnit;
- } else if (gh_eq_p(value,gh_symbol2scm("position"))) {
- spell->Target=TargetPosition;
+ spell->Name = gh_scm2newstr(gh_car(list), NULL);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("manacost"))) {
+ spell->ManaCost = gh_scm2int(gh_car(list));
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("range"))) {
+ if (gh_eq_p(gh_car(list), gh_symbol2scm("infinite"))) {
+ spell->Range = INFINITE_RANGE;
} else {
- errl("Unsupported spell target type tag",value);
+ spell->Range = gh_scm2int(gh_car(list));
}
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("action"))) {
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("target"))) {
+ value = gh_car(list);
+ if (gh_eq_p(value, gh_symbol2scm("self"))) {
+ spell->Target = TargetSelf;
+ } else if (gh_eq_p(value, gh_symbol2scm("unit"))) {
+ spell->Target = TargetUnit;
+ } else if (gh_eq_p(value, gh_symbol2scm("position"))) {
+ spell->Target = TargetPosition;
+ } else {
+ errl("Unsupported spell target type tag", value);
+ }
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("action"))) {
if (!spell->Action) {
- spell->Action=(SpellActionType*)malloc(sizeof(SpellActionType));
+ spell->Action =
(SpellActionType*)malloc(sizeof(SpellActionType));
}
- CclSpellAction(gh_car(list),spell->Action);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("condition"))) {
+ CclSpellAction(gh_car(list), spell->Action);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("condition"))) {
if (!spell->Condition) {
- spell->Condition=(ConditionInfo*)malloc(sizeof(ConditionInfo));
+ spell->Condition =
(ConditionInfo*)malloc(sizeof(ConditionInfo));
}
- CclSpellCondition(gh_car(list),spell->Condition);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("autocast"))) {
+ CclSpellCondition(gh_car(list), spell->Condition);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("autocast"))) {
if (!spell->AutoCast) {
- spell->AutoCast=(AutoCastInfo*)malloc(sizeof(AutoCastInfo));
- memset(spell->AutoCast,0,sizeof(AutoCastInfo));
+ spell->AutoCast = (AutoCastInfo*)malloc(sizeof(AutoCastInfo));
+ memset(spell->AutoCast, 0, sizeof(AutoCastInfo));
}
- CclSpellAutocast(gh_car(list),spell->AutoCast);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("ai-cast"))) {
+ CclSpellAutocast(gh_car(list), spell->AutoCast);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("ai-cast"))) {
if (!spell->AICast) {
- spell->AICast=(AutoCastInfo*)malloc(sizeof(AutoCastInfo));
- memset(spell->AICast,0,sizeof(AutoCastInfo));
+ spell->AICast = (AutoCastInfo*)malloc(sizeof(AutoCastInfo));
+ memset(spell->AICast, 0, sizeof(AutoCastInfo));
}
- CclSpellAutocast(gh_car(list),spell->AICast);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("sound-when-cast"))) {
+ CclSpellAutocast(gh_car(list), spell->AICast);
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("sound-when-cast"))) {
// Free the old name, get the new one
free(spell->SoundWhenCast.Name);
- spell->SoundWhenCast.Name=gh_scm2newstr(gh_car(list),0);
-
spell->SoundWhenCast.Sound=SoundIdForName(spell->SoundWhenCast.Name);
+ spell->SoundWhenCast.Name = gh_scm2newstr(gh_car(list), 0);
+ spell->SoundWhenCast.Sound =
SoundIdForName(spell->SoundWhenCast.Name);
// Check for sound.
if (!spell->SoundWhenCast.Sound) {
free(spell->SoundWhenCast.Name);
- spell->SoundWhenCast.Name=0;
+ spell->SoundWhenCast.Name = 0;
}
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("missile-when-cast"))) {
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("missile-when-cast"))) {
str = gh_scm2newstr(gh_car(list), NULL);
spell->Missile = MissileTypeByIdent(str);
if (spell->Missile == NULL) {
- DebugLevel0Fn("in spell-type '%s' : missile %s does not exist\n"
- _C_ spell->Name _C_ str);
+ DebugLevel0Fn("in spell-type '%s' : missile %s does not
exist\n" _C_
+ spell->Name _C_ str);
}
free(str);
- list=gh_cdr(list);
- } else if (gh_eq_p(value,gh_symbol2scm("depend-upgrade"))) {
+ list = gh_cdr(list);
+ } else if (gh_eq_p(value, gh_symbol2scm("depend-upgrade"))) {
str = gh_scm2newstr(gh_car(list), NULL);
spell->DependencyId = UpgradeIdByIdent(str);
free(str);
if (spell->DependencyId == -1) {
- errl("Bad upgrade name",gh_car(list));
+ errl("Bad upgrade name", gh_car(list));
}
list = gh_cdr(list);
} else {
@@ -545,74 +543,74 @@
*/
local void SaveSpellAction(CLFile *file,SpellActionType* action)
{
- if (action->CastFunction==CastAreaBombardment) {
- CLprintf(file,"(area-bombardment fields %d shards %d damage %d
start-offset-x %d start-offset-y %d)",
- action->Data.AreaBombardment.Fields,
- action->Data.AreaBombardment.Shards,
- action->Data.AreaBombardment.Damage,
- action->Data.AreaBombardment.StartOffsetX,
- action->Data.AreaBombardment.StartOffsetY);
- } else if (action->CastFunction==CastFireball) {
- CLprintf(file,"(fireball ttl %d damage %d)",
- action->Data.Fireball.TTL,
- action->Data.Fireball.Damage);
- } else if (action->CastFunction==CastAdjustVitals) {
- CLprintf(file,"(adjust-vitals");
+ if (action->CastFunction == CastAreaBombardment) {
+ CLprintf(file, "(area-bombardment fields %d shards %d damage %d
start-offset-x %d start-offset-y %d)",
+ action->Data.AreaBombardment.Fields,
+ action->Data.AreaBombardment.Shards,
+ action->Data.AreaBombardment.Damage,
+ action->Data.AreaBombardment.StartOffsetX,
+ action->Data.AreaBombardment.StartOffsetY);
+ } else if (action->CastFunction == CastFireball) {
+ CLprintf(file, "(fireball ttl %d damage %d)",
+ action->Data.Fireball.TTL,
+ action->Data.Fireball.Damage);
+ } else if (action->CastFunction == CastAdjustVitals) {
+ CLprintf(file, "(adjust-vitals");
if (action->Data.AdjustVitals.HP) {
- CLprintf(file," hit-points %d",action->Data.AdjustVitals.HP);
+ CLprintf(file, " hit-points %d", action->Data.AdjustVitals.HP);
}
if (action->Data.AdjustVitals.Mana) {
- CLprintf(file," mana-points %d",action->Data.AdjustVitals.Mana);
+ CLprintf(file, " mana-points %d", action->Data.AdjustVitals.Mana);
}
if (action->Data.AdjustVitals.MaxMultiCast) {
- CLprintf(file," max-multi-cast
%d",action->Data.AdjustVitals.MaxMultiCast);
+ CLprintf(file, " max-multi-cast %d",
action->Data.AdjustVitals.MaxMultiCast);
}
- CLprintf(file,")\n");
- } else if (action->CastFunction==CastSummon) {
- CLprintf(file,"(summon unit-type %s time-to-live %d",
- action->Data.Summon.UnitType->Ident,
- action->Data.Summon.TTL);
+ CLprintf(file, ")\n");
+ } else if (action->CastFunction == CastSummon) {
+ CLprintf(file, "(summon unit-type %s time-to-live %d",
+ action->Data.Summon.UnitType->Ident,
+ action->Data.Summon.TTL);
if (action->Data.Summon.RequireCorpse) {
- CLprintf(file," require-corpse ");
+ CLprintf(file, " require-corpse ");
}
- CLprintf(file,")\n");
- } else if (action->CastFunction==CastAdjustBuffs) {
- CLprintf(file,"(adjust-buffs");
- if (action->Data.AdjustBuffs.HasteTicks!=BUFF_NOT_AFFECTED) {
- CLprintf(file," haste-ticks
%d",action->Data.AdjustBuffs.HasteTicks);
- }
- if (action->Data.AdjustBuffs.SlowTicks!=BUFF_NOT_AFFECTED) {
- CLprintf(file," slow-ticks %d",action->Data.AdjustBuffs.SlowTicks);
- }
- if (action->Data.AdjustBuffs.BloodlustTicks!=BUFF_NOT_AFFECTED) {
- CLprintf(file," bloodlust-ticks
%d",action->Data.AdjustBuffs.BloodlustTicks);
- }
- if (action->Data.AdjustBuffs.InvisibilityTicks!=BUFF_NOT_AFFECTED) {
- CLprintf(file," invisibility-ticks
%d",action->Data.AdjustBuffs.InvisibilityTicks);
- }
- if (action->Data.AdjustBuffs.InvincibilityTicks!=BUFF_NOT_AFFECTED) {
- CLprintf(file," invincibility-ticks
%d",action->Data.AdjustBuffs.InvincibilityTicks);
- }
- CLprintf(file,")");
- } else if (action->CastFunction==CastPolymorph) {
- CLprintf(file,"(polymorph new-form %s)",
- action->Data.Polymorph.NewForm->Ident);
- } else if (action->CastFunction==CastFlameShield) {
- CLprintf(file,"(flame-shield duration %d)",
- action->Data.FlameShield.TTL);
- } else if (action->CastFunction==CastRunes) {
- CLprintf(file,"(runes ttl %d damage %d)",
- action->Data.Runes.TTL,
- action->Data.Runes.Damage);
- } else if (action->CastFunction==CastSpawnPortal) {
- CLprintf(file,"(spawn-portal portal-type %s)",
- action->Data.SpawnPortal.PortalType->Ident);
- } else if (action->CastFunction==CastDeathCoil) {
- CLprintf(file,"(death-coil)");
+ CLprintf(file, ")\n");
+ } else if (action->CastFunction == CastAdjustBuffs) {
+ CLprintf(file, "(adjust-buffs");
+ if (action->Data.AdjustBuffs.HasteTicks != BUFF_NOT_AFFECTED) {
+ CLprintf(file, " haste-ticks %d",
action->Data.AdjustBuffs.HasteTicks);
+ }
+ if (action->Data.AdjustBuffs.SlowTicks != BUFF_NOT_AFFECTED) {
+ CLprintf(file, " slow-ticks %d",
action->Data.AdjustBuffs.SlowTicks);
+ }
+ if (action->Data.AdjustBuffs.BloodlustTicks != BUFF_NOT_AFFECTED) {
+ CLprintf(file, " bloodlust-ticks %d",
action->Data.AdjustBuffs.BloodlustTicks);
+ }
+ if (action->Data.AdjustBuffs.InvisibilityTicks != BUFF_NOT_AFFECTED) {
+ CLprintf(file, " invisibility-ticks %d",
action->Data.AdjustBuffs.InvisibilityTicks);
+ }
+ if (action->Data.AdjustBuffs.InvincibilityTicks != BUFF_NOT_AFFECTED) {
+ CLprintf(file, " invincibility-ticks %d",
action->Data.AdjustBuffs.InvincibilityTicks);
+ }
+ CLprintf(file, ")");
+ } else if (action->CastFunction == CastPolymorph) {
+ CLprintf(file, "(polymorph new-form %s)",
+ action->Data.Polymorph.NewForm->Ident);
+ } else if (action->CastFunction == CastFlameShield) {
+ CLprintf(file, "(flame-shield duration %d)",
+ action->Data.FlameShield.TTL);
+ } else if (action->CastFunction == CastRunes) {
+ CLprintf(file, "(runes ttl %d damage %d)",
+ action->Data.Runes.TTL,
+ action->Data.Runes.Damage);
+ } else if (action->CastFunction == CastSpawnPortal) {
+ CLprintf(file, "(spawn-portal portal-type %s)",
+ action->Data.SpawnPortal.PortalType->Ident);
+ } else if (action->CastFunction == CastDeathCoil) {
+ CLprintf(file, "(death-coil)");
// FIXME: more?
- } else if (action->CastFunction==CastWhirlwind) {
- CLprintf(file,"(whirlwind duration %d)",
- action->Data.Whirlwind.TTL);
+ } else if (action->CastFunction == CastWhirlwind) {
+ CLprintf(file, "(whirlwind duration %d)",
+ action->Data.Whirlwind.TTL);
// FIXME: more?
}
}
@@ -623,7 +621,7 @@
** @param file File pointer to save to
** @param action Pointer to action to save.
*/
-local void SaveSpellCondition(CLFile *file,ConditionInfo* condition)
+local void SaveSpellCondition(CLFile *file, ConditionInfo* condition)
{
char condstrings [3][10] = {
"true", /// CONDITION_TRUE
@@ -634,54 +632,54 @@
DebugCheck(!file);
DebugCheck(!condition);
- CLprintf(file,"( ");
+ CLprintf(file, "( ");
//
// First save data related to flags.
// NOTE: (int) is there to keep compilers happy.
//
- if (condition->Undead!=CONDITION_TRUE) {
- CLprintf(file,"undead %s ",condstrings[(int)condition->Undead]);
+ if (condition->Undead != CONDITION_TRUE) {
+ CLprintf(file, "undead %s ", condstrings[(int)condition->Undead]);
}
- if (condition->Organic!=CONDITION_TRUE) {
- CLprintf(file,"organic %s ",condstrings[(int)condition->Organic]);
+ if (condition->Organic != CONDITION_TRUE) {
+ CLprintf(file, "organic %s ", condstrings[(int)condition->Organic]);
}
- if (condition->Volatile!=CONDITION_TRUE) {
- CLprintf(file,"volatile %s ",condstrings[(int)condition->Volatile]);
+ if (condition->Volatile != CONDITION_TRUE) {
+ CLprintf(file, "volatile %s ", condstrings[(int)condition->Volatile]);
}
- if (condition->Hero!=CONDITION_TRUE) {
- CLprintf(file,"hero %s ",condstrings[(int)condition->Hero]);
+ if (condition->Hero != CONDITION_TRUE) {
+ CLprintf(file, "hero %s ", condstrings[(int)condition->Hero]);
}
- if (condition->Coward!=CONDITION_TRUE) {
- CLprintf(file,"coward %s ",condstrings[(int)condition->Coward]);
+ if (condition->Coward != CONDITION_TRUE) {
+ CLprintf(file, "coward %s ", condstrings[(int)condition->Coward]);
}
- if (condition->Alliance!=CONDITION_TRUE) {
- CLprintf(file,"alliance %s ",condstrings[(int)condition->Alliance]);
+ if (condition->Alliance != CONDITION_TRUE) {
+ CLprintf(file, "alliance %s ", condstrings[(int)condition->Alliance]);
}
- if (condition->Building!=CONDITION_TRUE) {
- CLprintf(file,"building %s ",condstrings[(int)condition->Building]);
+ if (condition->Building != CONDITION_TRUE) {
+ CLprintf(file, "building %s ", condstrings[(int)condition->Building]);
}
- if (condition->TargetSelf!=CONDITION_TRUE) {
- CLprintf(file,"self %s ",condstrings[(int)condition->TargetSelf]);
+ if (condition->TargetSelf != CONDITION_TRUE) {
+ CLprintf(file, "self %s ", condstrings[(int)condition->TargetSelf]);
}
//
// Min/Max vital percents
//
- CLprintf(file,"min-hp-percent %d ",condition->MinHpPercent);
- CLprintf(file,"max-hp-percent %d ",condition->MaxHpPercent);
- CLprintf(file,"min-mana-percent %d ",condition->MinManaPercent);
- CLprintf(file,"max-mana-percent %d ",condition->MaxManaPercent);
+ CLprintf(file, "min-hp-percent %d ", condition->MinHpPercent);
+ CLprintf(file, "max-hp-percent %d ", condition->MaxHpPercent);
+ CLprintf(file, "min-mana-percent %d ", condition->MinManaPercent);
+ CLprintf(file, "max-mana-percent %d ", condition->MaxManaPercent);
//
// Max buff ticks stuff
//
- CLprintf(file,"max-slow-ticks %d ",condition->MaxSlowTicks);
- CLprintf(file,"max-haste-ticks %d ",condition->MaxHasteTicks);
- CLprintf(file,"max-bloodlust-ticks %d ",condition->MaxBloodlustTicks);
- CLprintf(file,"max-invisibility-ticks %d
",condition->MaxInvisibilityTicks);
- CLprintf(file,"max-invincibility-ticks %d
",condition->MaxInvincibilityTicks);
+ CLprintf(file, "max-slow-ticks %d ", condition->MaxSlowTicks);
+ CLprintf(file, "max-haste-ticks %d ", condition->MaxHasteTicks);
+ CLprintf(file, "max-bloodlust-ticks %d ", condition->MaxBloodlustTicks);
+ CLprintf(file, "max-invisibility-ticks %d ",
condition->MaxInvisibilityTicks);
+ CLprintf(file, "max-invincibility-ticks %d ",
condition->MaxInvincibilityTicks);
//
// The end.
//
- CLprintf(file,")\n");
+ CLprintf(file, ")\n");
}
/*
@@ -690,7 +688,7 @@
** @param file The file to save to.
** @param autocast Auocastinfo to save.
*/
-void SaveSpellAutoCast(CLFile *file,AutoCastInfo* autocast)
+void SaveSpellAutoCast(CLFile* file, AutoCastInfo* autocast)
{
char condstrings [3][10] = {
"true", /// CONDITION_TRUE
@@ -698,15 +696,15 @@
"only" /// CONDITION_ONLY
};
- CLprintf(file,"( range %d ",autocast->Range);
- if (autocast->Combat!=CONDITION_TRUE) {
- CLprintf(file,"combat %s ",condstrings[(int)autocast->Combat]);
+ CLprintf(file, "( range %d ", autocast->Range);
+ if (autocast->Combat != CONDITION_TRUE) {
+ CLprintf(file, "combat %s ", condstrings[(int)autocast->Combat]);
}
if (autocast->Condition) {
- CLprintf(file," condition ");
- SaveSpellCondition(file,autocast->Condition);
+ CLprintf(file, " condition ");
+ SaveSpellCondition(file, autocast->Condition);
}
- CLprintf(file," )\n");
+ CLprintf(file, " )\n");
}
/*
@@ -714,40 +712,40 @@
**
** @param file The file to save to.
*/
-global void SaveSpells(CLFile *file)
+global void SaveSpells(CLFile* file)
{
- SpellType *spell;
+ SpellType* spell;
DebugCheck(!file);
for (spell = SpellTypeTable; spell < SpellTypeTable + SpellTypeCount;
++spell) {
- CLprintf(file,"(define-spell\n");
+ CLprintf(file, "(define-spell\n");
//
// Misc small stuff.
//
- CLprintf(file," \"%s\"\n",spell->IdentName);
- CLprintf(file," 'showname \"%s\"\n",spell->Name);
- CLprintf(file," 'manacost %d\n",spell->ManaCost);
- CLprintf(file," 'range %d\n",spell->Range);
+ CLprintf(file, " \"%s\"\n", spell->IdentName);
+ CLprintf(file, " 'showname \"%s\"\n", spell->Name);
+ CLprintf(file, " 'manacost %d\n", spell->ManaCost);
+ CLprintf(file, " 'range %d\n", spell->Range);
if (spell->SoundWhenCast.Name) {
- CLprintf(file," 'sound-when-cast
\"%s\"\n",spell->SoundWhenCast.Name);
+ CLprintf(file, " 'sound-when-cast \"%s\"\n",
spell->SoundWhenCast.Name);
}
if (spell->Missile) {
- CLprintf(file," 'missile-when-cast
\"%s\"\n",spell->Missile->Ident);
+ CLprintf(file, " 'missile-when-cast \"%s\"\n",
spell->Missile->Ident);
}
//
// Target type.
//
- CLprintf(file," 'target '");
+ CLprintf(file, " 'target '");
switch (spell->Target) {
case TargetSelf:
- CLprintf(file,"self\n");
+ CLprintf(file, "self\n");
break;
case TargetPosition:
- CLprintf(file,"position\n");
+ CLprintf(file, "position\n");
break;
case TargetUnit:
- CLprintf(file,"unit\n");
+ CLprintf(file, "unit\n");
break;
default:
DebugLevel0("Bad spell, can't save.\n");
@@ -756,34 +754,34 @@
//
// Save the action(effect of the spell)
//
- CLprintf(file," 'action '");
- SaveSpellAction(file,spell->Action);
- CLprintf(file,"\n");
+ CLprintf(file, " 'action '");
+ SaveSpellAction(file, spell->Action);
+ CLprintf(file, "\n");
//
// Save conditions
//
if (spell->Condition) {
- CLprintf(file," 'condition '");
- SaveSpellCondition(file,spell->Condition);
- CLprintf(file,"\n");
+ CLprintf(file, " 'condition '");
+ SaveSpellCondition(file, spell->Condition);
+ CLprintf(file, "\n");
}
//
// Save own unit autocast
//
if (spell->AutoCast) {
- CLprintf(file," 'autocast '");
- SaveSpellAutoCast(file,spell->AutoCast);
- CLprintf(file,"\n");
+ CLprintf(file, " 'autocast '");
+ SaveSpellAutoCast(file, spell->AutoCast);
+ CLprintf(file, "\n");
}
//
// Save AI autocast.
//
if (spell->AICast) {
- CLprintf(file," 'ai-cast '");
- SaveSpellAutoCast(file,spell->AICast);
- CLprintf(file,"\n");
+ CLprintf(file, " 'ai-cast '");
+ SaveSpellAutoCast(file, spell->AICast);
+ CLprintf(file, "\n");
}
- CLprintf(file,")\n");
+ CLprintf(file, ")\n");
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src action/action_spellcast.c clone/c...,
Jimmy Salmon <=