Jump to content
XCOMUFO & Xenocide

Source Code?


Recommended Posts

Do you have the source code for 2.5 available (and the exe editor would be nice)? Is it masquerading under the "version 2.4 source" link?

I was looking at some of the code (the 2.4), and you can shorten quite a few of the functions:

 

In PubStuff:

Public Function GetBaseMult(BaseNum As Double) As Long
GetBaseMult = (BaseNum-1)*292
End Function
-------------------------------------------------------------
Public Function GetHex(ToGet As String) As Integer
GetHex = Asc(ToGet)
End Function
-------------------------------------------------------------
Public Function CheckMonth(MonthNum As String) As String
'Select Case blocks are prefered for descisions like this, in VB they 
'can use strings as well as numbers, and can be set to cover a range 
'([1 to 6] or [a to d]) and can take multiple arguments ([a to d, A to D])
'and can use comparisons as well ([>5], [<f])
'I cast MonthNum to a numeric value to ensure matching wouldn't get 
'"wierd" though it shouldn't matter

Select Case Val(MonthNum)
Case 0
	CheckMonth = "Jan"
Case 1
	CheckMonth = "Feb"
Case 2
	CheckMonth = "Mar"
Case 3
	CheckMonth = "Apr"
'Continue cases as above
Case 11
	CheckMonth = "Dec"
End Select
End Function
------------------------------------------------
Public Function LoadUFOP()
'not sure about this one, but it should work since  
'the caption is a string, if it was a value you could 
'cast it to a string as you concatenated

'Note that the final Else that throws is not capturing 
'the error it says it is. The entire If-Then-Else set is 
'only testing the value stored in the lblLoad.Caption
'which is set by the Options at the top of the form 
'and by nothing else, the values that can be set are
'know and will the final else will never throw.

 mHandle5 = FreeFile
 Open MyPath & "\game_" & frmBaseEditor.lblLoad.Caption & "\up.dat" For Binary As #mHandle5
'Rest of code that follows the End If is unchanged
End Function
------------------------------------------------

If I'm going to play with the code, I'd rather play with the most recent.

Thnx, Robert

 

BTW, in case you had't seen, check this out: http://www.ufo-extraterrestrials.com/; also, the UFO series by Altair are good (Aftershock, Aftermath, and Afterlight), You should also check out the X-com WIKI, lots of DATs decrypted: http://en.wikipedia.org/wiki/X-COM

Edited by Chaman
Link to comment
Share on other sites

Here's another one from PubStuff that can be shortened:

 

'This function adds commas to the money
Public Function AddCommas(Comma As String) As String
AddCommas=str(format(val(Comma), "###,###,###,##0"))
End Function

 

Note: though VB will cast types safely most of the time, it is often safer to

explicitly cast, and I use the Explicit option to make sure I do.

 

BTW I checked the "About" message box & found that this is from the 2.45 version

Edited by Chaman
Link to comment
Share on other sites

  • 2 months later...

Yeah, I didn't have much formal VB training. I just finished my first college level VB class (I thought I was a musician for several years). I just looked at the code and I'm kinda finding it funny how much didn't need to be that long. But, these two projects really helped me to get a good understanding of things.

 

Anyway, yeah, I do have the code available. If you do any modifying let me know, I was hoping someone would want to help. I believe the code for 2.5 is available if you just change the name from 2.4 to 2.5 in the download link. Lemme check though...

 

Here is the link:

 

http://www.stonepool.com/xcom/X-COMHACKsrcv25.rar

Link to comment
Share on other sites

  • 5 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...