Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Invincible Countermeasure

This thread is locked; no one can reply to it. rss feed Print
Invincible Countermeasure
Linley Henzell
Member #3,963
October 2003

I've finally finished the first beta version of my new game, Invincible Countermeasure! It's a game about fighting for control of a computer system, and it looks like this:

{"name":"ss2s.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/9\/d9e91d51aecec6100a9c0f91f2267255.png","w":640,"h":479,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/9\/d9e91d51aecec6100a9c0f91f2267255"}ss2s.png

(Youtube video)

You can play is as a real-time strategy game, but you can also play it as a programming game: the units you can see in the screenshot above are all processes running in a virtual machine emulating an imaginary 16-bit processor, and you can use the game's built-in C compiler (with inline assembler) to write your own processes. These processes can move around, interact in various ways, reproduce themselves, among other things.

In addition to the RTS-style single-player mode, asynchronous (play-by-email) multiplayer is supported, for up to 4 players. This involves writing autonomous processes and pitting them against each other.

Windows binaries are here (this includes everything you need to play).
Source code is here (requires Allegro 5).
The Depot page is here.

The licence is GPL v3 or later, and system requirements are very low.

Any feedback welcome!

Arthur Kalliokoski
Second in Command
February 2005
avatar

They all watch too much MSNBC... they get ideas.

Slartibartfast
Member #8,789
June 2007
avatar

Peter Hull
Member #1,136
March 2001

A new Linley Henzell game is definitely worth downloading! :D

[edit] Compiled it for Linux, just one problem with loading the 'game' C files which have DOS CRLF line endings. These caused an error in the preprocessor. I have a fix if you're interested?

--- src/c_prepr.c~  2014-08-17 21:41:22.000000000 +0100
+++ src/c_prepr.c  2014-08-21 09:27:59.450780911 +0100
@@ -2362,6 +2362,11 @@
 
  for (i = 0; i < read_in; i ++)
  {
+   /* hack for *nix */
+   if (buffer[i] == '\r') {
+     continue;
+   }
+   /* end hack */
   target_source->text [src_line] [src_pos] = buffer [i];
 //  target_source->source_file [src_line] = src_file_index; // only actually need to do this once per line. Oh well.
   line_finished = 0;

Pete

Linley Henzell
Member #3,963
October 2003

Peter: Thanks for the fix! At one stage I wondered whether I'd have to do something about line endings but then forgot about it. I've added the fix and uploaded a new source file.

Arthur: That Proganisms thread is hilarious. I hope no-one's hard drive got wiped.

Audric
Member #907
January 2001

I'm not 100% sure, but I think that if you open a file as text instead of binary (ie. you don't put "b" in the mode of fopen()), the windows implementation of stdio will swallow the '\r' characters when you read with fscanf() etc.

But Peter's proposal is one step safer, in case a file is transferred from windows to unix/linux without converting the line endings.

Peter Hull
Member #1,136
March 2001

Audric, you are correct and that's what the code does - so it works on Windows. Unfortunately on Linux "b" and "t" are the same so reading a Windows file gives me spurious CRs in the text. Probably a better solution would have been to convert all the files to Unix line endings for Linux but I didn't do that!

If I've got time I will see if I can build it on Mac too.

[edit] Duh, if I just use the -a flag to unzip it all works without modification. However there are a lot of warnings during compilation and it seems to segfault on exit. LINLEY I AM ON YOUR CASE!! :)

Linley Henzell
Member #3,963
October 2003

Cheers!

I'm surprised there are lots of warnings - using MingW with -Wall it compiles without any at all. What kinds of warnings are you getting?

Peter Hull
Member #1,136
March 2001

I was using gcc on linux and clang on osx. The warnings innocuous - comparing signed and unsigned, unused parameter, etc.

I did find a couple of issues that made it not work on OS X. What's the best way of getting these to you? I can also send the makefile I used.
1) struct scodestruct is massive (>1MB) and if allocated on the stack, overflows it. This surprisingly did not cause any compiler error but mysterious segfaults which I assumed (for a long time...) were thread-related.
2) The declaration of init_view_at_startup doesn't match its definition. When it's called by m_main.c it puts garbage into window_w and window_h. Again, no compiler error because i_view.c doesn't include i_view.h so it doesn't notice the mismatch, and C doesn't care if the signatures don't match at link time.

