123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- //
- // Copyright 2020 Electronic Arts Inc.
- //
- // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
- // software: you can redistribute it and/or modify it under the terms of
- // the GNU General Public License as published by the Free Software Foundation,
- // either version 3 of the License, or (at your option) any later version.
- // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
- // in the hope that it will be useful, but with permitted additional restrictions
- // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
- // distributed with this program. You should have received a copy of the
- // GNU General Public License along with permitted additional restrictions
- // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
- /* $Header: F:\projects\c&c\vcs\code\sdata.cpv 2.17 16 Oct 1995 16:52:10 JOE_BOSTIC $ */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : SDATA.CPP *
- * *
- * Programmer : Joe L. Bostic *
- * *
- * Start Date : August 9, 1994 *
- * *
- * Last Update : August 12, 1994 [JLB] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * SmudgeTypeClass::Draw_It -- Renders the smudge image at the coordinate specified. *
- * SmudgeTypeClass::Create_One_Of -- Creates a smudge object of this type. *
- * SmudgeTypeClass::Create_And_Place -- Creates and places on map, a smudge object. *
- * SmudgeTypeClass::Prep_For_Add -- Prepares the scenario editor for adding a smudge object. *
- * SmudgeTypeClass::Init -- Performs theater specific initializations. *
- * SmudgeTypeClass::Display -- Draws a generic version of this smudge type. *
- * SmudgetypeClass::Occupy_List -- Determines occupation list for smudge object. *
- * SmudgeTypeClass::From_Name -- Converts an ASCII name into a smudge type. *
- * SmudgeTypeClass::SmudgeTypeClass -- Constructor for smudge type objects. *
- * SmudgeTypeClass::One_Time -- Performs one-time initialization *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- #include "type.h"
- static SmudgeTypeClass const Crater1 (
- SMUDGE_CRATER1,
- "CR1",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Crater2 (
- SMUDGE_CRATER2,
- "CR2",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Crater3 (
- SMUDGE_CRATER3,
- "CR3",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Crater4 (
- SMUDGE_CRATER4,
- "CR4",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Crater5 (
- SMUDGE_CRATER5,
- "CR5",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Crater6 (
- SMUDGE_CRATER6,
- "CR6",
- TXT_CRATER,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- true // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch1 (
- SMUDGE_SCORCH1,
- "SC1",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch2 (
- SMUDGE_SCORCH2,
- "SC2",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch3 (
- SMUDGE_SCORCH3,
- "SC3",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch4 (
- SMUDGE_SCORCH4,
- "SC4",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch5 (
- SMUDGE_SCORCH5,
- "SC5",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Scorch6 (
- SMUDGE_SCORCH6,
- "SC6",
- TXT_SCORCH,
- 1,1, // Width and height of smudge (in icons).
- false, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Bibx1 (
- SMUDGE_BIB1,
- "BIB1",
- TXT_BIB,
- 4,2, // Width and height of smudge (in icons).
- true, // Is this a building bib?
- false // Is this a crater smudge?
- );
- static SmudgeTypeClass const Bibx2 (
- SMUDGE_BIB2,
- "BIB2",
- TXT_BIB,
- 3,2, // Width and height of smudge (in icons).
- true, // Is this a building bib?
- false // Is this a crater smudge?
- );
- /*
- ** The watcom code optimiser screws up the last constructor call. Making it 'volatile' reduces the
- ** level of optimisation enough for the problem not to manifest.
- */
- volatile SmudgeTypeClass const Bibx3 (
- SMUDGE_BIB3,
- "BIB3",
- TXT_BIB,
- 2,2, // Width and height of smudge (in icons).
- true, // Is this a building bib?
- false // Is this a crater smudge?
- );
- /*
- ** Working array to the smudge control objects types. This routine is
- ** used for quick conversion from a SmudgeType number into an actual
- ** smudge type object pointer.
- */
- SmudgeTypeClass const * const SmudgeTypeClass::Pointers[SMUDGE_COUNT] = {
- &Crater1, // SMUDGE_CRATER1
- &Crater2, // SMUDGE_CRATER2
- &Crater3, // SMUDGE_CRATER3
- &Crater4, // SMUDGE_CRATER4
- &Crater5, // SMUDGE_CRATER5
- &Crater6, // SMUDGE_CRATER6
- &Scorch1, // SMUDGE_SCORCH1
- &Scorch2, // SMUDGE_SCORCH2
- &Scorch3, // SMUDGE_SCORCH3
- &Scorch4, // SMUDGE_SCORCH4
- &Scorch5, // SMUDGE_SCORCH5
- &Scorch6, // SMUDGE_SCORCH6
- &Bibx1, // SMUDGE_BIB1
- &Bibx2, // SMUDGE_BIB2
- (SmudgeTypeClass const * const)&Bibx3 // SMUDGE_BIB3
- };
- /***********************************************************************************************
- * SmudgeTypeClass::SmudgeTypeClass -- Constructor for smudge type objects. *
- * *
- * This constructor is used to create the smudge type objects. These type objects contain *
- * static information about the various smudge types supported in the game. *
- * *
- * INPUT: see below... *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- SmudgeTypeClass::SmudgeTypeClass(SmudgeType smudge, char const *ininame, int fullname, int width, int height, bool isbib, bool iscrater) :
- ObjectTypeClass(false, false, false, true, false, false, true, true, fullname, ininame, ARMOR_NONE, 0)
- {
- IsBib = isbib;
- Width = width;
- Height = height;
- IsCrater = iscrater;
- Type = smudge;
- }
- /***********************************************************************************************
- * SmudgeTypeClass::From_Name -- Converts an ASCII name into a smudge type. *
- * *
- * This converts an ASCII name into a smudge type number. This is typically necessary *
- * when processing scenario INI files and not used otherwise. *
- * *
- * INPUT: name -- Pointer to the name to convert. *
- * *
- * OUTPUT: Returns with the SmudgeType number that matches the name supplied. If no match *
- * was found, then SMUDGE_NONE is returned. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- SmudgeType SmudgeTypeClass::From_Name(char const *name)
- {
- if (name) {
- for (SmudgeType index = SMUDGE_FIRST; index < SMUDGE_COUNT; index++) {
- if (stricmp(As_Reference(index).IniName, name) == 0) {
- return(index);
- }
- }
- }
- return(SMUDGE_NONE);
- }
- /***********************************************************************************************
- * SmudgetypeClass::Occupy_List -- Determines occupation list for smudge object. *
- * *
- * Smudges are always only one icon in dimension, so this routine always returns a cell *
- * occupation offset list of the center cell. *
- * *
- * INPUT: placement -- Is this for placement legality checking only? The normal condition *
- * is for marking occupation flags. *
- * *
- * OUTPUT: Returns occupation list specifying all the cells that the overlay occupies. This *
- * is just the center cell. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- short const * SmudgeTypeClass::Occupy_List(bool) const
- {
- static short _occupy[4*4];
- short * ptr = &_occupy[0];
- for (int x = 0; x < Width; x++) {
- for (int y = 0; y < Height; y++) {
- *ptr++ = x + (y*MAP_CELL_W);
- }
- }
- *ptr = REFRESH_EOL;
- return(_occupy);
- }
- /***********************************************************************************************
- * SmudgeTypeClass::Init -- Performs theater specific initializations. *
- * *
- * Smudge object imagery varies between theaters. This routine will load the appropriate *
- * imagery for the theater specified. *
- * *
- * INPUT: theater -- The theater to prepare for. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- void SmudgeTypeClass::Init(TheaterType theater)
- {
- if (theater != LastTheater){
- for (SmudgeType index = SMUDGE_FIRST; index < SMUDGE_COUNT; index++) {
- SmudgeTypeClass const & smudge = As_Reference(index);
- char fullname[_MAX_FNAME+_MAX_EXT]; // Fully constructed smudge data set name.
- _makepath(fullname, NULL, NULL, smudge.IniName, Theaters[theater].Suffix);
- ((void const *&)smudge.ImageData) = MixFileClass::Retrieve(fullname);
- }
- }
- }
- #ifdef SCENARIO_EDITOR
- /***********************************************************************************************
- * SmudgeTypeClass::Display -- Draws a generic version of this smudge type. *
- * *
- * The scenario object editor will call this routine to display a typical imagery of this *
- * smudge object for graphical identification purposes. *
- * *
- * INPUT: x,y -- Coordinate to render the smudge at. *
- * *
- * window-- The window to base the coordinate rendering upon. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- void SmudgeTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
- {
- void const *ptr = Get_Image_Data();
- x += WindowList[window][WINDOWX] << 3;
- y += WindowList[window][WINDOWY];
- if (ptr) {
- for (int w = 0; w < Width; w++) {
- for (int h = 0; h < Height; h++) {
- CC_Draw_Shape(ptr, 0, x + w*ICON_PIXEL_W, y + h*ICON_PIXEL_H, WINDOW_TACTICAL, SHAPE_WIN_REL);
- //LogicPage->Draw_Stamp(ptr, w + (h*Width), x + w*ICON_PIXEL_W, y + h*ICON_PIXEL_H, NULL, WINDOW_TACTICAL);
- }
- }
- }
- }
- /***********************************************************************************************
- * SmudgeTypeClass::Prep_For_Add -- Prepares the scenario editor for adding a smudge object. *
- * *
- * This routine adds smudge objects to the list of objects that the scenario editor can *
- * place upon the ground. It is only called from the scenario editor. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- void SmudgeTypeClass::Prep_For_Add(void)
- {
- for (SmudgeType index = SMUDGE_FIRST; index < SMUDGE_COUNT; index++) {
- if (As_Reference(index).Get_Image_Data()) {
- Map.Add_To_List(&As_Reference(index));
- }
- }
- }
- #endif
- /***********************************************************************************************
- * SmudgeTypeClass::Create_And_Place -- Creates and places on map, a smudge object. *
- * *
- * This routine will, in one motion, create a smudge object and place it upon the map. *
- * Since placing a smudge on the map will destroy the object, this routine will leave the *
- * smudge object count unchanged. Typically, this routine is used by the scenario editor *
- * for creating smudges and placing them on the map. *
- * *
- * INPUT: cell -- The cell to place the smudge object. *
- * *
- * OUTPUT: bool; Was the placement successful? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- bool SmudgeTypeClass::Create_And_Place(CELL cell, HousesType ) const
- {
- if (new SmudgeClass(Type, Cell_Coord(cell))) {
- return(true);
- }
- return(false);
- }
- /***********************************************************************************************
- * SmudgeTypeClass::Create_One_Of -- Creates a smudge object of this type. *
- * *
- * This routine will create a smudge object of the appropriate type. Smudge objects are *
- * transitory in nature. They exist only from the point of creation until they are given *
- * a spot on the map to reside. At that time the map data is updated and the smudge *
- * object is destroyed. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with a pointer to a created smudge object. If none could be created, then *
- * NULL is returned. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- ObjectClass * SmudgeTypeClass::Create_One_Of(HouseClass *) const
- {
- return(new SmudgeClass(Type, -1));
- }
- /***********************************************************************************************
- * SmudgeTypeClass::Draw_It -- Renders the smudge image at the coordinate specified. *
- * *
- * This routine will draw the smudge overlay image at the coordinate (upper left) *
- * specified. The underlying terrain icon is presumed to have already been rendered. *
- * *
- * INPUT: x,y -- Coordinate of the upper left corner of icon to render the smudge object. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- void SmudgeTypeClass::Draw_It(int x, int y, int data) const
- {
- void const * ptr = Get_Image_Data();
- if (ptr) {
- IsTheaterShape = true; // Smudges are theater specific
- CC_Draw_Shape(ptr, data, x, y, WINDOW_TACTICAL, SHAPE_WIN_REL);
- IsTheaterShape = false;
- // LogicPage->Draw_Stamp(ptr, data, x, y, NULL, WINDOW_TACTICAL);
- }
- }
- /***********************************************************************************************
- * SmudgeTypeClass::One_Time -- Performs one-time initialization *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/12/1994 JLB : Created. *
- *=============================================================================================*/
- void SmudgeTypeClass::One_Time(void)
- {
- }
|