Conversion of SP maps to MP-playable, serverside

Discussions about modding, questions, mod requests or just show off what you're working on.
ozzeh
Posts: 13
Joined: 16 Dec 2015, 21:32

Conversion of SP maps to MP-playable, serverside

Post by ozzeh »

Has anyone here determined what causes calls to CM_InlineModel() with a negative model index on the SP maps that don't pass the submodels limit?
User avatar
Daggolin
Administrator
Posts: 794
Joined: 23 Feb 2015, 13:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Daggolin »

As far as I remember this is caused by the modelindex being an unsigned 8-bit integer, but getting networked as signed 8-bit integer. So any modelindex above 127 leads to an overflow and the client gets a CM_InlineModel() error. The only way to prevent that error on the serverside is to remove any entity with a submodel > 127. So you got to remove all trigger_* and func_* with the model value "*128" and higher.

Regarding SPMaps you should also remove all target_speaker without a noise.

There was a third thing that kicked clients (for instance when you come close to the lightsaber's cage on yavin_trial), but I don't remember what exactly it was. I think it was related to entities with a "loopsound" that kicked clients out of the server, when they were triggered.
User avatar
ouned
Administrator
Posts: 596
Joined: 23 Feb 2015, 13:03
Location: Gliese581c

Re: Conversion of SP maps to MP-playable, serverside

Post by ouned »

lol a single byte ^^

i guess that's for compatibility with 27kbit/s modems :lol:
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by Tr!Force »

idk the cause ure asking for, but in any case u want get working...

Image
Image
Image
Image
Image
Image

as far i remember, u need to do this:
for MAX_SUBMODELS thing in cm_load.cpp (on the jk2mp engine, others client need to have this)

Code: Select all

	if ( count > MAX_SUBMODELS ) {
			//Com_Error( ERR_DROP, "MAX_SUBMODELS exceeded" );  //TriForce: SP Fix
			count = MAX_SUBMODELS - 1; //TriForce: SP Fix
	}

Code: Select all

	//TriForce: SP Fix
	if ( handle < MAX_SUBMODELS ) {
	// Com_Error( ERR_DROP, "CM_ClipHandleToModel: bad handle %i < %i < %i", cm.numSubModels, handle, MAX_SUBMODELS ); //TriForce: SP Fix
	return &box_model;
	}
	//Com_Error( ERR_DROP, "CM_ClipHandleToModel: bad handle %i", handle + MAX_SUBMODELS ); //TriForce: SP Fix
	return &box_model;
	//return NULL; //TriForce: SP Fix
	//TriForce: SP Fix
Note: someone asked my why not just increasing MAX_SUBMODELS, i dont remember today, but just increased didnt worked to load SP maps properly.

about the target speaker thingy (to get the others maps with no MAX_SUBMODELS error working, clients dont need to download nothing), look at g_target.c (on game code) in the SP_target_speaker function
change

Code: Select all

G_Error( "target_speaker without a noise key at %s", vtos( ent->s.origin ) );
for:

Code: Select all

G_Printf ( "target_speaker without a noise key at %s. Skipping", vtos( ent->s.origin ) ); //TriForce: SP Fix
G_FreeEntity(ent); //TriForce: SP Fix
and in g_spawn.c look for G_SpawnGEntityFromSpawnVars and below

Code: Select all

for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}
add this:

Code: Select all

//TriForce: SP Fix
if ( ent->model[0] == '*' )
		{
			int		j;
			int		k;
			char	modelNum[16];

			k = 0;

			memset( modelNum, 0, sizeof(modelNum) );
			
			for (j = 1; j < strlen(ent->model); j++)
			{
				modelNum[k] = ent->model[j];
				k++;
			}

			if ( atoi(modelNum) > 127 )
			{
				G_FreeEntity( ent );
				return;
			}
		}


		if ( Q_stricmp(ent->classname, "target_speaker") == 0 )
		{
			if ( ent->spawnflags & 1 || ent->spawnflags & 8 )
			{
				G_FreeEntity( ent );
				return;
			}
		}

		if ( Q_stricmp(ent->classname, "func_usable") == 0 )
		{
			G_ParseField( "spawnflags", "8", ent );
		}
//TriForce: SP Fix
so after that, u will need to start fix sp map entities to match with mp entities. (misc_model, breakable, etc....)
Last edited by Tr!Force on 27 Dec 2015, 16:06, edited 1 time in total.
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
Daggolin
Administrator
Posts: 794
Joined: 23 Feb 2015, 13:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Daggolin »

Tr!Force, he was not asking how to "bypass" the amount of submodels on both ends, but how to solve the CM_InlineModel (bad number) error. Your last codepiece however removed all entities with subModels > 127, so that is exactly what he needs to do in a mod. I think my approach for that looked roughly like that:

Code: Select all

if ( strlen(ent->model) > 1 && ent->model[0] == '*' )
{
	if ( atoi(ent->model+1) > 127 )
	{
		G_FreeEntity(ent);
		return;
	}
}
(shorter, but should do the same).

