Code Restructuring to make mega-glest more standard

This commit is contained in:
Mark Vejvoda
2010-03-12 05:11:28 +00:00
parent b8082e83ce
commit 7cb4f99ec4
41 changed files with 768 additions and 431 deletions

1
mk/linux/data Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/data

View File

@@ -1,4 +1,4 @@
; === Properties File ===
; === propertyMap File ===
AiLog=0
AiRedir=0
@@ -24,13 +24,13 @@ FontConsole=-*-*-*-*-*-*-12-*-*-*-*-*-*-*
FontDisplay=-*-*-*-*-*-*-12-*-*-*-*-*-*-*
FontMenu=-*-*-*-*-*-*-12-*-*-*-*-*-*-*
Lang=english
MaxLights=1
NetworkConsistencyChecks=1
MaxLights=3
NetworkConsistencyChecks=0
PhotoMode=0
RefreshFrequency=75
ScreenHeight=768
ScreenWidth=1024
ServerIp=192.168.1.102
ScreenHeight=984
ScreenWidth=1680
ServerIp=200.200.200.200
ServerPort=6666
ShadowAlpha=0.2
ShadowFrameSkip=2
@@ -38,10 +38,10 @@ ShadowTextureSize=512
Shadows=Projected
SoundStaticBuffers=16
SoundStreamingBuffers=4
SoundVolumeAmbient=80
SoundVolumeFx=80
SoundVolumeMusic=90
SoundVolumeAmbient=90
SoundVolumeFx=100
SoundVolumeMusic=0
StencilBits=0
Textures3D=1
UnitParticles=1
Windowed=0
Windowed=1

1
mk/linux/glest_game Symbolic link
View File

@@ -0,0 +1 @@
../../source/glest_game

1
mk/linux/glest_map_editor Symbolic link
View File

@@ -0,0 +1 @@
../../source/glest_map_editor

1
mk/linux/maps Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/maps

1
mk/linux/scenarios Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/scenarios

1
mk/linux/screenshots Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/screenshots

3
mk/linux/servers.ini Normal file
View File

@@ -0,0 +1,3 @@
; === propertyMap File ===
Martino=192.168.1.100

1
mk/linux/shared_lib Symbolic link
View File

@@ -0,0 +1 @@
../../source/shared_lib

1
mk/linux/techs Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/techs

1
mk/linux/tilesets Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/tilesets

1
mk/linux/tutorials Symbolic link
View File

@@ -0,0 +1 @@
/home/softcoder/Code/glest/megaglest/data/glest_game/tutorials

0
mk/windoze/Glest.sln Normal file → Executable file
View File

BIN
mk/windoze/Glest.suo Normal file → Executable file

Binary file not shown.

0
mk/windoze/g3d_viewer.vcproj Normal file → Executable file
View File

0
mk/windoze/glest.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

0
mk/windoze/glest.rc Normal file → Executable file
View File

0
mk/windoze/glest_editor.vcproj Normal file → Executable file
View File

0
mk/windoze/glest_game.vcproj Normal file → Executable file
View File

0
mk/windoze/shared_lib.vcproj Normal file → Executable file
View File

View File

