Jump to content

Weather Replacer


winz

Recommended Posts

This is a simple as running a .bat file or a one-line command before the mission start.

 

http://forums.eagle.ru/showpost.php?p=1810753&postcount=14

 

Not possible for my wing. Missions are loaded on-demand, with no access to shell... we need to do our own lua hook on S_EVENT_MISSION_START event callback, so, you know what ?

 

Let's Winz do the implementation once :smilewink:


Edited by galevsky06
Link to comment
Share on other sites

Just an insight why it's taking so long. There are two main problems in mp support.

1)MP doesn't use temporary file, but instead uses the mission files directly. So injecting weather = permanently modifying the mission file. Which is someting I consider unacceptable behavior, so I need to implement a way of backuping/restoring files.

 

2)When DCS calls a 'mission loaded' lua event, it has already the mission file locked. So I'm unable to modify the mission loaded. So the weather has to be replaced before you pick the mission. The only real solution I found to this is to modify the weather of the mission that was played last.

 

How it will work in mp, (only required for server ofc):

During configuration you'll select missions that you intend to play in MP. When the server is started, then the app will back-up them and replace weather in all of them (so you get random weather, no matter what mission you pick).

After each mission load the app will replace weather for the mission you played last (so you get random weather if you choose to play the mission in the future).

During server shutdown the app will restore all backed mission files.

 

I'm opened to suggestions if you have ideas on other ways how to work around the mp constrains.

Link to comment
Share on other sites

Not possible for my wing. Missions are loaded on-demand, with no access to shell... we need to do our own lua hook on S_EVENT_MISSION_START event callback, so, you know what ?

 

Let's Winz do the implementation once :smilewink:

 

Why would you want a shell ? All you need is some kind of access to the hard drive =)

 

Troposphere could be run from *any* machine, provided you have a way to send the results to the server.

 

I'm assuming at least one person has write access to the server ? Here I'm using a SFTP mount to directly write in the mission folder of the server, but a temp dir on some guy's machine would do just as fine, all you'd need to do is mod/upload the files as often as needed.

 

I'm opened to suggestions if you have ideas on other ways how to work around the mp constrains.

 

It could be as simple as hooking the net.load_mission function, same way Slmod does for the "-admin load" chat command. From what I understand by reading this

slmod.scheduleFunctionByRt(net.load_mission, {path .. self.filename}, net.get_real_time() + 5)

, one just has to call "net.load_mission(full_path_to.miz)" in order to switch the current mission on the server.

 

Concerning the backup concern, would it be very hard for you to implement a two step mechanism, by first copying the miz to some MODDED.miz file, then modifying this one, and finally loading it with net.load_mission ?

 

Which, translated in rough lua, would give:

 

function replaceWeather(missionPath)
   -- binary copy of the input file to an arbitrary location
   local out_path = "MODDED_" .. missionPath
   local in_file = io.open(missionPath, "rb")
   local out_file = io.open(out_path, "wb")
   local data = in_file:read("*all")
   out_file:write(data)    
   out_file:close()

   -- Troposphere stuff
   local lpath = "__local_path_to__\\Troposphere\\Troposphere.exe"
   local executionPath = base.string.format('"%s" "%s"', lpath, out_path)
   base.os.execute(executionPath)

   -- server load
   net.load_mission(out_file)
end

 

I'm no Lua guru, so this may be off, but you get the idea =) Also, you could choose to have only one "MODDED_*.miz", "Tropo_temp.miz" for example, which would be overwritten every time Troposphere runs. It would prevent useless cluttering of the users' mission folder. That temp file could also be stored somewhere else on the drive, in Tropo's main dir for example.

 

Something totally different now ! I think it would be nice to be able to choose the output file, with

troposhpere.exe input.miz output.miz

, for example.

 

And then, but I know I'm pushing my luck, I'd love to be able to select the weather database at runtime, by moving the "weather_groups.cfg" into the "weather_definitions" folder, and be able to do something like

