mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Merge branch 'master' into master
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
* Functions: *
|
||||
* fixed::As_ASCII -- Returns a pointer (static) of this number as an ASCII string. *
|
||||
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
||||
* fixed::To_Float -- Convert a fixed point number into a float value *
|
||||
* fixed::fixed -- Constructor for fixed integral from ASCII initializer. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
@@ -40,6 +41,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/*
|
||||
@@ -148,6 +150,33 @@ fixed::fixed(char const * ascii)
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* fixed::To_Float -- Convert a fixed point number into a float *
|
||||
* *
|
||||
* Use this routine to convert this fixed point number into a float. This can be lossy for *
|
||||
* fine values. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: Returns with the float value of this fixed point number *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/27/2020 JJ : Created. *
|
||||
*=============================================================================================*/
|
||||
float fixed::To_Float() const
|
||||
{
|
||||
|
||||
unsigned int whole = Data.Composite.Whole;
|
||||
unsigned int frac = ((unsigned int)Data.Composite.Fraction * 1000U) / PRECISION;
|
||||
|
||||
float this_raw_value = (whole + (frac * .001));
|
||||
|
||||
return floor(this_raw_value * 100.0 + 0.5) / 100.0;
|
||||
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
||||
* *
|
||||
|
||||
@@ -206,6 +206,11 @@ class fixed
|
||||
int To_ASCII(char * buffer, int maxlen=-1) const;
|
||||
char const * As_ASCII(void) const;
|
||||
|
||||
/*
|
||||
** Helper function to convert fixed point number to float (JJ)
|
||||
*/
|
||||
float To_Float() const;
|
||||
|
||||
/*
|
||||
** Helper constants that provide some convenient fixed point values.
|
||||
*/
|
||||
|
||||
+7376
-4057
File diff suppressed because it is too large
Load Diff
+117
-1
@@ -1,4 +1,4 @@
|
||||
// MapScript.h
|
||||
// mapscript.h
|
||||
//
|
||||
|
||||
#ifndef MAPSCRIPT_H
|
||||
@@ -15,11 +15,22 @@ extern "C" {
|
||||
// Object Cache Item
|
||||
// Stores an id lookup table
|
||||
struct MapScriptObject {
|
||||
|
||||
int UID; // The UID of the object (to prevent ID collisions)
|
||||
|
||||
int ID=-1; // The object's "Global ID"
|
||||
int classIndex=-1; // The object's "Global ID"
|
||||
RTTIType RTTI; // The type of object
|
||||
|
||||
};
|
||||
|
||||
// Stores defaults of object attributes whenever they are changed for the first time (for later restoration)
|
||||
struct MapScriptDefaultObjectAttribute {
|
||||
RTTIType RTTI; // The type of object
|
||||
int ID=-1; // The index of the object in its heap
|
||||
int attribute;
|
||||
int value;
|
||||
};
|
||||
|
||||
//
|
||||
// MapScript Class
|
||||
@@ -27,6 +38,7 @@ struct MapScriptObject {
|
||||
class MapScript {
|
||||
public:
|
||||
|
||||
int cUID = 0;
|
||||
|
||||
~MapScript() { Deinit(); };
|
||||
|
||||
@@ -34,15 +46,114 @@ public:
|
||||
bool Init(const char* mapName);
|
||||
void Deinit();
|
||||
|
||||
MapScriptObject* CreateCacheObject();
|
||||
|
||||
void CallFunction(const char* functionName);
|
||||
void SetLuaPath(const char* input_path);
|
||||
|
||||
std::vector<MapScriptObject*> ObjectCache;
|
||||
std::vector<MapScriptDefaultObjectAttribute*> DefaultObjectTypeAttributeCache;
|
||||
|
||||
private:
|
||||
lua_State* L;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Enums
|
||||
typedef enum MapScriptObjectAttributeType : char {
|
||||
|
||||
// Techno types
|
||||
ATTRIBUTE_TYPE=0,
|
||||
ATTRIBUTE_STRENGTH,
|
||||
ATTRIBUTE_MAX_STRENGTH,
|
||||
ATTRIBUTE_COST,
|
||||
ATTRIBUTE_SIGHT_RANGE,
|
||||
ATTRIBUTE_TECH_LEVEL,
|
||||
ATTRIBUTE_ARMOR,
|
||||
ATTRIBUTE_PRIMARY_WEAPON,
|
||||
ATTRIBUTE_SECONDARY_WEAPON,
|
||||
ATTRIBUTE_SPEED,
|
||||
ATTRIBUTE_MAX_SPEED,
|
||||
ATTRIBUTE_MAX_AMMO,
|
||||
ATTRIBUTE_ROTATION_SPEED,
|
||||
ATTRIBUTE_CRUSHABLE,
|
||||
ATTRIBUTE_STEALTHY,
|
||||
ATTRIBUTE_SELECTABLE,
|
||||
ATTRIBUTE_LEGAL_TARGET,
|
||||
ATTRIBUTE_REPAIRABLE,
|
||||
ATTRIBUTE_SELF_HEALING,
|
||||
ATTRIBUTE_EXPLODES,
|
||||
ATTRIBUTE_HAS_CREW,
|
||||
ATTRIBUTE_MAX_PASSENGERS,
|
||||
ATTRIBUTE_IS_REPAIRING,
|
||||
|
||||
// Building Specific
|
||||
ATTRIBUTE_CAPACITY,
|
||||
ATTRIBUTE_POWER,
|
||||
ATTRIBUTE_SELLABLE,
|
||||
|
||||
// Unit Specific
|
||||
ATTRIBUTE_CRATE_GOODIE,
|
||||
ATTRIBUTE_CRUSHER,
|
||||
ATTRIBUTE_HARVEST,
|
||||
ATTRIBUTE_RADAR_EQUIPPED,
|
||||
ATTRIBUTE_JAMMER,
|
||||
ATTRIBUTE_GAPPER,
|
||||
|
||||
// Infantry Specific
|
||||
ATTRIBUTE_FEMALE,
|
||||
ATTRIBUTE_CAPTURE,
|
||||
ATTRIBUTE_FRAIDY_CAT,
|
||||
ATTRIBUTE_CIVILIAN,
|
||||
ATTRIBUTE_BOMBER,
|
||||
ATTRIBUTE_DOG
|
||||
|
||||
|
||||
} MapScriptObjectAttributeType;
|
||||
|
||||
// Enums
|
||||
typedef enum MapScriptHouseAttributeType : char {
|
||||
|
||||
// Techno types
|
||||
HOUSE_ATTRIBUTE_IQ = 0,
|
||||
HOUSE_ATTRIBUTE_TECH_LEVEL,
|
||||
HOUSE_ATTRIBUTE_IS_HUMAN,
|
||||
HOUSE_ATTRIBUTE_FIREPOWER_BIAS,
|
||||
HOUSE_ATTRIBUTE_GROUNDSPEED_BIAS,
|
||||
HOUSE_ATTRIBUTE_ARMOR_BIAS,
|
||||
HOUSE_ATTRIBUTE_ROF_BIAS,
|
||||
HOUSE_ATTRIBUTE_COST_BIAS,
|
||||
HOUSE_ATTRIBUTE_REPAIR_DELAY,
|
||||
HOUSE_ATTRIBUTE_BUILD_DELAY,
|
||||
HOUSE_ATTRIBUTE_STARTED,
|
||||
HOUSE_ATTRIBUTE_ALERTED,
|
||||
HOUSE_ATTRIBUTE_BASE_BUILDING,
|
||||
HOUSE_ATTRIBUTE_DISCOVERED,
|
||||
HOUSE_ATTRIBUTE_CAPACITY,
|
||||
HOUSE_ATTRIBUTE_TIBERIUM,
|
||||
HOUSE_ATTRIBUTE_CREDITS,
|
||||
HOUSE_ATTRIBUTE_ALERT_TIMER,
|
||||
HOUSE_ATTRIBUTE_REPAIR_TIMER,
|
||||
HOUSE_ATTRIBUTE_POINTS,
|
||||
HOUSE_ATTRIBUTE_DESTROYED_BUILDINGS,
|
||||
HOUSE_ATTRIBUTE_DESTROYED_VEHICLES,
|
||||
HOUSE_ATTRIBUTE_DESTROYED_INFANTRY,
|
||||
HOUSE_ATTRIBUTE_DESTROYED_AIRCRAFT,
|
||||
HOUSE_ATTRIBUTE_DESTROYED_VESSELS,
|
||||
HOUSE_ATTRIBUTE_CAPTURED_BUILDINGS,
|
||||
HOUSE_ATTRIBUTE_CRATES,
|
||||
HOUSE_ATTRIBUTE_BUILDING_FACTORIES,
|
||||
HOUSE_ATTRIBUTE_UNIT_FACTORIES,
|
||||
HOUSE_ATTRIBUTE_INFANTRY_FACTORIES,
|
||||
HOUSE_ATTRIBUTE_AIRCRAFT_FACTORIES,
|
||||
HOUSE_ATTRIBUTE_VESSEL_FACTORIES,
|
||||
HOUSE_ATTRIBUTE_POWER,
|
||||
HOUSE_ATTRIBUTE_DRAIN,
|
||||
HOUSE_ATTRIBUTE_LAST_ATTACKER
|
||||
|
||||
} MapScriptHouseAttributeType;
|
||||
|
||||
// Non-Class-Functions
|
||||
bool Script_SetObjectTrigger(int input_object_id, TriggerClass* input_trigger);
|
||||
ObjectClass* Script_GetCacheObject(int input_object_id);
|
||||
@@ -53,4 +164,9 @@ int Script_AircraftIndexFromID(int input_object_id);
|
||||
int Script_InfantryIndexFromID(int input_object_id);
|
||||
int Script_VesselIndexFromID(int input_object_id);
|
||||
|
||||
static int Script_SetObjectTypeAttribute(lua_State* L, TechnoTypeClass* this_type_class, MapScriptObjectAttributeType attribute_type);
|
||||
static int Script_GetObjectTypeAttribute(lua_State* L, TechnoTypeClass* this_type_class, MapScriptObjectAttributeType attribute_type);
|
||||
|
||||
void Script_CacheDefaultObjectTypeAttribute(RTTIType input_rtti, int input_id, MapScriptObjectAttributeType input_attribute, int input_value);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user