____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

groups.cpp File Reference

The units' groups handling. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"
#include "script.h"
#include "player.h"
#include "iolib.h"

Go to the source code of this file.

Classes

struct  CUnitGroup

Functions

void InitGroups (void)
 < Initialize data structures for groups
void SaveGroups (CFile *file)
 Cleanup groups.
void CleanGroups (void)
int GetNumberUnitsOfGroup (int num)
 < Get the number of units in a particular group
CUnit ** GetUnitsOfGroup (int num)
 Remove all units from a group.
void ClearGroup (int num)
 Add the array of units to the group.
void AddToGroup (CUnit **units, int nunits, int num)
 Set the contents of a particular group with an array of units.
void SetGroup (CUnit **units, int nunits, int num)
 Remove a unit from a group.
void RemoveUnitFromGroups (CUnit *unit)
 Register CCL group features.
static int CclGroup (lua_State *l)
void GroupCclRegister (void)

Variables

static CUnitGroup Groups [NUM_GROUPS]
 Number of groups predefined.


Detailed Description

The units' groups handling.

Definition in file groups.cpp.


Function Documentation

void AddToGroup ( CUnit **  units,
int  nunits,
int  num 
)

Set the contents of a particular group with an array of units.

Add units to group num contents from unit array "units"

Parameters:
units Array of units to place into group.
nunits Number of units in array.
num Group number for storage.

Definition at line 160 of file groups.cpp.

References Assert, CUnit::GroupId, CPlayer::IsTeamed(), MaxSelectable, NUM_GROUPS, CUnitGroup::NumUnits, CUnitType::SelectableByRectangle, ThisPlayer, CUnit::Type, and CUnitGroup::Units.

Referenced by SetGroup(), and UiAddToGroup().

static int CclGroup ( lua_State *  l  )  [static]

Define the group.

Parameters:
l Lua state.

Definition at line 242 of file groups.cpp.

References InitGroups(), int(), LuaCheckArgs, LuaToNumber(), LuaToString(), CUnitGroup::NumUnits, CUnitGroup::Units, and UnitSlots.

Referenced by GroupCclRegister().

void CleanGroups ( void   ) 

Clean up group part.

Definition at line 102 of file groups.cpp.

References NUM_GROUPS, CUnitGroup::NumUnits, and CUnitGroup::Units.

Referenced by CleanGame(), and CleanModules().

void ClearGroup ( int  num  ) 

Add the array of units to the group.

Clear contents of group num

Parameters:
num Group number.

Definition at line 140 of file groups.cpp.

References Assert, CUnit::Destroyed, CUnit::GroupId, CUnitGroup::NumUnits, and CUnitGroup::Units.

Referenced by SetGroup().

int GetNumberUnitsOfGroup ( int  num  ) 

< Get the number of units in a particular group

Return the number of units of group num

Parameters:
num Group number.
Returns:
Returns the number of units in the group.

Definition at line 118 of file groups.cpp.

References CUnitGroup::NumUnits.

Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().

CUnit** GetUnitsOfGroup ( int  num  ) 

Remove all units from a group.

Return the units of group num

Parameters:
num Group number.
Returns:
Returns an array of all units in the group.

Definition at line 130 of file groups.cpp.

References CUnitGroup::Units.

Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().

void GroupCclRegister ( void   ) 

Register CCL features for groups.

Definition at line 271 of file groups.cpp.

References CclGroup(), and Lua.

Referenced by InitCcl().

void InitGroups ( void   ) 

< Initialize data structures for groups

Initialize group part.

Todo:
Not needed with the new unit code!

Definition at line 71 of file groups.cpp.

References MaxSelectable, NUM_GROUPS, CUnitGroup::Units, and Units.

Referenced by CclGroup(), CreateGame(), and InitModules().

void RemoveUnitFromGroups ( CUnit unit  ) 

Register CCL group features.

Remove unit from its groups

Parameters:
unit Unit to remove from group.

Definition at line 207 of file groups.cpp.

References Assert, CUnit::GroupId, CUnitGroup::NumUnits, NumUnits, and CUnitGroup::Units.

Referenced by UnitLost().

void SaveGroups ( CFile file  ) 

Cleanup groups.

Save groups.

Parameters:
file Output file.

Definition at line 85 of file groups.cpp.

References NUM_GROUPS, CUnitGroup::NumUnits, NumUnits, CFile::printf(), UnitReference(), and Units.

Referenced by SaveGame().

void SetGroup ( CUnit **  units,
int  nunits,
int  num 
)

Remove a unit from a group.

Set group num contents to unit array "units"

Parameters:
units Array of units to place into group.
nunits Number of units in array.
num Group number for storage.

Definition at line 194 of file groups.cpp.

References AddToGroup(), Assert, ClearGroup(), MaxSelectable, and NUM_GROUPS.

Referenced by UiDefineGroup().


Variable Documentation

CUnitGroup Groups[NUM_GROUPS] [static]

Number of groups predefined.

Definition at line 60 of file groups.cpp.


Generated on Sat Feb 21 00:28:16 2009 for Bos Wars by  doxygen 1.5.6