Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 6 7 [8] 9 10 ... 57

Author Topic: Terra Vitae Fork (version 2.0 released!)  (Read 318016 times)

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #105 on: September 18, 2014, 05:10:18 pm »

Okay, SVN LCS installs. I gotta run now, and I'll try to install your code (and upload it) later tonight! Thanks again! :)
Logged

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Mod Planning: Terra Vitae mod
« Reply #106 on: September 18, 2014, 05:12:41 pm »

Whew! I was beginning to think this might go on forever, but the two of us got it working! Good teamwork! ;D

P.S. I have just updated all the comments I posted in this thread in the last 2 days so they have the link to the latest download based on revision 852 instead of links to older versions, and so that directions I gave that turned out to be incorrect are now replaced with correct information. So anybody looking at this conversation later on will not see my original comments, they have gone through many edits.
« Last Edit: September 18, 2014, 05:32:45 pm by Liberal Elitist »
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #107 on: September 18, 2014, 07:09:09 pm »

Okay, first, the good news: it compiles.

Next, I'm getting some weird characters in the code. For example, the minus sign dash is replaced with ƒ, and several other characters have been changed. For example, what is MayagÅez, Puerto Rico? Is it Mayaguez? :p


More to the point: the code in lines 396 through 403 of sitedisplay.cpp has six illegal characters that I can't easily figure out what they're supposed to be. Could you tell me what they are so that I can fix them?


Edit: Well, the problem is not the length of the strings in weapons.xml.

Edit to edit: I discover that when reading weapons in xml, WeaponType::WeaponType(MCD_STR xmlstring) only reads in the short name and future short name of each weapon. This includes both the Terra Vitae weapons (magic, blasters, powers), and the existing LCS weapons. However as I have now tested, I also note that the game displays these names correctly; I am guessing that it is somehow not correctly reading the long names of these weapons. Where can I find the function that reads these?
« Last Edit: September 18, 2014, 08:47:13 pm by SlatersQuest »
Logged

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Mod Planning: Terra Vitae mod
« Reply #108 on: September 19, 2014, 12:27:23 am »

It appears that Code Page 437 characters aren't working on your system. That's odd, I thought my code for it was cross-platform. I wish I had a Mac OS X computer to debug this on... oh and it's Mayagüez, Puerto Rico. That's an "u" with an umlaut in it.

Evidently your console doesn't display Code Page 437 characters. Although I think on UNIX-based consoles it will try to use UTF-8 encoding. So most likely the program thinks it is outputting in one character set (either Code Page 437 or UTF-8, I'm not sure which, probably UTF-8 on your system), but it is instead getting output in a different code page (whatever the default on Mac OS X is), and the functions to set the locale don't seem to change the code page used by your console window.

Hmm... this means I will need to look at Mac OS X's API for console mode applications and see if it actually has a different API than other UNIXes for this. As far as I'm aware the code displays correct characters on Linux. So this is specific to Mac OS X, this confusion over code pages. Honestly I thought I solved all the problems with code pages months ago back in June or July. But I guess that just solved it on Windows and Linux and not Mac OS X.

Well, this project does aim to work as well as possible on as many operating systems as possible. I'll need to research Mac OS X's API documentation on this and see how it differs from Linux when it comes to console applications. If there is a quick and easy way to enable UTF-8 that will be the best solution. UTF-8 contains all characters in Code Page 437 and many more, and Liberal Crime Squad is capable of outputting in either of those 2 code pages (it has a handy code page conversion table that every single character it outputs is processed through, if it is in UTF-8 mode, since all char and string literals in the game, as well as in the .cmv and .cpc files in the /art directory, are encoded in Code Page 437).

As for getting the characters to display properly in your text editor, there are comments in the source code files that use extended Code Page 437 characters explaining that those files are in that code page and how to view them properly in various IDEs and text editors. Although maybe the comments might not include whatever IDE or text editor you use since I don't know what you use. It does cover quite a number of them, though. Also I would not call those "illegal characters", those characters are meant to be there and they are most certainly the correct characters, you just need to view the .cpp source files in Code Page 437 (also known as PC-8 or IBM DOS OEM-US or a couple other names) and you will be able to see exactly what those characters are. Anyway these are NOT "illegal characters" and they do NOT need to be "fixed".

What needs to be fixed is getting both your text editor to use the correct code page to display them properly, and calling whatever API functions Mac OS X uses to set the code page to UTF-8 (since probably the characters get converted from Code Page 437 to UTF-8 before being output on your system, I think this is the default on non-Windows platforms).

You can enable the macro CH_USE_ASCII_HACK (I think that's what it's called anyway) to force all characters output to be in the range 32-126 of standard ASCII display characters. I think the place to enable it would be somewhere in common.h, rather than in includes.h. Or maybe the code checks to see if that is defined, ahead of time, I don't remember right now, but from what I recall, I don't think it's something that you can define as a macro in your makefile or whatever, you'll probably have to edit the source code, the ASCII hack is just a nasty hack to avoid this sort of thing.

Anyway I'm a bit surprised you have this problem since the game has used extended characters quite a bit for quite some time, in stuff like newspaper display and curses movies. Did newspapers and curses movies display correctly before? I am glad we are getting to the bottom of this, though, since when I was working on fixing up the code page code so that it would be able to display any character in either CP437 or UTF-8 and do the necessary conversion if necessary, I needed people on both Linux and Mac OS X to test it, and while people tested it on Linux and got it working fine, you're one of the few people testing and building stuff on Mac OS X so your feedback is very valuable in finding bugs that exist on your platform but not on others.

