Game Development Community

Advanced Resource/Supply manager available!

by Stephen Zepp · in RTS Starter Kit · 11/20/2004 (4:09 pm) · 28 replies

EDIT: This resource is now outdated, and is no longer available. It has been enhanced and included within the Community Resource-Building-Villager Mod.

I've built upon the foundation Jared made, and included art (2-d icons) that John McGlamory made to produce as "drop in and play" resource manager for the RTS Starter Kit.

It has been tested against Stock RTS-SK in single player mode, as well as dedicated server-client mode.

From the readme.txt:

Summary:

This resource is designed to encapsulate and abstract resource management, including:
--Client non-authoritative display and inventory tracking
(resources-client.cs)
--Server authoritative inventory tracking and modification
--functionality to:
---assign a resource "cost" to an action the player can perform
(see building.cs modifications for the example)
----validate the cost, and return either an ALLOW or DENY message to the action, including information about why it was denied
(resources-server.cs)
----update the server's inventory, and inform the client of the updates
---allow server objects to add supplies to a player's resource store
---demonstrate one (not very elegant) method to add resources over time to a player's resource store
(see building.cs modifications for the example)
[/quote]

Download File: RTS-SKResourceManagement.zip

The restricted login is : GGRTS
password : ggrocks

PLEASE do not distribute this login to anyone outside of this private forum.

Thanks to:
Jared for the initial functionality.
John for the icons, and installation testing, and temporary hosting.
Addison for additional installation testing.

NOTE: There is one known issue in dedicated server-client mode, and possibly multiplayer host mode: When a client exits the game but the server stays active, there may be hanging scheduled auto-update supply events. These events seem to continue to reschedule even though the underlying objects are gone. I do not plan on following through on this last bug myself, since it is only for the demo (not the underlying functionality per se), but would welcome any ideas on how to fix it!
Page «Previous 1 2
#1
11/20/2004 (5:00 pm)
Thanks Stephen !
#2
11/20/2004 (5:28 pm)
@ Stephen If you are referring to your repeatingAddSupplies function, there should be an easy way to cancel the schedule...
Doing a simple isObject check should take care of it....

if(!isObject(%this))
{
    cancel(%this.supplyAddEventId);
    return;
}

Ought to work :)
#3
11/21/2004 (3:41 am)
I agree, it -ought- to work, hehe.
Unfortunately, it doesn't :(

I'm still tracing through to see if this is an artifact of implemention changes right at the end (this was the last thing I worked on), or something deeper (possibly placing the supplyAddEventId on the wrong "this", and therefore loosing track of the previous one if/when we overwrite it.

If you feel like taking a look at it, the current schedule cleaning code is in onDisabled in /server/scripts/avatars/player.cs, which as far as I can tell is what is called when the player leaves game, for all RTSUnits.

Hmm...maybe it isn't in fact called for buildings--I'll have to trace that through.
#4
11/21/2004 (5:30 am)
It would get called for buildings, if the building ID's were stored in ClientID.units. So I'd think that all you'd need to do is add a for loop to RTSConnection::onClientLeaveGame which will cycle through the ClientID.buildings simgroup and call onDisabled for them as well.
#5
11/21/2004 (5:46 am)
Good thought--let me take a look at that, thanks!

EDIT: Your instinct was correct, it turns out that buildings are directly deleted, while units are simply disabled. Not quite sure why, but this shows why my current cleanup isn't working! Will post a fix shortly.
#6
11/21/2004 (8:26 am)
Well, I'm a bit stumped. It seems that even though we add the building to the ClientID.buildings SimGroup, when we check back again, it's no longer there. Either there is an issue with something deleting it prior, or something whacky with SimGroups itself.

Here is some debugging output:

serverCmdPlaceBuilding--request by   APPROVED
----adding building to SimGroup (1115) for client (1063), building is (1122). Old set list was
New set list:
   1122: RTSBuilding 

..client creates another building, first one still "in game":

serverCmdPlaceBuilding--request by   APPROVED
----adding building to SimGroup (1115) for client (1063), building is (1125). Old set list was
New set list:
   1125: RTSBuilding

Not that our %client, %client.buildings both agree, but when we do a %client.buildings.listObjects(); the second time around, the list is empty again.

