cnlohr / noeuclid

Non-euclidean GPU Raytraced Game
BSD 3-Clause "New" or "Revised" License
644 stars 48 forks source link

exploding when TCC tries to compile scripthelpers.h #29

Closed erinzm closed 9 years ago

erinzm commented 9 years ago

Any ideas @cnlohr?

➜  noeuclid git:(fix-tcc-relocate) ./noeuclid 
Populate Complete.
Textures Loaded.
Loaded addinfo pointers.
Allocated Addinfo.
RB Setup. Loading Shaders.
Compiling Shaders/Pass1
Linking Shaders. 3 <- 2 + 1 + 0
Shaders Linked
Shaders Linked.
Compiling Shaders/Pass1
Linking Shaders. 6 <- 5 + 4 + 0
Shaders Linked
Shaders Linked.
Compiling Shaders/Pass2
Linking Shaders. 9 <- 8 + 7 + 0
Shaders Linked
Shaders Linked.
Compiling Shaders/Pass3
Linking Shaders. 12 <- 11 + 10 + 0
Shaders Linked
Shaders Linked.
Shaders loaded.
Loading attribute map.
Loading tileattributes.txt
Malformatted line in TileAttributes.txt, line 56
Tile attributes loaded.
Done with tile attributes.
Done loading attributes. Making map.
 Making map...