In short, these are all Mac OS X-specific problems and they occurred because we don't have enough developers who test it in Mac OS X but it shouldn't be any trouble getting it working if we cooperate on this and I try implementing code and you test it out until it finally works right. I am a bit saddened that my code doesn't work right in Mac OS X but I want to make certain that it is fixed, I want this game to support as many operating systems as possible, as fully as possible, especially modern operating systems that are widely in use on desktop or laptop computers, and Mac OS X definitely qualifies as one of those. I usually assume that code that works on Linux will also work on Mac OS X since they are both UNIX-based and in MOST cases this is correct but not always, there are some major differences between Mac OS X and Linux and it appears we've found one of them involving console applications and the code pages they use.

Anyway there's a good chance you can also fix this, instead of with CH_USE_ASCII_HACK, by using either CH_USE_UNICODE or CH_USE_CP437. You should try out all 3.

OK so now I am ready to recommend some changes to code.

In common.h, lines 86-90 read this:
Code: [Select]
   #if defined(HAVE_WIDE_NCURSES) && defined(__STDC_ISO_10646__)
     #define CH_USE_UNICODE
   #else
     #define CH_USE_ASCII_HACK
   #endif

Comment those lines out, all 5 of them.
Then add one of the following 3 lines (ONE of them) in that same place (best to put right after the 5 commented-out lines):
Code: [Select]
     #define CH_USE_UNICODE
Code: [Select]
     #define CH_USE_ASCII_HACK
Code: [Select]
     #define CH_USE_CP437
Also I'd like to know what version of curses you're using? ncurses? xcurses? Is it wide-character or not? Does it have UTF-8 support or not?

Anyway see what those 3 different options for CH_USE_whatever do and see which one works best...

Also find out whether or not the following macros are defined on your system and report back for each one please (you can add checks for them into the Liberal Crime Squad code and have it print out a message):
HAVE_WIDE_NCURSES
__STDC_ISO_10646__
HAVE_LIBXCURSES
HAVE_LIBNCURSES
USE_NCURSES
USE_NCURSES_W
USE_XCURSES
PDCURSES
PDC_WIDE
NCURSES
XCURSES
__APPLE__
__MACH__
__unix__
Linux
_POSIX_VERSION
DONT_INCLUDE_SDL

For instance to check if HAVE_WIDE_NCURSES is defined you could use this code:
Code: [Select]
erase();
#ifdef HAVE_WIDE_NCURSES
set_color(COLOR_GREEN,COLOR_BLACK,1);
mvaddstr(0,0,"HAVE_WIDE_NCURSES is defined",gamelog);
#else // HAVE_WIDE_NCURSES
set_color(COLOR_RED,COLOR_BLACK,1);
mvaddstr(0,0,"HAVE_WIDE_NCURSES is not defined",gamelog);
#endif // HAVE_WIDE_NCURSES
getkey();
erase();

Then just insert that code at the beginning of the function mode_title() in /title/titlescreen.cpp. You can do that to test out each of those macros to see if they're defined or not. I need to know this so I can set up the #ifdefs properly for your system. Also I need to know which of the 3 character sets works best for you, Unicode, CP437, or the ASCII Hack. Then I can update the code so it'll display the proper character set on your system once I have this info.
« Last Edit: September 19, 2014, 01:30:23 am by Liberal Elitist »
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #109 on: September 19, 2014, 08:39:57 am »

It's okay - I'm figuring out what most of the characters are, anyhow (actually it seems to work in-game; it's the compiler that's flipping out and sending warning messages).

More importantly, where are the full names of weapons interpreted from XML? I've tested and discovered that it does not appear to be in WeaponType::WeaponType(MCD_STR xmlstring), since putting addstr() commands into that after every input does not pick up the full names (only the short names).

Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #110 on: September 19, 2014, 05:37:19 pm »

Okay, I think I may finally know what is going on. Please read this and verify if this sounds right!

In Creature.h:
Code: [Select]
class Creature
{
...
bool is_armed() const { return get_weapon().get_itemtypename()!="WEAPON_NONE"; }
...
}


And in Creature.cpp:

Code: [Select]
Weapon& Creature::weapon_none()
{
   static Weapon unarmed(*weapontype[getweapontype("WEAPON_NONE")]);
   return unarmed;
}

Weapon& Creature::weapon_magic()
{
   static Weapon magic(*weapontype[getweapontype("WEAPON_MAGIC")]);
   return magic;
}

Weapon& Creature::weapon_powers()
{
   static Weapon powers(*weapontype[getweapontype("WEAPON_POWERS")]);
   return powers;
}

Weapon& Creature::weapon_suit()
{
   static Weapon battlesuit(*weapontype[getweapontype("WEAPON_BATTLESUIT")]);
   return battlesuit;
}

...

Weapon& Creature::get_weapon() const
{
    //Terra Vitae: modified to account for magic
   if (!is_unarmed())
       return *weapon;
   else if (get_skill(SKILL_MAGIC) > 0)
       return weapon_magic();
   else if (get_skill(SKILL_POWERS) > 0)
       return weapon_powers();
   else if (get_armor().get_itemtypename() == "ARMOR_BATTLESUIT")
       return weapon_suit();
   else
      return weapon_none();
}

...

string Creature::get_weapon_string(int subtype) const
{
   string r;
   if(is_armed())
   {
      r = weapon->get_name(subtype);
      if(weapon->uses_ammo())
         r += " (" + tostring(weapon->get_ammoamount()) + "/" + tostring(count_clips()) + ")";
      else if(weapon->is_throwable())
         r += " (1/" + tostring(count_weapons()-1) + ")"; // -1 so not to count weapon in hands.
   }
   else if(len(extra_throwing_weapons))
   {
      r = extra_throwing_weapons[0]->get_name(subtype);
      r += " (0/" + tostring(count_weapons()) + ")";
   }
   else r = "None";
   return r;
}