What I can't figure out is why this works fine for %client.units, but fails for buildings...and since we can't maintain a list of current buildings created by the player (each of which stores our repeating scheduled event ID, we can't clean up on client enter game:

RTSConnection::onClientLeaveGame()--cleaning up units
RTSUnitData::onDisabled()--attempting to cancel scheduled addSupply  for unit 1066
Client(1063) has disconnected, disabling unit 1066

...repeats for each unit...

RTSConnection:onClientLeaveGame()--cleaning up buildings
----buildings count in %this.buildings = (0).
CDROP: 1063 IP:69.139.199.88:3147
Client 0, IP:69.139.199.88:3148 disconnected. (1060)

EDIT: Note, that last number (1060) is our internal accountId, not the clientID.
#7
11/21/2004 (12:24 pm)
Ok, I've resolved the issue (see this thread), and re-worked the resource store cleanup.

All new files are in the currently posted version at the link above.

Summary changes:
--removed some echo lines that were for debugging only. Left in ones that demonstrate execution flow
--removed the MissionCleanup line from buildings.cs
--fixed onClientLeaveGame() cleanup issues.

If you haven't made any major changes to your installation of the resource yet, I suggest you simply replace resources-server/client and building.cs, as well as re-read the readme.txt for the fixes to the cut/paste areas.

Thanks for your patience!
#8
11/22/2004 (8:34 am)
Im having trouble understanding a couple of things in the readme setup text (i hate beeing a newb at things )
Sounds greate though :D
#9
11/22/2004 (8:51 am)
@Mattinn: if you post specific questions (possibly in a thread in the "RTS General" forum would be better), I'll do my best to help clear things up for you, and possibly make the readme.txt more clear!
#10
11/23/2004 (5:28 am)
Sorry i didnt say more about the problem, but my way is to try untill i either get really frusterated or i finally get it right ;) but its time to say somethign (i'm frustrerated) well no problem with the readme text only that i'm thick headed, ok here it goes: i have no idea where in the playgui to put the gui files and there is a part in the readme file i just dont understand: --We need to make sure that we clean up any automated addSupply schedules as well.

File: /server/scripts/avatars/player.cs

search for the function RTSUnitData::onDisabled and add near the bottom, above the line
"// Schedule corpse removal. Just keeping the place clean." add:

// hopefully clean up any pending suppy auto-adds
cancel(%obj.supplyAddEventId);

NOTE: This is one known issue in the resource--in a dedicated server setup, and possibly in
multiplayer host as well, we haven't figured out yet how to clean up some hanging schedules
when one player leaves the game. If you check the console.log for these configurations after
a player builds some buildings, and then leaves the game, you will see the hanging scheduled events.
If anyone can track down where to clean them up via cancel(), I would appreciate it!

this part looks kinda messy and it at least messed me up! well thats just about it! and yes while i'm at it pictures would help newbs like me understand better ;D
#11
11/23/2004 (6:20 am)
First thing I would do is to grab the latest copy of the resource. It fixed the memory problem completely (as far as reported) so the NOTE: section doesn't even apply.

The add to /server/scripts/avatars/player.cs is -separate- from where the NOTE: is...you don't add the Note itself to the file, just the lines

// hopefully clean up any pending suppy auto-adds
cancel(%obj.supplyAddEventId);

Those two lines are the -only- change to player.cs in that directory.

For the playgui, open the file, and look down around lines 21-23 for the following:

helpTag = "0";
firstResponder = "1";

You can the controls from the readme.txt and past them right after the last line above, and before the line

new GuiBitmapCtrl(centerPrintDlg) {


That should get you up and running!

EDIT: If you haven't made many other changes to the RTS SK yet, it may make sense to "practice" on a fresh installation right out of the installer--get it working against the stock release, and then see if you can match it up against what you have changed. Again, do this with the latest download (grab it again).
#12
11/23/2004 (8:42 am)
K ill check it out, thanks alot, hopefully it will cleare things up for me.
Edit: Darn it didnt work, it gave an error
Edit2: ok i looked through the console and found the error it is working fine (man i am really happy right now, see my smile -->:D ) but thier is one thing not working propperly is that the building doesnt appear when i build!?
#13
11/23/2004 (1:55 pm)
Hello Mattin:

The building doesn't appear because the path that appears in the second line of building.cs is pointing somewhere else.

If you have the default version of the RTS installed, then the path should be:

shapeFile = "~/data/shapes/building/building.dts";

I hope it works

William
#14
11/24/2004 (9:23 am)
Important note: This resource appears currently not working as implemented using the readme.txt installation directions.

I'm working on updating the instructions, but I am very seriously inclined to package the Resource Manager and the Building Actions modules as one combined resource--mostly because they work together so well.

Any thoughts on that idea? If I don't hear anyone screaming "NO FOR THE LOVE OF ALL THAT IS GG!", then I will probably re-issue this resource only as part of the combined package.
#15
11/24/2004 (11:41 am)
Hello Stephen:

Thanks for your effort in this great resource and for being working on solving the issues with the .txt file. At this time I have the resource partially working. I see in the log the echoes of the resource manager and the system run out of resources after I place 10 buildings. However, I don't see any of the icons of the resource or am able to increase or change the inventory.

As for the merge of the resource with the building I don't se any problem, however, I don't how this would affect games that wants to make different uses of the building (evolve them into Mega machines, Heavy Artillery, etc) and don't make use of inventory.

Again, thanks for that excellent resource.....

William.
#16
11/24/2004 (11:45 am)
@William: change your resolution to 1024x768. I didn't do a very good job of providing a "standard" gui--I use 1024x768 pretty much exclusively! You can then hit F10, set the resolution there to 1024x768 as well, and then move the supply panel pretty much wherever you like. If you set it to "left" and "top" instead of "right" and "bottom", and make sure it's position is less than 800x600, you can then swap back to that resolution, move it exactly where you want it, and then save gui.

Complicated kind of, but it will fix the problem for any resolution 800x600 or above.

Regarding the "merge", it's a merge of the two resources, not a merge of "everything into buildings".

Basically, it's -much- easier for me to try to maintain the resource if I can at least have just one copy of everything, instead of a bunch of branches with different levels of resource :)
#17
11/24/2004 (11:48 am)
@Stephen:

Thanks a lot for your quick answer. Once I arrive home I will try it, and I think it is going to solve the problem.
#18
06/05/2005 (1:08 pm)
Hmmm - i followed everything step by step - but after the mission/objects loads it crashes: i took out the log and there are no errors or missing files. this is the last bit:

Mapping string: AcceptSetupStores to index: 20
clientCmdAcceptSetupStores--setting up resource store
----MOVE THIS TO APPROPRIATE PLACE IN CLIENT STARTUP
resourceStore::Ctor()
Mapping string: AckStoresSetUp to index: 4
resourceStore::initServerStore
resourceStore::initServerStore--Index is 0 supply is Gold Total store count is 4
resourceStore::initServerStore--Index is 1 supply is Wood Total store count is 4
resourceStore::initServerStore--Index is 2 supply is Food Total store count is 4
resourceStore::initServerStore--Index is 3 supply is stone Total store count is 4
resourceStore::initServerStore--Sending inventory to client: Gold 1000 Wood 500 Food 20 Stone 150
Mapping string: blue to index: 21
Mapping string: AcceptSupplyUpdate to index: 22
clientCmdAcceptSupplyUpdate--store is LOCAL Inventory list is Gold 1000 Wood 500 Food 20 Stone 150 stock type is
clientCmdAcceptSupplyUpdate--Trying to stock 1000 Gold
clientCmdAcceptSupplyUpdate--Trying to stock 500 Wood
clientCmdAcceptSupplyUpdate--Trying to stock 20 Food

anybody got any idea what would come next or why it would crash?
cheers :)
#19
06/05/2005 (1:17 pm)
@Rutger: email me your complete console.log (looking at the last several lines doesn't always point to where the error or issue is, just the last executed output before TGE finally gives up or crashes!) and I'll try to take a quick look. Off the top of my head I'd think you have some missing art or gui profiles. It's possible there is an issue with the latest executable as well, but that would be the last thing I check, as others haven't had any issues with the latest installer version.
#20
06/06/2005 (5:57 am)
Ok - now that's all under control: i was under the impression that the villagers are able to harvest, right? how do you give them the command to harvest? havn't found the option anywhere? when i select a villager i just get the options to build buildings, when i select multiple villagers i see the options for them to move/attack... this correct? =)

cheers :)
Page «Previous 1 2