Closed kas1e closed 5 years ago
Ah, to add, Barony have use of one single glu* function in opengl.cpp file: gluPerspective , so i had to replace it on:
void kas_gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat znear, GLfloat zfar) { GLfloat xmin, xmax, ymin, ymax;
ymax = znear * tan(fovy * 0.008726646);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustum(xmin, xmax, ymin, ymax, znear, zfar);
}
At least that works in other projects, and crash which i describe happens on the more initial stage, imho..
Damn, in new version the start to use that crappy PhysFS :(( I always had problems with it :( Probably i need to stay with your previous version which you had hour ago, but then how we can test the same code at the same time ..
Yeah, I have seen that. And it's using latest PhysFS that need to be build from Mercurial repo.
You gluPerspective seems correct to me, and yeah, most of the time glu is not used much, exept for a few things like that.
I remember that generatePolyModel to be cpu intensive, I'm not surprised there could be bigendian issue on this one.
Do you mean even 3.0.1 version of PhysFS is old ? I will try probably to build it, just those usuall slashes problems vs PROGDIR: and stuff ..
v3? No that's fine. I meant v1 will not do it.
As i see from sources of 3.0.1, they at least support big endianes, one problem less
Mmm, maybe it's time I update to 3.0.1 also on my toolchain...
And as far as i can see, it is now cleaner a lot than old versions. At least, as far as i can see, i need to add in the physfs_platform.h :
#elif defined(__amigaos4__)
# define PHYSFS_PLATFORM_AMIGAOS4 1
# define PHYSFS_PLATFORM_POSIX 1
# define PHYSFS_NO_CDROM_SUPPORT 1
Create physfs_platform_amigaos4.c
In which just 4 functions:
#ifdef PHYSFS_PLATFORM_AMIGAOS4
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <limits.h>
#include "physfs_internal.h"
int __PHYSFS_platformInit(void)
{
return 1; /* always succeed. */
} /* __PHYSFS_platformInit */
void __PHYSFS_platformDeinit(void)
{
/* no-op */
} /* __PHYSFS_platformDeinit */
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
} /* __PHYSFS_platformCalcBaseDir */
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
{
} /* __PHYSFS_platformCalcPrefDir */
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
{
} /* __PHYSFS_platformDetectAvailableCDs */
#endif
So i only had to implement platformCalcBaseDir() and platformCalcBasePreDir()
I hope at least that nothing more need it :)
They pretty much doing something with Barony :) There is lots of warnings and new errors .. I see you fix some of them (i have them on 8.2.0gcc as well), but i also have some more:
[ 1%] Building CXX object CMakeFiles/editor.dir/src/files.cpp.obj
/amiga/Barony-master/src/files.cpp: In function ‘int physfsLoadMapFile(int, Uint32, bool, int*)’:
/amiga/Barony-master/src/files.cpp:1552:62: error: ‘stoi’ is not a member of ‘std’
std::get
If i remove std:: , then pure "stoi" also erroring.. damn.. Those guys who "update" Barony are the same as authors or other ones ?:)
std::stoi(...)
issue... It should be there with C++11 and more. You can also try to use atoi(..)
instead
(authors of changes, well, it depends, original authors does a ot of things, but they are some external contributions too).
I build phyfs for amigaos4 , through there implement normaly at moment only necessary for Barony function.
Can you also put os4 ifdefs there (at least at moment our compiler will not deal with):
I replace all stoi() on atoi() in the files.cpp, like this:
#ifdef __amigaos4__
std::get<LEVELPARAM_CHANCE_SECRET>(mapParameters) = std::atoi(parameterStr.c_str());
#else
std::get<LEVELPARAM_CHANCE_SECRET>(mapParameters) = std::stoi(parameterStr);
#endif
Then, there was error in the messages.cpp, about vsnprintf(), as it was:
#include "draw.hpp"
#include "messages.hpp"
#include "main.hpp"
So, to make messages.cpp compiles i had to swap it a bit: put "main.hpp" at top, like this:
#include "main.hpp"
#include "draw.hpp"
#include "messages.hpp"
Dunno why it matter for compiler, but probabaly because of way how includes including in those hpp files.
Then, in files scores.cpp , i meet with another error:
/amiga/Barony-master/src/scores.cpp:3088:53: error: ‘to_string’ is not a member of ‘std’ std::string filename = "savegames/savegame" + std::to_string(saveIndex);
Another issue of the same kind with our c++11 , so made the bug reports for both of them (stoi and to_string). At moment just commented this string out, as it anyway for "save game", while i even didn't start it :):
#ifdef __amigaos4__
std::string filename = "savegames/savegame"; //empty for now
#else
std::string filename = "savegames/savegame" + std::to_string(saveIndex);
#endif
Then another issue at almost end of compilation, in interface.cpp:
error: ‘round’ is not a member of ‘std’
Damn, another one :) And while i create BZ for it too, i still dunno how to deal with.
Sure, I'll add those #ifdef
tonight.
done...
Also, that __amigaos4__
is defined by your compiler or should I add some Amigaos4 section to the cmake project?
That define in the compiler , so all ok already.
Thanks ! Now i can build and link both (editor and barony itself) binaries. Now, have as expected issues with physfs , will try to fix it firstly. I only implement there __PHYSFS_platformCalcBaseDir , but barony use it damn a lot :(
PHYSFS_init PHYSFS_isInit PHYSFS_deinit PHYSFS_close
PHYSFS_enumerateFiles PHYSFS_freeList PHYSFS_getDirSeparator PHYSFS_getLastErrorCode PHYSFS_getRealDir PHYSFS_getSearchPath PHYSFS_mkdir PHYSFS_mount PHYSFS_openWrite PHYSFS_setWriteDir PHYSFS_unmount PHYSFS_writeBytes
At moment i use posix variants, they of course didn't works as want it all with "/" everywhere, so trying to deal with step by step.
Once will be ready, will let you know :)
Thanks for help !
Oh, by the way, there is 2 more ifdefs need it in editor.cpp and game.cpp, if you can add it plz as well:
#ifdef WINDOWS
strcpy(outputdir, "./");
#elif __amigaos4__
strcpy(outputdir, "PROGDIR:.barony");
if ( access(outputdir, F_OK) == -1 )
mkdir(outputdir, 0777);
#else
char *basepath = getenv("HOME");
snprintf(outputdir, sizeof(outputdir), "%s/.barony", basepath);
if ( access(outputdir, F_OK) == -1 )
mkdir(outputdir, 0777);
#endif
Its the same for both files
Ok, it's done.
Thanks ! I also deal with the physfs (by some ugly hacks, but whatever, is it only for that game), as well as had to change something in the game as well about those "patches" (while they use physfs, they still, do consuct and add those "/" and ":" in different places, so kind of mix of platform independant and platform dependant code, what is strange..). Anyway, binary now runs, open a windows, and bam ! same crash as before in the init.cpp's generatePolyModels() , while do "find front faces".. I may try to ask on Barony repo, if that part is endian aware, but something make me think that is not..
Yeah, I can see inside that function that the fread are not bigendian aware. I can try some fix (I'll use that amigaos4__
defined).
Ok, I have pushed some tentative fixes... If you can try it.
Oh ! Some very good progress ! No more crashes in generation of models, and i even can run Editor already as well as game itself:
http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/editor.jpg http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony.jpg
Through editor at some point give visual garbage and crashes, as well as Barony looks a bit odd by colors seems so, as well as missing textures (looks like?) , as well as before i can go to menu, i flooded in the debug log by lots of bad memory accesses , coming from the AssignActions() function placed in maps.cpp.
Probabaly there still issues with that sucking physfs and "/" things , so maybe its better to grab previous version where you have coursed edition, and where wasnt' physfs added, and tryed it with your path. What you think ?
I think the bad color are due to then conversion of SDL_Surface format. Missing are maybe caused by phyfs, but there a few games out there that use physfs, so a working version could really be interresting for you I guess. Using older version of code means back porting all the BigEndian convertion stuff from files.cpp/files.hpp, plus all other fixes that are still needed (at least for texture color), so it's still a lot of work.
Also, note that I do have missing texture issue for now on the Pandora. They are caused by the SDL2 version I use (2.0.8 in my last testing), and it was ok with an older version (2.0.5 probably, not sure), but I'm unsure if the issue is because of SDL2, or because some added code for the Pandora.
I just backport your freadBE/fwriteBE changes to the old cursed edition, and it seems to runs fine too, at least i the same can pass the generation of models, and then it the same bring on me bad memory accesses from assignActions() function.. I.e. its not physfs or patches related then :( maybe again ednianes crap.. Will try to printf() from which line crash come exactly
Builded with -gstabs, so stacktrace point our me right on the crashes line in the assingnActions() : it is part for "add lava lights" :
if ( lavatiles[map->tiles[y * MAPLAYERS + x * MAPLAYERS * map->height]] )
{
lightSphereShadow(x, y, 2, 128);
}
crashlog point out on line with "if".
It's code right at begining of assignActions() function . I for sake of tests tryed to comment it out at all (that whole "if" block), then it crashes futher, in the paths.cpp, in function fillPathMap(), in that part:
if ( !foundWallModifier && !foundObstacle )
{
int index = v * MAPLAYERS + (u + 1) * MAPLAYERS * map.height;
if ( !map.tiles[OBSTACLELAYER + index] && (pathMap == pathMapFlying
|| (map.tiles[index] && !(swimmingtiles[map.tiles[index]] || lavatiles[map.tiles[index]]) )) )
{
pathMap[v + (u + 1)*map.height] = zone;
repeat = true;
}
}
On second "if" (that big line). And it seems it have connection with checkTileForEntity() function. At least, in stack trace i see that there is first was call to the
'list_t* list = checkTileForEntity(u + 1, v);'
And then crashed line that if
. Dunno if it can be related to my commented out part about lava for now..
What commented part?
I mean part from where first crash come: from assignActions() part about "add lava light". That one where first crash come, and for sake if tests i comment out that " if" block (was in hope all will continue well after, but it lead to another crash)
Ah ok, I see. For now, I'm trying to figured out why texture are messed up. When this is fixed, I'll look at this issues (probably bigendian stuff).
So last commit should have fixed the missing texture. It may also fixed the bad color (not 100% sure).
And this commit e25b046306d66e3815cc573d9504759972d1b5cd should help for the crashes.
Have compiling errors in the writeBE on the line: char* p = tmp; error: cannot convert ‘char*’ to ‘char’ in initialization probably should be char p = (char )tmp; ?
Oops, I have pushed a fix.
Yeah, rebuild with fix, and can say that with Editor it visually help that way : i can see mouse cursor now. With Barony itself, first crash gone, yeah ! But then it still crashes in the path.cpp , in the fillPathMap(), on the line 593. There :
else if ( entity->behavior == &actWallBuilder || entity->behavior == &actWallBuster )
{
foundWallModifier = true;
break;
}
(but i still use Cursed Edition data files, but that probabaly should't lead to crash, right ?)
And editor's palette window looks like this: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/editor2.jpg (seems colors wrong ?)
I'll focus on the game for now, and will look at editor later (but yeah, palette seems wrong, I have to check later). The Cursed data shouldn't make it crash. I have to check why it could crash.
The crash you have is strange, and I'm not sure why it happens there.
Because you are using modern gcc, maybe this -fno-delete-null-pointer-checks
flag is needed?
If this build flags is not enough, can you try to get more info on the crash, like does entity
has a sensible address (well, probably not has this is the only chance for a crash in that line), but also is list
and node
have correct adresses.
I just redownload everything, rebuild from scratch, and this second strange crash just gone ! Even without -fno-delete-null-pointer-checks
flag !
See: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony2.jpg http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony3.jpg http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony4.jpg
Now had to check everything how it works and looks, etc. But at least i can switch to full screen :) Does it have FPS counter ?
But for brief look, something with fonts : line at bottom seems overwriten or shifted. Maybe even 2-3 pixels down. I.e. words "Introduction" and "Settings" quite visibly to looks wrong.
I didn't need that flag on the Pandora, but as I didn't understood your crash, it was worth a shot. But yeah, rebuilding was also a good idea!
That look great :) I'm guessing it's smooth on your Amiga (it is smooth on the Pandora, that is less powerfull). Be sure to grab the book on the table on your left when you start and go to the first down 1 time at least to check the performances.
I don't remember having seen any fps counter, but you can use LIBGL_FPS=1 to have fps timing printed every second on the console as a workaround.
Is fonts renders correctly on pandora ? I have it also in all windowses where font renders. Also in settings many strings missing, but that imho can be because of differenced between edition's data files (or again physfs :) ). Will check it more today.
I don't have super clean font rendering on the Pandora. It is looking similar to what you have on Amiga. I may have to check how the rendering is done...
It looks like drawing itself (where it draws) are clean, just about last 3 lines of pixels didnt drawed, like too early ended part about drawing
Btw, for you every running of binary are generated models ? Why i ask : for me is. While for editor some cache file created after first run, and then new runs are fast
Yes it generate all the time for game. There is a parameter to use the cache but it's OFF by default.
Btw, is LIBGL_FPS works in latest gl4es ? Just tried and seems it didn't .. At least on amigaos4 it prints nothing when i run Barony or Q3 or prototype.
I also found a screenshot of blessed addition menu from win32:
https://pbs.twimg.com/media/DYiV_4tUMAE8uSA.jpg
Can see there that fonts renders correctly. So it probabaly or amigaos4 again, or general issue in sources we have now (or they, authors have).
Yes it's there, but probably not for Amiga because it's not using regular glXSwapBuffers(...)
. So I implemented the counter in amiga_post_swap()
(commit pushed on gl4es repo)
About font rendering, yes, there is something odd, I'm working on it (I have the some on the Pandora, so maybe it's gl4es).
Drawing of text should be good now.
Tested latest build : yes, MUCH cleaner look now, but there few issues (with amigaos4 build at least):
In the game itself there is something wrong : all text is black now. See screenshot: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony6_blackfont.jpg
In the main menu , and in all settings, etc, there is missing "black lines around the letters". I.e. some kind of effect which make letters looks good. Check for example that screenshot from win32: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony_win32.jpg
And there is amigaos4 screenshot from about the same place: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony7_whiteletters.jpg
See, on amigaos4 all letters/font are just white.
Also i note 2 other issues, but they can be probably because of unfinished physfs port , and so something just didn't loads which make it all looks like this. For example, in the main menu, i have big empty space between "Credits" and "Quit" words, see: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony5_30fps.jpg
Also in settings, i have that kind of mess: http://kas1e.mikendezign.com/aos4/gl4es/games/Barony/barony8_settings.jpg
But that all probabaly because something just don't loads for me ... like some .txt or so.
Also FPS counter works for amigaos4 too now (thanks!) , and i have 30-60fps in the game's settings screen (depend on background's scene), and have about 30fps in the first level. That all with the 1280x720 + all extra options set (as on last screenshot). But i probably didn't have enabled your speedups defined via pandora, will try to do so
Right, empty space between "credits" and "quit" was because of missing content (i used for tests en.txt from the repo, while should use GOG's one instead, so replaced, and there is no empty space, but "Custom Content" phrase now. That one less then.
Also checking "settings" and there almost all phrases in there now, just few missed (that probably i should use blessed edition's en.txt, instead of gog's one).
Yes, it's better in your case to use the lang files from the lang
folder of the github, because thoses string are more linked to the binary than the data.
You still don't have outline on fonts, even with latest commit?
Seems so, but i may try to rebuild latest commit from scratch to be sure
Builded amigaos4 version of CursedEdition, and it runs, show the window, show phrase "loading polygon models", and then crashes. I prinfs it a bit, and found that crash happens in the init.cpp file, in the function generatePolyModels().
It going till the place where comment "find front faces" placed, and then crashed in that loop , without till next part in that function called "find back faces". Probably can be again endian issues, but at least game itself in theory support big endian, as i have found in 3 files ifdefs for. But maybe there its forgotten, or it just another erorr , in compiler for example :)
Will try in meantime to build new version as well, as pinpoint on which line exactly crash happens.