Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move parse.cpp from engine to gamelogic #1105

Merged
merged 3 commits into from Jan 28, 2019
Merged

Conversation

slipher
Copy link
Contributor

@slipher slipher commented Jan 26, 2019

No description provided.

gamelogic

This code has been located in the engine, but it is only used by the
gamelogic through trap calls. So it can be moved into the gamelogic and
the trap calls removed.

Diff of parse.cpp versus the engine version:

diff --git a/daemon/src/engine/qcommon/parse.cpp b/src/shared/parse.cpp
index 71947a71c..b56bf1d61 100644
--- a/daemon/src/engine/qcommon/parse.cpp
+++ b/src/shared/parse.cpp
@@ -1,28 +1,43 @@
 /*
 ===========================================================================
+
+Unvanquished GPL Source Code
 Copyright (C) 1999-2005 Id Software, Inc.
 Copyright (C) 2000-2009 Darklegion Development

-This file is part of Daemon.
+This file is part of the Unvanquished GPL Source Code (Unvanquished Source Code).

-Daemon is free software; you can redistribute it
+Unvanquished is free software; you can redistribute it
 and/or modify it under the terms of the GNU General Public License as
 published by the Free Software Foundation; either version 2 of the License,
 or (at your option) any later version.

-Daemon is distributed in the hope that it will be
+Unvanquished is distributed in the hope that it will be
 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
-along with Daemon; if not, write to the Free Software
+along with Unvanquished; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 ===========================================================================
 */

-#include "qcommon/q_shared.h"
-#include "qcommon.h"
+#ifdef BUILD_CGAME
+#include "cgame/cg_local.h"
+#else
+#include "sgame/sg_local.h"
+#endif
+
+static void* Z_Malloc(size_t size)
+{
+  return calloc(size, 1);
+}
+static void Z_Free(void* ptr)
+{
+  free(ptr);
+}

 //script flags
 static const int SCFL_NOERRORS            = 0x0001;
@@ -47,6 +62,9 @@ static const int TT_FLOAT           = 0x0800; // floating point number
 static const int TT_INTEGER         = 0x1000; // integer number
 static const int TT_LONG            = 0x2000; // long number
 static const int TT_UNSIGNED        = 0x4000; // unsigned number
+
+namespace {
+
 //punctuation sub type
 //--------------------
 enum class punctuationSub_t {
@@ -224,10 +242,6 @@ struct directive_t

 #define DEFINEHASHSIZE 1024

-static bool Parse_ReadToken( source_t *source, token_t *token );
-static bool Parse_AddDefineToSourceFromString( source_t *source,
-    char *string );
-
 int             numtokens;

 //list with global defines added to every source loaded
@@ -309,6 +323,12 @@ punctuation_t   Default_Punctuations[] =
 	{ nullptr, Util::enum_cast<punctuationSub_t>(0), nullptr }
 };

+} // namespace
+
+static bool Parse_ReadToken( source_t *source, token_t *token );
+static bool Parse_AddDefineToSourceFromString( source_t *source,
+    char *string );
+
 /*
 ===============
 Parse_CreatePunctuationTable
@@ -1143,7 +1163,7 @@ static script_t *Parse_LoadScriptFile( const char *filename )
 	void         *buffer;
 	script_t     *script;

-	length = FS_FOpenFileRead( filename, &fp, false );
+	length = trap_FS_FOpenFile( filename, &fp, fsMode_t::FS_READ );

 	if ( !fp ) { return nullptr; }

@@ -1168,8 +1188,8 @@ static script_t *Parse_LoadScriptFile( const char *filename )
 	//
 	Parse_SetScriptPunctuations( script, nullptr );
 	//
-	FS_Read( script->buffer, length, fp );
-	FS_FCloseFile( fp );
+	trap_FS_Read( script->buffer, length, fp );
+	trap_FS_FCloseFile( fp );
 	//

 	return script;
@slipher
Copy link
Contributor Author

slipher commented Jan 27, 2019

Now fixes #503

@slipher slipher merged commit 87c2104 into Unvanquished:master Jan 28, 2019
@slipher slipher deleted the parse.cpp branch January 28, 2019 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants