Compare commits

...

2 Commits

Author SHA1 Message Date
Sven Eberhardt 81ba07cc48 reproduce lights assertion in C4Application constructor 2015-02-17 21:03:50 +01:00
Sven Eberhardt 33b49e21aa Implement loading of serialized light sections. 2015-02-17 21:02:37 +01:00
5 changed files with 303 additions and 6 deletions

View File

@ -0,0 +1,260 @@
[LightSection]
iRot=90
a=0
b=1
c=-1
d=0
ra=0
rb=-1
rc=1
rd=0
[Beam]
iLeftX=-1
iLeftY=1
iRightX=-55
iRightY=61
iLeftEndY=61
iRightEndY=61
iError=9
fDirty=false
[Beam]
iLeftX=-55
iLeftY=61
iRightX=-55
iRightY=61
iLeftEndY=62
iRightEndY=62
iError=0
fDirty=false
[Beam]
iLeftX=-55
iLeftY=61
iRightX=-52
iRightY=61
iLeftEndY=61
iRightEndY=61
iError=0
fDirty=false
[Beam]
iLeftX=-52
iLeftY=61
iRightX=-64
iRightY=80
iLeftEndY=142
iRightEndY=142
iError=0
fDirty=true
[Beam]
iLeftX=-64
iLeftY=80
iRightX=-57
iRightY=80
iLeftEndY=80
iRightEndY=80
iError=8
fDirty=false
[Beam]
iLeftX=-57
iLeftY=80
iRightX=-57
iRightY=80
iLeftEndY=81
iRightEndY=81
iError=0
fDirty=false
[Beam]
iLeftX=-57
iLeftY=80
iRightX=-50
iRightY=81
iLeftEndY=80
iRightEndY=81
iError=6
fDirty=false
[Beam]
iLeftX=-50
iLeftY=81
iRightX=-48
iRightY=78
iLeftEndY=81
iRightEndY=81
iError=0
fDirty=false
[Beam]
iLeftX=-48
iLeftY=78
iRightX=-45
iRightY=77
iLeftEndY=78
iRightEndY=77
iError=2
fDirty=false
[Beam]
iLeftX=-45
iLeftY=77
iRightX=-44
iRightY=76
iLeftEndY=77
iRightEndY=77
iError=0
fDirty=false
[Beam]
iLeftX=-44
iLeftY=76
iRightX=-35
iRightY=75
iLeftEndY=76
iRightEndY=75
iError=10
fDirty=false
[Beam]
iLeftX=-35
iLeftY=75
iRightX=-34
iRightY=82
iLeftEndY=76
iRightEndY=82
iError=6
fDirty=false
[Beam]
iLeftX=-34
iLeftY=82
iRightX=-32
iRightY=84
iLeftEndY=82
iRightEndY=84
iError=2
fDirty=false
[Beam]
iLeftX=-32
iLeftY=84
iRightX=-33
iRightY=93
iLeftEndY=90
iRightEndY=93
iError=3
fDirty=false
[Beam]
iLeftX=-33
iLeftY=93
iRightX=-38
iRightY=111
iLeftEndY=111
iRightEndY=111
iError=0
fDirty=false
[Beam]
iLeftX=-38
iLeftY=111
iRightX=-43
iRightY=139
iLeftEndY=142
iRightEndY=142
iError=0
fDirty=true
[Beam]
iLeftX=-43
iLeftY=139
iRightX=-40
iRightY=130
iLeftEndY=139
iRightEndY=139
iError=0
fDirty=false
[Beam]
iLeftX=-40
iLeftY=130
iRightX=-35
iRightY=125
iLeftEndY=130
iRightEndY=127
iError=3
fDirty=false
[Beam]
iLeftX=-35
iLeftY=125
iRightX=-15
iRightY=65
iLeftEndY=125
iRightEndY=123
iError=9
fDirty=false
[Beam]
iLeftX=-15
iLeftY=65
iRightX=-9
iRightY=52
iLeftEndY=65
iRightEndY=61
iError=5
fDirty=false
[Beam]
iLeftX=-9
iLeftY=52
iRightX=-4
iRightY=28
iLeftEndY=52
iRightEndY=52
iError=0
fDirty=false
[Beam]
iLeftX=-4
iLeftY=28
iRightX=0
iRightY=27
iLeftEndY=28
iRightEndY=27
iError=2
fDirty=false
[Beam]
iLeftX=0
iLeftY=27
iRightX=0
iRightY=26
iLeftEndY=27
iRightEndY=27
iError=0
fDirty=false
[Beam]
iLeftX=0
iLeftY=26
iRightX=5
iRightY=15
iLeftEndY=26
iRightEndY=18
iError=10
fDirty=false
[Beam]
iLeftX=5
iLeftY=15
iRightX=1
iRightY=1
iLeftEndY=15
iRightEndY=6
iError=9
fDirty=false

View File

@ -39,6 +39,8 @@
#include <C4Network2.h>
#include <C4Network2IRC.h>
#include <C4Particles.h>
#include <C4FoWLight.h>
#include <C4FoWRegion.h>
#include <getopt.h>
@ -54,6 +56,9 @@ C4Application::C4Application():
AppState(C4AS_None),
pGameTimer(NULL)
{
C4Object o;
C4FoWLight l(&o); C4FoWRegion r(NULL, NULL);
l.Render(&r, NULL);
}
C4Application::~C4Application()