Finally, in weapon.cpp:
Code: [Select]
const string& Weapon::get_name(unsigned subtype) const
{return weapontype[getweapontype(itemtypename())]->get_name(subtype);}


When printing a liberal's stats, the game calls get_weapon_string(int subtype). The very first line of this calls is_armed(), which in turn calls get_weapon(). If the liberal is genuinely unarmed, get_weapon() returns weapon_none() which causes is_armed() to return false. As a result, get_weapon_string(int subtype) returns the string "None" without actually fiddling with the character's nonexistent weapon.

However, if the liberal possesses SKILL_MAGIC, get_weapon() returns weapon_magic() to is_armed(), causing the if statement in get_weapon_string() to then call Weapon::get_name(). However, the magic weapon of the creature doesn't actually exist, and since Weapon::get_name() does not know to call weapon_magic() to get the static constant weapon that it needs. As a result, itemtypename() in Weapon::get_name(unsigned subtype) returns an invalid string id.

Hence, segmentation fault.

The solution it seems to me then is to rewrite Creature::get_weapon_string(int subtype) so that it knows to go and get weapon_magic() (or weapon_powers() or weapon_suit()) before proceeding to call Weapon::get_name().

Does this sound right?
Logged

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Mod Planning: Terra Vitae mod
« Reply #111 on: September 19, 2014, 06:38:33 pm »

OK, first replying to the first of your 2 recent comments...

It would be nice if I could get this bug with incorrect characters displayed on Mac OS X fixed before I leave for vacation for a month on Tuesday. You know starting Tuesday I won't be here on these forums or do any programming for a month since I'll be on vacation. I was wanting that detailed info about values of debug defines and which of the 3 character sets works best on your system so I could improve the code in common.h and maybe also /common/consolesupport.cpp and cursesgraphics.h to do the correct checks to display the characters properly not just for you but for everyone on Mac OS X.

I have thought a bit more about what feedback I HAVE gotten from you on this subject and the research I've done online. Well it seems Mac OS X uses the exact same POSIX APIs for setting console code pages as Linux, the BSDs, and other modern UNIX-based systems. But I realized you had this compiler warning and remembered that Mac OS X, in recent versions of XCode, no longer uses the GCC compiler but uses the Clang compiler instead! So your COMPILER is the thing that is having a problem, not your operating system. After some quick thinking I determined that Clang probably expects string literals to be in UTF-8 already and might be attempting some type of code page conversion on them (BAD IDEA), whereas GCC and MS Visual compilers both process string literals as a series of bytes which they do not alter (GOOD IDEA). Clang supposedly is supposed to behave the same way as GCC, it even identifies itself as GCC via debug defines, but there are separate debug defines to detect Clang. I'll probably have to download the version of Clang for Windows and try that compiler on for size to sort this all out, now that I've realized the problem isn't incompatibility with your operating system, but incompatibility with your compiler. Incompatibility with how it processes string literals that are in between double quotes "like this" in C/C++. So due to this newfound discovery that the incompatibility is most likely with your compiler rather than your operating system, and the fact that Clang is available on Windows to work with MinGW the same as GCC is and ought to work with my Code::Blocks IDE too, I think I shall be able to sort this out without requiring your assistance, although maybe not until after my vacation.

I will see if I can get it done before then though... I'll need to install the Clang compiler on my system and get it working.

I would ask you, could you try installing the GCC compiler on your computer and using it instead of Clang and seeing if that solves the problem with incorrect characters being displayed, or does that problem persist even if you switch compilers from Clang to GCC? Because I think the cause of the wrong characters being displayed is a difference in how those 2 compilers handle string literals, and I think if you used GCC it would produce correct results for Mac OS X, identical to the correct results people on Linux who use GCC get, and all your characters would display properly.

As for all those things about trying out different character sets and telling me the values of different debug defines I don't think that is necessary, that was based on the assumption the problem was an incompatibility with your operating system or version of curses, rather than your compiler itself. The main change between the older versions (stable and beta releases) and newer SVN versions that might potentially cause incorrect characters to be displayed is the use of Code Page 437 string literals in the C++ source code itself, which some compilers might not like... it works on the 2 most popular compilers, Microsoft Visual C++ and the GNU Compiler Collection, but apparently there is an incompatibility with the Clang compiler that Mac OS X uses by default in more recent versions of XCode (older versions of XCode used GCC and they would probably have no problem at all with this code). So the problem is not incompatibility with your operating system but incompatibility with your compiler, but I'm sure we'll eventually get that sorted out and solved. But I'm going on a trip soon so it might not necessarily happen this month.

You see I'm going on a vacation In Real Life soon (Tuesday) so this being Friday, after today there's just Saturday, Sunday, and Monday and then I'll spend Tuesday traveling... and I need to start getting packed for the trip and do laundry and run some errands etc. I'm talking about real life in this paragraph, not a video game.

Back to the video game Liberal Crime Squad, as for how full names are interpreted from XML, this takes place in the function void ItemType::init(const MCD_STR& xmlstring) in ItemType.cpp. You see WeaponType is a class that extends the class ItemType so when a new WeaponType is created, it is also a new ItemType, so the constructors for both classes are apparently called... I think. Not entirely sure how that works. Anyway somehow the function void ItemType::init(const MCD_STR& xmlstring) in ItemType.cpp gets called, apparently by the ItemType constructor, which is called when a new WeaponType is created along with the WeaponType constructor (not sure which order they are called in though, I am guessing probably the ItemType constructor is called first most likely). Anyway this is all a use of fancy C++ object-oriented programming which honestly even I find a bit confusing. Just remember every WeaponType is also an ItemType, every Weapon is also an Item, and so on... if you look at weapontype.h the class declaration for it says "class WeaponType : public ItemType" which means WeaponType also includes everything from the ItemType class and extends upon it. :o

