Jump to content

Disscussion on usage of the worldspace field by mod makers.


RimBlock

Recommended Posts

As the Dev team seem dead set on not opening up the Hiveext.dll to allow mod makers to create and fire custom sql or stored procedures (999 & 998 calls) we are having to find alternative fields to store presistant data for our mods or resort to using various custom hiveext.dlls / solutions (ARMA2Net etc). 

 

I personally prefer to work with the standard Epoch tools rather than being reliant on one or more third parties so I have stuck with finding space in other fields that can be utilised without any custom DB connectivity. 

 

This has been done and supported in Epoch with the use of the characterID field to store door lock / safe lock and vehicle key combinations and witht eh currentstate field to store the tag friendly characterIDs.

 

When everything went to Steam, saving the playerUIDs in the characterID field was no longer an option (at the time) and so I started hunting around for another suitable place to save persistant data can came away with the worldspace field in object_data.

 

The filed is around 200 chars long (will check the actual figure when home and update) of which the world space cordinates only make up around 30-40 characters.  That leaves around 150 characters for saving other date (with a bit of buffer for other future updates).  This is more than enough for my v2 A Plot for Life mod.

 

Now it seems that great minds think alike (an fools seldom differ) and a number of other mod makers have been looking at using the same woldspace field for saving their persistant data and so in order to try and prevent future conflicts, I have put this thread up so we can discuss the usage of this field and adopt a 'best practices' loose agreement about who is using it for what and how to seperate the extra fields out.

 

My initial suggestion would be to create a nested array after the worldspace details with tags which can be defined by each mod maker.

 

i.e.

 

For my A Plot for Life mod, I may change a worldspace field value of

[10,[12345,12345]]

to

[10,[12345,12345]],[["P4L"],["playersUID number"]]

 

If another mod maker also wanted to use that filed for their persistant data like Stiker with his Vector build mod then he could add his data like

[10,[12345,12345]],[["P4L","Vectors"],["playersUID number", [[v1,v2,v3],[v4,v5,v6]]]]

 

The server monitor could then be easily amended to look for the tags when processing the object loads and deal with the corrisponding data accordingly.

 

Any other thoughts or suggestions from other mod makers out there ?.

Link to comment
Share on other sites

  • 1 month later...

I must say i had experiences now with both ways.

 

Single Currency: Own hive dll files. Great way but we are forcing players to change their servers ( for dedi's not that hard, but hosts have a bit more problems).

+ This could get problems for other scripts ( needs to be compatible with multible hives). 

 

FYI: i'm making a single currency system with default hives again (without 999 calls).

 

 

Using worldspace is def the way to go.

BUT

 

 

Worldspace default with P4L and vectors in can almost completely fill up the worldspace field already, if i remember correctly. ( EDIT, this was when i saved PUID's in this aswell).

 

Now i have a paint scripts ( which i probably going to release soon)

 

This makes the the worldspace for VEHICLES to look like this for example:

[217,[4548.71,8759.35,0.1],[["color1","#(argb,1,1,1)color(0,0,1,1)"],["color2","#(argb,1,1,1)color(0,0,1,1)"]]]

Now, i use the color1 string to let the script check which variable it's reading, (same is your idea). This can be indeed solved with your idea.

 

Into this. ( Probably also adding 3th collor soon).

[217,[4548.71,8759.35,0.1],["Paint"],["#(argb,1,1,1)color(0,0,1,1)","#(argb,1,1,1)color(0,0,1,1)"]]]

Edit: Rethinking this, i can make it way shorter to:

[217,[4548.71,8759.35,0.1],["Paint"],["0,0,1","0,0,1"]]]

Now, i also want to bring front some other options.

 

As i use in door and plotManagement the Gear field to store the users on the door/plot. Now this is great and doable.

 

I want to do the same for Safes and Lockboxes, but their gear gield is filled with the inventory data. Now, bringing this to worldspace is too much PUID's to handle, or i have to limit the poepl on the list to 3 or 2 if they use p4l and vectors.

 