troposphere [-i[n] input.miz [-o[ut] output.miz [-c[onf] weather_def_folder

 

With this, we would be able to generate a bonanza of missions to choose from in a single huge batch sweep, making different kind of weather for the same mission, and making them all available at the same time. Currently I'm doing it with a script that moves the weather_def and the config in between the runs, but I thought it would make a nice suggestion, so here it is =)

 

Bunch of kudos once again for your work, and many thanks for giving it away, much appreciated :beer:

Link to comment
Share on other sites

I don't think I follow. net.load_mission is a functionality provided by DCS and allows a script to load a specific mission. I need the opposite functionality, and event that gets called when server loads the mission. I have found that event, but it's triggered after the mission file is locked. If by hook you mean inserting my custom code into the net.load_mission, then yeah, that would be great, but I haven't found the method definition yet, so I doubt it's in the lua files. :) If I got it wrong then correct me :)

 

But...Hmmm...now you got me thinking....how would dcs world react if I would call net.load_mission inside the 'mission loading event'? Well, if it's robust enough to survive this loadception, then that might be an effective solution, thanks :)

 

Edit: It looks like net.load_mission is not available during mission load.

 

 

Something totally different now ! I think it would be nice to be able to choose the output file, with

troposhpere.exe input.miz output.miz

, for example.

 

And then, but I know I'm pushing my luck, I'd love to be able to select the weather database at runtime, by moving the "weather_groups.cfg" into the "weather_definitions" folder, and be able to do something like

troposphere [-i[n] input.miz [-o[ut] output.miz [-c[onf] weather_def_folder

It's certainly possible. Having more functionality accesible from command line is certainly something I would like to have.

 

Bunch of kudos once again for your work, and many thanks for giving it away, much appreciated :beer:

No problem, I finally have the opportunity to give somethig to the community :) :beer:


Edited by winz
Link to comment
Share on other sites

I don't think I follow. net.load_mission is a functionality provided by DCS and allows a script to load a specific mission. I need the opposite functionality, and event that gets called when server loads the mission.

 

Actually, what I was thinking about was to use the same mechanism as Slmod. Almost all dedicated servers are running Slmod anyway, so you could go with the "chat command hook" thingy.

 

For the people hosting the regular way, would a GUI hook do ?

 

In "/Scripts/net/uiSelectMission.lua", I found this:

function onFileSelect(lst, item, dblClick)
if not item then
	window["8"]:setText('')
	return
else
	window.selected = nil
	local f = item:getText()
	local fname
	if f == '..' then
		local s,e
		s, e, fname = string.find(window.path, '(.*[/\\])([^/\\]+)[/\\]*')
		--base.print("up from "..window.path.." to "..fname)
	else
		fname = lfs.normpath(window.path .. '/' .. f)
	end
	if item.isdir then
		window["8"]:setText('')
		if dblClick then
			update(window, fname)
		end
	else
		if dblClick then
			--window["8"]:setText('run '..fname)
			net.start_server(fname)
			window:setVisible(false)
		else
			window.selected = fname
			local descr = net.get_mission_info(fname)
			--base.print("description: "..base.tostring(descr))
			window["8"]:setText(descr or '')
		end
	end
end
end

 

The "if dblClick" calls "net.start_server(fname)" with "fname" being the selected mission in the file list right hand of the Gui.

 

As for the "START" button, I *think* it is in this function:

function create()
   window = net.center(loader.spawnDialogFromFile('Scripts/net/ui/load-mission.dlg', cdata))
   window:setTop(true)
   
window["6"].onChange = onPathSelect
window["7"].onChange = onFileSelect

window["10"].onChange = function()
	if window.selected then
		net.start_server(window.selected)
		window:setVisible(false)
	end
end
window["9"].onChange = function()
	window:setVisible(false)
end

-- fill paths
local i,v
local lst = window["6"]
for i,v in base.ipairs(lfs.locations()) do
	local item = ListBoxItem.new(_(v.name))
	item.lfs_path = v.path
	lst:insertItem(item, lst:getItemCount())
end

-- fill files
local path = base.config.server.mission_dir
if path then
	lst:setText(path)
	update(window, path)
end
end

 

, this part to be precise:

 

	window["10"].onChange = function()
	if window.selected then
		net.start_server(window.selected)
		window:setVisible(false)
	end
end

 

( the window["10"] is related to the "/scripts/nets/ui/load-mission.dlg" file)

 

I'm running out of time this morning to confirm, unfortunately, so I can but hope that this info is relevant and will be useful to you.

Link to comment
Share on other sites

Yeah, the chat command hook is pretty straightforward and is something that could be available for people using slmod, but I don't want to rely on another addon too much.

It can be done with current version of troposphere, just add troposhere call before the net.load_mission. Any volunteer familiar with lua adn slmod wanna try that out? :D

 

I experimented with the GUI select mission hook a while back, and the problem with it is that you don't catch missions that are loaded by a mission trigger, or some other script using net.load_mission. :)

 

Thanks for the help, I'm 100% SP guy, so slmods, server setups are all new things to me :) What would be great, if people could describe how their servers are set-up, so I get a more clear idea about the restrictions.

Link to comment
Share on other sites

  • 3 months later...

I can empathise.

 

From reading the thread though, do I understand correctly the weather "injection" works on multiplayer mission files using the current binary, but that finding an appropriate trigger inside DCS at load time is a problem, and that such an injection alters the main file, which is considered undesireable?

 

If so, I think it might be possible for me to write a quick Python script, scheduled to run hourly (or more often), which would copy a "master copy" of a mission file into the Multiplayer directory and run your weather injection binary on the new copy, whenever the file access time exceeded the file creation time for the copy in the multiplayer directory - that is, if the file had been loaded into the server.

 

It's a "band-aid" solution, but it might work on our server as an interim solution.

Link to comment
Share on other sites

Hi Winz

Your app sounds like great addition. Just before I install it, a couple of questions. Can you effectively remove the modifying effect at a later date by calling up the app and ticking the "no" box? In this case will the original weather for the missions be in place, or will there be no weather at all? Secondly is the app effective after updates.Thanks in anticipation.

Link to comment
Share on other sites

Yes, ticking 'no' will allow you to play the mission in original weather.

DCS always makes a copy from the launched mission. It's this copy that is used by the sim, and it's this copy that is modified the app. So the original file remains untouched.:)

 

After each patch you need to re-inject it into dcs, but yours setting will be preserved.

Link to comment
Share on other sites

  • 2 weeks later...

Just downloaded Troposphere and was looking forward to try it out. Unfortunately got warning message that I needed ".net framework 4.0".

Being not familiar with it, could anyone tell me where I could find that to download and install? Is it a simple install or is it rather complicated and can disrupt computer?

Appreciate any help with this....

ASUS Sabertooth X79 TUF Motherboard / Intel Core i7-3930K Unlocked Processor Six Core / Corsair CMP32GX3M4X1600C10 Dominator Memory Kit - 32GB (4x 8GB) / OCZ Solid 3 480GB Solid State Drive / EVGA GeForce GTX 670 FTW+ / Corsair CW-9060002-WW Hydro H70 CORE CPU Cooler / Seagate ST1000DM003 1TB Hard Drive / BenQ XL2420TX 24" Widescreen LED Gaming Monitor - 1920 x 1080 / Windows 7 Ultimate Edition, 64-bit / C-Tek 12-bit: Foot Pedals - Robinson Cyclic - 5-button-hat cyclic - Collective / TrackIR-5

Link to comment
Share on other sites

Go here.

All the info you need is there or linked from there.

In case you need it the 4.5 update is on the same page


Edited by Bolt-1

My Specs. below



 

ASUS TUF Z390 Pro Gaming

I5 9600K@4.5 Ghz.







32 Gb. G. Skill Rip Jaw V DDR4 @ 3200

MSI Gaming 1070 TI

Samsung 970 EVO+ NVME Pcie 500GB

Samsung 850 EVO 500GB SSD

OCZ 120GB vertex 2 SSD

Win10 64 Pro

TM Warthog

TM Cougar

Samsuny Odyssey +

CH Pro Pedals

ASUS 32" 2560X1440 Main

Samsung 23" LED/LCD 1920X1080

Corsair TX 850W

Corsair H100i GTX

HAF 932

 





 



 

Link to comment
Share on other sites

Hi winz, I just downloaded your app 1 week ago. I tested it a couple of times and everythink was ok.I left the sim until today. When I turned on my computer, I realized that there was an update for net framework 4.5.1 and DCS 126.20768. I applied both of them.

After this actions something get wrong with the app and no change in weather any more.

 

 

I tried to call the app and get a error message saying: Error executing application. See log.

Message: Acceso denegado a la ruta de acceso 'Vergeevs_group_002_eng.miz'.

Trace: en System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)

en System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)

