git » fp-git.git » commit b66cf03

bugfixes

author ecalot
2006-02-04 18:44:59 UTC
committer ecalot
2006-02-04 18:44:59 UTC
parent aec783dded5488024f76115582c0981abeb315f8

bugfixes

PV4/src/level.cpp +38 -20
PV4/src/main.cpp +20 -2
PV4/src/outertile.cpp +1 -1
PV4/src/pop1levelformat.cpp +1 -0

diff --git a/PV4/src/level.cpp b/PV4/src/level.cpp
index 00248c9..9433f77 100644
--- a/PV4/src/level.cpp
+++ b/PV4/src/level.cpp
@@ -151,7 +151,7 @@ void Level::arrangeRooms() {
  for (int i=0;i<MATRIX_HEIGHT;i++) {
   for (int j=0;j<MATRIX_WIDTH;j++) {
    if (!matrix(i,j)) {
-    this->rs=i;
+    this->cs=i;
     i=j=MATRIX_WIDTH;
    }
   }
@@ -160,7 +160,7 @@ void Level::arrangeRooms() {
  for (int i=MATRIX_HEIGHT;i--;) {
   for (int j=0;j<MATRIX_WIDTH;j++) {
    if (!matrix(i,j)) {
-    this->re=i;
+    this->ce=i;
     i=0;
     j=MATRIX_WIDTH;
    }
@@ -170,7 +170,7 @@ void Level::arrangeRooms() {
  for (int i=0;i<MATRIX_WIDTH;i++) {
   for (int j=0;j<MATRIX_HEIGHT;j++) {
    if (!matrix(j,i)) {
-    this->cs=i;
+    this->rs=i;
     i=j=MATRIX_WIDTH;
    }
   }
@@ -179,13 +179,22 @@ void Level::arrangeRooms() {
  for (int i=MATRIX_WIDTH;i--;) {
   for (int j=0;j<MATRIX_HEIGHT;j++) {
    if (!matrix(j,i)) {
-    this->ce=i;
+    this->re=i;
     i=0;
     j=MATRIX_WIDTH;
    }
   }
  }
 
+cout<<"level=("<<this->rs<<","<<this->cs<<"),("<<this->re<<","<<this->ce<<")"<<endl;
+	for (int j=this->rs;j<=this->re;j++) {
+		for (int i=this->cs;i<=this->ce;i++) {
+			cout<<(int)(matrix(i,j))<<" ";
+		}
+		cout<<endl;
+	}
+
+
 	//Now it's time to add all screens in the screens array
 	this->screens=new int[this->level->countMax()];
 	for (int i=0;i<this->level->countMax();i++)
@@ -202,16 +211,13 @@ void Level::arrangeRooms() {
 }
 
 int Level::getHeight(){
- return (this->rs-this->re-2)*3+2;
+ return (this->re-this->rs-1)*3+2;
 }
 
-
 int Level::getWidth(){
- return (this->cs-this->ce-2)*10+2;
+ return (this->ce-this->cs-1)*10+2;
 }
 
-int Level::countRooms(){}
-
 bool Level::addGuard(int floor,int col,Guard g){}
 bool Level::delGuard(int floor,int col){}
 bool Level::moveGuard(int floor,int col,int nfloor,int ncol){}
@@ -288,7 +294,7 @@ Tile* Level::getTile(int floor,int col) {
 	int location;
 
 	this->abstractToFormat(floor,col,screen,location);
-
+//cout<<"f("<<floor<<","<<col<<")=("<<screen<<","<<location<<")"<<endl;
 	if (screen<1) {
 		int r=0;
 		if (!screen) { //only screens 0 (means near to a level)
@@ -306,7 +312,24 @@ Tile* Level::getTile(int floor,int col) {
 	}
 }
 
-void copyTiles(int sfloor,int scol,int efloor,int ecol) {}
+void copyTiles(int sfloor,int scol,int efloor,int ecol,int tfloor, int tcol) {
+
+//equal col and floor are done
+if (sfloor==efloor) return;
+if (scol==ecol) return;
+
+//order col and floor in case the selection is in other order
+if (sfloor<efloor) {int aux=efloor;efloor=sfloor;sfloor=aux;}
+if (scol<ecol)     {int aux=ecol;ecol=scol;scol=aux;}
+
+tTile* t;
+
+for (int i=0;i<efloor-sfloor;i++) {
+	for (int j=0;j<ecol-scol;j++) {
+		t=this->getTile(sfloor+i,scol+j);
+		this->setTile(tfloor+i,tcol+j,t); //TODO: handle sollapations
+	}
+}
 
 /*
 bool addTrigger(int triggerfloor,int triggercol,int targetfloor,int targetcol)
@@ -375,23 +398,18 @@ bool redo();
 
 //Functions
 void Level::floorColToXY(int floor,int col, int &x, int &y){
-	x=this->rs+1+col/10;
-	y=this->cs+1+floor/3;
+	x=this->rs+(floor+2)/3;
+	y=this->cs+(col+9)/10;
 }
 
 void Level::abstractToFormat(int floor,int col, int &screen, int &location){
-
-	//ignore the first col and row
-	col--;
-	floor--;
-
 	//calculate x and y of the screen
 	int x,y;
 	floorColToXY(floor,col,x,y);
 
 	//return values
-	screen=matrix(x,y);
-	location=col%10+(floor%3)*10;
+	screen=matrix(y,x);
+	location=(col-1)%10+((floor-1)%3)*10;
 }
 
 void Level::formatToAbstract(int &floor,int &col, int screen, int location){
diff --git a/PV4/src/main.cpp b/PV4/src/main.cpp
index 331bf29..5275878 100644
--- a/PV4/src/main.cpp
+++ b/PV4/src/main.cpp
@@ -1,5 +1,6 @@
 #include <cstdlib>
 #include <iostream>
+#include <stdio.h>
 
 #include "level.h"
 
@@ -9,9 +10,26 @@ int main(int argc, char *argv[])
 {
 
 try {
-	Level l("lev\\level001.plv");
+	Level l("lev\\level002.plv");
+
+	int w,h;
+
+	h=l.getHeight();
+	w=l.getWidth();
+
+	cout<<"h="<<h<<" w="<<w<<endl;
+
+	Tile* t;
+
+	for (int i=0;i<h;i++) {
+		for (int j=0;j<w;j++) {
+			t=l.getTile(i,j);
+			printf("%02X ",t->getCode()&0x1f);
+		}
+		cout<<endl;
+	}
+
 
-	int x,y;
 
   cout<<"Done";
 } catch (int error) {
diff --git a/PV4/src/outertile.cpp b/PV4/src/outertile.cpp
index 6f8895d..6db0ffd 100644
--- a/PV4/src/outertile.cpp
+++ b/PV4/src/outertile.cpp
@@ -17,5 +17,5 @@ int OuterTile::getImg() {
 }
 
 int OuterTile::getCode() {
-	return this->code; //TODO: calculate the special codes
+	return 0x14;//this->code; //TODO: calculate the special codes
 }
diff --git a/PV4/src/pop1levelformat.cpp b/PV4/src/pop1levelformat.cpp
index de589e4..86631cb 100644
--- a/PV4/src/pop1levelformat.cpp
+++ b/PV4/src/pop1levelformat.cpp
@@ -132,6 +132,7 @@ void Pop1LevelFormat::setTile(int screen, int location, Tile* t) {
 }
 
 Tile* Pop1LevelFormat::getTile(int screen, int location) {
+//cout << "s="<<screen<<" l="<<location<<endl;
 	if (screen<1||screen>24||location<0||location>29) throw -10;
 	return (Tile*)new Pop1Tile(
 		this->walls[(screen-1)*30+location],