Hope this helps, I really want to see this game finished!

pete

Linley Henzell
Member #3,963
October 2003

Ah, I tried compiling with gcc's -Wextra and got those kinds of warnings. I should at least clean up the unused parameter ones.

I meant to include the header files in the .c files but I must have missed some! You've probably already worked this out, but the init_view_at_startup call in m_main.c should be:

init_view_at_startup(settings.option [OPTION_WINDOW_W], settings.option [OPTION_WINDOW_H]);

And scodestruct is actually unnecessarily large. All of the ints (src_line, src_line_pos, src_file) can be safely changed to s16b - that should make it considerably smaller (I've made this change). It can also be global or static, or malloc'd (I've made it global). I don't really know why I put it on the stack.

Your help is much appreciated! I'm definitely going to finish this game, if only because it took so long to get this far.

Peter Hull
Member #1,136
March 2001

I've just posted the makefiles as tickets on the SF.net page. I hope others will now be able to try the games.

Would it be possible to change the scrolling a bit? I found it a bit awkward to avoid inadvertently scrolling when aiming to click near the screen edge (and also impossible to mouse off the application without scrolling) Also could there be a shortcut for 'select the nearest idle process'? - I found during mission 1 that by the time I'd scrolled to find a suitable defender then scrolled back to find an attacker to target they'd sneaked in and destroyed my base. (which I admit maybe just means I need more practice!)

Linley Henzell
Member #3,963
October 2003

Thanks for putting those makefiles up!

The problem with the display scrolling when the mouse is off the window is there because the game doesn't keep track of where the mouse is very well at all. I'm going to fix that as soon as I work out how to use Allegro mouse events.

But I'm trying to avoid adding too many features to the basic operator program. It's supposed to be minimalist, and improving it is kind of part of the game itself.

Peter Hull
Member #1,136
March 2001

Great - just let me know if there's anything else I can help with!
Pete

[edit] Was just messing about a bit and I implemented a syntax change for the `interface {}` section. It only needed adding about 30 lines to one function! Basically it allows you (optionally) to label the method slots so you don't need an enum section to identify them. This makes it less error prone IMO. For example the interface for missions/m1_sy.c looks like this:

#SelectExpand
1interface 2{ 3 PROGRAM_TYPE_SYSTEM, 4 // remember, the following are: option, default, min, max 5 {0, 2}, // players 6... snip ... 7 {0, 0}, // may_change_proc_templates 8 { 9 METH_PLACE:{MT_SY_PLACE_PROC}, 10 {MT_NONE}, // space for PLACE_PROC 11 METH_TEMPLATE:{MT_SY_TEMPLATE}, 12 METH_MODIFY:{MT_SY_MODIFY}, 13 METH_MANAGE:{MT_SY_MANAGE}, 14 {MT_NONE}, // space for MANAGE 15 METH_INPUT:{MT_OB_INPUT}, 16 METH_VIEW:{MT_OB_VIEW}, 17 {MT_NONE}, // space for VIEW 18 METH_CONSOLE:{MT_OB_CONSOLE}, 19 METH_CHANNEL:{MT_CLOB_CHANNEL}, 20 METH_QUERY:{MT_CLOB_QUERY}, 21 METH_WORLD:{MT_CLOB_WORLD}, 22 } 23}

What do you think?
pete

Linley Henzell
Member #3,963
October 2003

That looks like a definite improvement. If you send it to me (or maybe just upload it to sourceforge or post it here) I'll fold it into the code for the next version.

Edit: great, that works perfectly - and I'm impressed that you could make any sense at all of the compiler code. I've put the patch in c_comp.c and updated the error messages.

Peter Hull
Member #1,136
March 2001

That's good. I've made an XCode project for Mac and a Visual Studio project too. Let me know if there's anything else I can do to help.

Looking forward to the next version!
Pete

Go to: