Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 11 12 [13] 14 15 ... 36

Author Topic: LCS 4.06.5 Download (Bank Heists, Mar 2013)  (Read 94023 times)

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #180 on: September 24, 2012, 08:29:16 pm »

Really? I have a 1600x900 monitor and most of it only goes up to halfway through the monitor. Thewidest is a comment I should have put on the line before the code involved with the comment (shown in the screenshot).

Screenshot to show what I mean/see:
http://imageshack.us/a/img109/1626/programmingn.png (linking as to not bloat the page here)

That has the widest code present in my contributions.
« Last Edit: September 24, 2012, 08:34:00 pm by addictgamer »
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Carlos Gustavos

  • Bay Watcher
    • View Profile
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #181 on: September 25, 2012, 02:00:41 pm »

I also thought about how it seemed you'd have to repeat every text message if you wanted it in the log too, but my idea to avoid that looked something like:
Code: [Select]
int addstr(const char* c, Log& log, bool endline)
{
   if (endline)
      log.log(c);
   else
      log.log_noLineEnd(c);

   /* or: log.log(c, endline); */

   return addstr(c);
}
So if you want something logged you tack on the log as a second parameter and endline could possibly have true as default value.
Logged

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #182 on: September 25, 2012, 02:22:51 pm »

I also thought about how it seemed you'd have to repeat every text message if you wanted it in the log too, but my idea to avoid that looked something like:
Code: [Select]
int addstr(const char* c, Log& log, bool endline)
{
   if (endline)
      log.log(c);
   else
      log.log_noLineEnd(c);

   /* or: log.log(c, endline); */

   return addstr(c);
}
So if you want something logged you tack on the log as a second parameter and endline could possibly have true as default value.

My idea was more or less adding a second parameter to the addstr function to determine if it should log the text.

In the end, though, I prefer doing this:

Code: [Select]
            gamelog.newlmode(1); //Set automatic newline to 1 newline.
            gamelog.begl(); //Begin logging line.
            print(cr->name);
            print(" turns the tables on ");
            print(a->name);
            print("!");
            gamelog.endl(); //End logging line.
     
            gamelog.begl(); //Begin logging line.
            print(a->name);
            print(" has been tainted with wisdom!");
            gamelog.newlmode(NEWLINEMODE_GAMELOG); //Reset this to the default.
            gamelog.endl(); //End logging line.

I guess if one doesn't want to do that endl() begl() in the middle of the text, they could do this:

Code: [Select]
            gamelog.begl(); //Begin logging.
            print(cr->name);
            print(" turns the tables on ");
            print(a->name);
            print("!");
            gamelog.newline(); //Add a newline here in the gamelog, for formatting purposes (and instead of doing endl() begl())
            //or one could do
            //gamelog.record("\n");
            //But I personally find gamelog.newline() easier to type.

            print(a->name);
            print(" has been tainted with wisdom!");
            gamelog.endl(); //End logging.