Now replying to the 2nd of your 2 recent comments...

That looks about right, I think you might have solved the segfault bug, I'm not sure, you should test it out... I would agree with what you said, "The solution it seems to me then is to rewrite Creature::get_weapon_string(int subtype) so that it knows to go and get weapon_magic() (or weapon_powers() or weapon_suit()) before proceeding to call Weapon::get_name()." That sounds correct judging by your analysis there. It seems you did a very good analysis of the bug there and finally caught it. At least I hope this is true. I didn't see any errors in your XML code for the new weapons, and this segfault does not happen in the vanilla game, so logically it is most likely to do with the changes to the source code made in the Terra Vitae mod to accommodate the 3 new weapon types for people who don't have weapons equipped, and you seem to have found and identified exactly what the problem is with that code as well as how to fix it, in your most recent comment here.

So I say, you are probably correct and I think you've finally solved this. I always thought you were rather closer to solving that segfault bug than me, I was a bit too baffled by it to know what to do but you knew exactly where the segfault was coming from, from your debugging, whereas I couldn't even get my stupid debugger to work properly. Well I think you've found the solution. ;)

But due to my upcoming month-long trip to Europe, that I leave for on Tuesday, I'm going to be away from programming for a month. What I suggest you do now is try out GCC on Mac OS X as your compiler instead of Clang on Mac OS X and see if it displays the characters properly. That warning message about "illegal characters" actually WAS correct, from the perspective of the Clang compiler, since it was expecting UTF-8 characters most likely, and it got Code Page 437 characters instead. But this is a misunderstanding between the code and the Clang compiler. I think the Clang compiler, like other compilers, has many options, and there might be a way to solve this and make it compatible with Clang using one of Clang's compiler options. But right now the easiest solution is to just use GCC instead because I know that it works on GCC with the current code.
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Mod Planning: Terra Vitae mod
« Reply #112 on: September 19, 2014, 08:42:12 pm »

Alright I have read a lot of documents online and figured out the issue with Clang. Clang doesn't support any non-Unicode character sets other than plain ASCII, which is actually a strict subset of both UTF-8 and other character sets like Code Page 437. If a string literal contains characters outside the 0-127 range, Clang detects this and treats the string as encoded in UTF-8, if the string is made up of the regular char type instead of wide characters such as wchar_t. Clang then enforces the rules of UTF-8 on the string. Clang also supports other Unicode character sets like UTF-16 and UTF-32. But it does not support character sets that are non-Unicode. Microsoft Visual C++, on the other hand, treats string literals that are made of chars as if they are encoded in the system's default code page as set in the Microsoft Windows Control Panel, unless the source code file is saved as UTF-8 with a Byte Order Mark (BOM) at the beginning, in which case it treats them as UTF-8. And GCC by default claims to treat string literals as UTF-8, although it does not enforce any of the rules of this encoding or do any code page conversion, and leaves it up to the programmer to deal with the encoding, and GCC essentially behaves in an encoding-agnostic way unless you use special command line options such as "-fexec-charset" and "-finput-charset".

Anyway, we don't want the compiler to do ANY code page conversion AT ALL, because Liberal Crime Squad's source code handles that directly. Microsoft Visual C++ and GCC both avoid doing code page conversion, on the current code. Clang, on the other hand, appears to do some sort of unwanted conversion.

The ultimate problem here is that there is no standard in C or C++ for dealing with extended characters in string or even char literals (inside "double quotation marks" for strings or 'single quotation marks') for chars. So the workaround to make cross-platform code that works correctly on all compilers on all platforms is to never ever ever use extended characters inside string OR char literals. Instead, numbers must be used and then typecast to type char. So for character 130 in Code Page 437, which is é (you can get this in non-console programs in Windows by making sure Num Lock is on, holding down the ALT key, typing 130 on the numeric keypad, and then letting go of the ALT key, a method that also works with any other Code Page 437 character in Windows), the code in C/C++ for this character, to be cross-platform, should be (char)130. That is just an example for character 130, but you can generalize this to any character between 0 and 31 or 127 and 255. Characters between 32 and 126 are standard ASCII characters that CAN be contained in string literals cross-platform.

Another possible solution is using backslash codes (or escape sequences, as they are called) to specify characters. In the case of character 130 from Code Page 437, to do this as a char you would do '\x82' and to do it as a string you would do "\x82". This is because \x codes use 2-digit hexadecimal codes to represent a value from 0-255 in decimal (00 to ff in hexadecimal), and 82 is hexadecimal for 130 in decimal. Backslash codes are the easier solution and hopefully they work. The code already uses backslash codes for characters between 0 and 31 because those characters are not allowed in the source code and are considered control characters. So I just need to make it also do this for characters between 127 and 255.

And these would both have the added benefit of making the source code files be in plain ASCII and look the same no matter what character set your text editor or IDE is set up to use, since all characters outside the 32-126 range (other than newlines) would be encoded using escape sequences that would only use standard ASCII characters within that range, and these characters are the same in all character sets (other than obscure, never-used ones like EBCDIC).

At least I THINK that is what the solution is...

The downfall to this is that you won't be able to directly look at the source code and see what characters are in something if it uses extended characters, instead you will see the 2-digit hexadecimal codes for the characters, making the char and string literals in the code less readable. Also, looking at how Clang "works" (in quotes, because I have looked at how it handles string and char literals and it treats everything as Unicode and doesn't allow any other option, whereas GCC and MS Visual C++ both have multiple options for character sets), well the \x escape sequences might not work, it might actually require typecasting from an integer constant to a char like so (char)0. Or it might even require some other typecast such as static_cast or reinterpret_cast.

