| » Stats |
Members: 103,531
Threads: 85,004
Posts: 1,031,271
Top Poster: Karky (9,546) | | Welcome to our newest member, samule456 | |
If you register for free, you will be able to post threads, vote on polls and lots more. If you have problems with the registration or logging in, please contact the administrator.
 | |
06-14-2003, 10:50 PM
|
Pre-game database format information Post #21 | | Newb
Join Date: Oct 2007
Posts: 0
Rep Power: 0 |
<BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by EdL:
I'll have to run those files through grep when I can be arsed, to look for anything else amusing.<HR></BLOCKQUOTE>
One I particularly like is the constants ( tut tut SI, not very type safe are they  ), indicating where an injury occured, in injury.h
<pre class="ip-ubbcode-code-pre">// how the injury was received...#define INJURY_RECEIVED_IN_PUB 3</pre>
Also spotted a constant there for "FAITH_HEALING_INJURY_ID".
Incidentally, ( one for SI ) should there be an additional injury category to cover back injuries specifically, or is that covered by other categories sufficiently?
|
| |
06-15-2003, 11:24 AM
|
Pre-game database format information Post #22 | | Registered User
Join Date: Sep 2007
Posts: 0
Rep Power: 0 |
Back injuries are in the upper body injuries section.
VB, erm, i'll try and do it at some point. Are there any other VB people out there anyway?
A question for you editor geeks - re: constants and the like. How do you deal with them in your editor UI? Say you have all those injury ones defined in your injury class. And you have a function to add/edit an injury - how do you go about mapping the injury ID to a "display name" for it? I never used to bother, instead opting to add the display names of the injuries to a listbox (injury ID conveniently mapping to listbox listindex). But it's stupid and messy (it was 4 years ago :p ) and i'll need to rethink it. So what's the best way to do it then? Just an array of strings?
|
| |
06-15-2003, 02:21 PM
|
Pre-game database format information Post #23 | | Newb
Join Date: Oct 2007
Posts: 0
Rep Power: 0 |
Not much help for you, I guess, but the way I do it is to utilise a Type Safe Enumeration pattern within Java.
As it stands, because constants defined within C++ are IIRC ints, it means different constants with the same value can become interchangeable, ie
<pre class="ip-ubbcode-code-pre">#define GRAEME_KELLY 2#define POT_NOODLE 2</pre>
Both constants there are theoretically belonging to a different problem domain space, but resolve to the same value, hence can be used interchangeably.
I therefore spend hours converting the constants into Java objects; for example...
<pre class="ip-ubbcode-code-pre">public final class InjuryCategoryType{ private String text; private InjuryCategoryType(String text) {this.text = text; } public String toString() {return text; } public static final InjuryCategoryType ANY = new InjuryCategoryType("Any"); public static final InjuryCategoryType INTERNAL = new InjuryCategoryType("Internal"); public static final InjuryCategoryType FOOT = new InjuryCategoryType("Foot"); public static final InjuryCategoryType SHIN = new InjuryCategoryType("Shin"); public static final InjuryCategoryType KNEE = new InjuryCategoryType("Knee"); public static final InjuryCategoryType THIGH = new InjuryCategoryType("Thigh"); public static final InjuryCategoryType GROIN = new InjuryCategoryType("Groin"); public static final InjuryCategoryType UPPER_BODY = new InjuryCategoryType("Upper Body"); public static final InjuryCategoryType HAND = new InjuryCategoryType("Hand"); public static final InjuryCategoryType ARM = new InjuryCategoryType("Arm"); public static final InjuryCategoryType SHOULDER = new InjuryCategoryType("Shoulder"); public static final InjuryCategoryType NECK = new InjuryCategoryType("Neck"); public static final InjuryCategoryType HEAD = new InjuryCategoryType("Head"); public static final InjuryCategoryType REHABILITATION = new InjuryCategoryType("Rehabilitation"); public static final InjuryCategoryType[] CM4_INJURY_CATEGORY_TYPES = new InjuryCategoryType[] { ANY, INTERNAL, FOOT, SHIN, KNEE, THIGH, GROIN, UPPER_BODY, HAND, ARM, SHOULDER, NECK, HEAD, REHABILITATION }; public static InjuryCategoryType getInjuryTypeByIndex(Version version, int index){ int tempIndex = index+1; if ( version == Version.CM4 ) { if (( tempIndex >= 0 ) && ( tempIndex < CM4_INJURY_CATEGORY_TYPES.length)) { return CM4_INJURY_CATEGORY_TYPES[tempIndex]; } } return ANY;}}</pre>
So, where a field value points to an Injury Category, rather than defining it within the particular class as a primitive data type, I instead define it's type as being InjuryCategoryType. This gives me type safety, as any attempt to push an invalid object into the attribute gives a compile time error, so I avoid any potential run time logic errors.
From a GUI perspective, I also define an array enumerating the values allowed for a specific game version. Hence, to populate them into say a JComboBox in Java, it's as simple as
<pre class="ip-ubbcode-code-pre">JComboBox tempComboBox = new JComboBox(InjuryCategoryType.CM4_INJURY_CATEGORY_T YPES);</pre>
As a consequence, it means I can be more confident that those particular fields are therefore validated correctly if they are change, because you can only select an allowed value object.
The obvious other issue required is to code load/save functionality to map between the primitive value defined in the files and the objects I define.
In VB, then I'd guess an array / list of Strings is probably the way you have to do it; try to encapsulate the Strings, constant values, lookup code into a separate file if possible.
[This message was edited by Graeme Kelly on 15 June 2003 at 15:17.]
|
| |
06-15-2003, 02:22 PM
|
Pre-game database format information Post #24 | | Newb
Join Date: Oct 2007
Posts: 0
Rep Power: 0 |
And if a kindly mod ( or Kelly  ) could sort the editing out on the last post ( ie ANY, } misplaced ) would be appreciated.
Now people know why my code hasn't been released |
| |
06-15-2003, 04:32 PM
|
Pre-game database format information Post #25 | | Registered User
Join Date: Sep 2007
Posts: 0
Rep Power: 0 |
Geek.
That would be:
<pre class="ip-ubbcode-code-pre">Enum InjuryTypes ANY, INTERNAL, FOOT, SHIN, KNEE, THIGH, GROIN, UPPER_BODY, HAND, ARM, SHOULDER, NECK, HEAD, REHABILITATIONEnd Enum</pre>
In VB. But you can't add them to a combobox(i meant combobox above, well spotted) because VB has no equivalent (I don't think) to "this", so you can't ever return their names in string format. I suppose I'd need to have an array of strings, under the assumption that array index = injury type ID.
Anyways, purely hypothetical, everyone knows that Cm3 editors > Cm4 editors :cool:
|
| |
06-15-2003, 06:10 PM
|
Pre-game database format information Post #26 | | Newb
Join Date: Oct 2007
Posts: 0
Rep Power: 0 |
<BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by Graeme Kelly:
Geek.<HR></BLOCKQUOTE>
Doofus.
<BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>But you can't add them to a combobox(i meant combobox above, well spotted) because VB has no equivalent (I don't think) to "this", so you can't ever return their names in string format. I suppose I'd need to have an array of strings, under the assumption that array index = injury type ID.<HR></BLOCKQUOTE>
Well, you can write code to maintain the mapping, that shouldn't be a problem. The thrust of my code was that you can easily put an array/Vector of objects as the data model for a ComboBox in Java - as a consequence, what gets displayed is the <<object>>.toString() value. Hence, storing a description within a type safe enumerated object means you're not storing / processing strings, but dealing with the objects directly - ie <<comboBox>>.getSelectedItem() returns the Object the user selected.
Hence, knowing that the comboBox is for Injury Categories, you just cast the selected object back to an InjuryCategoryType object. Simple.
<BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Anyways, purely hypothetical, everyone knows that Cm3 editors > Cm4 editors :cool:<HR></BLOCKQUOTE>
Just because you're a lazy boy who hasn't written his yet...
[This message was edited by Graeme Kelly on 15 June 2003 at 17:13.]
|
| |
06-18-2003, 12:31 AM
|
Pre-game database format information Post #27 | | Registered User
Join Date: Sep 2007
Posts: 0
Rep Power: 0 |
ToString() is far too java-esque for me :shudders:
I'll do VB equivalents of this still(maybe) when i get a minute. haven't seen anyone ask, so i'll hold off for a bit anyways.
|
| |
06-18-2003, 03:41 PM
|
Pre-game database format information Post #28 | | Newb
Join Date: Oct 2007
Posts: 0
Rep Power: 0 |
I was wondering if it would be possible to convert the data (CM4) to CM01/02. You'd need the base code for 01/02. I think it'd be possible.
|
| |
06-19-2003, 12:13 PM
|
Pre-game database format information Post #29 | | Registered User
Join Date: Sep 2007
Posts: 0
Rep Power: 0 |
Not impossible, but an awful amount of work. Essentially you'd be creating the CM0102 database from scratch - all the normal data etc you would just read from the CM4 one, but you'd need to take the record IDs from a CM0102 database (as these remain constant in some/most(?) cases). You'd also run into problems where any of the variable length strings/arrays were larger than the fixed size ones in the CM0102 database - certainly too many players for some of the clubs I would think.
|
| |
06-19-2003, 12:31 PM
|
Pre-game database format information Post #30 | | Newb
Join Date: Mar 2008
Posts: 0
Rep Power: 0 |
> VB, erm, i'll try and do it at some point.
> Are there any other VB people out there
> anyway?
Yep - VB6, none of this .NET rubbush though.
Come on Graeme we're waiting
Alan
|
| |  | | | Thread Tools | | | | Display Modes | Linear Mode | | » Online Users: 28 | | 1 members and 27 guests | | samule456 | | Most users ever online was 2,128, 07-21-2008 at 08:27 PM. | |