This commit is contained in:
2025-05-25 23:37:40 +03:00
commit 7f054e2904
79 changed files with 4850 additions and 0 deletions

42
tier1/__build.c Normal file
View File

@@ -0,0 +1,42 @@
#include "god/c.h"
#include "god/ld.h"
char* tier1_lib = 0;
void tier1_build(struct build_data b)
{
char* files[] = {
"tier1/commandline.cpp",
"tier1/utlbuffer.cpp",
"tier1/utlmap.cpp",
"tier1/utlstring.cpp",
"tier1/utlvector.cpp",
NULL,
};
struct C_Macro macros[] = {
(struct C_Macro){"TIER0_IMPLEMENTATION","1"},
NULL,
};
struct project p = {
.b = &b,
.files = files,
.name = "tier1",
};
struct project o = C_compile(p, (struct C_settings){
.generation_flags = C_GENERATION_FLAGS_PIC,
.compile_flags = C_COMPILE_FLAGS_WALL,
.include_dirs = include_dirs,
.macros = macros,
});
char* libs[] = {
"c",
NULL,
};
tier1_lib = ld_link_project(o, (struct link_settings){
.type = LINK_TYPE_STATIC,
.libs = libs,
});
}

61
tier1/commandline.cpp Normal file
View File

@@ -0,0 +1,61 @@
#include "tier1/commandline.h"
#include "tier1/utlvector.h"
CUtlVector<char*> cl_params;
void ICommandLine::CreateCommandLine( int argc, char **argv )
{
cl_params.AppendTail(argv,argc);
}
bool ICommandLine::CheckParam( char *psz )
{
for (auto szParam: cl_params) {
V_printf("%s\n",szParam);
}
return false;
}
char *ICommandLine::ParamValue( const char *psz )
{
int i = 0;
for (auto szParam: cl_params) {
i++;
if (i>=cl_params.GetSize())
{
return 0;
}
if (!V_strcmp(szParam, psz))
return cl_params[i];
}
return 0;
}
void ICommandLine::AddParam( char *psz )
{
}
void ICommandLine::RemoveParam( char *psz )
{
}
int ICommandLine::ParamCount()
{
return cl_params.GetSize();
}
int ICommandLine::FindParam( const char *psz )
{
int i = 0;
for (auto szParam: cl_params) {
if (!V_strcmp(szParam, psz))
return i;
i++;
}
return 0;
}
const char *ICommandLine::GetParam(int nIndex)
{
return cl_params[nIndex];
}
static ICommandLine g_CommandLine;

1
tier1/utlbuffer.cpp Normal file
View File

@@ -0,0 +1 @@
#include "tier1/utlbuffer.h"

1
tier1/utlmap.cpp Normal file
View File

@@ -0,0 +1 @@
#include "tier1/utlmap.h"

96
tier1/utlstring.cpp Normal file
View File

@@ -0,0 +1,96 @@
#include "tier1/utlstring.h"
#include "tier0/lib.h"
#include "stdarg.h"
CUtlString::CUtlString( void )
{
m_data.Reserve(1);
m_data[0]=0;
}
CUtlString::CUtlString( const char *szFormat, ... )
{
if (szFormat == 0)
{
m_data.Reserve(1);
m_data[0]=0;
return;
}
va_list vlArgs;
va_start(vlArgs, szFormat);
va_list vlArgs2;
va_copy(vlArgs2, vlArgs);
size_t nSize = V_vsnprintf(NULL, 0, szFormat, vlArgs2);
m_data.Reserve(nSize + 1);
va_end(vlArgs2);
V_vsnprintf(m_data.GetData(), nSize + 1, szFormat, vlArgs);
m_data.Resize(nSize);
va_end(vlArgs);
}
void CUtlString::AppendTail( const char *psz )
{
m_data.AppendTail(psz,V_strlen(psz));
m_data.Reserve(m_data.GetSize()+1);
m_data[m_data.GetSize()] = 0;
}
void CUtlString::AppendHead( const char *psz )
{
}
void CUtlString::AppendAt( size_t nPosition, const char *psz )
{
}
void CUtlString::RemoveTail( size_t nCount )
{
}
void CUtlString::RemoveHead( size_t nCount )
{
}
void CUtlString::RemoveAt( size_t nPosition, size_t nCount )
{
}
char *CUtlString::GetString( void )
{
return m_data.GetData();
}
CUtlString::operator char*( void )
{
return GetString();
}
bool CUtlString::operator==(const char* psz)
{
if (psz==0)
psz = "";
if (!V_strcmp(GetString(), psz))
return true;
return false;
}
bool CUtlString::operator!=(const char* psz)
{
if (psz==0)
psz = "";
if (!V_strcmp(GetString(), psz))
return false;
return true;
}
bool CUtlString::operator==(CUtlString& string)
{
if (!V_strcmp(GetString(), string.GetString()))
return true;
return false;
}
bool CUtlString::operator!=(CUtlString& string)
{
if (!V_strcmp(GetString(), string.GetString()))
return false;
return true;
}

1
tier1/utlvector.cpp Normal file
View File

@@ -0,0 +1 @@
#include "tier1/utlvector.h"