And Tr!Force, there is no point in increasing MAX_SUBMODELS (currently 256), when only 128 (0-127) get networked anyway.
The reason why we get that overflow for the modelindex:

Code: Select all

	{ NETF(modelindex), -8 },
the -8 tells the game to interpret it as signed 8 bit. If they actually made that 8 instead of -8 we could use the full 256 submodels. And when making a jk2 version with more submodels one should also increase the amount of networked bits, but that makes that version of jk2 incompatible to normal jk2. :/

I once tried to make a clientside that reads modelindex as 8-bit unsigned and my client could use the full 256 submodels, even on basejk servers trying to load those SPMaps. However some other parts of the code (like dismember) work with negative modelindex values, so changing the networking from "-8" to "8" is probably going to cause other side-effects and that's the reason we haven't done that in jk2mv.

But I had an idea for a work-around in cgame that might make the full 256 submodels usable, by assuming that negative modelindexes are overflows when loading subModels (cause negative subModels don't exist) and correcting them after getting them. Would be "hacky", but could actually work. If I get to try that I am probably going to include that in the mvsdk.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by Tr!Force »

Daggolin wrote:Tr!Force, he was not asking how to "bypass" the amount of submodels on both ends, but how to solve the CM_InlineModel (bad number) error. Your last codepiece however removed all entities with subModels > 127, so that is exactly what he needs to do in a mod. I think my approach for that looked roughly like that:

Code: Select all

if ( strlen(ent->model) > 1 && ent->model[0] == '*' )
{
	if ( atoi(ent->model+1) > 127 )
	{
		G_FreeEntity(ent);
		return;
	}
}
(shorter, but should do the same).
lol true :lol: i know he isnt asking how to bypass, is why i said "but in any case u want get working..." :lol: well, not off topic
Daggolin wrote: And Tr!Force, there is no point in increasing MAX_SUBMODELS (currently 256), when only 128 (0-127) get networked anyway.
The reason why we get that overflow for the modelindex:

Code: Select all

	{ NETF(modelindex), -8 },
the -8 tells the game to interpret it as signed 8 bit. If they actually made that 8 instead of -8 we could use the full 256 submodels. And when making a jk2 version with more submodels one should also increase the amount of networked bits, but that makes that version of jk2 incompatible to normal jk2. :/
have u looked for how jk3 (or jk2 sp) does? maybe there is a reference :/
Daggolin wrote: I once tried to make a clientside that reads modelindex as 8-bit unsigned and my client could use the full 256 submodels, even on basejk servers trying to load those SPMaps. However some other parts of the code (like dismember) work with negative modelindex values, so changing the networking from "-8" to "8" is probably going to cause other side-effects and that's the reason we haven't done that in jk2mv.

But I had an idea for a work-around in cgame that might make the full 256 submodels usable, by assuming that negative modelindexes are overflows when loading subModels (cause negative subModels don't exist) and correcting them after getting them. Would be "hacky", but could actually work.
solve this via cgame would fantastic.
Daggolin wrote: If I get to try that I am probably going to include that in the mvsdk.
mvsdk? in the next 5 months? :lol: jk Image
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
ozzeh
Posts: 13
Joined: 16 Dec 2015, 21:32

Re: Conversion of SP maps to MP-playable, serverside

Post by ozzeh »

Thanks for all the info.


Daggolin wrote:As far as I remember this is caused by the modelindex being an unsigned 8-bit integer, but getting networked as signed 8-bit integer. So any modelindex above 127 leads to an overflow and the client gets a CM_InlineModel() error./quote]
That... is really lame.

Daggolin wrote:But I had an idea for a work-around in cgame that might make the full 256 submodels usable, by assuming that negative modelindexes are overflows when loading subModels (cause negative subModels don't exist) and correcting them after getting them. Would be "hacky", but could actually work. If I get to try that I am probably going to include that in the mvsdk.
This is an interesting idea, I might give this a shot some time next week.
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

Hey guys, I was just trying to do TriForce's modifications, but I can't seem to find any of the 'target_speaker' stuff in the jk2mv code. Now, he writes 'game code'. Is it somewhere else? Is it some VM code thingy? Some info would be great.

(I can find the referenced code in, say, JoMME, but not JK2MV)
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

Yes it's a game module not included in jk2mv I described earlier. I'm not really sure if there is any clean 1.04 source code with modern build scripts. I have one for linux but that's all. You can always download jk2 sdk 2.0 and use batch scripts included there. Or try this thing Triforce put together.

jomme has them included because it doesn't care about mods.
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

I see, thanks. I downloaded TriForce's code, but the compilers he claims are in there are not actually in there, so I will have to download them separately, I suppose. Maybe I'll give that SDK thing a try.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

Tom Arrow wrote:I see, thanks. I downloaded TriForce's code, but the compilers he claims are in there are not actually in there, so I will have to download them separately, I suppose. Maybe I'll give that SDK thing a try.
Do you need qvm compiler though? If it's just for local testing you can compile to shared libraries with msvc. Put them in your mod directory and launch jk2mvmp with "+set vm_game 0 +set vm_cgame 0 +set vm_ui 0" commandline parameters. It's actually better for development because you can use generic C debuggers.
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

Sounds good. Shared libraries = dlls? I would need to compile those first, though. I have no idea how to set up the jk2mv solution in VS2013 to also build the shared libraries and how to go about that. If it's not too much hassle, input will be appreciated.

Here's what I'm trying to do: I want to use JK2MV to create ingame demos of SP maps. Nothing fancy, I basically just want this so that I can then use JoMME to create a camera path through SP maps and render this for a short outro of a project I'm working on.
Kevin
Administrator
Posts: 393
Joined: 07 Jun 2015, 08:36

Re: Conversion of SP maps to MP-playable, serverside

Post by Kevin »

fau wrote:Yes it's a game module not included in jk2mv I described earlier. I'm not really sure if there is any clean 1.04 source code with modern build scripts.
Not yet, but Daggolin is working hard on finishing it :D
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

Not really ;-)
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

I tried to run JK2MV with vm_game 0 and the other parameters, but it doesn't seem to have any effect. I tried putting the JoMME shared libraries (the ddls from the mme folder) into the base folder of JK2MV, but I can't tell if it does any difference. Then I changed the g_target and g_spawn codes in JoMME and tried to recompile ... to realize that Visual Studio does not recognize any change in the code and after forcing a recompile, the dll file stayed exactly the same (I use a file sync tool to synchronize the build folder with my jomme folder). What am I missing?
User avatar
ouned
Administrator
Posts: 596
Joined: 23 Feb 2015, 13:03
Location: Gliese581c

Re: Conversion of SP maps to MP-playable, serverside

Post by ouned »

make sure you got the right dll name and you can see whether its actually using the dll with /vminfo
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

Aight, see screenshots. That's what I get for vminfo and those are the names of the DLLs.

I now realize that I compiled JK2MV in 64 bit mode. May that be the problem? The dlls are obviously x86. Also, do the dlls need the x86 in the name or shall I discard it?

Am I correct to assume that the game will ignore the vm_game parameter if no dlls are found? If so, what are the correct dll names?
Attachments
Screenshot 2016-10-10 20.55.04.png
Screenshot 2016-10-10 20.55.04.png (226.98 KiB) Viewed 115293 times
shot0000.jpg
shot0000.jpg (786.08 KiB) Viewed 115293 times
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

Yes, dlls need to be binary compatible with JK2MV - 64 bit. This is why qvms are so nice for mod distribution, no compatibility issues. They should compile just fine in 64bit mode. vm_game will fallback to 2 if it can't load dlls.

PS This bespin looks really fresh, can't wait until it's ready :-)
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