(And as you can see, addstr has been replaced by print

Are you all okay with this? If not, tell me now, so that I don't finish updating all the code to use this method.
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #183 on: September 25, 2012, 03:31:31 pm »

Stylistically, I much prefer Carlos Gustavos' model of overloading addstr, since it doesn't deprecate every line of existing display code in the game, and force everyone on the project to start using a new display function. It would also avoid two differently named functions (addstr and print) that do exactly the same thing except when you call a separate function, thereby changing the behavior of one of those two functions.

With his solution, existing code stays the same, and you just add a second log parameter to lines that you want to log. It also slips in gracefully -- not modifying the existing addstr (which is part of the Curses library), just adding a new overloaded definition that takes additional parameters, then does other things before calling the normal addstr(str). C++ will have no problem disambiguating these.

What I particularly do like about it is that addstr("foo", log) logs the message, while addstr("foo") doesn't. This makes the code self-documenting, far more than an alternative addstr("foo", true) or something like that. Even a non-programmer can figure that out how to log a message by looking at addstr("foo", log) -- it's very clean, and barely alters the existing model for adding text at all.

The one thing I'm a little hesitant about is using a boolean to request a newline, as the resulting code looks like this:

Code: [Select]
addstr(cr->name, log, false);
addstr(" turns the tables on ", log, false);
addstr(a->name, log, false);
addstr("!", log);

addstr(a->name, log, false);
addstr(" has been tainted with wisdom!", log);

That's confusing and ugly to me, and I don't think turning it around to false as default (so only the last lines have the boolean, showing true) makes it much better. Something like this may be more clear, just from the standpoint of having easy to understand code:

Code: [Select]
addstr(cr->name, log);
addstr(" turns the tables on ", log);
addstr(a->name, log);
addstr("!", log);
log.newline();

addstr(a->name, log);
addstr(" has been tainted with wisdom!", log);
log.nextmessage();
Logged

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #184 on: September 25, 2012, 03:41:24 pm »

Something like this may be more clear, just from the standpoint of having easy to understand code:

Code: [Select]
addstr(cr->name, log);
addstr(" turns the tables on ", log);
addstr(a->name, log);
addstr("!", log);
log.newline();

addstr(a->name, log);
addstr(" has been tainted with wisdom!", log);
log.nextmessage();

The code evolves yet again :D
Looks good to me. If we all are for it, I'll do it.
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #185 on: September 25, 2012, 04:04:39 pm »

Purely tangential to this code discussion, but on the topic of code quality and keeping display code clean, check out this totally reasonable block of code from a prototype I made (this is the high score screen from LCS):

Code: [Select]
// Title of the screen
set_color(Color.WHITE);
addstr_move(0, 0, "The Liberal ELITE");

// Show top scores
for(var s:int=0; s < MAX_SCORES_SHOWN && s < Game.highScores.length; s++)
{
var y:int = 2 + s * 4;

// Special colors for showing your squad's fate, if relevant
if (Game.yourHighScoreIndex == s) {
if (Game.highScores[s].endtype == Endings.WON) {
set_color(Color.BRIGHT_GREEN);
} else set_color(Color.BRIGHT_RED);
} else set_color(Color.WHITE);

// Slogan
addstr_move(y, 0, Game.highScores[s].slogan);

// Dimmer colors for other stats
if (Game.yourHighScoreIndex == s) {
if (Game.highScores[s].endtype == Endings.WON) {
set_color(Color.DARK_GREEN);
} else set_color(Color.DARK_RED);
} else set_color(Color.LIGHT_GRAY);

// Cause of death (or victory string)
addstr_move(y + 1, 0, Game.highScores[s].endstring);

// Stats
addstr_move(y + 2, 0, "Recruits: " + Game.highScores[s].stats.recruits);
addstr_move(y + 3, 0, "Martyrs: " + Game.highScores[s].stats.dead);
addstr_move(y + 2, 20, "Kills: " + Game.highScores[s].stats.kills);
addstr_move(y + 3, 20, "Kidnappings: " + Game.highScores[s].stats.kidnappings);
addstr_move(y + 2, 40, "$ Taxed: " + Game.highScores[s].stats.funds);
addstr_move(y + 3, 40, "$ Spent: " + Game.highScores[s].stats.spent);
addstr_move(y + 2, 60, "Flags Bought: " + Game.highScores[s].stats.flags);
addstr_move(y + 3, 60, "Flags Burned: " + Game.highScores[s].stats.flagburns);
}

// Universal stats
set_color(Color.BRIGHT_GREEN);
addstr_move(22, 0, "Universal Liberal Statistics");
addstr_move(23, 0, "Recruits: " + Game.universalStats.recruits);
addstr_move(24, 0, "Martyrs: " + Game.universalStats.dead);
addstr_move(23, 20, "Kills: " + Game.universalStats.kills);
addstr_move(24, 20, "Kidnappings: " + Game.universalStats.kidnappings);
addstr_move(23, 40, "$ Taxed: " + Game.universalStats.funds);
addstr_move(24, 40, "$ Spent: " + Game.universalStats.spent);
addstr_move(23, 60, "Flags Bought: " + Game.universalStats.flags);
addstr_move(24, 60, "Flags Burned: " + Game.universalStats.flagburns);

The same high score screen in the normal code:

Code: [Select]
49    set_color(COLOR_WHITE,COLOR_BLACK,1);
50    move(0,0);
51    addstr("The Liberal ELITE");
52
53    char num[20];
54
55    int y=2;
56    for(s=0;s<SCORENUM;s++)
57    {
58       if(score[s].valid)
59       {
60          if(yourscore==s&&score[s].endtype==END_WON)set_color(COLOR_GREEN,COLOR_BLACK,1);
61          else if(yourscore==s)set_color(COLOR_RED,COLOR_BLACK,1);
62          else set_color(COLOR_WHITE,COLOR_BLACK,1);
63          move(y,0);
64          addstr(score[s].slogan);
65          if(yourscore==s&&score[s].endtype==END_WON)set_color(COLOR_GREEN,COLOR_BLACK,0);
66          else if(yourscore==s)set_color(COLOR_RED,COLOR_BLACK,0);
67          else set_color(COLOR_WHITE,COLOR_BLACK,0);
68          move(y+1,0);
69          switch(score[s].endtype)
70          {
71             case END_WON:
72                addstr("The Liberal Crime Squad liberalized the country in ");
73                break;
74             case END_POLICE:
75                addstr("The Liberal Crime Squad was brought to justice in ");
76                break;
77             case END_CIA:
78                addstr("The Liberal Crime Squad was blotted out in ");
79                break;
80             case END_HICKS:
81                addstr("The Liberal Crime Squad was mobbed in ");
82                break;
83             case END_CORP:
84                addstr("The Liberal Crime Squad was downsized in ");
85                break;
86             case END_DEAD:
87                addstr("The Liberal Crime Squad was KIA in ");
88                break;
89             case END_REAGAN:
90                addstr("The country was Reaganified in ");
91                break;
92             case END_PRISON:
93                addstr("The Liberal Crime Squad died in prison in ");
94                break;
95             case END_EXECUTED:
96                addstr("The Liberal Crime Squad was executed in ");
97                break;
98             case END_DATING:
99                addstr("The Liberal Crime Squad was on vacation in ");
100                break;
101             case END_HIDING:
102                addstr("The Liberal Crime Squad was in permanent hiding in ");
103                break;
104             case END_DISBANDLOSS:
105                addstr("The Liberal Crime Squad was hunted down in ");
106                break;
107             case END_DISPERSED:
108                addstr("The Liberal Crime Squad was scattered in ");
109                break;
110             case END_CCS:
111                addstr("The Liberal Crime Squad was out-Crime Squadded in ");
112                break;
113             case END_FIREMEN:
114                addstr("The Liberal Crime Squad was burned in ");
115                break;
116          }
117          switch(score[s].month)
118          {
119             case 1:addstr("January");break;
120             case 2:addstr("February");break;
121             case 3:addstr("March");break;
122             case 4:addstr("April");break;
123             case 5:addstr("May");break;
124             case 6:addstr("June");break;
125             case 7:addstr("July");break;
126             case 8:addstr("August");break;
127             case 9:addstr("September");break;
128             case 10:addstr("October");break;
129             case 11:addstr("November");break;
130             case 12:addstr("December");break;
131          }
132          addstr(" ");
133          itoa(score[s].year,num,10);
134          addstr(num);
135          addstr(". ");
136
137          move(y+2,0);
138          addstr("Recruits: ");
139          itoa(score[s].stat_recruits,num,10);
140          addstr(num);
141
142          move(y+3,0);
143          addstr("Martyrs: ");
144          itoa(score[s].stat_dead,num,10);
145          addstr(num);
146
147          move(y+2,20);
148          addstr("Kills: ");
149          itoa(score[s].stat_kills,num,10);
150          addstr(num);
151
152          move(y+3,20);
153          addstr("Kidnappings: ");
154          itoa(score[s].stat_kidnappings,num,10);
155          addstr(num);
156
157          move(y+2,40);
158          addstr("$ Taxed: ");
159          itoa(score[s].stat_funds,num,10);
160          addstr(num);
161
162          move(y+3,40);
163          addstr("$ Spent: ");
164          itoa(score[s].stat_spent,num,10);
165          addstr(num);
166
167          move(y+2,60);
168          addstr("Flags Bought: ");
169          itoa(score[s].stat_buys,num,10);
170          addstr(num);
171
172          move(y+3,60);
173          addstr("Flags Burned: ");
174          itoa(score[s].stat_burns,num,10);
175          addstr(num);
176
177          y+=4;
178       }
179    }
180
181    set_color(COLOR_GREEN,COLOR_BLACK,1);
182
183    //UNIVERSAL STATS
184    move(22,0);
185    addstr("Universal Liberal Statistics:");
186
187    move(23,0);
188    addstr("Recruits: ");
189    itoa(ustat_recruits,num,10);
190    addstr(num);
191
192    move(24,0);
193    addstr("Martyrs: ");
194    itoa(ustat_dead,num,10);
195    addstr(num);
196
197    move(23,20);
198    addstr("Kills: ");
199    itoa(ustat_kills,num,10);
200    addstr(num);
201
202    move(24,20);
203    addstr("Kidnappings: ");
204    itoa(ustat_kidnappings,num,10);
205    addstr(num);
206
207    move(23,40);
208    addstr("$ Taxed: ");
209    itoa(ustat_funds,num,10);
210    addstr(num);
211
212    move(24,40);
213    addstr("$ Spent: ");
214    itoa(ustat_spent,num,10);
215    addstr(num);
216
217    move(23,60);
218    addstr("Flags Bought: ");
219    itoa(ustat_buys,num,10);
220    addstr(num);
221
222    move(24,60);
223    addstr("Flags Burned: ");
224    itoa(ustat_burns,num,10);
225    addstr(num);
« Last Edit: September 25, 2012, 04:08:54 pm by Jonathan S. Fox »
Logged

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #186 on: September 25, 2012, 04:35:21 pm »

Purely tangential to this code discussion, but on the topic of code quality and keeping display code clean, check out this totally reasonable block of code from a prototype I made (this is the high score screen from LCS):

Code: [Select]
// Title of the screen
set_color(Color.WHITE);
addstr_move(0, 0, "The Liberal ELITE");

// Show top scores
for(var s:int=0; s < MAX_SCORES_SHOWN && s < Game.highScores.length; s++)
{
var y:int = 2 + s * 4;

// Special colors for showing your squad's fate, if relevant
if (Game.yourHighScoreIndex == s) {
if (Game.highScores[s].endtype == Endings.WON) {
set_color(Color.BRIGHT_GREEN);
} else set_color(Color.BRIGHT_RED);
} else set_color(Color.WHITE);

// Slogan
addstr_move(y, 0, Game.highScores[s].slogan);

// Dimmer colors for other stats
if (Game.yourHighScoreIndex == s) {
if (Game.highScores[s].endtype == Endings.WON) {
set_color(Color.DARK_GREEN);
} else set_color(Color.DARK_RED);
} else set_color(Color.LIGHT_GRAY);

// Cause of death (or victory string)
addstr_move(y + 1, 0, Game.highScores[s].endstring);

// Stats
addstr_move(y + 2, 0, "Recruits: " + Game.highScores[s].stats.recruits);
addstr_move(y + 3, 0, "Martyrs: " + Game.highScores[s].stats.dead);
addstr_move(y + 2, 20, "Kills: " + Game.highScores[s].stats.kills);
addstr_move(y + 3, 20, "Kidnappings: " + Game.highScores[s].stats.kidnappings);
addstr_move(y + 2, 40, "$ Taxed: " + Game.highScores[s].stats.funds);
addstr_move(y + 3, 40, "$ Spent: " + Game.highScores[s].stats.spent);
addstr_move(y + 2, 60, "Flags Bought: " + Game.highScores[s].stats.flags);
addstr_move(y + 3, 60, "Flags Burned: " + Game.highScores[s].stats.flagburns);
}

// Universal stats
set_color(Color.BRIGHT_GREEN);
addstr_move(22, 0, "Universal Liberal Statistics");
addstr_move(23, 0, "Recruits: " + Game.universalStats.recruits);
addstr_move(24, 0, "Martyrs: " + Game.universalStats.dead);
addstr_move(23, 20, "Kills: " + Game.universalStats.kills);
addstr_move(24, 20, "Kidnappings: " + Game.universalStats.kidnappings);
addstr_move(23, 40, "$ Taxed: " + Game.universalStats.funds);
addstr_move(24, 40, "$ Spent: " + Game.universalStats.spent);
addstr_move(23, 60, "Flags Bought: " + Game.universalStats.flags);
addstr_move(24, 60, "Flags Burned: " + Game.universalStats.flagburns);

That's a huge improvement. Shorter, much cleaner, and more readable.
What's the symbol DF uses to signify masterpiece? Some wagonwheel-esque character? That's the quality of that code.
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #187 on: September 25, 2012, 04:44:45 pm »

Something like this may be more clear, just from the standpoint of having easy to understand code:

Code: [Select]
addstr(cr->name, log);
addstr(" turns the tables on ", log);
addstr(a->name, log);
addstr("!", log);
log.newline();

addstr(a->name, log);
addstr(" has been tainted with wisdom!", log);
log.nextmessage();

I never thought about making a new overload for addstr. This seems to be, by far, the best solution. A few questions, though:
- What is "log"? Is it a pointer to the gamelog, a define, or what? If it were the gamelog, it would be easy to make a debug log by replacing it with "debuglog" or something.
- What is log.nextmessage() ? How is it different from log.newline() ? Does it add an extra line or something?


On the code prototype: That looks like perfect code to me. Infinitely better than LCS's mess.

Also:
Code: [Select]
var y:int = 2 + s * 4;
Do you plan on changing the codebase to JavaScript or something?  :P
Logged

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #188 on: September 25, 2012, 04:55:46 pm »

I never thought about making a new overload for addstr. This seems to be, by far, the best solution. A few questions, though:
- What is "log"? Is it a pointer to the gamelog, a define, or what? If it were the gamelog, it would be easy to make a debug log by replacing it with "debuglog" or something.
- What is log.nextmessage() ? How is it different from log.newline() ? Does it add an extra line or something?

I can't tell you exactly what he was thinking but here's what I got out of it:

1. He's using log to refer to whatever log we want to log the message to.

2. I'm making it work like this:

The overloaded addstr function calls log.record() and passes the text to it.
The log stores this text in a buffer.

log.nextMessage() tells the log to write the buffer to file and add the newlines needed and then to clear the buffer (of course).

class Log still has a newline() function in cases such as this:
Code: [Select]
case 1:
            move(2,0);
            if (d.date.size()>2)
            {
               addstr("Unfortunately, they all turn up at the same time.", gamelog);
            }
            else
            {
               addstr("Unfortunately, they turn up at the same time.", gamelog);
            }
            gamelog.record("\n"); //Newline here for formatting purposes.
            move(3,0);
            addstr("Uh oh...", gamelog);
            gamelog.nextMessage(); //Prepare gamelog for the next message (writes buffer out to file appending "\n\n" if NEWLINE_GAMELOG is set to 2, \n if it's set to 1, and no modifications in the case of 0.)
            refresh();
            getch();
            break;

Edit: On a side note, does that look good? Yes, you'll have to write gamelog.record("\n"); in cases such as the above, but it looks better than the alternatives I can think of. gamelog.nextMessage does more than add a newline, it formats the gamelog such that everything fed into gamelog prior to the nextMessage() is part of the same message while everything after is part of different messages.

Code: [Select]
You shoot the conservative.

The conservative dies.

Your activists have done so and so.

Police are trying to arrest Urist for graffiti.

Urist darts into an alley!

It looks like you've lost them!

vs

Code: [Select]
You shoot the conservative.
The conservative dies.

Your activists have done so and so.

Police are trying to arrest Urist for graffiti.
Urist darts into an alley!
It looks like you've lost them!

Using nextMessage() for every newline needed would produce the former. Using it when the message is actually over produces the latter.
In the former, the newlines in every message is obtained via gamelog.newline().

This is the best I've come up with so far. The code looks readable to me, and so does the log.
If you have any better ideas, feel free to say them! Writing gamelog.newline() every time you need a new line inside of a message might not be the best solution to this problem, although I find it ok.
« Last Edit: September 25, 2012, 05:05:13 pm by addictgamer »
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #189 on: September 25, 2012, 05:41:22 pm »

Yeah, the difference I had in mind is that log.newline() is used to add a single newline, and log.nextmessage() adds two newlines. They're distinguished for reasons of breaking up the exported log into logical blocks.
Logged

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #190 on: September 25, 2012, 05:50:45 pm »

addictgamer: if you fixed up your logger using the suggestions here and pushed out a revision, we could allocate game files for people to add logging methods to. I would elect to go through siege.cpp and fight.cpp and add messages to the logger. Anyone else?
Logged

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #191 on: September 25, 2012, 06:21:20 pm »

addictgamer: if you fixed up your logger using the suggestions here and pushed out a revision, we could allocate game files for people to add logging methods to. I would elect to go through siege.cpp and fight.cpp and add messages to the logger. Anyone else?

I'm not sure what you mean by "allocate game files for people to add logging methods to.", but I've finished patching up the logger. I'm going to test the code after a rather late lunch, fix up any problems I find, and then push the revision.

I volunteer to log messages for...I guess what nobody else volunteers to go through. I have some free time this evening, so I'll be able to get a few files out of the way.

Edit: Oh, I realize now what you meant by "allocate game files". You meant "assign game files to people to go through and add the logging for". Okay. Good idea.
« Last Edit: September 25, 2012, 06:48:43 pm by addictgamer »
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Jboy2000000

  • Bay Watcher
  • Hello good people of the interwebs!
    • View Profile
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #192 on: September 25, 2012, 06:30:14 pm »

I found a pretty big glitch. If you have caps on, and try to hit "R" while dismembered, you won't recreate. A glitch I find out by losing.
Logged
"Wanna be a better liberal? Go get shot in the fuckin' face."

Just goes to show, even a Male Doctor that Looks Like a Female and a Criminal with Poor Hygiene Habits can fall in love.

addictgamer

  • Bay Watcher
  • Penguin Developer
    • View Profile
    • Github
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #193 on: September 25, 2012, 07:21:09 pm »

includes.h:
Code: [Select]
int addstr(const char *text, Log &log);

compile log:
Code: [Select]
g++ -DHAVE_CONFIG_H -I. -I..  -DINSTALL_DATA_DIR=\"/usr/local/share\"  -I../src -g -O2 -MT crimesquad-game.o -MD -MP -MF .deps/crimesquad-game.Tpo -c -o crimesquad-game.o `test -f 'game.cpp' || echo './'`game.cpp
In file included from game.cpp:73:0:
includes.h:1318:54: error: macro "addstr" passed 2 arguments, but takes just 1
includes.h:1318:28: error: ‘int addstr’ redeclared as different kind of symbol
In file included from includes.h:149:0,
                 from game.cpp:73:
/usr/include/ncurses.h:555:28: error: previous declaration of ‘int addstr(const char*)’

I...don't even know. I've never encountered a situation similar to this.

ncurses.h line 555:
Code: [Select]
extern NCURSES_EXPORT(int) addstr (const char *); /* generated */Odd. Look pdcurses's curses.h:
Code: [Select]
int     addstr(const char *);
It seems gcc thinks that addstr is a macro, and it's looking at the definition provided by ncurses, not pdcurses. I thought the project used pdcurses...

Like I said, I've never encountered a situation similar to this. So...what do I/we do?

Edit: I changed the declaration to this in includes.h:
Code: [Select]
/* A wrapper to addstr() which logs the input and then calls addstr to draw it. */
#undef addstr
int addstr(const char *text, Log &log);

Nothing seems to be broken... :/
I'll be doing some more tests and making sure everything's working good.

Oh, and:
Code: [Select]




------PROGRAM STARTED------




A NEW CONSERVATIVE ERA
The Year is 2009.
Conservative President Steve Zedner ends his second term with approval
ratings in the high 70s, and is succeeded by hardcore Arch-Conservative
Rick Thomson.

With Conservatives sweeping into power in the House of Representatives
and Senate, and a Conservative majority in the Supreme Court of the
United States, commentators are hailing it as the beginning of a new
Conservative era.

President Rick Thomson has asked the new Congress to move quickly
to rubber stamp his radical Arch-Conservative agenda. The left seems
powerless to stop this imminent trampling of Liberal Sanity and Justice.

In this dark time, the Liberal Crime Squad is born...
:)
« Last Edit: September 25, 2012, 07:29:22 pm by addictgamer »
Logged
I'm patiently waiting for the ability to mine and construct palaces in adventure mode.
Barony. A 3D, multiplayer roguelike I am developing.

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: LCS 4.06.3 Download (Bank Heists, Sept 2012)
« Reply #194 on: September 25, 2012, 07:49:26 pm »

Oh, ugh, that's unexpected... I'm not immediately sure how to deal with that optimally.

One ugly possibility is, in the Linux compatibility section of includes.h, after including ncurses.h, to straight up #undef addstr and replace it with an inline function. Something like this:

Code: [Select]
#ifdef addstr
   #undef addstr
   inline int addstr(const char * str) { return waddnstr(stdscr,str,-1); }
#endif

I've never run into this sort of issue before, so I don't have a sense of whether that's a graceful hack or an ugly one.

The ncurses/pdcurses difference is platform -- pdcurses is a Windows port of curses, ncurses is for Linux and OSX.
Logged
Pages: 1 ... 11 12 [13] 14 15 ... 36