Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Linux/Unix/*BSD portability  (Read 1308 times)

cribozai

  • Bay Watcher
    • View Profile
Linux/Unix/*BSD portability
« on: June 02, 2009, 01:47:39 pm »

(Sticky this?)

This thread is for reporting bugs for the native compile of the 31104branch.
Do not derail the thread!

So i recently played LCS 3.19.4 under wineconsole and realized that many crucial characters are missing. I Decided to "fight the power" and compile it under linux. Everything worked like a charm except for sitemaps.txt not working properly. So then i decided to ask the community if there is a fix to this since the old site generation was flawed at least critically in apartments (all doors unlocked and loot lying around). After a certain waiting period i decided to take my gcc and gdb out for a spin with my semi-programmer skills. Today at work (yes, my work is sometimes a lot of waiting) i was reading the source codes and trying to figure out what is wrong. So when i came home i decided to learn gdb a bit more and try to properly debug. After many many hours of debugging loops i finally found the problem.

The following code in configfile.cpp needs to be changed for 31104branch:
Code: [Select]
   // Leading whitespace

   while(source<600 && (line[source]==' ' || line[source]=='\t') && line[source]!=0)

      source++;



   // Command

   while(source<600 && (line[source]!=' ' && line[source]!='\t' && line[source]!='\r') && line[source]!=0) //fixed for linux - Cribozai

      command.push_back(line[source++]);



   // Delimiting whitespace

   while(source<600 && (line[source]==' ' || line[source]=='\t') && line[source]!=0)

      source++;



   // Value

   while(source<600 && (line[source]!=' ' && line[source]!='\t' && line[source]!='\r') && line[source]!=0) //fixed for linux - Cribozai

      value.push_back(line[source++]);



   return 1;

As of now i will continue to "fight the power" and try to fix all *nix related issues (primarily linux but it should affect all *nix quite the same. I call out for any and all support to make this work. I will try making *nix bugfixes and eventually get the code fit for packaging for distributions like debian (and derivative) and Fedora Core.

Anyway, this is how much l love LCS. It needs to find all its glory even for an open source platform.

PS. For the sitemaps.txt to work correctly atm you need to have the sitemaps.txt in your current working directory and you need to have converted it from dos to unix format to avoid issues with carriage returns.
On a debian system the package will be named tofrodos and the command dos2unix.

TL;DR Send bug reports that are obviously linux specific here. You can also feel free and try to fix them.

Hack on brothers...
« Last Edit: June 02, 2009, 04:13:16 pm by cribozai »
Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: Linux/Unix/*BSD portability
« Reply #1 on: June 02, 2009, 02:03:00 pm »

Awesome. But yikes, comments need to be removed? Do you know how to fix that so the comments are ignored properly? The comments are pretty important if anyone wants to mod the sitemaps file!
Logged

cribozai

  • Bay Watcher
    • View Profile
Re: Linux/Unix/*BSD portability
« Reply #2 on: June 02, 2009, 02:27:21 pm »

Awesome. But yikes, comments need to be removed? Do you know how to fix that so the comments are ignored properly? The comments are pretty important if anyone wants to mod the sitemaps file!
Working on it tomorrow. I understand your concern, and we want it to work properly don't we?  ;)

In what source file is the configfile.txt handled? Its not in the 31104branch tarball.
« Last Edit: June 02, 2009, 02:29:32 pm by cribozai »
Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: Linux/Unix/*BSD portability
« Reply #3 on: June 02, 2009, 02:45:18 pm »

It's probably in configfile.cpp and maybe sitemaps.cpp? Honestly, that function you quoted from is probably precisely the one that handles comment skipping. It is responsible for reading configfile.txt, breaking down the syntax, and storing its contents in memory as a series of objects representing individual commands. The code for building the map itself is in the objects that it creates.
Logged

cribozai

  • Bay Watcher
    • View Profile
Re: Linux/Unix/*BSD portability
« Reply #4 on: June 02, 2009, 02:53:10 pm »

It's probably in configfile.cpp and maybe sitemaps.cpp? Honestly, that function you quoted from is probably precisely the one that handles comment skipping. It is responsible for reading configfile.txt, breaking down the syntax, and storing its contents in memory as a series of objects representing individual commands. The code for building the map itself is in the objects that it creates.
I know, and that code i posted was the problem since windows handles the endline character differently. In *nix systems every endline is \r. This i fixed and it should not affect windows since \r is not used. The comment part i still need to run trough a debugger. It should in theory work now, but it doesn't. Its just a huge load of work going trough all the loops and checking every line for possible oddities. I should have a significantly less breaking patch for tomorrow.
Logged

temptemp

  • Escaped Lunatic
    • View Profile
Re: Linux/Unix/*BSD portability
« Reply #5 on: June 02, 2009, 03:38:01 pm »

Just running 'dos2unix sitemaps.txt' should fix the end of line issues.
Logged

cribozai

  • Bay Watcher
    • View Profile
Re: Linux/Unix/*BSD portability
« Reply #6 on: June 02, 2009, 04:05:44 pm »

Just running 'dos2unix sitemaps.txt' should fix the end of line issues.

Thanks for the heads up!
That actually worked fine. I converted the file to unix form and along with the code fix this also fixes the carriage return issue with some comment lines. So now i can remove the "need" to have it without quotes. It still presents an extra step to make things work fine. But it will do for now.
Logged

LiteralKa

  • Bay Watcher
  • LCS Developer
    • View Profile
    • My Website!
Re: Linux/Unix/*BSD portability
« Reply #7 on: June 03, 2009, 07:15:17 am »

I'm going to (hopefully) work on the code with Servant Corps today... Maybe version 4 can be the compile-ready version? :P
Logged
LCS developer, insomniac, writer.

cribozai

  • Bay Watcher
    • View Profile
Re: Linux/Unix/*BSD portability
« Reply #8 on: June 03, 2009, 12:40:29 pm »

I'm going to (hopefully) work on the code with Servant Corps today... Maybe version 4 can be the compile-ready version? :P
Sure, i can test the versions before that to make sure there are no major issues that will break a lot of the code. Then at version 4 we can try getting it in to the distributions and their servers for mainstream release. There is one license issue i could find of the top (not checked graphics yet) that actually will cause an issue with getting into the main repositories. The vector.h (iirc) is not under the GPL license and will make us drop to the non-free repositories. But that's an issue to be resolved later.
Logged

LiteralKa

  • Bay Watcher
  • LCS Developer
    • View Profile
    • My Website!
Re: Linux/Unix/*BSD portability
« Reply #9 on: June 03, 2009, 12:49:16 pm »

I'm going to (hopefully) work on the code with Servant Corps today... Maybe version 4 can be the compile-ready version? :P
Sure, i can test the versions before that to make sure there are no major issues that will break a lot of the code. Then at version 4 we can try getting it in to the distributions and their servers for mainstream release. There is one license issue i could find of the top (not checked graphics yet) that actually will cause an issue with getting into the main repositories. The vector.h (iirc) is not under the GPL license and will make us drop to the non-free repositories. But that's an issue to be resolved later.
Hmm, repositories would expand/increase the user base, and possibly the dev team!
Logged
LCS developer, insomniac, writer.