Jump to content
The Dark Mod Forums

Searching existing maps


Recommended Posts

The second tracker issue I want to ask about:

0002867: "Search in files" functionality

Sometimes I want to know whether a certain entity/model/texture is already used in any of the released fms. It would be nice if DR could search map files in a certain folder (preferrably in pk4s) for them.

 

This seems an ideal job for a python script in DR. The python interface already comes with methods to let a script explore a darkmod installation, including inside pk4s.

 

I imagine this one popping up a filter menu where you can choose texture / entity / model (anything else?). The specific texture or entity type to search for could default to whatever the mapper has selected.

 

Perhaps it should let users add additional filters if they want: e.g. entity selection could have an "advanced options" button that'd let you match spawnargs too. This could sometimes answer the question "which existing maps would such-and-such a change break?". Only sometimes of course. There are plenty of things you can't work out from just parsing the map file.

 

One example where it would work: On the other tracker issue I just posted (a target entity to change objective amounts) it's tempting to wonder whether the "Amount" setting on objective components could be extended to work for items too (currently it doesn't. The objective will complete the first time you get an entity of the right spec without counting how many you've got). In the game code, there's a comment that indicates whoever wrote the code was considering adding that functionality later. The problem with adding it now would be that there could be maps out there that would break. A mapper could have tried setting up "Get 3 apple cores" using amount "3", found it didn't work, and made a workaround but leaving that amount=3 setting in place. That's a situation that could be tested by searching map and def and possibly script files.

 

Questions:

  • Does this tool already exist in some form? I'm sure I've seen people say things like "this model is only used in 4 existing maps"
  • Anything else useful that it could do?

Link to comment
Share on other sites

This is a good idea.

 

I've been handling this with this setup:

 

I have a folder where I keep copies of every *.map that's been released.

 

I use Windows Grep to look through the map files for whatever.

 

I don't use the darkmod/fms/<mission>/<mission>.pk4 files because my darkmod folder is too fluid, and there's no guarantee that all released maps are present there at any given moment.

 

(This was the reason I griped about mission *.map filenames not matching or representing their mission names. For example, if I find what I'm looking for in "mc.map" it's not obvious what mission that's from.)

 

I do the same thing with *.script files, to see if someone's used a particular function in the past.

 

This is an essential process to help with the goal of not breaking existing missions with new code.

Link to comment
Share on other sites

Cool. So it needs to let you specify a search folder. Fortunately that selection can be saved between script calls and DR sessions. Re using grep, Python will make it easy to support regular expression searches.

 

Yeah, I see the problem with unhelpfully named maps. Probably best to use this with a folder of pk4s, although it would work with both. I might make a separate python script that can purge a folder of pk4s of all binary files and then recompress the zips, for test purposes and for anyone else who wants to use it. That would only be a loop and a couple of calls to library functions.

Link to comment
Share on other sites

I've started researching this one. An immediate problem came up: it turns out the DR python interface is set up to let you explore your main darkmod installation, not mission pk4s. Basically you get access to the same set of files that DR uses to populate the entity and media browsers and so forth. It'll tell you the names of any other pk4s it discovers, but you don't get to search them.

 

Not only that, but the python implementation doesn't include the modules you'd normally use in python for searching file paths or reading zips. I know absolutely nothing about implementing python in another app, so I don't know whether there's an easy option of supporting the zipfile module in a later release.

 

There *is* a workaround possible. Python has an internal read-only zip handler that it uses to load python modules stored in archives, in exactly the same way that TDM loads its resources from pk4s. That can be got at by a script, and I've successfully tested misusing it to extract the map, script, and def files from the training mission. It's not a supported use of the package (and you have to read internal private data from the module to get the list of contents in the pk4), but the worst that could happen is that the script stops working one day in the future if the python implementation changes. Not a deal-breaker in my opinion.

 

The script would still have to rely on DR's virtual file system to get the list of pk4s. That means that anyone wanting to maintain a separate archive of released FMs will have to store it somewhere in their mod base or engine path folders. Restricting the search *within* those paths is fine, and the script will be able to remember the setting.

 

Still worth doing?

Link to comment
Share on other sites

Yeah I agree that takes the shine off it. I'll take a step back and go do the research on how difficult it would be to support the extra file-handling modules in the embedded python interpreter. I don't think it's out of the question because some file operations are already supported, so it's not like scripts are isolated from the file system. It seems better to implement this through the python interface than through the DR file handling code, given that that's set up to do a different and quite specific job.

Link to comment
Share on other sites

Pls make sure that whatever you're doing matches what other folks would use. I'm sure mappers will take whatever help they can get as long as it doesn't mess with their work procedure. New mappers who haven't quite settled into a routine would be particularly grateful, IMHO.

 

You don't need to accommodate my situation, because what I'm doing now works quite well for me, and I'm not looking to have DR take over the job.

Link to comment
Share on other sites

Fair point. I'm conflating two different tools, because when I saw this issue I thought it was an ideal chance to kill 2 birds with one stone. I'd been wanting to make a map-breaker searcher of some kind anyway. But there's no need to shoehorn that one into DR now it turns out that it's an awkward fit. A simple tool for people to use find usage examples would be very useful in its own right. It could have saved me hours myself, like when I couldn't figure out how to use a func_portal, for example.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Finally got round to publishing a tutorial on baking normal maps in Blender, since most of the ones we have are inaccessible or years out of date.
      · 0 replies
    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
×
×
  • Create New...