en WeatherReplacer.Config.ReplacerConfiguration.InitDirs()

en WeatherReplacer.Config.ReplacerConfiguration..ctor()

en WeatherReplacer.Config.ReplacerConfiguration.get_Instance()

en WeatherReplacer.MainForm.LoadConfiguration()

en WeatherReplacer.MainForm..ctor()

en WeatherReplacer.Program.Main(String[] args)

 

 

Trying to look for the problem, I found the recent update 20768 modified me_mission.lua, maybe this would be the reason? maybe the new framework version? maybe I should did some action before the DCS update?

It's weird the message Acces denied 'Vergeevs_group_002_eng.miz' because I had the vergeevs campaing working well the first time I installed your app and everything was fine.

I unnistalled your app following your instructions and everytime I try to run troposphere get the same message as above. I deleted every file found in my computer, in reg, etc... related to troposphere but nothing changed.

 

It's a pity because I like very much your mod. Thanks in advanced for your effort. It's amazing the job all of you do with the community.

Win 7 64bits Sp1; Panda Dome; i7 2600k 3,4gh OC 4,5; 16gb 4x1333 DDR3; Gigabyte GTX1080ti stock clocks; ASUS P8Z68V; OS and DCS on SDD 240gb 2,5"; 500gb HDD; cooler master silent pro 1000w; Track IR 5; Saitek X52; Saitek pro Combat rudder; 2560 x 1440