View File

@ -55,6 +55,7 @@ public:
bool isDirty() const { return fDirty; }
bool isClean() const { return !fDirty; }
C4FoWBeam *getNext() const { return pNext; }
void setNext(C4FoWBeam *next) { pNext=next; }
// Get a point on the beam boundary.
inline int32_t getLeftX(int32_t y) const { return iLeftX * y / iLeftY; }

View File

@ -18,6 +18,7 @@
#include "C4FoWLightSection.h"
#include "C4FoWBeamTriangle.h"
#include "C4FoWDrawStrategy.h"
#include "C4FoWRegion.h"
#include "C4PlayerList.h"
#include "C4Player.h"
@ -94,6 +95,17 @@ void C4FoWLight::Render(C4FoWRegion *region, const C4TargetFacet *onScreen)
TriangleList triangles;
bool clip = false;
iX = 199; iY = 579;
iReach = 300;
iFadeout = 80;
iSize = 20;
StdStrBuf test;
assert(FileExists("light_section_assertion.txt"));
test.LoadFromFile("light_section_assertion.txt");
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(*sections[0], "LightSection"), test);
region->Update(C4Rect(0, 0, 1000, 1000), FLOAT_RECT());
sections[0]->CalculateTriangles(region);
for(size_t i = 0; i < sections.size(); ++i )
{

View File

@ -512,7 +512,7 @@ std::list<C4FoWBeamTriangle> C4FoWLightSection::CalculateTriangles(C4FoWRegion *
if (tri.fanRY > tri.fanLY && !logged_bug_asc)
{
// Bug finding helper
C4Rect rc;
C4Rect rc = region->getRegion();
LogF("tri.fanRY(%d) > tri.fanLY(%d) while updating rectangle (%d,%d,%d,%d)", (int)tri.fanRY, (int)tri.fanLY, (int)rc.x, (int)rc.y, (int)rc.Wdt, (int)rc.Hgt);
if (pLight) LogF("Light at %d/%d, r=%d f=%d s=%d obj=%s", (int)pLight->getX(), (int)pLight->getY(), (int)pLight->getReach(), (int)pLight->getFadeout(), (int)pLight->getSize(), pLight->getObj() ? pLight->getObj()->GetName() : "NULL");
Log(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*const_cast<C4FoWLightSection *>(this), "LightSection")).getData());
@ -604,7 +604,7 @@ std::list<C4FoWBeamTriangle> C4FoWLightSection::CalculateTriangles(C4FoWRegion *
if (nextTri.fanLY > nextTri.fanRY && !logged_bug_desc)
{
// Bug finding helper
C4Rect rc;
C4Rect rc = region->getRegion();
LogF("nextTri.fanLY(%d) > nextTri.fanRY(%d) while updating rectangle (%d,%d,%d,%d)", (int)nextTri.fanLY, (int)nextTri.fanRY, (int)rc.x, (int)rc.y, (int)rc.Wdt, (int)rc.Hgt);
if (pLight) LogF("Light at %d/%d, r=%d f=%d s=%d obj=%s", (int)pLight->getX(), (int)pLight->getY(), (int)pLight->getReach(), (int)pLight->getFadeout(), (int)pLight->getSize(), pLight->getObj() ? pLight->getObj()->GetName() : "NULL");
Log(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*const_cast<C4FoWLightSection *>(this), "LightSection")).getData());
@ -760,8 +760,6 @@ void C4FoWLightSection::transTriangles(std::list<C4FoWBeamTriangle> &triangles)
void C4FoWLightSection::CompileFunc(StdCompiler *pComp)
{
// only writing implemented for now
assert(pComp->isDecompiler());
pComp->Value(mkNamingAdapt(iRot, "iRot"));
pComp->Value(mkNamingAdapt(a, "a"));
pComp->Value(mkNamingAdapt(b, "b"));
@ -771,6 +769,27 @@ void C4FoWLightSection::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(rb, "rb"));
pComp->Value(mkNamingAdapt(rc, "rc"));
pComp->Value(mkNamingAdapt(rd, "rd"));
for (C4FoWBeam *beam = pBeams; beam; beam = beam->getNext())
pComp->Value(mkNamingAdapt(*beam, "Beam"));
if (pComp->isDecompiler())
{
for (C4FoWBeam *beam = pBeams; beam; beam = beam->getNext())
pComp->Value(mkNamingAdapt(*beam, "Beam"));
}
else
{
ClearBeams();
int32_t beam_count = 0;
pComp->Value(mkNamingCountAdapt<int32_t>(beam_count, "Beam"));
C4FoWBeam *last_beam = NULL;
for (int32_t i = 0; i < beam_count; ++i)
{
std::auto_ptr<C4FoWBeam> beam(new C4FoWBeam(0, 0, 0, 0));
pComp->Value(mkNamingAdapt(*beam, "Beam"));
C4FoWBeam *new_beam = beam.release();
if (!last_beam)
pBeams = new_beam;
else
last_beam->setNext(new_beam);
last_beam = new_beam;
}
}
}