I see. Well, I did try this: I compiled JK2MV in x86 mode, but still no change. Is x64 a requirement? Also, how do I name the dll files for them to get recognized?

PS Thanks. Can't promise it will be done anytime soon, tho. I tend to get carried away into all kinds of ideas all the time.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

No, x86 jk2mv should work with x86 .dlls You could just download 32 bit jk2mv I believe. I checked for you and .dll names on windows need to look like this: "game_x86.dll" and "game_x64.dll" If you had read jk2mv log carefully you'd have figured it out.
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

Good point, but for that I would have needed to know to look in the jk2mv log. Now I know.

I managed to do what I wanted, btw. I used TriFoce's game code and snatched the compilers from the SDK as you recommended.

Thanks a lot. :)
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »



Here's what I had in mind!

Btw, fau, if you have keen eyes, you will notice the high quality texture 'pop in' on the pillar towards the end. Can that be fixed with JoMME? Some Mipmapping stuff or so?
User avatar
Boothand
Administrator
Posts: 986
Joined: 24 Feb 2015, 08:21
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by Boothand »

Almost looks like it's under water. Cool.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Conversion of SP maps to MP-playable, serverside

Post by fau »

This isn't high quality texture but high polygon curvature I believe. Try r_subdivisions 4 (for curvatures) and r_lodbias -2 for brush models. This may be also caused by some assumptions about fov in the renderer (I recall there were such) or patch stitching bug I fixed in jk2mv a while ago. If these cvars don't work, can you check if the same happens in jk2mv?

PS There is a simple avi rendering code for jk2mv that I wrote a while ago but haven't merged yet because it's not tested enough. It will render to uncompressed or motionJPEG avi with wav sound. Not trying to compete with jomme but wanted to make simple demo recording easier. If you want to use/test it, it's here: https://github.com/aufau/jk2mv/tree/avi
Tom Arrow
Posts: 92
Joined: 21 Sep 2016, 03:05

Re: Conversion of SP maps to MP-playable, serverside

Post by Tom Arrow »

I'll check later, but it may be "inaccurate", because I don't have exactly the same camera perspective in JK2MV. Thanks for the cvar tips, I'll check those out too.

You know what would be REALLY awesome? To be able to record demos in SP and play them in Jomme. I always wondered why it wasn't possible to record SP demos...
Post Reply
Created by Matti from StylesFactory.pl and Warlords of Draenor (modified by jk2.info)
Powered by phpBB® Forum Software © phpBB Limited
 

 

cron