It's an annoying situation tbh, maybe we could also start using other fields? Maybe like Hitpoints, since thats already default 512 characters long?

Link to comment
Share on other sites

im not a 100% certain but i dont think that returning results from a integer field will be working let alone storing something else then integers to it.

the hive expects an integer value for those fields. fields that have default values like [] are treated as sqf values (arrays with mixed data).

 

be aware that "callExtension" can only handle data blocks up to 4096bytes per call. If you exceed this your call will return a cut off value and spawning in that certain object will fail.

I have seen this happen with especially ural type vehicles that have to much gear in them, especially if theirs alot of gear in with long classnames etc. Making extended use of the

worldspace field will increase occurences of these faillures. Length per field is defo a limitation but the biggest concern is the total lenght of returned data per call.

Link to comment
Share on other sites

im not a 100% certain but i dont think that returning results from a integer field will be working let alone storing something else then integers to it.

the hive expects an integer value for those fields. fields that have default values like [] are treated as sqf values (arrays with mixed data).

 

About what field are you talking?

 

Cus i cant follow the context here ^^

Link to comment
Share on other sites

would be any unused field that normaly only stores integerial values.

 

Yep, from what I have read in the C++ code, the field types are locked.  Changing them at a DB level is a non starter due to that (was why we could not change the characterID to a larger int size for SteamID storage).

 

It is well worth noting the max extension call return length.  As you say, this is likely to be a big issue as we repurpose fields.

 

The standard hive has the large return call used for streaming the objects on server load.  Does this not take the data in 'chunks' so as not to breach the max byte size ?.

 

@Zupa:

 

Yep your option 3 is what I would have gone for in your position.  Just need to store the unique values and then plug them in to the code line when the object is loaded.

 

I was also looking at storing the playerUIDs in the gear field for the plot builder management but no longer need tt :) .  The only thing about using the inventory is that the code uses ARMA functions to manage the inventory rather than it just being a variable attached to the object.  There is no reason not to side step this of course.

 

I am currently testing out another extension to better suit my purpose as the Hiveext is just too crazy limited, not actively enhanced as requirements change by the developers meaning we have to rely on people like Soul with the skills to have the time and willingness to modify it.

Link to comment
Share on other sites

Hy guys, 

 

Since i'm making a new single currency ( with the default hive) i wanted to make it official:

 

I proppose the following structure: CLEAN AND SIMPLE, If it doesnt excist it doesnt cause errors, alot better then nested if's 2...

if (count _worldspace > 2) then
		{
			_extraData = _worldspace select 2;
			
			{			
				switch(_x select 0)do{
				case "SC" : 
					{
						_money = _x select 1;
					};
				case "P4L" : 
					{
						_ownerPUID = _x select 1;
					};
				case "Vector" : 
					{
						_vector = _x select 1;
					};
				case "Paint" :
					{
						_paint = true;
						_color1 = (_x select 1) select 0;
						_color2 = (_x select 1) select 1; 
					};
				};
			}count _extraData;
		};	

after that u can do stuff like this:

if(isNil "_ownerPUID")then{
	_ownerPUID = _ownerID;
};
_object setVariable ["OwnerPUID", _ownerPUID, true];

if(!isNil "_paint")then{
	// do your paint stuff on object
};

if(!isNil "_vector")then{
	// do your vector stuff on object
};

if(!isNil "_money")then{
	_object setVariable ["bankMoney", _money, true];
};

how does it looks like in DB:

[245.228,[3388.97,14243,3.644],[["Vector",[[-0.908,-0.419,0],[0,0,1]]],["SC",25034],["P4L","76561198092449476"]]]
Link to comment
Share on other sites

 

Hy guys, 

 

Since i'm making a new single currency ( with the default hive) i wanted to make it official:

 

I proppose the following structure: CLEAN AND SIMPLE, If it doesnt excist it doesnt cause errors, alot better then nested if's 2...

