|
|
|
|
1. Don't try to convert "char *" to "string", just make it pchar.
That is because many functions expect the pchar type of behaviour, so if we start to use string somewhere, we end up changing all the project.
Besides we can't use "string" in structures which are used for interfacing dlls.
2. Don't convert pointer function parameters to "var".
This is because many functions can take "nil" as parameters, and compares internally if parameter was nil.
We can't compare var parameter for nil.
3. "char something[MAX_LENGTH]" converts to "something: array[0..MAX_LENGTH-1] of char".
Also don't try to convert these places to string, or dynamically allocated memory area.
(I fixed some places where these were converted to dynamically allocated memory blocks, where memory was never actually freed).
4. Do not convert For-loop to While-loop
I noticed some places where for-loop were converted to while-loop, which contained "continue" on it.
This means that when continue is executed, rest of the while loop never gets executed, and usually variable incrementation is moved at the end.
This results as deadlock, because variable never gets incremented.
Please try to inspect the loop behaviour carefully when converting for-loop to while-loop.
5. Leave all Structure names the same as the original,But also create the Delphi equivalent
This will aid in stamping out bugs before they occur.
E.G.
{ frame_t }
frame_t = record //Original Struct Name
valid: QBOOLEAN;
serverframe: Integer;
servertime: Integer;
deltaframe: Integer;
areabits: Array[0..(MAX_MAP_AREAS/8)-1] of BYTE;
playerstate: PLAYER_STATE_T;
num_entities: Integer;
parse_entities: Integer;
end {frame_t};
Pframe_t = ^frame_t; //Pointer to Struct/record
TFrame_T = frame_t;//Delphi Naming Convention for struct
PFrame_T = Pframe_t;//Pointer to Delphi Naming Convention for struct
6. Change char** parameters to PPChar
7. "Lots of "boolean" CVars ... are these QBoolean or Integer, i.e. can we use the "not" operator on them."
A: CVar value is always single, you can round it and then typecast it to qboolean.
If it was qboolean, it should be also after conversion.
8. "Static variables/procs, not supprted in Delphi?"
A: Static variables should be moved outside of the procedure to be "static".
I am not sure wether any extra care needs to be taken on static procedures.
9. "Some calls to va - should i use Format?"
A: va is implemented in conversion, so just use it.
If it will not work, it is easier to fix just one va than hundred places where it was used.
10. "Use of Com_printf and others."
A: Don't try to convert it to Delphi string.
Just pass everything as parameters, like they was.
Parameter(s) just needs to be in [] to make it work.
If the string has \n in end or beginning, convert it to #10.
11. "Const name lists (eg yes/no) had null tail item, removed (eg. l. 2857)"
A: All lists needs to have null tail items, as all routines that I have checked are depended to null tail items.
(They browse the list as far as they face the null item)
12. Converting C/C++ operators to Delphi
A:
-= operator
var1 -= var2;
{ this equates to: }
var1 := var1 - var2;
+= operator
var1 += var2;
{ this equates to: }
var1 := var1 + var2;
&= operator
var1 &= var2;
{ this equates to: }
var1 := var1 AND var2;
|= operator
var1 |= var2;
{ this equates to: }
var1 := var1 OR var2;
*= operator
var1 *= var2;
{ this equates to: }
var1 := var1 * var2;
13. Continuous assignment
C/C++ allows you to Assign values to variables IN-SIDE logical expression
valuators. We can not do this in Delphi, and affected areas need to be
changed.
An example of some C/C++ use of Assignment in-side a logical expression is:
while ((target = G_Find (target, FOFS(targetname), self->combattarget)) !=
NULL)
This actual While..Loop Assigns a Value to the 'target' variable, and THEN
tests that the 'target' variable is not NULL, looping until such time as it
is NULL. The nearest alternative to this in Delphi is the following:
target := G_Find(target, FOFS(targetname), self^.combattarget));
while (target <> Nil) do
try
{ ... }
finally
target := G_Find(target, FOFS(targetname), self^.combattarget));
end;
This should operate in a similar state to the above C/C++ statement.
If you have any comments or Conversion Guidelines please Mail them to me.
|
|