Announcement

Collapse
No announcement yet.

Trying to understand darkplaces source code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #46
    this thing in makefile

    ifeq ($(WIN32RELEASE), 1)
    ifeq ($(D3D), 1)

    but

    ifeq ($(DP_CDDA), enabled)
    ifeq ($(DP_VIDEO_CAPTURE), enabled)

    maybe worth changing all to 1

    change_in_original

    Comment


    • #47
      vid_glx.o: vid_glx.c
      $(CHECKLEVEL2)
      $(DO_CC) -I/usr/X11R6/include

      keysym2ucs.o: keysym2ucs.c
      $(CHECKLEVEL2)
      $(DO_CC) -I/usr/X11R6/include

      those are linux only I pressume

      deleted

      Comment


      • #48
        interesting how music in darkplaces is in
        id1/sound/CDTRACKS
        and named
        Track002.ogg
        Track003.ogg

        and in quakespasm it's in
        id1/music
        and named
        track02.ogg
        track03.ogg


        Actually, according to this piece of code in cd_shared.c/CDAudio_Play_byName, darkplaces supports both schemes.

        Code:
        	// Try playing a fake track (sound file) first
        	if(track >= 1)
        	{
        		                              dpsnprintf(filename, sizeof(filename), "sound/cdtracks/track%03u.wav", track);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/track%03u.ogg", track);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/track%03u.ogg", track);// added by motorsep
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/cdtracks/track%03u.ogg", track);// added by motorsep
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/track%02u.wav", track);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/track%02u.ogg", track);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/track%02u.ogg", track);// added by motorsep
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/cdtracks/track%02u.ogg", track);// added by motorsep
        	}
        	else
        	{
        		                              dpsnprintf(filename, sizeof(filename), "%s", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "%s.wav", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "%s.ogg", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/%s", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/%s.wav", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/%s.ogg", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/%s", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/%s.wav", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "sound/cdtracks/%s.ogg", trackname);
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/%s.ogg", trackname); // added by motorsep
        		if (!FS_FileExists(filename)) dpsnprintf(filename, sizeof(filename), "music/cdtracks/%s.ogg", trackname); // added by motorsep
        	}

        I deleted almost everything from the first half, but I don't know if anything from the second half is ever going to be used.

        Comment


        • #49
          qte seems to behave like that too, according to this code in engine/client/m_mp3.c/Media_NamedTrack

          Code:
          	static char *path[] =
          	{
          		"music/",
          		"sound/cdtracks/",
          		"",
          		NULL
          	};
          Don't understand why music doesn't play with "playdemo demo1" though.

          Searching for "track%0" is really helpful, thanks to that dick for reminding me about full text search.

          Also, there is a simular to darkplaces thing in qte, for playing music by string instead of by number, but it's surrounded with "#ifdef NOLEGACY". I guess it's safe to remove then. Wonder where it was used before.

          Code:
          #ifdef NOLEGACY
          	if (!tracknum)	//might as well require exact file
          	{
          		Q_snprintfz(trackname, sizeof(trackname), "%s", track);
          		found = COM_FCheckExists(trackname);
          	}
          	else
          #endif

          Comment


          • #50
            While I'm at it, in quakespasm it's in Quake/bgmusic.c/BGM_PlayCDtrack

            Code:
            		q_snprintf(tmp, sizeof(tmp), "%s/track%02d.%s",
            				MUSIC_DIRNAME, (int)track, handler->ext);
            It does it twice, first time for checking if this file exists, second to actually read it. A bit wasteful. Not really sure what's really going on in here.

            They are so different, even if they do pretty much the same thing, hehe.

            Comment


            • #51
              What are end1.bin and end2.bin?

              Is it safe to delete them?

              They are mentioned in world.qc

              Code:
              	precache_file ("end1.bin");
              	precache_file2 ("end2.bin");
              and in models.qc (maybe it's not related)

              Code:
              $modelname end1
              $cd id1/models/end1
              $flags 8		// client side rotate
              $base base
              $skin skin
              $frame frame1
              
              $modelname end2
              $cd id1/models/end2
              $flags 8		// client side rotate
              $base base
              $skin skin
              $frame frame1
              
              $modelname end3
              $cd id1/models/end3
              $flags 8		// client side rotate
              $base base
              $skin skin
              $frame frame1
              
              $modelname end4
              $cd id1/models/end4
              $flags 8		// client side rotate
              $base base
              $skin skin
              $frame frame1

              Comment


              • #52
                Open progs.src, files are in somewhat correct order here.
                Description are from here
                https://quakewiki.org/wiki/Quake_QuakeC_source

                Actually reading it is easier here, html crossreference:
                Modules of Quake-C

                defs.qc
                This Quake-C file contains the definitions for variables and functions that are used throughout the QC code.

                subs.qc
                This Quake-C file contains the code for the subroutines used in various entities.

                fight.qc
                for the general monster fight behavior.

                ai.qc
                contains the AI code which determines the general behavior of the monsters.

                combat.qc
                for general combat behavior.

                items.qc
                for the items.

                hook.qc

                weapons.qc
                for the player weapon behavior.

                world.qc
                for general world-related behavior such as default precaching.

                client.qc
                for general client-side game behavior.

                player.qc
                for basic player-related appearance and behavior.

                monsters.qc
                for the initial monster placement and death behavior.

                It includes a bug that causes Rotfish to be counted twice in the map statistics. This is due to the duplicate line total_monsters = total_monsters + 1; in the swimmonster_start_go function.

                doors.qc
                for doors and secret doors.

                buttons.qc
                for pressable buttons.

                triggers.qc
                for the triggers.

                plats.qc
                for moving platforms and elevators.

                misc.qc
                for miscellaneous entities.


                The rest are for monsters. You can see which monster is which here
                https://www.quaddicted.com/quake/monsters

                ogre.qc
                demon.qc
                shambler.qc
                knight.qc
                soldier.qc
                wizard.qc
                dog.qc
                zombie.qc
                boss.qc

                Monsters from registered version:

                tarbaby.qc
                hknight.qc
                fish.qc
                shalrath.qc
                enforcer.qc
                oldone.qc

                Comment


                • #53
                  end1.bin+end2.bin contain vga blobs that are copied into the text-mode video memory when you quit. end1.bin is a sellscreen for the demo, while end2.bin is basically the credits screen. I don't know of any non-dos engine that actually uses them.

                  the precache_file[2] builtin is redundant. you can safely strip all calls to it.
                  originally, it was the qcc that wrote out iD's .pak files, with file lists generated from the precache_[model|sound|file] calls.
                  for the engine itself, precache_file does nothing.
                  such mechanisms only really work if you're making a full total conversion (due to copyrights), so the community at large have never really used this.

                  models.qc and sprites.qc or whatever they're called were used by mdlgen and sprgen, which are annoying clumsy tools that only id used. as such, all their markup is redundant, and in the case of those two files they're EXCLUSIVELY markup. they're not even listed from the progs.src

                  jctest.qc and amtest.c can also go. progdefs.h is similarly useless.
                  Some Game Thing

                  Comment


                  • #54
                    not_important

                    tried to remove precache_sound and precache_model from world.qc too, it caused fire to be replaced with a soldier. Sounds are also replaced randomly.



                    Comment


                    • #55
                      Better way to see what key is pressed

                      vid_wgl.c
                      MainWndProc

                      between
                      vkey = MapKey(lParam, wParam);
                      and
                      GetKeyboardState (state);

                      add this
                      Code:
                                  int is_repeat = lParam & (1 << 26);
                                  int is_keyup  = lParam & (1 << 30);
                                  if (!is_repeat && !is_keyup) {
                                      Con_Printf("lParam: %08x vkey: %2x\n", lParam, vkey);
                                  }

                      Comment


                      • #56
                        just notes

                        in the standard human-readable form,
                        bit 0 = least significant bit = one which is most to the right = changes the numerical value of number the least


                        bit 0-15, is actually half of dword, and it's always (0x)0001 to me.

                        bit 16-23, only quater of dword (8 bit), is the scan code

                        bit 24 is 01 00 00 00

                        >>> 1 << 0
                        1
                        >>> 1 << 1
                        2
                        >>> 1 << 2
                        4
                        >>> 1 << 3
                        8
                        >>> 1 >> 1
                        0
                        >>> 1 >> 2
                        0
                        >>> 1 >> 3
                        0
                        >>> hex(1 << 24)
                        '0x1000000'
                        >>> hex(0xc12e0001 >> 16)
                        '0xc12e'


                        int modified = (key >> 16) & 255;
                        bit 16-23 is modified





                        I suspect that
                        MapKey()
                        is broken
                        it's in vid_wgl.c
                        the most often pressed keys should be first
                        profiling kind of does that already



                        scantokey

                        https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html

                        Comment


                        • #57
                          if you typed +speed, type -speed too

                          Comment


                          • #58
                            Currently darkplaces keeps config and saves in %HOMEPATH%/Saved Games/darkplaces/id1

                            Wonder if there is a way to make it use local folder instead

                            Comment


                            • #59
                              makefile level

                              makefile uses those to make sure that targets are worked on in correct order with those. Look at makefile itself to see where they are.

                              # Invalid call detection
                              CHECKLEVEL1 = @if [ "$(LEVEL)" != 1 ]; then $(MAKE) help; false; fi
                              CHECKLEVEL2 = @if [ "$(LEVEL)" != 2 ]; then $(MAKE) help; false; fi

                              LEVEL=1
                              $(CHECKLEVEL1)
                              LEVEL=2
                              $(CHECKLEVEL2)

                              Comment


                              • #60
                                i'll just copy this here

                                makefile

                                Code:
                                # note that builddate.c is very intentionally not compiled to a .o before
                                # being linked, because it should be recompiled every time an executable is
                                # built to give the executable a proper date string
                                OBJ_WGL= builddate.c sys_win.o vid_wgl.o thread_null.o $(OBJ_MENU) $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
                                entirety of builddate.c

                                Code:
                                #define STRINGIFY2(arg) #arg
                                #define STRINGIFY(arg) STRINGIFY2(arg)
                                
                                extern const char *buildstring;
                                const char *buildstring =
                                #ifndef NO_BUILD_TIMESTAMPS
                                __TIME__ " " __DATE__ " "
                                #endif
                                #ifdef SVNREVISION
                                STRINGIFY(SVNREVISION)
                                #else
                                "-"
                                #endif
                                #ifdef BUILDTYPE
                                " " STRINGIFY(BUILDTYPE)
                                #endif
                                ;


                                buildstring is used in those files:

                                sv_main.c
                                quakedef.h
                                host_cmd.c
                                host.c
                                cl_demo.c

                                I think I've seen it in console.

                                Don't want to go deeper right now.

                                Comment

                                Working...
                                X