Skip to content

Commit

Permalink
- general cleanup
Browse files Browse the repository at this point in the history
- added some new entries to the lua Game table
  (which should be converted to a userdata access table)
- added the chi.png image for ico_customicons
  (for displaying enemy units of unknown type)



git-svn-id: https://spring.clan-sy.com/svn/spring/trunk@5953 37977431-3df6-0310-b722-df95706aa16b
  • Loading branch information
trepan committed May 26, 2008
1 parent 7663fbf commit e3e61e7
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 144 deletions.
Binary file added game/LuaUI/Icons/chi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions game/LuaUI/Widgets/ico_customicons.lua
Expand Up @@ -42,7 +42,8 @@ local unitIcons = {
-- radiusadjust = false,
-- distance = 1.0,
-- },
{ name = 'default', size = 1.0, texture = '' },
{ name = 'default', size = 1.0, texture = iconDir..'chi.png' },
{ name = 'default.user', size = 1.0, texture = '' },
{ name = 'star.user', size = 1.5, texture = iconDir..'star.png' },
{ name = 'star-dark.user', size = 1.4, texture = iconDir..'star-dark.png' },
{ name = 'tri-up.user', size = 1.5, texture = iconDir..'tri-up.png' },
Expand Down Expand Up @@ -166,7 +167,7 @@ function widget:Initialize()
end
else
-- FIXME: allow unknowns to use mod icons?
Spring.SetUnitDefIcon(udid, "default")
Spring.SetUnitDefIcon(udid, "default.user")
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions installer/builddata/springcontent/gamedata/sidedata.lua
@@ -1,9 +1,9 @@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: sidedata.lua
-- brief: sidedata.tdf lua parser
-- author: Craig Lawrence, Dave Rodgers
-- file: sidedata.lua
-- brief: sidedata.tdf lua parser
-- authors: Dave Rodgers, Craig Lawrence
--
-- Copyright (C) 2007.
-- Licensed under the terms of the GNU GPL, v2 or later.
Expand Down
11 changes: 8 additions & 3 deletions rts/Game/Game.cpp
Expand Up @@ -210,6 +210,8 @@ CGame::CGame(std::string mapname, std::string modName, CInfoConsole *ic, CLoadSa
timeLeft = 0.0f;
consumeSpeed = 1.0f;

memset(gameID, 0, sizeof(gameID));

infoConsole = ic;

script = NULL;
Expand Down Expand Up @@ -396,7 +398,7 @@ CGame::CGame(std::string mapname, std::string modName, CInfoConsole *ic, CLoadSa
defsParser = NULL;

ENTER_UNSYNCED;
sky=CBaseSky::GetSky();
sky = CBaseSky::GetSky();

resourceBar = SAFE_NEW CResourceBar();
keyCodes = SAFE_NEW CKeyCodes();
Expand Down Expand Up @@ -473,10 +475,12 @@ CGame::CGame(std::string mapname, std::string modName, CInfoConsole *ic, CLoadSa

chatSound = sound->GetWaveId("sounds/beep4.wav");

if (!saveFile) UnloadStartPicture();
if (!saveFile) {
UnloadStartPicture();
}

net->loading = false;
thread.join();
thread.join();
logOutput.Print("Spring %s",VERSION_STRING);
//sending your playername to the server indicates that you are finished loading
net->SendPlayerName(gu->myPlayerNum, p->playerName);
Expand Down Expand Up @@ -3368,6 +3372,7 @@ void CGame::ClientReadNet()
if (record != NULL) {
record->SetGameID(p);
}
memcpy(gameID, p, sizeof(gameID));
logOutput.Print(
"GameID: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7],
Expand Down
2 changes: 2 additions & 0 deletions rts/Game/Game.h
Expand Up @@ -99,6 +99,8 @@ class CGame : public CGameController
float gameSoundVolume;
float unitReplyVolume;

unsigned char gameID[16];

CScript* script;

CInfoConsole *infoConsole;
Expand Down
2 changes: 0 additions & 2 deletions rts/Game/UI/MiniMap.cpp
Expand Up @@ -349,15 +349,13 @@ void CMiniMap::ConfigCommand(const std::string& line)
else if (command == "drawcommands") {
if (words.size() >= 2) {
drawCommands = std::max(0, atoi(words[1].c_str()));

} else {
drawCommands = (drawCommands > 0) ? 0 : 1;
}
}
else if (command == "drawprojectiles") {
if (words.size() >= 2) {
drawProjectiles = !!atoi(words[1].c_str());

} else {
drawProjectiles = !drawProjectiles;
}
Expand Down
85 changes: 57 additions & 28 deletions rts/Lua/LuaConstGame.cpp
Expand Up @@ -8,7 +8,7 @@
#include "LuaInclude.h"

#include "LuaUtils.h"
#include "Sim/Units/CommandAI/Command.h"
#include "Game/Game.h"
#include "Game/GameSetup.h"
#include "Game/GameVersion.h"
#include "Map/MapDamage.h"
Expand All @@ -20,6 +20,7 @@
#include "Sim/Misc/DamageArrayHandler.h"
#include "Sim/Misc/Wind.h"
#include "Sim/Units/UnitDef.h" // MAX_UNITS
#include "Sim/Units/CommandAI/Command.h"
#include "System/FileSystem/ArchiveScanner.h"


Expand All @@ -40,12 +41,20 @@ static void LuaPushNamedColor(lua_State* L,

bool LuaConstGame::PushEntries(lua_State* L)
{

// FIXME -- this is getting silly, convert to userdata?

const float gravity = -(mapInfo->map.gravity * GAME_SPEED * GAME_SPEED);
const bool limitDGun = gameSetup ? gameSetup->limitDgun : false;
const bool diminishingMMs = gameSetup ? gameSetup->diminishingMMs : false;
const bool ghostedBuildings = gameSetup ? gameSetup->ghostedBuildings : false;
const int startPosType = gameSetup ? gameSetup->startPosType : 0;

// FIXME -- loaded too early - not set yet (another reason to use userdata)
lua_pushliteral(L, "gameID");
lua_pushlstring(L, (const char*)game->gameID, sizeof(game->gameID));
lua_rawset(L, -3);

LuaPushNamedString(L, "version", VERSION_STRING);

LuaPushNamedNumber(L, "maxUnits", MAX_UNITS);
Expand All @@ -62,33 +71,53 @@ bool LuaConstGame::PushEntries(lua_State* L)
LuaPushNamedBool(L, "diminishingMetal", diminishingMMs);
LuaPushNamedBool(L, "ghostedBuildings", ghostedBuildings);

LuaPushNamedBool(L, "mapDamage", !mapDamage->disabled);
LuaPushNamedNumber(L, "gravity", gravity);
LuaPushNamedNumber(L, "windMin", wind.GetMinWind());
LuaPushNamedNumber(L, "windMax", wind.GetMaxWind());
LuaPushNamedString(L, "mapName", mapInfo->map.name);
LuaPushNamedString(L, "mapHumanName", mapInfo->map.humanName);
LuaPushNamedNumber(L, "mapX", readmap->width / 64);
LuaPushNamedNumber(L, "mapY", readmap->height / 64);
LuaPushNamedNumber(L, "mapSizeX", readmap->width * SQUARE_SIZE);
LuaPushNamedNumber(L, "mapSizeZ", readmap->height * SQUARE_SIZE);
LuaPushNamedNumber(L, "extractorRadius", mapInfo->map.extractorRadius);
LuaPushNamedNumber(L, "tidal", mapInfo->map.tidalStrength);
LuaPushNamedString(L, "waterTexture", mapInfo->water.texture);
LuaPushNamedBool(L, "waterVoid", mapInfo->map.voidWater);
LuaPushNamedBool(L, "waterPlane", mapInfo->hasWaterPlane);
LuaPushNamedColor(L, "waterAbsorb", mapInfo->water.absorb);
LuaPushNamedColor(L, "waterBaseColor", mapInfo->water.baseColor);
LuaPushNamedColor(L, "waterMinColor", mapInfo->water.minColor);
LuaPushNamedColor(L, "waterSurfaceColor", mapInfo->water.surfaceColor);
LuaPushNamedNumber(L, "waterSurfaceAlpha", mapInfo->water.surfaceAlpha);
LuaPushNamedColor(L, "waterSpecularColor", mapInfo->water.specularColor);
LuaPushNamedNumber(L, "waterSpecularFactor", mapInfo->water.specularFactor);
LuaPushNamedColor(L, "waterPlaneColor", mapInfo->water.planeColor);
LuaPushNamedColor(L, "fogColor", mapInfo->atmosphere.fogColor);
LuaPushNamedColor(L, "groundAmbientColor", mapInfo->light.groundAmbientColor);
LuaPushNamedColor(L, "groundSpecularColor", mapInfo->light.groundSpecularColor);
LuaPushNamedColor(L, "groundSunColor", mapInfo->light.groundSunColor);
const CMapInfo* mi = mapInfo;

LuaPushNamedBool(L, "mapDamage", !mapDamage->disabled);
LuaPushNamedNumber(L, "gravity", gravity);
LuaPushNamedNumber(L, "windMin", wind.GetMinWind());
LuaPushNamedNumber(L, "windMax", wind.GetMaxWind());
LuaPushNamedString(L, "mapName", mi->map.name);
LuaPushNamedString(L, "mapHumanName", mi->map.humanName);
LuaPushNamedNumber(L, "mapX", readmap->width / 64);
LuaPushNamedNumber(L, "mapY", readmap->height / 64);
LuaPushNamedNumber(L, "mapSizeX", readmap->width * SQUARE_SIZE);
LuaPushNamedNumber(L, "mapSizeZ", readmap->height * SQUARE_SIZE);
LuaPushNamedNumber(L, "extractorRadius", mi->map.extractorRadius);
LuaPushNamedNumber(L, "tidal", mi->map.tidalStrength);
LuaPushNamedNumber(L, "waterDamage", mi->water.damage);
LuaPushNamedString(L, "waterTexture", mi->water.texture);
LuaPushNamedNumber(L, "waterRepeatX", mi->water.repeatX);
LuaPushNamedNumber(L, "waterRepeatY", mi->water.repeatY);
LuaPushNamedString(L, "waterFoamTexture", mi->water.foamTexture);
LuaPushNamedString(L, "waterNormalTexture", mi->water.normalTexture);
LuaPushNamedBool(L, "waterVoid", mi->map.voidWater);
LuaPushNamedBool(L, "waterPlane", mi->hasWaterPlane);
LuaPushNamedColor(L, "waterAbsorb", mi->water.absorb);
LuaPushNamedColor(L, "waterBaseColor", mi->water.baseColor);
LuaPushNamedColor(L, "waterMinColor", mi->water.minColor);
LuaPushNamedColor(L, "waterSurfaceColor", mi->water.surfaceColor);
LuaPushNamedNumber(L, "waterSurfaceAlpha", mi->water.surfaceAlpha);
LuaPushNamedColor(L, "waterSpecularColor", mi->water.specularColor);
LuaPushNamedNumber(L, "waterSpecularFactor", mi->water.specularFactor);
LuaPushNamedColor(L, "waterPlaneColor", mi->water.planeColor);
LuaPushNamedNumber(L, "waterFresnelMin", mi->water.fresnelMin);
LuaPushNamedNumber(L, "waterFresnelMax", mi->water.fresnelMax);
LuaPushNamedNumber(L, "waterFresnelPower", mi->water.fresnelPower);
LuaPushNamedColor(L, "fogColor", mi->atmosphere.fogColor);
LuaPushNamedColor(L, "groundAmbientColor", mi->light.groundAmbientColor);
LuaPushNamedColor(L, "groundSpecularColor", mi->light.groundSpecularColor);
LuaPushNamedColor(L, "groundSunColor", mi->light.groundSunColor);

const string* causticTexs = mi->water.causticTextures;
lua_pushstring(L, "waterCausticTextures");
lua_newtable(L);
for (int i = 0; i < CMapInfo::causticTextureCount; i++) {
lua_pushnumber(L, i + 1);
lua_pushstring(L, causticTexs[i].c_str());
lua_rawset(L, -3);
}
lua_rawset(L, -3);

LuaPushNamedString(L, "modName", modInfo.humanName);
LuaPushNamedString(L, "modShortName", modInfo.shortName);
Expand Down
8 changes: 0 additions & 8 deletions rts/Lua/LuaUnitDefs.cpp
Expand Up @@ -745,14 +745,6 @@ ADD_BOOL("canAttackWater", canAttackWater); // CUSTOM
ADD_INT("armorType", ud.armorType);
ADD_FLOAT("armoredMultiple", ud.armoredMultiple);

/*
ADD_FLOAT("hitSphereScale", ud.collisionSphereScale);
ADD_FLOAT("hitSphereOffsetX", ud.collisionSphereOffset.x);
ADD_FLOAT("hitSphereOffsetY", ud.collisionSphereOffset.y);
ADD_FLOAT("hitSphereOffsetZ", ud.collisionSphereOffset.z);
ADD_BOOL("useHitSphereOffset", ud.useCSOffset);
*/

ADD_FLOAT("minCollisionSpeed", ud.minCollisionSpeed);
ADD_FLOAT("slideTolerance", ud.slideTolerance);

Expand Down
7 changes: 4 additions & 3 deletions rts/Map/MapInfo.cpp
Expand Up @@ -32,9 +32,10 @@ CMapInfo::CMapInfo(const std::string& mapname)
map.name = mapname;
mapDefParser = new TdfParser(GetTDFName(mapname));
resourcesParser = new LuaParser ("gamedata/resources.lua",
SPRING_VFS_MOD_BASE, SPRING_VFS_ZIP);
if (!resourcesParser->Execute() || !resourcesParser->IsValid())
SPRING_VFS_MOD_BASE, SPRING_VFS_ZIP);
if (!resourcesParser->Execute()) {
logOutput.Print(resourcesParser->GetErrorLog());
}

ReadGlobal();
ReadAtmosphere();
Expand Down Expand Up @@ -194,7 +195,7 @@ void CMapInfo::ReadWater()
water.normalTexture = "maps/" + water.normalTexture;

char num[10];
for (int i = 0; i < 32; i++) {
for (int i = 0; i < causticTextureCount; i++) {
sprintf(num, "%02i", i);
water.causticTextures[i] = std::string("bitmaps/") + causticsTable.GetString(std::string("caustic")+num,
std::string("caustic")+num+".jpg");
Expand Down
3 changes: 2 additions & 1 deletion rts/Map/MapInfo.h
Expand Up @@ -113,6 +113,7 @@ class CMapInfo

/** settings read from "MAP\WATER" section
prefix their name with "Water" to get the TDF variable */
static const int causticTextureCount = 32;
struct water_t {
float repeatX; ///< (calculated default is in CBaseWater)
float repeatY; ///< (calculated default is in CBaseWater)
Expand All @@ -131,7 +132,7 @@ class CMapInfo
std::string texture;
std::string foamTexture;
std::string normalTexture;
std::string causticTextures[32];
std::string causticTextures[causticTextureCount];
} water;
bool hasWaterPlane; ///< true if "MAP\WATER\WaterPlaneColor" is set

Expand Down
1 change: 0 additions & 1 deletion rts/Map/ReadMap.cpp
Expand Up @@ -23,7 +23,6 @@
#include "System/LoadSaveInterface.h"
#include "System/LogOutput.h"
#include "System/Platform/errorhandler.h"
#include "System/TdfParser.h"
#include "mmgr.h"

using namespace std;
Expand Down
25 changes: 12 additions & 13 deletions rts/Map/SM3/terrain/TerrainTexture.cpp
Expand Up @@ -249,10 +249,9 @@ namespace terrain {
GenerateInfo gi;
gi.bmMipmaps = bmMipmaps;

if (cb) cb->PrintMsg (" generating blendmap mipmaps...");
if (cb) { cb->PrintMsg (" generating blendmap mipmaps..."); }

for (int a=0;a<blendMaps.size();a++)
{
for (int a=0;a<blendMaps.size();a++) {
Blendmap *bm = blendMaps[a];

AlphaImage *cur = bm->image;
Expand All @@ -273,13 +272,11 @@ namespace terrain {
if (cb) cb->PrintMsg (" loading blendmaps into OpenGL...");

// Convert to textures
for (int a=0;a<blendMaps.size();a++)
{
for (int a=0;a<blendMaps.size();a++) {
AlphaImage *bm = bmMipmaps[a].back();

// Save image
if (blendMaps[a]->generatorInfo)
{
if (blendMaps[a]->generatorInfo) {
char fn[32];
SNPRINTF (fn,32, "blendmap%d.jpg", a);
remove(fn);
Expand Down Expand Up @@ -319,20 +316,20 @@ namespace terrain {
// see how lighting should be implemented, based on config and avaiable textures
InstantiateShaders(cfg, cb);

if (cb) cb->PrintMsg (" initializing terrain node shaders...");
if (cb) { cb->PrintMsg (" initializing terrain node shaders..."); }

CreateTexProg (quadtree, &gi);
shaderHandler->EndBuild();

// count passes
maxPasses = 0;
for (map<uint, RenderSetupCollection*>::iterator mi=gi.nodesetup.begin();mi!=gi.nodesetup.end();++mi)
{
for (map<uint, RenderSetupCollection*>::iterator mi=gi.nodesetup.begin();mi!=gi.nodesetup.end();++mi) {
for (int i = 0; i < mi->second->renderSetup.size(); i++) {
RenderSetup *rs = mi->second->renderSetup[i];

if (rs->passes.size () > maxPasses)
if (rs->passes.size () > maxPasses) {
maxPasses = rs->passes.size();
}
}
texNodeSetup.push_back (mi->second);
}
Expand All @@ -341,14 +338,16 @@ namespace terrain {

// Free blendmap mipmap images
for (int a=0;a<blendMaps.size();a++) {
for (deque<AlphaImage*>::iterator i=bmMipmaps[a].begin();i!=bmMipmaps[a].end();++i)
for (deque<AlphaImage*>::iterator i=bmMipmaps[a].begin();i!=bmMipmaps[a].end();++i) {
delete *i;
}
}

delete[] bmMipmaps;

if (cfg->useShadowMaps)
if (cfg->useShadowMaps) {
shadowMapParams = SAFE_NEW ShadowMapParams;
}
}

void TerrainTexture::CreateTexProg (TQuad *node, TerrainTexture::GenerateInfo *gi)
Expand Down
21 changes: 13 additions & 8 deletions rts/Map/SMF/SmfReadMap.cpp
Expand Up @@ -221,18 +221,23 @@ void CSmfReadMap::HeightmapUpdated(int x1, int x2, int y1, int y2)

float3 CSmfReadMap::GetLightValue(int x, int y)
{
float3 n1=facenormals[(y*gs->mapx+x)*2]+facenormals[(y*gs->mapx+x)*2+1];
float3 n1 = facenormals[((y * gs->mapx) + x) * 2] +
facenormals[((y * gs->mapx) + x) * 2 + 1];
n1.Normalize();

float3 light=mapInfo->light.groundSunColor*mapInfo->light.sunDir.dot(n1);
for(int a=0;a<3;++a)
if(light[a]<0)
light[a]=0;
float3 light = mapInfo->light.groundSunColor*mapInfo->light.sunDir.dot(n1);
for (int a = 0; a < 3; ++a) {
if (light[a] < 0.0f) {
light[a] = 0.0f;
}
}

light+=mapInfo->light.groundAmbientColor;
for(int a=0;a<3;++a)
if(light[a]>1)
light[a]=1;
for (int a = 0; a < 3; ++a) {
if (light[a] > 1.0f){
light[a] = 1.0f;
}
}

return light;
}
Expand Down

0 comments on commit e3e61e7

Please sign in to comment.