Programmer wanted...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buzzkill
    Prophet
    • May 2008
    • 2939

    Programmer wanted...

    I'm looking for someone, anyone, to write a little piece of code for me. It doesn't have to be pretty, just effective. What I want is a program that will that will take the guts of a typical angband-type edit file and output, in a new text file, a 'skeleton' graf-dvg.prf.

    It shouldn't take any more work than reading each set of lines, breaking it down into it's parts, and spitting it back out again in a different format. I'll strip out the header and other irrelevant parts of the file in advance...

    So, something like this...

    Code:
    # 0x00 --> nothing
    
    N:0:nothing
    G: :w
    
    # 0x01 --> open floor
    
    N:1:open floor
    G:.:w
    
    # 0x02 --> invisible trap (drawn as open floor)
    
    N:2:invisible trap
    G:.:w
    M:1

    would be turned into something like this..

    Code:
    # nothing
    F:0:0x80:0x80
    
    # open floor
    F:1:0x80:0x81
    
    # invisible trap
    F:2:0x80:0x81
    Obviously, it would have to insert 'dummy' hex values.

    It needs to work in windows. I'm working with Dev-C++ (so if plays nice all the better). It would be nice if it was able to handle the terrain, objects and monster files, all of which are a little different. Given the source for any one of the above, I could probably, with some effort, modify it to work with the others. It would be a learning experience. The file input and output is what I have no idea how to do.

    As should be obvious by now, I plan to use this to create .prf files for variants that don't currently have 'working' graphics. The bulk of the work is creating a matching .prf so having such a program would save hours. Manually adding the hex values is easy.

    If I don't get any takers, I'll probably go ahead and try to do it in visual basic (but I'd rather learn C++).
    www.mediafire.com/buzzkill - Get your 32x32 tiles here. UT32 now compatible Ironband and Quickband 9/6/2012.
    My banding life on Buzzkill's ladder.
  • Pete Mack
    Prophet
    • Apr 2007
    • 6883

    #2
    You probably want to use VB or some other scripting language (perl) for this. There's no benefit to doing basic string manipulation in C.

    Comment

    • PowerDiver
      Prophet
      • Mar 2008
      • 2820

      #3
      I'd be happy to write you a perl script, but I don't do windows, so you should try to get another volunteer. It looks pretty trivial.

      Comment

      • zaimoni
        Knight
        • Apr 2007
        • 590

        #4
        Originally posted by buzzkill
        If I don't get any takers, I'll probably go ahead and try to do it in visual basic (but I'd rather learn C++).
        Of the languages I am personally competent enough in to immediately implement (C, C++, Perl, Python):
        1) Perl or Python (for this particular task they're about equivalent, as this doesn't look like something that needs regular expression-like processing. Perl would win if regular expressions were important. Python would win if processing files hundreds of megabytes in size was important.) Any reasonably modern scripting language that garbage-collects for you and allows you to loop over the read-in lines directly, should have the required functions to be in this class.

        It is very unlikely that you need Genuine C Performance. For text-processing like this, Python will give you Genuine C Performance if you don't do something stupid like copying strings instead of using those handy reference slices.

        2) C++ : assuming you actually use Resource Acquisition Is Initialization, the C++ Looking-glass land mirror of garbage collection . While the standard library does provide std::string, you might be better served by std::vector<char> and the C library functions.

        Just because C++ is my dominant programming language, doesn't mean I use it for everything.

        For this application, if you use malloc/calloc/realloc/free you're programming C with a C++ compiler. That's in the next category.

        3) C : C standard libary string functions are great at what they do, but being damned to malloc/calloc/realloc/free just isn't worth it.

        The problem is that C and C++ are both targeting "next to the machine" programming, and this application doesn't need "next to the machine" programming.

        So...
        * Choose a familiar language, or
        * Choose a portable language in 1) [Perl, Python, Lua are obvious; you probably could get away with PHP.], or
        * Choose a language you want to learn no matter what.
        Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
        Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
        Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

        Comment

        • zaimoni
          Knight
          • Apr 2007
          • 590

          #5
          Originally posted by PowerDiver
          I'd be happy to write you a perl script, but I don't do windows, so you should try to get another volunteer. It looks pretty trivial.
          But windows has Perl.

          ActivePerl, Strawberry Perl, ....

          Building Perl from source is more difficult than it should be on Windows, but possible. [I can think of exactly two projects that use DMake. Perl and OpenOffice.org. ]
          Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
          Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
          Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

          Comment

          • PowerDiver
            Prophet
            • Mar 2008
            • 2820

            #6
            Originally posted by zaimoni
            But windows has Perl.

            ActivePerl, Strawberry Perl, ....

            Building Perl from source is more difficult than it should be on Windows, but possible. [I can think of exactly two projects that use DMake. Perl and OpenOffice.org. ]
            I wouldn't even know what extension to use. .prl or .per or .perl ?

            My first line, #!/usr/bin/perl , would most likely be wrong. Or would it not matter?

            Things that claim to be portable usually aren't until you tweak them.

            Comment

            • konijn_
              Hellband maintainer
              • Jul 2007
              • 367

              #7
              hellband.net is your first and best source for all of the information you&#8217;re looking for. From general topics to more of what you would expect to find here, hellband.net has it all. We hope you find what you are searching for!
              * Are you ready for something else ? Hellband 0.8.8 is out! *

              Comment

              • zaimoni
                Knight
                • Apr 2007
                • 590

                #8
                Originally posted by PowerDiver
                I wouldn't even know what extension to use. .prl or .per or .perl ?
                .pl would be most traditional. The Windows-native ones don't use extension binding, so it's whatever works.

                Originally posted by PowerDiver
                My first line, #!/usr/bin/perl , would most likely be wrong. Or would it not matter?
                It doesn't matter when executing from the Windows command prompt.

                In bash, it does matter -- but you're already in trouble because Windows-native Perl uses /r/n newlines and the results won't play well with just about anything using /n newlines. And the MingW perl (which has /n newlines, thus isn't Windows-native) ships with a broken Cwd module, so lots of things break.
                Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
                Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
                Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

                Comment

                • buzzkill
                  Prophet
                  • May 2008
                  • 2939

                  #9
                  Originally posted by konijn_
                  It's alive! Thanks a lot. It works fine, churning through a whole file in a couple of minutes. After outlining my own project today, I came to the conclusion that it's a lot easier than I originally thought, and I didn't think it would be all that hard to begin with. I'm going to try to write one in C++, just as an exercise for myself. With any luck, mine will also compare item/monster/terrain names to the V pref file, and substitute V hex values for objects with identical names. Perfect? no. Better? hopefully.

                  PS. Hellband is the project I had in mind when I proposed this. Did you recognize the snippet, or just coincidence.

                  EDIT: Just one little bug. When MaxHex2 is reached it rolls over to 0, rather than StartHex2. Default vaules of 128, 128 and 255 wouldn't hurt anything either.
                  Last edited by buzzkill; October 3, 2009, 04:29.
                  www.mediafire.com/buzzkill - Get your 32x32 tiles here. UT32 now compatible Ironband and Quickband 9/6/2012.
                  My banding life on Buzzkill's ladder.

                  Comment

                  • konijn_
                    Hellband maintainer
                    • Jul 2007
                    • 367

                    #10
                    Originally posted by buzzkill
                    It's alive! Thanks a lot. It works fine, churning through a whole file in a couple of minutes. After outlining my own project today, I came to the conclusion that it's a lot easier than I originally thought, and I didn't think it would be all that hard to begin with. I'm going to try to write one in C++, just as an exercise for myself. With any luck, mine will also compare item/monster/terrain names to the V pref file, and substitute V hex values for objects with identical names. Perfect? no. Better? hopefully.

                    PS. Hellband is the project I had in mind when I proposed this. Did you recognize the snippet, or just coincidence.
                    Pure coincidence, go figure..

                    Originally posted by buzzkill
                    EDIT: Just one little bug. When MaxHex2 is reached it rolls over to 0, rather than StartHex2. Default vaules of 128, 128 and 255 wouldn't hurt anything either.
                    Well, its not a bug, its a feature I assumed hex1 is row , hex2 is column, so that if you reach the end of the row, you start the new row at column 0.

                    Since you are the only user so far, I modified it to start again with starthex2 and added your proposed defaults.

                    T.
                    * Are you ready for something else ? Hellband 0.8.8 is out! *

                    Comment

                    • buzzkill
                      Prophet
                      • May 2008
                      • 2939

                      #11
                      You the man!
                      www.mediafire.com/buzzkill - Get your 32x32 tiles here. UT32 now compatible Ironband and Quickband 9/6/2012.
                      My banding life on Buzzkill's ladder.

                      Comment

                      Working...
                      😀
                      😂
                      🥰
                      😘
                      🤢
                      😎
                      😞
                      😡
                      👍
                      👎