Contents
Back
Forward

13. Developing Scenarios and Distributing Them


13.1 Compiling and Linking a CSPL program manually
The process of taking source code and transforming it into an executable file consists of two phases:
compiling and linking.
These phases should be executed automatically by CSPLCompanion, but you may find it useful to have a discussion about manually compiling and linking CSPL programs. Borland 5.5 comes with two programs; a compiler (BCC32.EXE) and a linker (ILINK32.EXE). They have a lot of complex options but you don't need to know most of them.
(BTW: I wrote a batch file called CSPLCompanion that should automate this process and you can find its documentation in Appendix A. Anyway, if something goes wrong it would be helpful to know how to compile and link the program manually.)
Let's say we have coded our CSPL program in two files called csplclient.cpp and csplclient.h. To compile it I suggest the following command line (remember to copy the cspl.h file into the same directory as csplclient.cpp!):
BCC32 -c -w- -W csplclient.cpp
    -c option just tells the compiler to compile only and not launch the linker automatically (we need to configure the linker before launching it)
    -w- deactivates Warning messages
    -W just warns the compiler that the final executable will be a Windows 9x program
The output of the compiler will be the file csplclient.obj, an intermediate step between .cpp and .exe
Now you need to call the linker on this object file to finish the work (remember to copy cspl.res and cspl.lib in the same directory as csplclient.obj!)
Here is the correct command line:
ILINK32 /aa c0w32.obj csplclient.obj,csplclient.exe,,cspl.lib import32.lib cw32.lib,,cspl.res
(a bit complex, don't you think?)
     /aa warns the linker that the final .exe will be a Windows 32 application
     c0w32.obj is just an initialization module
     csplclient.obj is the name of the object file we obtained through the compiling phase
     csplclient.exe is the final name of the executable we will obtain
     cspl.lib is obviously the cspl library
     import32.lib and cw32.lib are two libraries of the Borland compiler
     cspl.res is the resource file for CSPL (it contains information about the CSPL graphic and menu)
If all goes well, at the end of the linking phase you'll have your program ready to use ("csplclient.exe" as written in the linker command line).


13.2 Releasing CSPL scenarios
If you want to use CSPL in your scenarios you'll have to follow these guidelines:
  1. "Register" CSPL.
  2. Leave the "About CSPL Box" exactly as it is in the template of the CSPL Client.
  3. Add a section to your readme file which warns about the security problems inherent in CSPL scenarios (see the "Security Issue" section for details).
  4. Include the source-code of your CSPL Client in your scenario files package.


13.3 Security Issue
As we saw during the tutorial, the end result of the CSPL process is the creation of an exe file that will be executed on the computers of a lot of civ players. This raises security questions (what if some malicious designer creates an event to format an hard-disk if a particular unit is killed?), resulting in much the same risk you face whenever you run foreign executables on your computer.
With the premise that CSPL (and its programmer) cannot be held responsible for any damage caused by the hostile use of CSPL, I want to suggest some ways to avoid this problem:
  1. Every CSPL designer should include the source-code and makefile of the CSPL client with the corresponding scenario. In this way, everyone can check the source code and test it for harmlessness.
  2. Every user worried about security should re-compile the source-code on his computer before using it (this means he has to download CSPL and the Borland Compiler).
  3. Every web site hosting scenarios should execute passes 1 & 2 to certify CSPL scenarios as clean.
Obviously, these are only suggestions. Personally I will apply recommendation #1 to each scenario of mine (since it's also useful as a tutorial) and I will apply recommendation #2 before trying any other CSPL scenario. You are free to "trust" other scenario designers, but if viruses or other bad things reach your computer through CSPL, remember that I warned you!


13.3 Registering CSPL
As you can see, I worked very hard to create this library, but I don't want to make you pay for using CSPL. Therefore I've decided to make CSPL "cardware".
In other words if you've found this library useful, how about sending me a greetings postcard from your country?
Please send them to:
Angelo Scotto
Casella Postale
CAP 23036
Teglio (SO)
Italy
(No mailbombs please. It is not my personal address, just the address of the post office.) ;-)

If for some strange reason you find CSPL useful but you can't send me a postcard don't worry. But please remember to give me credit in your future CSPL programs.





Contents / Introduction
Chapter I / Chapter II / Chapter III / Chapter IV / Chapter V / Chapter VI / Chapter VII
Chapter VIII / Chapter IX / Chapter X / Chapter XI / Chapter XII / Chapter XIII
Appendix A / Appendix B / Appendix C