For now you are best off using GCC instead of Clang and seeing if that works... if it does fix the character display problems than I'll need to fix this to work on Clang. If it doesn't fix things I'll have to throw these theories about what causes these character display problems out the window. But it will be important for me to know whether using GCC instead of Clang as your compiler on Mac OS X fixes your character display problems. I think this is true, but if I am wrong, then all of my thinking about how to fix it is also wrong too and I'll need to start over from scratch.

So it would be VERY helpful if you installed GCC on your Mac OS X computer and tried it out and told me whether or not it fixed things with character display problems, because then I'd know for sure what the cause of this incompatibility is. (Ultimately the cause is that the behavior of compilers on string literals is not standardized except in the C++11 standard and we can't use that because it doesn't work on older compilers so if we used it, we would break compatibility with many compilers and the whole point of what I'm trying to do here is improve compatibility with compilers, not make it worse.)
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #113 on: September 19, 2014, 10:29:22 pm »

That was, indeed, the bug! :)

Version 0.2 is released!![/u] (link to top thread)

Major changes:
-Fixed the bug that caused the new weapons (magic, super powers, battle suit blasters) to crash the game!
-Added a wide number of cheat/debugging codes (to be further documented and expanded in next version)
-Added most of the new professions/character/creature types to the game
-Updated to current version of LCS with Stalinist features and many other tweaks (thanks to Liberal Elitist)

More minor changes:
-Recruits can sometimes be married. Their spouses can join the LCS as love-slaves!

More to come:
-Port 0.2 to Windows
-Expand debug codes for making scenarios (ever want an elite liberal Congress, an arch-conservative president, and a supreme court that is, to a man, Stalinist?)

Next planned update:
-New locations!


*


Re: illegal characters -

 - Everything I've done so far has been with gcc. I've never used Clang.

Upon further inspection, I am discovering the following: gcc issues lots of warnings about illegal characters. However, in-game, these characters display correctly.

Logged

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Mod Planning: Terra Vitae mod
« Reply #114 on: September 19, 2014, 11:19:35 pm »

Re: illegal characters -

 - Everything I've done so far has been with gcc. I've never used Clang.

Upon further inspection, I am discovering the following: gcc issues lots of warnings about illegal characters. However, in-game, these characters display correctly.

Ah! I am actually a little relieved you are using GCC and not Clang. I just tried installing Clang on my computer and it is quite difficult to get it set up, in fact my computer's CPU is an AMD Sempron 2800+ and doesn't support SSE2 instructions, and the Windows binaries they make available for download don't work on my CPU, so I would have to compile their compiler from scratch to get it working on my machine, and I was not looking forward to that... now I can cancel those plans! Whew! :D So we both use the same compiler, GCC. It is strange then, that you get warnings and I don't, but I think I have an idea what to do.

Well then, you should try the following GCC options: "-finput-charset=CP437 -fexec-charset=CP437". See if that fixes things! From what I read about it, it ought to work. I was under the impression that things were working on GCC on other platforms and it displayed correct characters. I know firsthand that it displays correct characters on Windows with the GCC compiler (from the TDM-GCC 4.8.1-3 package). And after I fixed up some code a few months ago to fix character display on Linux I haven't had any complaints about that anymore, earlier I had complaints about it not displaying the right characters on Linux. I never had any Linux users positively confirm that this problem was fixed but since several developers use Linux and none of them complained anymore about incorrect character display and I had just done major fixes for that I assumed my fixes must work. Well maybe they do, maybe they don't. But you should try out those GCC options, you can add them to your CPPFLAGS.

So you can add this line to configure.ac to add those GCC options:
Code: [Select]
CPPFLAGS="$CPPFLAGS -finput-charset=CP437 -fexec-charset=CP437"
That will set GCC to recognize the character set of the source code as Code Page 437, and not try to convert it to anything else, at least from what I have read. That line should go somewhere in configure.ac after stuff is initialized (after "AC_PROG_CXX" in line 12) but before the end part (before "AC_CHECK_FUNCS([memset mkdir strchr])" in line 91)... and not inside any if..fi conditional section. Lines 88, 89, and 90 are all blank, 3 in a row, that's a good place to add that line to configure.ac. Just see whether that fixes the character set so the right characters are outputted.

And see if it gets rid of the warnings about illegal characters too. I am hopeful about this but not sure if it is the solution...

If you want here is the entire code for configure.ac that you can copy and paste to try out, with that line I had above added in a suitable location, along with a comment explaining it:
Code: [Select]
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.6)

#The following line has the program name, the program version, and the bug report address.
AC_INIT([crimesquad], [4.07.5],[jonathansfox@users.sourceforge.net])
AC_CONFIG_SRCDIR([src/cursesgraphics.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX

# Defines
# TODO: Conditionally set these depending on build system.
AC_DEFINE([UNIX],[],[Defined if on a UNIX based system])
AC_DEFINE([Linux],[],[Defined if running on Linux])
AC_DEFINE([NCURSES],[],[Defined if we use NCURSES (always true on linux)])

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h sys/time.h unistd.h ncurses.h ncursesw/ncurses.h])

# Check for ncurses libraries, preferring wide character ones:
for lib in ncurses ncursesw; do
   if test "$lib" = ncursesw; then
      name="NCURSES_W"
      header="$ac_cv_header_ncursesw_ncurses_h"
   else
      name="NCURSES"
      header="$ac_cv_header_ncurses_h"
   fi

   if test "$header" = "yes"; then
      AC_CHECK_LIB($lib, addch, [
         AC_CHECK_LIB($lib, add_wch,
            [wide_ncurses="$wide_ncurses $lib"],
            [plain_ncurses="$plain_ncurses $lib"]
         )
      ])
   fi
done

AC_SEARCH_LIBS(initscr, [$wide_ncurses $plain_ncurses], [],
   [AC_MSG_ERROR([You need ncurses!])])