if (count _worldspace > 2) then
		{
			_extraData = _worldspace select 2;
			
			{			
				switch(_extraScripts select 0)do{
				case "SC" : 
					{
						_money = _x select 1;
					};
				case "P4L" : 
					{
						_ownerPUID = _x select 1;
					};
				case "Vector" : 
					{
						_vector = _x select 1;
					};
				case "Paint" :
					{
						_paint = true;
						_color1 = (_x select 1) select 0;
						_color2 = (_x select 1) select 1; 
					};
				};
			}count _extraData;
		};	

after that u can do stuff like this:

if(isNil "_ownerPUID")then{
	_ownerPUID = _ownerID;
};
_object setVariable ["OwnerPUID", _ownerPUID, true];

if(!isNil "_paint")then{
	// do your paint stuff on object
};

if(!isNil "_vector")then{
	// do your vector stuff on object
};

if(!isNil "_money")then{
	_object setVariable ["bankMoney", _money, true];
};

how does it looks like in DB:

[245.228,[3388.97,14243,3.644],[["Vector",[[-0.908,-0.419,0],[0,0,1]]],["SC",25034],["P4L","76561198092449476"]]]

 

Very nice method clean and simple :)

Link to comment
Share on other sites

i'll make a server monitor that supports all the following scripts: ( even if u dont have it).

 

Worldspace:

  • P4l
  • Paint
  • Single Currency ( my new soon to be released one)
  • Vector

Gear:

 

  • PlotManagement
  • DoorManagement

 

Or are there more?

Really great Zupe its like i said you are just awesome looking forward to this, If you need any testers im pretty sure the Scripters Channel will jump on it.

Link to comment
Share on other sites

One thing that worries me a bit is that the allowed space for the worldspace currently is by default limited to varchar(128). 

When looking at your final example string, it is currently pushing the envelope: 

 

[245.228,[3388.97,14243,3.644],[["Vector",[[-0.908,-0.419,0],[0,0,1]]],["SC",25034],["P4L","76561198092449476"]]]

Total count: 113

 

Give some extra leeway for bigger maps, and vector buildings potential for (ie. non-scientific numbering) and peoples banks being huge, you might end up with this: 

[245.228,[33188.0021,14243.1111,111.644],[["Vector",[[-0.009018,-0.004191,0],[0,0,1]]],["SC",25031114],["P4L","76561198092449476"]]]

Total count: 132, leading to value being truncated.

Now, the above is based on the positions saving up to 4 decimals and vectoring having up to 6... since I am at work, I cant really verify that this is currently something that Vector is doing... but just want to make sure that this is being considered. 

 

Perhaps a pull request to increase the default worldspace varchar value in the default epoch.sql script to something higher, like 255?

Link to comment
Share on other sites

 

One thing that worries me a bit is that the allowed space for the worldspace currently is by default limited to varchar(128). 

When looking at your final example string, it is currently pushing the envelope: 

 

[245.228,[3388.97,14243,3.644],[["Vector",[[-0.908,-0.419,0],[0,0,1]]],["SC",25034],["P4L","76561198092449476"]]]

Total count: 113

 

Give some extra leeway for bigger maps, and vector buildings potential for (ie. non-scientific numbering) and peoples banks being huge, you might end up with this: 

[245.228,[33188.0021,14243.1111,111.644],[["Vector",[[-0.009018,-0.004191,0],[0,0,1]]],["SC",25031114],["P4L","76561198092449476"]]]

Total count: 132, leading to value being truncated.

Now, the above is based on the positions saving up to 4 decimals and vectoring having up to 6... since I am at work, I cant really verify that this is currently something that Vector is doing... but just want to make sure that this is being considered. 

 

Perhaps a pull request to increase the default worldspace varchar value in the default epoch.sql script to something higher, like 255?

 

 

indeed, we can provide a simple sql that u need to execute that convert that field to allow more data.

 

The only problem i'm seeing is that everyone has to update their scripts and their database entries already there.

Link to comment
Share on other sites

indeed, we can provide a simple sql that u need to execute that convert that field to allow more data.

 