Bound textures. Loading Fake/Default.  Fake: 0
In Default.
Basis created. Recalculating structure.
Acceleration Structure Calculated.
Done loading map.
Loading tileattributes.txt
Malformatted line in TileAttributes.txt, line 56
Tile attributes loaded.
Done with tile attributes.
Reloading texture...
Loading rooms.txt
<string>:146: identifier expected
terminate called after throwing an instance of 'std::invalid_argument'
  what():  Error compiling code ((/*
        Copyright (c) 2014 <>< Charles Lohr
        All rights reserved.

        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
                  notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
                  notice, this list of conditions and the following disclaimer in the
                  documentation and/or other materials provided with the distribution.
 * Neither the name of the <organization> nor the
                  names of its contributors may be used to endorse or promote products
                  derived from this software without specific prior written permission.

        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
        DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
        ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _SCRIPTHELPERS_H
#define _SCRIPTHELPERS_H
#ifdef IS_TCC_RUNTIME
#define v(x,y,z) x,y,z
#define vf(x,y,z) x,y,z
typedef unsigned char byte;
// WARNING: tcc does not throw errors when the signature of a function is not known!
float sinf(float x);
float cosf(float x);
double sin(double x);
double cos(double x);
double pow(double a, double b);
#else 
#include "Common.h"
#include <algorithm>

#define CLAMP( x, mi, ma ) (x < mi ? mi:( x>ma ? ma:x ) )

extern Vec3f gPosition;
extern Vec3f gDirection;
extern Vec3f gTargetNormal;
extern Vec3f gTargetCompression;
extern Vec3f gTargetHit;

extern int AddSizeStride;

void ClearCellV(Vec3i p);
void PaintRangeV(Vec3i p, Vec3i s, RGBA val);
void ClearRangeV(Vec3i p, Vec3i s);
void EmptyBoxV(Vec3i p, Vec3i s, bool force_empty, RGBA val);
void JumpSpaceV(Vec3i p, Vec3i s, Vec3f ofs, Vec3f f1 = {1,0,0}, Vec3f f2={0,1,0}, Vec3f f3 = {0,0,1});
void WarpSpaceV(Vec3i p, Vec3i s, Vec3f comp);
int PlayerInRangeV(Vec3f p, Vec3f s) ;
void ChangeCellV(int t, Vec3i p, RGBA c);
void QuickCellV(int t, Vec3i p, RGBA c);
void QuickCell1GBAOnlyV(Vec3i p, byte g, byte b, byte a);
void UpdateZoneV(Vec3i p, Vec3i s);
bool fileChanged(string fname);
string readFile(string fname);

struct PickableBlock {
    Vec3i p;
    float phasing; //If +1 or 0, block is truly here.  If -1, phasing out.  Note: 0 = do not re-update.
    float density; //between 0 and 1.
    char in_use;
};

struct DeathBlock {
    Vec3i p;
    int in_use;
};

#endif

#define PICKABLE_CELL 114
#define DEFAULT_BRIGHT 190
#define DEFAULT_DENSITY 125
#define WALL_BLOCK 12
#define WHITE_BLOCK 19
#define GOAL_BLOCK 24
#define DEADGOAL_BLOCK 7
#define DEFAULT_EMPTY_BLOCK 0
#define SPAAACE_CELL 255

extern double worldDeltaTime;
extern float gDaytime;
extern float gRenderMixval;
extern float gRenderDensityLimit;
extern float gRenderDensityMux;
extern float gTargetActualDistance;
extern float gTargetProjDistance;
extern float gTargetPerceivedDistance;
extern char gDialog[1024];
extern byte gKeyMap[256];
extern byte gFocused;
extern int gMouseLastClickButton;
extern float gTimeSinceOnGround;
extern int pickables_in_inventory;
extern int gOverallUpdateNo;
extern double GameTimer;
extern double GameAttempt;

float swoovey(float f, float siny);

char loopingarrayaccess(char * map, int w, int h, int x, int y);

int PlayerInRange(float x, float y, float z, float x2, float y2, float z2);
void PaintRange(int x, int y, int z, int x2, int y2, int z2, byte block, byte density);
void JumpSpace(int x, int y, int z, int x2, int y2, int z2, float xofs, float yofs, float zofs);
void JumpSpaceExtended(int x, int y, int z, int x2, int y2, int z2, float xofs, float yofs, float zofs, float xm1, float ym1, float zm1, float xm2, float ym2, float zm2, float xm3, float ym3, float zm3);

void ClearPickableBlocks();
void PlacePickableAt(int x, int y, int z, float initDensity);
void ChangeCell(int x, int y, int z, byte block, byte density);
void ClearCell(int x, int y, int z);
void ClearRange(int x, int y, int z, int x2, int y2, int z2);
void EmptyBox(int x, int y, int z, int x2, int y2, int z2, byte block, byte density);
void WarpSpace(int x, int y, int z, int x2, int y2, int z2, float f1, float f2, float f3);
void QuickCell(int t, int x, int y, int z, byte block, byte density);
void AddDeathBlock(int x, int y, int z);
void UpdateZone(int x, int y, int z, int x2, int y2, int z2);
void die();
#endif
extern float gPositionX;
extern float gPositionY;
extern float gPositionZ;
extern float gDirectionX;
extern float gDirectionY;
extern float gDirectionZ;
extern float gTargetNormalX;
extern float gTargetNormalY;
extern float gTargetNormalZ;
extern float gTargetCompressionX;
extern float gTargetCompressionY;
extern float gTargetCompressionZ;
extern float gTargetHitX;
extern float gTargetHitY;
extern float gTargetHitZ;
void fun() {      for(int i=0;i<10;i++) {
              float den = (i+1.0)/12.0;
              if(den<.1) den=.1;
              WarpSpace(v(2,2,59-i),v(4,4,1),vf(den,den,den));
      }
}))
[1]    3651 abort (core dumped)  ./noeuclid
cnlohr commented 9 years ago

Just wondering, what version of libTCC are you using?

erinzm commented 9 years ago

I compiled it from source from a github fork, I think it's 0.9.26.

On Mon, Jan 5, 2015 at 12:28 AM, Charles notifications@github.com wrote:

Just wondering, what version of libTCC are you using?

— Reply to this email directly or view it on GitHub https://github.com/cnlohr/noeuclid/issues/29#issuecomment-68672786.

cnlohr commented 9 years ago

Just wondering: which fork? I could test with that, myself.

erinzm commented 9 years ago

See #27 for an explanation of why I think it's not working.

erinzm commented 9 years ago

Yes, it was that I had 0.9.25 instead. Stupid Ubuntu package manager installed libTCC 0.9.25, but I had also compiled 0.9.26 and installed it in /usr/local. Apparently the packaged one took precedence.

cnlohr commented 9 years ago

Excellent. Yeah, I know I need 0.9.26, I will add something to the readme.