for lib in $wide_ncurses; do
   if test "$ac_cv_search_initscr" = "-l$lib"; then
      AC_DEFINE(HAVE_WIDE_NCURSES, [],
         [Define if you have wide character support in your ncurses.])
   fi
done

# Tell the headers which one to use.
if test "$ac_cv_search_initscr" = "-lncurses"; then
   AC_DEFINE(USE_NCURSES, [], [Define to use libncurses.])
elif test "$ac_cv_search_initscr" = "-lncursesw"; then
   AC_DEFINE(USE_NCURSES_W, [], [Define to use libncursesw.])
fi

# Include SDL2 and SDL2_mixer, or define DONT_INCLUDE_SDL as a fallback if they aren't available, so it still compiles.
AC_PATH_PROG(SDL_CONFIG, sdl2-config)
if test -n "$SDL_CONFIG"; then
   LIBS="$LIBS `$SDL_CONFIG --libs`"
   CPPFLAGS="$CPPFLAGS `$SDL_CONFIG --cflags`"
fi
AC_CHECK_LIB([SDL2], [SDL_Init], ,
   AC_MSG_WARN([ *** Unable to find SDL2 library (http://www.libsdl.org/)]) ; LACK_SDL2=1)
AC_CHECK_LIB([SDL2_mixer], [Mix_OpenAudio], ,
   AC_MSG_WARN([ *** Unable to find SDL2_mixer library (http://www.libsdl.org/projects/SDL_mixer/)]) ; LACK_SDL2=1)
if test "$LACK_SDL2" = 1; then
   AC_DEFINE(DONT_INCLUDE_SDL, [], [Define to avoid including SDL2 and SDL2_mixer.])
   AC_MSG_WARN([ *** Compiling without SDL2 or SDL2_mixer, and with DONT_INCLUDE_SDL defined.])
fi

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_HEADER_TIME

# Checks for library functions.
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT

# Use Code Page 437 for source code.
CPPFLAGS="$CPPFLAGS -finput-charset=CP437 -fexec-charset=CP437"



AC_CHECK_FUNCS([memset mkdir strchr])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

Remember to save it with UNIX-style line endings instead of DOS/Windows style line endings if you try this out! Of course that is the default on your system so it will happen automatically... :P
« Last Edit: September 19, 2014, 11:34:03 pm by Liberal Elitist »
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #115 on: October 29, 2014, 09:50:38 pm »

The maps for the Terra Vitae House and Terra Vitae Office have been made; the next update (0.3) should be forthcoming.

Jonathan Fox, how much work was it to port version 0.1 of this mod to Windows? It looks like it was a fair number of steps.
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #116 on: November 04, 2014, 05:09:24 pm »

The maps for most of the other locations are made. Expect version 0.3 in a week or two.

The next project will be to port 0.3 to Windows.

Major highlight of version 0.3:
The saved game files will no longer be saved and loaded save.dat. They will be saved and loaded from saveTV0.3.dat. This will allow you to play this mod and regular LCS (and any other Terra Vitae mod) without having to do gymnastics with files!
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #117 on: November 07, 2014, 11:40:16 pm »

Update: Version 0.3 is now playable.

I still want to playtest some of the bugs that are no doubt in it before I release it, but it should be very soon, now.

All of the new locations (except supervillain lairs) are in this new version! (although some of them don't have their specials working yet)

 :)
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #118 on: November 26, 2014, 10:36:36 pm »

Version 0.3 is released!

Go and get it! I'll work on porting it to Windows soon. In the meantime, check out https://www.cygwin.com. You may be able to play the game on Windows that way with a minimum of hassle!

Highlights:

-Most of the new locations are now part of the game (although the special map features aren't yet)
-People you recruit can be married, in which case their spouses can also join the LCS
-More miscellaneous bug fixes

Also, I included what I'm calling cheat codes in version 0.2, but they're in 0.3 more-or-less complete. Here is documentation for them:

===Cheat Code Documentation===

The Terra Vitae Mod has a number of cheat (or debug) codes that you can enter that will adjust the game to your liking. Not only can they be used to increase or decrease the difficulty of the game, but in addition they can also be used to set up custom scenarios you may be interested in playing, or even simply to debug the software. This document lists all of the different cheat codes, what they do, and how to invoke them.


==Contents==
1. How to invoke all cheat codes
2. Add or remove juice from a liberal
3. Clear a liberal’s criminal record
4. Set the age of a liberal
5. Add or remove funds from the LCS budget
6. Trigger a siege at a liberal’s base
7. Pacify a faction who COULD besiege you
8. Set the value of a view
9. Change the current value of a law
10. Dissolve the CCS (the CCS will reform if public opinion is liberal enough)
11. Increase the CCS’ activity level (or defeat them if already on the sieging stage)
12. Force elections to happen at the end of the month
13. Force Congressional legislation
14. Force the Supreme Court to act
15. Bias elections and Supreme Court turnover
16. Switch Stalin-mode on or off
17. Create a CCS Strikes news story
18. Move an LCS member to a different safehouse
19. Sleeperizing a liberal
20. Add a spouse to an LCS member
21. Create a superhero



==Chapter 1 - All cheat codes==

All cheat codes are input in the review screen. When in base mode, press ‘r’ to access the review mode, then press the number and then the letter of the liberal on whom you wish to enter the code. Some codes matter which liberal is used to invoke them; others do not. Then, once you are viewing the liberal’s statistics, press ’n’ to rename the liberal. Instead of entering a new name, enter the cheat code.

All cheat codes have the form of “Cheat <input parameters>”, where the input parameters determine both which code you are using as well as what it will do. If the code is successful, then your liberal’s name will be returned to his or her proper name. If the code is unsuccessful, you will see the liberal’s name change to something else, which will usually explain what you did wrong that caused the code to not work (i.e. error messages are displayed through the liberal’s new name).



==Chapter 2 - Add or remove juice from a liberal==

Syntax: “Cheat Juice Me <number>”

The liberal’s juice will be increased by the number given. To reduce the juice of a liberal, enter a negative number instead. You cannot increase juice to more than 10 times the number given; for example, if your liberal already has 200 juice, you cannot give the liberal less than 21 more juice. If the number of juice that you give the liberal is negative, then the liberal will instead lose the amount of juice that you specify.



==Chapter 3 - Alter a liberal’s criminal record==

Syntax: “Cheat Clear My Name”

At present, the only use of this function is to clean a liberal’s criminal record. This will remove all crimes from the liberal’s rap sheet. Functions by which you can add crimes to a liberal are planned but not yet implemented.

This does not cause currently incarcerated liberals to be released from prison (although you could use the movement command to do that instead). Liberals who go to trial without crimes will have Loitering added to their list, and possibly other crimes as well (particularly Sexual Treason and Adultery as of version 0.3).



==Chapter 4 - Set the age of a liberal==

Syntax: “Cheat Set Age <number>”

This sets the age of a liberal to a particular value. It does not change the month and day of the liberal’s birthday, but it does move the birth year appropriate to the current year.



==Chapter 5 - Add or remove funds from the LCS budget==

Syntax: “Cheat Embezzle <number>”

This command adds (or removes, if the number is negative) some amount of money from the Liberal Crime Squad’s budget. The LCS’ monthly financial report will record this income as donations.



==Chapter 6 - Trigger a siege at a liberal’s base==

Syntax: “Cheat Attack Me <faction name>”

This causes the faction named to attack the base where the liberal you use to invoke this command is staying on the following day. If the liberal moves between now and then, the attack will still arrive at where the liberal is located when you invoke the cheat code and not at the liberal’s new location. You can invoke the following factions to besiege you:

Police/Death Squads (“Police”)
National Guard troops (“National Guard”)
Army with tanks (“Army”)
Navy SEALS, preceded by an air strike (“Navy”)
Corporate mercenaries (“Corps”)
The CCS (“CCS”)
The CIA (“CIA”)
Firemen (“Firemen”)

The following restrictions apply to factions that CANNOT besiege you:
-You cannot trigger sieges by hicks
-In order to trigger a CCS siege, the CCS must be active. Use “Cheat Activate CCS” or “Cheat Dissolve CCS” to make the CCS active before invoking the siege.
-In order to trigger a Firemen siege, Free Speech laws must be C+. Use “Cheat Legislate Speech -“ repeatedly until this is so before invoking the Firemen siege.

Other factions from the Terra Vitae mod that can besiege you aren’t yet coded.



==Chapter 7 - Pacify a faction who COULD besiege you==

Syntax: “Cheat Pacify <faction>”

This command pacifies the faction in question (they no longer want to raid you, if applicable), and cancels any impeding raids on the safehouse of the liberal used to invoke the cheat code. The factions are the same as those for provoking, although it is possible to pacify the hicks (or AM Radio and Cable News separately). Pacifying a faction has no effect on any sieges that are currently ongoing.



==Chapter 8 - Set the value of a view==

Syntax: “Cheat <Liberalize/Conservatize/Moderate/Stalinize> View <view name>”

This command changes the public opinion of a specific view of your choice or, if you select “All” for view name, it will affect all views at once.

Selecting “Liberalize” will set the view(s) to 100% liberal, “Conservatize” to 0% liberal, and “Moderate” to 50% liberal. Selecting “Stalinize” will change the view to either 100% or 0% liberal depending on whether the Stalinists agree or disagree with the liberals on this particular view. Stalinizing views works even if you are not playing in Stalin mode - it will affect the views, but will not enable Stalinist politicians to be elected to office.



==Chapter 9 - Change the current value of a law==

Syntax: “Cheat Legislate <law name> <+/->”

This adjusts the current state of your chosen law one step more liberal (if +) or one step more conservative (if -). The commands Liberalize, Conservatize, Moderate, and Stalinize work for laws as for views, and it is possible to affect all laws at once as well.



==Chapter 10 - Dissolving the Conservative Crime Squad==

Syntax: “Cheat Dissolve CCS”

This command sets the CCS to a not-formed state, similar to how a normal game of Liberal Crime Squad begins. The CCS will then reform or not depending on public opinion, just as if the CCS had not yet formed until this point.

This command has the potential for some bugs; in particular, I do not know what will happen if a CCS safehouse is exposed to the player when the CCS is dissolved.



==Chapter 11 - Activating the CCS==

Syntax: “Cheat Activate CCS”

This command makes the CCS one step more active, which normally happens due to changing public opinion. If the CCS is unformed (or dissolved), this will (re)form the CCS. If the CCS is in its highest active state (level 3 as of this writing), using this code again will destroy the CCS.

If the CCS is destroyed, it can be resurrected by first dissolving it (see chapter 10), and then by activating it. Note, however, that the CCS can only be destroyed in each way once, once by killing the CCS founder in the Robert E. Lee Bunker and once by allowing the FBI to wipe them out after publishing the CCS Backer List. If the CCS is resurrected twice, the only way to destroy it again is to use cheat codes.



==Chapter 12 - Force elections==

Syntax “Cheat Force Elections <branches>”

This command will cause next month and every month thereafter to have elections for the branches that you specify. Adding “Senate”, “House”, or “Pres” for branches will respectively force elections for the Senate, House, and President. Without any branches specified, only initiative propositions will be voted on. This cheat code will not prevent any elections from normally occurring (but see presidential term limits, below).

This cheat code is not saved when you quit the game; thus, exiting the program and reloading your save file will erase all election forcing caused by invoking this cheat code. This can be used to cancel the effect of this cheat code once the elections you want to cause have taken place.

Presidential elections mandated by this cheat code will not augment the number of terms that the president has served in office, and this non-augmentation overprints the presidential term effects for any existing presidential elections. Thus, it is possible to keep a first-term president in office indefinitely this way by forcing presidential elections in month and year in which those elections would happen anyway.



==Chapter 13 - Force congressional legislation==

Syntax: “Cheat Force Congress”

In earlier versions of Liberal Crime Squad, Congress only acted on legislation twice per year. This was changed in the most recent version, so this cheat code is semi-obsolete. However, using this code will increase the number of congressional acts each month to 4-7 instead of 1-4.

As with forcing elections, this code is not saved when you quit and restart the program.



==Chapter 14 - Force supreme court action==

Syntax: “Cheat Force Court <Syntax, Change, or left blank>”

This cheat code forces the Supreme Court to hand out a round of law-affecting decisions next month and each subsequent month. Adding the word “Stasis” on the end of the cheat code will prevent the court from replacing justices after handing out decisions; adding the word “Change” will force the replacement of one of the justices.

As with forcing elections, this code is not saved when you quit and restart the program.



==Chapter 15 - Biasing elections and court turnover==

Syntax: “Cheat Bias <arguments> <magnitude>”

This cheat code will bias elections and supreme court nominations irrespective of public opinion (or, for supreme court nominations, the alignments of the President and Senate). After the arguments, finish the code with a number, which can be positive or negative, representing the magnitude of the bias. Arguments that you can use are:

“House” - biases elections for the House. Can be used with the Stalin argument.
“Senate” - biases elections for the Senate. Can be used with the Stalin argument.
“Primary” - biases the primary elections of one of the presidential parties. You must specify either “Liberal” to bias the Liberal Party or “Conservative” to bias the Conservative Party. The Stalinist Party cannot be biased as none of its candidates will be anything other than Stalinist.
“President” - biases the final elections for the president. This does not affect who wins or loses the primaries! Can be used with the Stalin argument.
“Court” - biases nominations for the Supreme Court.
“Stalin” - species that the bias that you are using is for the Stalinist/non-Stalinist axis. Otherwise, you will only bias the Liberal/Conservative axis.

The magnitude is a number and can be positive or negative. If positive, it will bias the elections/nominations in favor of the Liberals (or, if used with the Stalin argument, of the Stalinists). Negative biases will do the opposite. In general, +200 is sufficient to guarantee the most Liberal/Stalinist possible outcome, and -200 guarantees the most Conservative/non-Stalinist possible outcome. For example, it is possible to nominate a Stalinist supreme court justice even with neither the president nor anybody in the senate being Stalinist if you use appropriate codes.

Biasing elections or nominations for or against Stalinism has no effect if not playing in Stalin mode.

As with forcing elections, this code is not saved when you quit and restart the program.



==Chapter 16 - Switching Stalin-mode on or off==

Syntax: “Cheat Stalin Mode <On/Off>”

This switches the game into or out of Stalinist mode (i.e. Stalinist politicians can run for office, be nominated to the supreme court, and pass a Stalinist constitutional amendment to cause the player to lose the game).

There is a potential for bugs here, as turning Stalinist mode off will not remove any Stalinist politicians or supreme court justices already holding office.



==Chapter 17 - Creating a CCS Strikes news story==

Syntax: “CCS Strikes <location> <other parameters>”

Triggers a news story in which the CCS will attack a location. The CCS does not need to be in existence for this command to work, and there is no limit to how many such news stories can be stacked up.

The location needs to be a location that the LCS could raid; otherwise, the cheat code will return an error message. Adding a ‘+’ in the other parameters ensures a positive spin on the resulting news story (i.e. makes public opinion on relevant site issues more conservative). Adding a ‘-‘ will do the opposite. Adding a ‘0’ for death and a ‘1’ for survival ensures that the news writeup will describe the CCS action as either being killed or not. Leaving out the spin or survival leaves it up to the same random chance that CCS strikes stories normally use. The city in which the news story takes place will be city in which the invoking liberal is currently based.



==Chapter 18 - Move a liberal to a new location==

Syntax: “Cheat Move Me <location name> <city name>”

Moves the liberal invoking the command to the specified location in the specified city. The location must be mappable, but has no other restrictions.

Be warned: moving non-sleeper liberals to the Police Station, Courthouse, or Prison will move them into the justice system.



==Chapter 19 - Making a liberal into a sleeper==

Syntax: “Cheat Sleeperize Me”

Turns the liberal into a sleeper agent, wherever s/he may be located.



==Chapter 20 - Adding a spouse to a liberal==

Syntax: “Cheat Marry Me”

Gives a randomly-generated spouse to the liberal. If the liberal is a sleeper, the spouse will be a sleeper; otherwise s/he will be active. Spouses generated work the same way as normal recruit spouses in the Terra Vitae mod. If the liberal is in prison, the spouse will also be an inmate.

There is no limit to how many spouses a liberal can be given in this way. The sexual orientation of the liberal is randomly determined for finding the gender of each new spouse.



==Chapter 21 - Adding a superhero to a liberal==

Syntax: “Cheat Test Super”

Attaches a superhero to the liberal as a recruit.
« Last Edit: November 26, 2014, 10:38:53 pm by SlatersQuest »
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Mod Planning: Terra Vitae mod
« Reply #119 on: November 27, 2014, 03:36:54 pm »

I realized that the upload did not occur correctly, so I am reuploading now. I also fixed a few bugs, so the version that will go up in a few minutes will be version 0.31, not 0.3.
Logged
Pages: 1 ... 6 7 [8] 9 10 ... 57