Link to comment
Share on other sites

Sorry, i forgot to show my spec.

 

Win 7/cpu i7-2600k 3,4/ram 16gb/graphics gtx680

Win 7 64bits Sp1; Panda Dome; i7 2600k 3,4gh OC 4,5; 16gb 4x1333 DDR3; Gigabyte GTX1080ti stock clocks; ASUS P8Z68V; OS and DCS on SDD 240gb 2,5"; 500gb HDD; cooler master silent pro 1000w; Track IR 5; Saitek X52; Saitek pro Combat rudder; 2560 x 1440

Link to comment
Share on other sites

Troposhpere changes me_mission lua, and that change is rollback by the DCS autoupdate, so it has to be re-injected after each update. But the problem lies elsewhere I think.

 

The Vergeevs group missions are marked as read-only. To fix it you need to manually delete the Troposhpere temp folder

1)Go to the temp folder - Start and type %TEMP% in the search field, enter

2)That should open the main temp folder. Delete the DCS_WEATHER folder, present there.

 

To prevent this happening in the future you need to umark the Vergeevs group 'read only' attrubutes.

Hope it helps, and thans for the kind words :)

Link to comment
Share on other sites

Wooow!!! that was a direct hit...:lol: Thank you so much for your quick reply, now I have a random weather again!!

 

Winz, just a question... It happens only once but, in your instructions pdf I read if you check "Filter by Season", the option "Replace Season" remains with no function. Despite of this I had a season replaced in one of the Medvedev missions. After that I unchecked "Replace Season" just in case and the season haven't been changed any more in that misión (3 of 3).

 

PD: "Speed is life, altitude is life insurance" This is a common phrase, a pilot way of think in real life, if you want to retire doing this job. Are you a pilot working in real life?:pilotfly:

Win 7 64bits Sp1; Panda Dome; i7 2600k 3,4gh OC 4,5; 16gb 4x1333 DDR3; Gigabyte GTX1080ti stock clocks; ASUS P8Z68V; OS and DCS on SDD 240gb 2,5"; 500gb HDD; cooler master silent pro 1000w; Track IR 5; Saitek X52; Saitek pro Combat rudder; 2560 x 1440

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...