The only problem i'm seeing is that everyone has to update their scripts and their database entries already there.

 

Small script for current servers that wants to use it, and then submit a pull request to alter the Epoch default SQL (or the 1.0.6_update.sql) for future DB's should be good.  basic one is probably a good idea. 

 

Should be as simple as: 

ALTER TABLE `Object_DATA` MODIFY `Worldspace` VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '[]';
Link to comment
Share on other sites

Just had a quick scan through the hiveext code and didn't see any restrictions to making the field bigger.

 

We would need to be mindful that this could broach the max size limit for ext.dll calls though (as Soul said above).

 

Would also include the precision positions as Glenn suggests in the mix as it seems to be quite popular.

Link to comment
Share on other sites

 

We would need to be mindful that this could broach the max size limit for ext.dll calls though (as Soul said above).

 

 

We just gotta keep it as same size as max gear then i guess ^^

 

It's just hard to release something now that uses worldspace, since you need to give a turtorial for 5 different things on the same piece of code. Because all players have it a bit different depending on the scrpts they use ^^

Link to comment
Share on other sites

Ok i just decided to make a server pack that supports most of the popular scripts (that use the worldspace) build on yourstarting p4l with snap pro.

 

But added to that 

 

Togglable ( ON/OFF )

 

  • Vector
  • Single Currency (Default hive)
  • Paint
  • Precise basebuilding
  • PlotManagement
  • DoorManagement

With the database/worldspace system i proposed ?

 

If you guys think thats good and ok?^^

Link to comment
Share on other sites

I would suggest you make a guide about how to integrate these mods using this system.  That way the separate mod owners can control and manage their mods independently and the guide can be updated by you independently when required.

 

Note: For A Plot for Life, I will probably be pushing it to the core Epoch build after a month or so.  When the Dev team get a break and can do some testing for A2 Epoch 1.0.6 I would expect it to be added and then the issue is likely to go away for A Plot for Life.

 

If we agree on a system then I am ok to modify my code to make it easier for other mods to integrate in to 1.06 using the worldspace variable.

 

I would suggest that positions are allocated for each of the mods using it currently though so the values placed in the worldspace field can be at targeted positions rather than having to scan the array for the correct place each time you need to update / create objects.

Link to comment
Share on other sites

 

I would suggest that positions are allocated for each of the mods using it currently though so the values placed in the worldspace field can be at targeted positions rather than having to scan the array for the correct place each time you need to update / create objects.

 

Not really following on that,

 

THe thing i proposed, it doesnt matter which position it's in? 

 

But i dont really get the while sentence ^^ i'm sorry

Link to comment
Share on other sites

Not really following on that,

 

THe thing i proposed, it doesnt matter which position it's in? 

 

But i dont really get the while sentence ^^ i'm sorry

 

What you have proposed is a way to read the values.  There is no unified way to write them though.  Some mods have modified the server object publish scripts and some just modify the worldspace data before it is sent to the server.  Something that is unified on both sides of the equation would be more balanced.

 

Having to scan the worldpace variable each time you want to save it to find the correct position for the data you want to save rather than using a lookup table (global array) to tell you the position to save that data (could be populated on server load I guess) would seem to be pretty inefficent.

 

A couple of other poiints on why a guide rather than a server pack may be better;

  • If the server owner only wants one or two of the mods, the clients still have to download all the mods code making a bigger download on connection (mission.pbo or code is not pbo'd).
  • VBAwol has on the forums.

Put a guide together on how to merge based on this framework.  I am sure there are lots of people out there who will be extremely grateful.

 

It would probably be prudent for someone to check the max data size for a buildable item (i.e. a safe) with max items, all having long names and sample info from all the mods and see if the ext.dll limit causes issues. 

Link to comment
Share on other sites

I revised my Worldspace length to 512, as I write the name of players after the uid in plot pole for life and my server has shareable strong holds that write all the people with access to it in the plot for life Worldspace position... (Can't use gear field as strongholds have gear) Is 512 to large a number and might cause me problems in the future?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...