VStanced/mods
Submit a mod
Mods Guides Forum Submit a mod Log in Register

Forum

Questions, builds, help and the odd argument. The mods and guides are out front.

How to make a deep ...
 
Notifications
Clear all

How to make a deep copy of a class(java)

16 Posts
4 Users
0 Reactions
9,836 Views
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter   [#951]

so i have this function in engine block java
Spoiler:

	
public void updatevariables()
{
	super.updatevariables();

if (the_car)
{
float vol=DynoData.maxTorque/500;
SfxTable tab;
if (tab = the_car.getSfxTable(0))//on
{
tab.clear();
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C2r), 1500,   500.0, 2500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C6r), 2000,   1500.0, 5000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C4r), 4500,   4000.0, 6000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C5r), 5500,   5000.0, 7000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C1r), 6500,   6000.0, RPM_limit+600, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C3r), 6500,   RPM_limit-600, 18000.0, 1.0, 1.0);
}

if (tab = the_car.getSfxTable(1))//off
{
tab.clear();
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BAr),  600,   500.0, 1250.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BCr), 1750,   750.0, 3000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C0r), 2500,   2000.0, 5000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BEr), 4500,   4000.0, 6500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BFr), 6000,   5500.0, 8500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BBr), 8000,   7500.0, 18000.0, 1.0, 1.0);
}

if (tab = the_car.getSfxTable(2))
{
tab.clear();
the_car.setSfxExhaustMinVol(0.9);
}
}
}

and i want to make a copy of SfxTable tab. I tried to do something with SfxTable.java but it didn't work. I don't know how to do it without Native.java file.



   
Quote
Bigg_Boss93
(@bigg_boss93_1370)
Member Admin
Joined: 15 years ago
Posts: 3835
 

you dont need the native.java, it is just an empty file with a lot of hungarian text that says that the game uses C sources for macros



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

do you have full source of the game?



   
ReplyQuote
Unseen
(@unseen_389)
Honorable Member
Joined: 16 years ago
Posts: 608
 

I think original java files for vanilla SLRR is still available on GOM, if I recall correctly.

We have MWM source code in the D/L section, tho. You can also try to study those.



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

i know, i have those. but it's not all source.



   
ReplyQuote
RedCarDriver
(@redcardriver_1155)
Member Moderator
Joined: 15 years ago
Posts: 1125
 

What I said about this on GOM, posted here for reference:

Doesn't "SfxTable tab2 = tab;" work? I would think it would, unless you're talking about something entirely different.

Also, there's no "Native.java" (or actually, it's blank). Anything referring to "native" means that the code for that is inside the C++ code of the game engine. The game engine is built in C++, and all of the GUIs and most of the parts are built in a Java layer on top of that.



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

"SfxTable tab2 = tab;" doesn't work. Even if you write tab = the_car.getSfxTable(0); and tab2 = the_car.getSfxTable(0); it will link everything into one sfx table.



   
ReplyQuote
Bigg_Boss93
(@bigg_boss93_1370)
Member Admin
Joined: 15 years ago
Posts: 3835
 

# mindeliszz :
do you have full source of the game?

Yes but i'm not authorized to share it.

Also i dont have exe source.



   
ReplyQuote
RedCarDriver
(@redcardriver_1155)
Member Moderator
Joined: 15 years ago
Posts: 1125
 

How about this?

SfxTable tab2 = new SfxTable;
tab2 = tab;

Sorry if I'm stating the obvious here.



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

nope, it doesn't work that way. also should be commas at the end of new sfx table, like this "SfxTable tab2 = new SfxTable();" i already tried everything. Even tried to crate another class that contained SfxTable inside and can be copied.

it's possible with the java file were .getSfxTable() function is. Maybe it's SfxRef.java, i don't know. It has to have a copy constructor, so you could use "SfxTable tab2 = new SfxTable(tab);"



   
ReplyQuote
Bigg_Boss93
(@bigg_boss93_1370)
Member Admin
Joined: 15 years ago
Posts: 3835
 

i havent understood what you're trying to do honestly



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

i want to play more than 2 sounds at once at same rpm 😃



   
ReplyQuote
Bigg_Boss93
(@bigg_boss93_1370)
Member Admin
Joined: 15 years ago
Posts: 3835
 

.__. you could say it before πŸ˜† i'll send you the script i use as soon as i get back home



   
ReplyQuote
mindeliszz
(@mindeliszz_704)
Honorable Member
Joined: 16 years ago
Posts: 536
Topic starter  

wanted to do it on my own 😃



   
ReplyQuote
Bigg_Boss93
(@bigg_boss93_1370)
Member Admin
Joined: 15 years ago
Posts: 3835
 

# mindeliszz :
public void updatevariables()
{
super.updatevariables();

if (the_car)
{
float vol=DynoData.maxTorque/500;
SfxTable tab;
if (tab = the_car.getSfxTable(0))//on
{
tab.clear();
//INTAKE SOUNDS
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C2r), 1500,   500.0, 2500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C6r), 2000,   1500.0, 5000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C4r), 4500,   4000.0, 6000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C5r), 5500,   5000.0, 7000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C1r), 6500,   6000.0, RPM_limit+600, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C3r), 6500,   RPM_limit-600, 18000.0, 1.0, 1.0);
}

if (tab = the_car.getSfxTable(1))//off
{
tab.clear();
//OTHER SOUNDS HERE(blowoff, exhaust popping etc)
}

if (tab = the_car.getSfxTable(2))
{
tab.clear();
//EXHAUST SOUNDS
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BAr),  600,   500.0, 1250.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BCr), 1750,   750.0, 3000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000C0r), 2500,   2000.0, 5000.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BEr), 4500,   4000.0, 6500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BFr), 6000,   5500.0, 8500.0, 1.0, 1.0);
tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BBr), 8000,   7500.0, 18000.0, 1.0, 1.0);
the_car.setSfxExhaustMinVol(0.9);
}
}

}

tab.addItem(new ResourceRef(Shift2_Sounds:0x000000BAr), 600, 500.0, 1250.0, 1.0, 1.0);

^ this means

tab.addItem(new ResourceRef(FileFolder:FileIDr), Pitch, Min RPM, Max RPM, Min Vol, Max Vol);

So just set intake and exhaust with same rpm bands and it will work fine(i always do it this way).

Also i commonly add other sounds(blowoff, exhaust popping etc) in the first tab because the center one often wont work(dont ask me why because i have no clue).



   
ReplyQuote
Page 1 / 2
Share: