tichtich wrote:OK. I've just made a fresh start, deleting all my repos at Github and my Phoenix project (after saving the src folder). Then I forked your repo, cloned the fork, made a new branch (rsw1) off the master, checking out that branch at the same time, copied my saved src folder over the project's src folder, committed everything, and pushed branch rsw1 to my fork without merging. I hope I've understood you correctly, and you didn't want me to merge, or edit my changes into your files.
Actually I started using that myself, making a new branch of the master and first integrating my unit building modifications to that and if all goes well then just do a simple fast forward merge to master. Actually I have been thinking of going so far as to push that new branch to github to test eg. authorship data is preserved and only push the master after I'm sure everything is ok. That way I will never (knock wood) have to re-init the github repo again.
Unfortunately, I didn't try compiling until after pushing, and now I've found there's a small problem. You've renamed a file (in folder gui) from Resources.java to Resource.java. When I copied my source over yours, I re-added the old Resources.java without deleting the new Resource.java. The new file was inconsistent with the rest of my source, and the compiler objected. No big deal, but I thought I'd better mention it, as you may be surprised I uploaded a version that doesn't compile!
Well, you should, always before committing, not only compile but play a short test game, moving a few units, attacking, saving and loading. When testing unit building I used your fillGalaxy to fill hexes with units so that unit building would be short of room and noticed that for 16 planets with 20 units per hex the compressed save file size is 4MB which is close to the java switch -Xss32m eg. 32MB stack size on threads. So if you really filled the galaxy 32MB might not be enough. Even 64MB might not be enough. But then we can't increase the stack size much cause then we run into the out of memory problem. So just to note that if try to save/load with a full galaxy you might have a stack overflow.
And I moved my "cleanLine" method into Util, as it's used by all 3 of my readers.
Proper error logging code needs to be included in those but basically it is almost just a simple procedure call inclusion.
Incidentally, at the moment Game declares two variables: "turn" (which is the number of the current faction) and "current_faction" (which isn't used). Let's agree to continue calling it "turn" and delete "current_faction".
I commented out current faction.
If we ever need a local faction number variable in a context where "owner" isn't appropriate (because we're not referring to ownership of anything), perhaps we should call it "faction_num", "faction_index", or for short "f_idx" (by analogy with p_idx).
f_idx is good.
Strictly speaking, perhaps we should be declaring such faction variables as an enum type instead of int. But I doubt it's worth changing. We're not using enum types much, and I for one am in no hurry to do so.
What little experience I have with java enums, I don't quite like them. They are a bit overgrown for simple enumeration. Also, the f_idx is stored as an int everywhere in EFS datafiles so an int based enumeration seems natural.
Alternatively, we could get rid of the boolean parameter and have two public methods intended for general use: deleteUnitExcCargo and deleteUnitIncCargo.
We might choose the overloaded way, ie. have deleteUnit() which deletes cargo and deleteUnit(boolean preserve_cargo) which does not delete cargo if preserve_cargo = true.
My thinking is that I want there to be no doubt about which methods are approved for creation and disposal of units, so that we can be sure that all creation and disposal is being funnelled through just those methods. "Delete" is the word I've chosen as indicating an approved method for unit disposal, but I'm open to using a different word if you think another one is clearer, maybe "destroy". I just didn't want it to be anything that suggested it was restricted to loss in combat.
After the unit building merge I have some refactoring to do since I made my own deleteUnit and unit creation procedures.
Better, I'll create a single method "initialiseUnitGameData(unit)" that intialises move_type, type_data and camo for one unit. createUnitInHex can call that for new units, and you can initialise units at the start of the game with just one loop that calls it for each unit. If it later turns out we need to initialise any more unit data, we only have to add the new code in one place.
Sounds sensible.
I'd also like to add a common initialisation method to Unit, for doing any initialisation that can be shared between both constructors.
That sounds reasonable.
flowerpot wrote:5. Harvest.java in dat can be deleted ?
??? That's my reader for the harvest DAT files: FARM.DAT, etc.
Ah, I thought you had moved reading to Resources as well.
flowerpot wrote:6. EfsIni gets EFS.INI data as a java Properties object.
OK. (I don't know anything about java Properties yet.)
It's just a glorified hashtable with string keys and values. The beef is in autoreading an entire init file with a single read operation. Downside is I don't think it provides for detailed read error reporting.
On the subject of your GameResources class, I'm not clear what this is for, and whether I should be putting anything in it myself.
Well, my ultimate solution to all loading of datafiles would be to do that wrapped in a progress manager displayed during game loading. There would be a proper loading screen etc. and then wherever the datafiles are now initialized would just need a simple pointer copy. But thinking about loading screens seems like a waste of time at this point. Although I may just implement that as an interesting exercise.
GameResources and Resource in gui were added halfway through the project when I thought that all datafile loading would naturally go in to its own class. Earlier I have been rather lazy at refactoring, adding new functionality preferentially.
Thinking some more about the subject of resource consumption, I'm strongly leaning towards maintaining a permanent secondary structure for cargo pods. Having such a structure not only saves execution time, it also makes programming easier, because I can program in the way that's simplest and most natural, without worrying about execution efficiency. Of course that has to be weighed against the extra programming effort to handle the structure. But I think it's worth it.
(A late response, sorry.) I have been leaning towards this. Something like an ArrayList of Factions of ArrayList of planets of ArrayList of resource_types of LinkedList of resources with planetside pods added to the beginning of the list and space pods added to the rear.
I was also concerned that we might overlook places in the existing program that create, move or delete units, all of which require updating the structure. But the IDE makes it quite easy to find such places, and I believe there are very few, namely:
- setUnitCoords (two versions)
- dropDead*, removeDead and resolveGroundBattleFinalize
- landStack, launchStack, moveSpaceStack. setUnitCoords only sets in_space, p_idx, x and y of a unit or stack.
If you agree, I'll proceed to implement the secondary structure, and modify those methods accordingly.
Go ahead.