@@ -562,6 +562,14 @@ void Renderer::renderMouse3d(){
glColor4fv(color.ptr());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color.ptr());
const Model *buildingModel= building->getFirstStOfClass(scStop)->getAnimation();
//!!!
float rotateAmount = gui->getUnitTypeBuildRotation(building->getId());
if(rotateAmount >= 0) {
//if(Socket::enableDebugText) printf("In [%s::%s] rotate unit id = %d amount = %f\n",__FILE__,__FUNCTION__,building->getId(),rotateAmount);
glRotatef(rotateAmount, 0.f, 1.f, 0.f);
}
buildingModel->updateInterpolationData(0.f, false);
modelRenderer->render(buildingModel);
glDisable(GL_COLOR_MATERIAL);
@@ -1350,6 +1358,14 @@ void Renderer::renderUnits(){
//render
const Model *model= unit->getCurrentModel();
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
//!!!
float rotateAmount = unit->getRotateAmount();
if(rotateAmount >= 0) {
//if(Socket::enableDebugText) printf("In [%s::%s] rotate unit id = %d amount = %f\n",__FILE__,__FUNCTION__,unit->getId(),rotateAmount);
glRotatef(rotateAmount, 0.f, 1.f, 0.f);
}
modelRenderer->render(model);
triangleCount+= model->getTriangleCount();
pointCount+= model->getVertexCount();
@@ -2328,6 +2344,14 @@ void Renderer::renderUnitsFast(){
//render
const Model *model= unit->getCurrentModel();
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive());
//!!!
float rotateAmount = unit->getRotateAmount();
if(rotateAmount >= 0) {
//if(Socket::enableDebugText) printf("In [%s::%s] rotate unit id = %d amount = %f\n",__FILE__,__FUNCTION__,unit->getId(),rotateAmount);
glRotatef(rotateAmount, 0.f, 1.f, 0.f);
}
modelRenderer->render(model);
glPopMatrix();

View File

@@ -1,4 +1,5 @@
// ==============================================================
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Marti<74>o Figueroa
@@ -87,6 +88,8 @@ void SelectionQuad::disable(){
//constructor
Gui::Gui(){
if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
posObjWorld= Vec2i(54, 14);
computeSelection= false;
validPosObjWorld= false;
@@ -96,6 +99,8 @@ Gui::Gui(){
selectingPos= false;
selectingMeetingPoint= false;
activePos= invalidPos;
if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
void Gui::init(Game *game){
@@ -167,9 +172,14 @@ void Gui::mouseDownLeftDisplay(int x, int y){
if(posDisplay!= invalidPos){
if(selection.isComandable()){
if(selectingBuilding){
//if(Socket::enableDebugText) printf("In [%s::%s] selectingBuilding == true\n",__FILE__,__FUNCTION__);
mouseDownDisplayUnitBuild(posDisplay);
}
else{
//if(Socket::enableDebugText) printf("In [%s::%s] selectingBuilding == false\n",__FILE__,__FUNCTION__);
mouseDownDisplayUnitSkills(posDisplay);
}
}
@@ -182,34 +192,55 @@ void Gui::mouseDownLeftDisplay(int x, int y){
}
void Gui::mouseMoveDisplay(int x, int y){
//if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
computeInfoString(computePosDisplay(x, y));
}
void Gui::mouseDownLeftGraphics(int x, int y){
//if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
if(selectingPos){
//if(Socket::enableDebugText) printf("In [%s::%s] selectingPos == true\n",__FILE__,__FUNCTION__);
//give standard orders
giveTwoClickOrders(x, y);
resetState();
}
//set meeting point
else if(selectingMeetingPoint){
if(Socket::enableDebugText) printf("In [%s::%s] selectingMeetingPoint == true\n",__FILE__,__FUNCTION__);
if(selection.isComandable()){
if(Socket::enableDebugText) printf("In [%s::%s] selection.isComandable() == true\n",__FILE__,__FUNCTION__);
Vec2i targetPos;
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos)){
if(Socket::enableDebugText) printf("In [%s::%s] computePosition() == true\n",__FILE__,__FUNCTION__);
commander->trySetMeetingPoint(selection.getFrontUnit(), targetPos);
}
}
resetState();
}
else{
if(Socket::enableDebugText) printf("In [%s::%s] selectionQuad()\n",__FILE__,__FUNCTION__);
selectionQuad.setPosDown(Vec2i(x, y));
computeSelected(false);
}
computeDisplay();
//if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
void Gui::mouseDownRightGraphics(int x, int y){
//if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
if(selectingPos || selectingMeetingPoint){
resetState();
}
@@ -217,9 +248,13 @@ void Gui::mouseDownRightGraphics(int x, int y){
giveDefaultOrders(x, y);
}
computeDisplay();
//if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
void Gui::mouseUpLeftGraphics(int x, int y){
//if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
if(!selectingPos && !selectingMeetingPoint){
if(selectionQuad.isEnabled()){
selectionQuad.setPosUp(Vec2i(x, y));
@@ -232,6 +267,8 @@ void Gui::mouseUpLeftGraphics(int x, int y){
selectionQuad.disable();
}
}
//if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
void Gui::mouseMoveGraphics(int x, int y){
@@ -247,6 +284,8 @@ void Gui::mouseMoveGraphics(int x, int y){
//compute position for building
if(isPlacingBuilding()){
//if(Socket::enableDebugText) printf("In [%s::%s] isPlacingBuilding() == true\n",__FILE__,__FUNCTION__);
validPosObjWorld= Renderer::getInstance().computePosition(Vec2i(x,y), posObjWorld);
}
@@ -270,7 +309,20 @@ void Gui::groupKey(int groupIndex){
}
}
float Gui::getUnitTypeBuildRotation(int unitId) const {
float rotationValue = -1;
if(unitTypeBuildRotation.find(unitId) != unitTypeBuildRotation.end()) {
rotationValue = unitTypeBuildRotation.find(unitId)->second;
}
return rotationValue;
}
void Gui::hotKey(char key){
if(Socket::enableDebugText) printf("In [%s::%s] key = [%c]\n",__FILE__,__FUNCTION__,key);
if(key==' '){
centerCameraOnSelection();
}
@@ -281,8 +333,28 @@ void Gui::hotKey(char key){
selectInterestingUnit(iutBuiltBuilding);
}
else if(key=='R'){
//!!!
if(isPlacingBuilding()){
const UnitType *unitType = getBuilding();
float unitTypeRotation = getUnitTypeBuildRotation(unitType->getId());
if(Socket::enableDebugText) printf("In [%s::%s] unitType->getId() = %d unitTypeRotation = %f\n",__FILE__,__FUNCTION__,unitType->getId(),unitTypeRotation);
if(unitTypeRotation < 0) {
unitTypeRotation = 0;
}
unitTypeRotation += 90;
if(unitTypeRotation >= 360) {
unitTypeRotation = 0;
}
unitTypeBuildRotation[unitType->getId()] = unitTypeRotation;
if(Socket::enableDebugText) printf("In [%s::%s] unitType->getId() = %d NEW unitTypeRotation = %f\n",__FILE__,__FUNCTION__,unitType->getId(),unitTypeRotation);
}
else {
selectInterestingUnit(iutProducer);
}
}
else if(key=='D'){
selectInterestingUnit(iutDamaged);
}

View File

@@ -19,6 +19,7 @@
#include "console.h"
#include "selection.h"
#include "random.h"
#include <map>
using Shared::Util::Random;
@@ -129,6 +130,8 @@ private:
bool selectingPos;
bool selectingMeetingPoint;
std::map<int, float> unitTypeBuildRotation;
public:
Gui();
void init(Game *game);
@@ -171,6 +174,8 @@ public:
//misc
void onSelectionChanged();
float getUnitTypeBuildRotation(int unitId) const;
private:
//orders

0
source/glest_game/network/client_interface.cpp Normal file → Executable file
View File

View File

@@ -24,6 +24,7 @@
#include "core_data.h"
#include "renderer.h"
#include "leak_dumper.h"
#include "socket.h"
using namespace Shared::Graphics;
using namespace Shared::Util;
@@ -103,7 +104,10 @@ const int Unit::invalidId= -1;
// ============================ Constructor & destructor =============================
Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map){
Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, float unitPlacementRotation) {
if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
Random random;
this->pos=pos;
@@ -111,6 +115,12 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map
this->faction=faction;
this->map= map;
this->id= id;
level= NULL;
cellMap= NULL;
if(Socket::enableDebugText) printf("In [%s::%s] A\n",__FILE__,__FUNCTION__);
setRotateAmount(unitPlacementRotation);
if(Socket::enableDebugText) printf("In [%s::%s] B unit id = %d [%s] rotate amount = %f\n",__FILE__,__FUNCTION__,getId(), getFullName().c_str(),unitPlacementRotation);
Config &config= Config::getInstance();
showUnitParticles= config.getBool("UnitParticles");
@@ -126,7 +136,7 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map
deadCount= 0;
hp= type->getMaxHp()/20;
toBeUndertaken= false;
level= NULL;
highlight= 0.f;
meetingPos= pos;
alive= true;
@@ -149,6 +159,8 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map
//starting skill
this->currSkill=getType()->getFirstStOfClass(scStop);
if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
}
Unit::~Unit(){
@@ -163,6 +175,9 @@ Unit::~Unit(){
unitParticleSystems.pop_back();
}
stopDamageParticles();
delete [] cellMap;
cellMap = NULL;
}
// ====================================== get ======================================
@@ -184,7 +199,6 @@ Vec2f Unit::getFloatCenteredPos() const{
}
Vec2i Unit::getCellPos() const{
if(type->hasCellMap()){
//find nearest pos to center that is free
@@ -194,7 +208,7 @@ Vec2i Unit::getCellPos() const{
for(int i=0; i<type->getSize(); ++i){
for(int j=0; j<type->getSize(); ++j){
if(type->getCellMapCell(i, j)){
if(getCellMapCell(i, j)){
Vec2i currPos= pos + Vec2i(i, j);
float dist= currPos.dist(centeredPos);
if(nearestDist==-1.f || dist<nearestDist){
@@ -256,9 +270,12 @@ const Level *Unit::getNextLevel() const{
}
string Unit::getFullName() const{
string str;
string str="";
if(level != NULL){
str+= level->getName() + " ";
str += (level->getName() + " ");
}
if(type == NULL) {
throw runtime_error("type == NULL in Unit::getFullName()!");
}
str += type->getName();
return str;
@@ -436,6 +453,8 @@ unsigned int Unit::getCommandSize() const{
//give one command (clear, and push back)
CommandResult Unit::giveCommand(Command *command){
//if(Socket::enableDebugText) printf("In [%s::%s] START\n",__FILE__,__FUNCTION__);
if(command->getCommandType()->isQueuable()){
//cancel current command if it is not queuable
if(!commands.empty() && !commands.front()->getCommandType()->isQueuable()){
@@ -448,12 +467,16 @@ CommandResult Unit::giveCommand(Command *command){
unitPath.clear();
}
//if(Socket::enableDebugText) printf("In [%s::%s] A\n",__FILE__,__FUNCTION__);
//check command
CommandResult result= checkCommand(command);
if(result==crSuccess){
applyCommand(command);
}
//if(Socket::enableDebugText) printf("In [%s::%s] B\n",__FILE__,__FUNCTION__);
//push back command
if(result== crSuccess){
commands.push_back(command);
@@ -462,6 +485,8 @@ CommandResult Unit::giveCommand(Command *command){
delete command;
}
//if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__);
return result;
}
@@ -1081,5 +1106,73 @@ void Unit::startDamageParticles(){
}
}
bool Unit::getCellMapCell(int x, int y) const {
const UnitType *ut= getType();
if(ut != NULL && rotateAmount > 0) {
return cellMap[ut->getSize() * y + x];
}
else {
return ut->getCellMapCell(x,y);
}
}
void Unit::setRotateAmount(float value) {
rotateAmount = value;
if(Socket::enableDebugText) printf("In [%s::%s] unit id = %d [%s] rotate amount = %f\n",__FILE__,__FUNCTION__,getId(), getFullName().c_str(),rotateAmount);
const UnitType *ut= getType();
if(ut != NULL && ut->hasCellMap() == true) {
int matrixSize = ut->getSize();
if(rotateAmount > 0) {
delete [] cellMap;
cellMap = new bool[matrixSize * matrixSize];
for(int iRow = 0; iRow < matrixSize; ++iRow) {
for(int iCol = 0; iCol < matrixSize; ++iCol) {
bool getCellResult = ut->getCellMapCell(iCol, iRow);
if(Socket::enableDebugText) printf("In [%s::%s] [%d,%d] = %d\n",__FILE__,__FUNCTION__,iRow,iCol,getCellResult);
int newRow = 0;
int newCol = 0;
switch((int)rotateAmount)
{
case 90:
newRow = (matrixSize - iCol - 1);
newCol = iRow;
break;
case 180:
newRow = (matrixSize - iRow - 1);
newCol = (matrixSize - iCol - 1);
break;
case 270:
newRow = iCol;
newCol = (matrixSize - iRow - 1);
break;
}
if(Socket::enableDebugText) printf("In [%s::%s] ABOUT TO Transform to [%d,%d] = %d\n",__FILE__,__FUNCTION__,newRow,newCol,getCellResult);
// bool getCellMapCell(int x, int y) const {return cellMap[size*y+x];}
// cellMap[i*size+j]= row[j]=='0'? false: true;
cellMap[matrixSize * newRow + newCol] = getCellResult;
}
}
}
if(Socket::enableDebugText) printf("In [%s::%s] Transformed matrix below:\n",__FILE__,__FUNCTION__);
for(int iRow = 0; iRow < matrixSize; ++iRow) {
for(int iCol = 0; iCol < matrixSize; ++iCol) {
bool getCellResult = ut->getCellMapCell(iCol, iRow);
bool getCellResultRotated = getCellMapCell(iRow, iCol);
if(Socket::enableDebugText) printf("In [%s::%s] matrix [%d,%d] = %d, rotated = %d\n",__FILE__,__FUNCTION__,iRow,iCol,getCellResult,getCellResultRotated);
}
}
}
}
}}//end namespace

View File

@@ -180,8 +180,11 @@ private:
UnitParticleSystems unitParticleSystems;
UnitParticleSystems damageParticleSystems;
float rotateAmount;
bool *cellMap;
public:
Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map);
Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, float unitPlacementRotation);
~Unit();
//queries
@@ -294,6 +297,10 @@ public:
CommandResult checkCommand(Command *command) const;
void applyCommand(Command *command);
void setRotateAmount(float value);
float getRotateAmount() { return rotateAmount; }
bool getCellMapCell(int x, int y) const;
private:
float computeHeight(const Vec2i &pos) const;
void updateTarget();

View File

@@ -719,6 +719,45 @@ const ProducibleType *MorphCommandType::getProduced() const{
return morphUnit;
}
// =====================================================
// class RotateUnitCommandType
// =====================================================
//varios
RotateUnitCommandType::RotateUnitCommandType(){
commandTypeClass= ccRotateUnit;
clicks= cOne;
}
void RotateUnitCommandType::update(UnitUpdater *unitUpdater, Unit *unit) const{
unitUpdater->updateStop(unit);
}
string RotateUnitCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{
string str;
Lang &lang= Lang::getInstance();
str= name+"\n";
//str+= lang.get("ReactionSpeed")+": "+ intToStr(stopSkillType->getSpeed())+"\n";
//if(stopSkillType->getEpCost()!=0)
// str+= lang.get("EpCost")+": "+intToStr(stopSkillType->getEpCost())+"\n";
return str;
}
string RotateUnitCommandType::toString() const{
Lang &lang= Lang::getInstance();
return lang.get("RotateUnit");
}
void RotateUnitCommandType::load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut){
CommandType::load(id, n, dir, tt, ft, ut);
//stop
//string skillName= n->getChild("stop-skill")->getAttribute("value")->getRestrictedValue();
//stopSkillType= static_cast<const StopSkillType*>(ut.getSkillType(skillName, scStop));
}
// =====================================================
// class CommandFactory
// =====================================================
@@ -734,6 +773,7 @@ CommandTypeFactory::CommandTypeFactory(){
registerClass<ProduceCommandType>("produce");
registerClass<UpgradeCommandType>("upgrade");
registerClass<MorphCommandType>("morph");
registerClass<RotateUnitCommandType>("rotate_unit");
}
CommandTypeFactory &CommandTypeFactory::getInstance(){

View File

@@ -41,6 +41,7 @@ enum CommandClass{
ccProduce,
ccUpgrade,
ccMorph,
ccRotateUnit,
ccCount,
ccNull
@@ -326,6 +327,29 @@ public:
int getDiscount() const {return discount;}
};
// ===============================
// class BuildCommandType
// ===============================
class RotateUnitCommandType: public CommandType{
private:
float rotateAmount;
public:
RotateUnitCommandType();
virtual void update(UnitUpdater *unitUpdater, Unit *unit) const;
virtual void load(int id, const XmlNode *n, const string &dir, const TechTree *tt, const FactionType *ft, const UnitType &ut);
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
virtual bool isQueuable() const {return true;}
//get
const float getRotateAmount() const {return rotateAmount; }
void setRotateAmount(float value) { rotateAmount = value; }
};
// ===============================
// class CommandFactory
// ===============================

0
source/glest_game/types/skill_type.cpp Normal file → Executable file
View File

0
source/glest_game/types/skill_type.h Normal file → Executable file
View File

View File

@@ -25,6 +25,7 @@
#include "game_util.h"
#include "leak_dumper.h"
#include "unit_particle_type.h"
#include "socket.h"
using namespace Shared::Xml;
using namespace Shared::Graphics;
@@ -170,6 +171,19 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa
cellMap[i*size+j]= row[j]=='0'? false: true;
}
}
if(Socket::enableDebugText) printf("In [%s::%s] Original Unit cellmap matrix below [%s] [%s]:\n",__FILE__,__FUNCTION__,getName().c_str(),path.c_str());
for(int iRow = 0; iRow < size; ++iRow) {
const XmlNode *rowNode= cellMapNode->getChild("row", iRow);
string row= rowNode->getAttribute("value")->getRestrictedValue();
if(Socket::enableDebugText) printf("In [%s::%s] row = %s\n",__FILE__,__FUNCTION__,row.c_str());
for(int iCol = 0; iCol < size; ++iCol) {
bool getCellResult = getCellMapCell(iCol, iRow);
if(Socket::enableDebugText) printf("In [%s::%s] matrix [%d,%d] = %d\n",__FILE__,__FUNCTION__,iRow,iCol,getCellResult);
}
}
}
//levels

View File

@@ -95,6 +95,7 @@ private:
int sight;
int size; //size in cells
int height;
float rotatedBuildPos;
//cellmap
bool *cellMap;
@@ -181,6 +182,9 @@ public:
//find
const CommandType* findCommandTypeById(int id) const;
float getRotatedBuildPos() { return rotatedBuildPos; }
float setRotatedBuildPos(float value) { rotatedBuildPos = value; }
private:
void computeFirstStOfClass();
void computeFirstCtOfClass();

View File

@@ -411,7 +411,7 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos){
for(int j=0; j<ut->getSize(); ++j){
Vec2i currPos= pos + Vec2i(i, j);
assert(isInside(currPos));
if(!ut->hasCellMap() || ut->getCellMapCell(i, j)){
if(!ut->hasCellMap() || unit->getCellMapCell(i, j)){
assert(getCell(currPos)->getUnit(unit->getCurrField())==NULL);
getCell(currPos)->setUnit(unit->getCurrField(), unit);
}
@@ -431,7 +431,7 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos){
for(int j=0; j<ut->getSize(); ++j){
Vec2i currPos= pos + Vec2i(i, j);
assert(isInside(currPos));
if(!ut->hasCellMap() || ut->getCellMapCell(i, j)){
if(!ut->hasCellMap() || unit->getCellMapCell(i, j)){
assert(getCell(currPos)->getUnit(unit->getCurrField())==unit);
getCell(currPos)->setUnit(unit->getCurrField(), NULL);
}

0
source/glest_game/world/map.h Normal file → Executable file
View File

View File

@@ -284,7 +284,10 @@ void UnitUpdater::updateBuild(Unit *unit){
assert(command->getUnitType()!=NULL);
if(map->isFreeCells(command->getPos(), ut->getSize(), fLand)){
const UnitType *builtUnitType= command->getUnitType();
Unit *builtUnit= new Unit(world->getNextUnitId(), command->getPos(), builtUnitType, unit->getFaction(), world->getMap());
//!!!
float unitRotation = gui->getUnitTypeBuildRotation(builtUnitType->getId());
Unit *builtUnit= new Unit(world->getNextUnitId(), command->getPos(), builtUnitType, unit->getFaction(), world->getMap(),unitRotation);
builtUnit->create();
if(!builtUnitType->hasSkillClass(scBeBuilt)){
@@ -304,6 +307,25 @@ void UnitUpdater::updateBuild(Unit *unit){
unit->getCurrVector(),
gameCamera->getPos());
}
//!!!
/*
if(unitRotation > 0) {
if(Socket::enableDebugText) printf("In [%s::%s] before sending ccRotateUnit...\n",__FILE__,__FUNCTION__);
RotateUnitCommandType *rotateCmdType = new RotateUnitCommandType();
rotateCmdType->setRotateAmount(unitRotation);
Command *rotateUnitCmd = new Command(rotateCmdType);
rotateUnitCmd->setUnit(builtUnit);
if(Socket::enableDebugText) printf("In [%s::%s] in sending ccRotateUnit...\n",__FILE__,__FUNCTION__);
builtUnit->giveCommand(rotateUnitCmd);
if(Socket::enableDebugText) printf("In [%s::%s] after sending ccRotateUnit...\n",__FILE__,__FUNCTION__);
}
*/
}
else{
//if there are no free cells
@@ -535,7 +557,10 @@ void UnitUpdater::updateProduce(Unit *unit){
if(unit->getProgress2()>pct->getProduced()->getProductionTime()){
unit->finishCommand();
unit->setCurrSkill(scStop);
produced= new Unit(world->getNextUnitId(), Vec2i(0), pct->getProducedUnit(), unit->getFaction(), world->getMap());
//!!!
float unitRotation = gui->getUnitTypeBuildRotation(pct->getProducedUnit()->getId());
produced= new Unit(world->getNextUnitId(), Vec2i(0), pct->getProducedUnit(), unit->getFaction(), world->getMap(),unitRotation);
//place unit creates the unit
if(!world->placeUnit(unit->getCenteredPos(), 10, produced)){

View File

@@ -47,6 +47,7 @@ World::World(){
nextUnitId= 0;
scriptManager= NULL;
this->game = NULL;
}
void World::end(){
@@ -62,6 +63,7 @@ void World::end(){
void World::init(Game *game, bool createUnits){
this->game = game;
scriptManager= game->getScriptManager();
unitUpdater.init(game);
@@ -309,7 +311,13 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
const FactionType* ft= faction->getType();
const UnitType* ut= ft->getUnitType(unitName);
Unit* unit= new Unit(getNextUnitId(), pos, ut, faction, &map);
//!!!
if(Socket::enableDebugText) printf("In [%s::%s] A\n",__FILE__,__FUNCTION__);
float unitRotation = game->getGui()->getUnitTypeBuildRotation(ut->getId());
if(Socket::enableDebugText) printf("In [%s::%s] B\n",__FILE__,__FUNCTION__);
Unit* unit= new Unit(getNextUnitId(), pos, ut, faction, &map, unitRotation);
if(placeUnit(pos, generationArea, unit, true)){
unit->create(true);
unit->born();
@@ -565,7 +573,14 @@ void World::initUnits(){
const UnitType *ut= ft->getStartingUnit(j);
int initNumber= ft->getStartingUnitAmount(j);
for(int l=0; l<initNumber; l++){
Unit *unit= new Unit(getNextUnitId(), Vec2i(0), ut, f, &map);
//!!!
if(Socket::enableDebugText) printf("In [%s::%s] A\n",__FILE__,__FUNCTION__);
float unitRotation = game->getGui()->getUnitTypeBuildRotation(ut->getId());
if(Socket::enableDebugText) printf("In [%s::%s] B\n",__FILE__,__FUNCTION__);
Unit *unit= new Unit(getNextUnitId(), Vec2i(0), ut, f, &map, unitRotation);
int startLocationIndex= f->getStartLocationIndex();
if(placeUnit(map.getStartLocation(startLocationIndex), generationArea, unit, true)){

View File

@@ -87,6 +87,7 @@ private:
bool fogOfWar;
int fogOfWarSmoothingFrameSkip;
bool fogOfWarSmoothing;
Game *game;
public:
World();

0
source/glest_map_editor/main.cpp Normal file → Executable file
View File

View File

0
source/shared_lib/sources/graphics/gl/shader_gl.cpp Normal file → Executable file
View File