Skip to content

Commit

Permalink
Updated gh workflow names and badges in README.
Browse files Browse the repository at this point in the history
Fixeid an invalid memory read when reading the last script file line.
  • Loading branch information
cbnolok committed Jun 25, 2024
1 parent c414145 commit 6e7ea8f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_linux_x86.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build Nightly Linux x86

on:
- push
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_linux_x86_64.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build Nightly Linux x86_64

on:
- push
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_osx_arm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build MacOS ARM

on:
- push
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_osx_x86_64.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build Nightly MacOS x86_64

on:
- push
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_win_x86.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build Nightly Windows x86

on:
- push
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SphereServer X

Ultima Online game server developed in C++
Ultima Online game server, developed in C++.
<br>
[![GitHub license](https://img.shields.io/github/license/Sphereserver/Source-X?color=blue)](https://github.com/Sphereserver/Source-X/blob/master/LICENSE)
[![GitHub repo size](https://img.shields.io/github/repo-size/Sphereserver/Source-X.svg)](https://github.com/Sphereserver/Source-X/)
Expand All @@ -11,12 +11,12 @@ Ultima Online game server developed in C++
<br>
[![Coverity Scan Build Status](https://scan.coverity.com/projects/20225/badge.svg)](https://scan.coverity.com/projects/sphereserver-source-x)
<br>
[![Build status: Windows x86_64](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86_64.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86_64.yml)
[![Build status: Windows x86] (https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86.yml)
[![Build status: Linux x86_64] (https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86_64.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86_64.yml)
[![Build status: Linux x86] (https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86.yml)
[![Build status: MacOS x86_64] (https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_x86_64.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_x86_64.yml)
[![Build status: MacOS ARM] (https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_arm.yml/badge.svg)](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_arm.yml)
[![Build status: Windows x86_64](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86_64.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86_64.yml)
[![Build status: Windows x86](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_win_x86.yml)
[![Build status: Linux x86_64](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86_64.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86_64.yml)
[![Build status: Linux x86](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_linux_x86.yml)
[![Build status: MacOS x86_64](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_x86_64.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_x86_64.yml)
[![Build status: MacOS ARM](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_arm.yml/badge.svg?branch=master)](https://github.com/Sphereserver/Source-X/actions/workflows/build_osx_arm.yml)
<br><br>
Join the SphereServer Discord channel!
[![Discord Shield](https://discordapp.com/api/guilds/354358315373035542/widget.png?style=shield)](https://discord.gg/ZrMTXrs)
Expand All @@ -35,8 +35,8 @@ of the new ones.
It is currently being revamped to add original OSI features.
Beware, it's still not 100% complete!

+ <a href="https://github.com/Sphereserver/Scripts-X">Up to date</a>
+ <a href="https://github.com/Sphereserver/Scripts-X/releases">Official releases</a>
+ <a href="https://github.com/Sphereserver/Scripts-X">Current (most updated)</a>
+ <a href="https://github.com/Sphereserver/Scripts-X/releases">Milestone releases</a>

### Resources

Expand Down Expand Up @@ -233,3 +233,4 @@ Copyright 2023 SphereServer development team.<br>
Licensed under the Apache License, Version 2.0 (the "License").<br>
You may not use any file of this project except in compliance with the License.<br>
You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>

46 changes: 23 additions & 23 deletions src/common/CCacheableScriptFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CCacheableScriptFile::CCacheableScriptFile()
_iCurrentLine = 0;
}

CCacheableScriptFile::~CCacheableScriptFile()
CCacheableScriptFile::~CCacheableScriptFile()
{
//_Close(); // No need to Close(), since it's already done by CSFileText destructor.
if ( _fRealFile && _fileContent ) // be sure that i'm the original file and not a copy/link
Expand All @@ -25,12 +25,12 @@ CCacheableScriptFile::~CCacheableScriptFile()
}
}

bool CCacheableScriptFile::_Open(lpctstr ptcFilename, uint uiModeFlags)
bool CCacheableScriptFile::_Open(lpctstr ptcFilename, uint uiModeFlags)
{
ADDTOCALLSTACK("CCacheableScriptFile::_Open");

_uiMode = uiModeFlags;
if ( _useDefaultFile() )
if ( _useDefaultFile() )
return CSFileText::_Open(ptcFilename, uiModeFlags);

if ( !ptcFilename )
Expand Down Expand Up @@ -95,7 +95,7 @@ bool CCacheableScriptFile::_Open(lpctstr ptcFilename, uint uiModeFlags)
const char *fileCursor = fileContentCopy.get();
size_t uiFileCursorRemainingLegth = iFileLength;
ssize_t iStrLen;
for (;; fileCursor += (size_t)iStrLen, uiFileCursorRemainingLegth -= (size_t)iStrLen)
for (;uiFileCursorRemainingLegth > 0; fileCursor += (size_t)iStrLen, uiFileCursorRemainingLegth -= (size_t)iStrLen)
{
iStrLen = sGetLine_StaticBuf(fileCursor, minimum(uiFileCursorRemainingLegth, SCRIPT_MAX_LINE_LEN));
if (iStrLen < 0)
Expand Down Expand Up @@ -153,7 +153,7 @@ bool CCacheableScriptFile::_Open(lpctstr ptcFilename, uint uiModeFlags)

return true;
}
bool CCacheableScriptFile::Open(lpctstr ptcFilename, uint uiModeFlags)
bool CCacheableScriptFile::Open(lpctstr ptcFilename, uint uiModeFlags)
{
ADDTOCALLSTACK("CCacheableScriptFile::Open");
THREAD_UNIQUE_LOCK_RETURN(CCacheableScriptFile::_Open(ptcFilename, uiModeFlags));
Expand All @@ -166,7 +166,7 @@ void CCacheableScriptFile::_Close()
{
CSFileText::_Close();
}
else
else
{
_iCurrentLine = 0;
_fClosed = true;
Expand All @@ -179,55 +179,55 @@ void CCacheableScriptFile::Close()
_Close();
}

bool CCacheableScriptFile::_IsFileOpen() const
bool CCacheableScriptFile::_IsFileOpen() const
{
ADDTOCALLSTACK("CCacheableScriptFile::_IsFileOpen");

if ( _useDefaultFile() )
if ( _useDefaultFile() )
return CSFileText::_IsFileOpen();

return (!_fClosed);
}
bool CCacheableScriptFile::IsFileOpen() const
bool CCacheableScriptFile::IsFileOpen() const
{
ADDTOCALLSTACK("CCacheableScriptFile::IsFileOpen");

THREAD_SHARED_LOCK_SET;
if ( _useDefaultFile() )
if ( _useDefaultFile() )
TS_RETURN(CSFileText::_IsFileOpen());

TS_RETURN(!_fClosed);
}

bool CCacheableScriptFile::_IsEOF() const
bool CCacheableScriptFile::_IsEOF() const
{
//ADDTOCALLSTACK("CCacheableScriptFile::_IsEOF");
if ( _useDefaultFile() )
if ( _useDefaultFile() )
return CSFileText::_IsEOF();

return (_fileContent->empty() || ((uint)_iCurrentLine == _fileContent->size()) );
}
bool CCacheableScriptFile::IsEOF() const
bool CCacheableScriptFile::IsEOF() const
{
//ADDTOCALLSTACK("CCacheableScriptFile::IsEOF");
THREAD_SHARED_LOCK_RETURN(_IsEOF());
}

tchar * CCacheableScriptFile::_ReadString(tchar *pBuffer, int sizemax)
tchar * CCacheableScriptFile::_ReadString(tchar *pBuffer, int sizemax)
{
// This function is called for each script line which is being parsed (so VERY frequently), and ADDTOCALLSTACK is expensive if called
// this much often, so here it's to be preferred ADDTOCALLSTACK_INTENSIVE, even if we'll lose stack trace precision.
//ADDTOCALLSTACK_INTENSIVE("CCacheableScriptFile::_ReadString");
ASSERT(sizemax > 0);
if ( _useDefaultFile() )
if ( _useDefaultFile() )
return CSFileText::_ReadString(pBuffer, sizemax);

//*pBuffer = '\0';
ASSERT(_fileContent);

if (_fileContent->empty() || ((uint)_iCurrentLine >= _fileContent->size()))
return nullptr;

std::string const& cur_line = (*_fileContent)[_iCurrentLine];
++_iCurrentLine;
if (cur_line.empty())
Expand All @@ -246,23 +246,23 @@ tchar * CCacheableScriptFile::_ReadString(tchar *pBuffer, int sizemax)
return pBuffer;
}

tchar * CCacheableScriptFile::ReadString(tchar *pBuffer, int sizemax)
tchar * CCacheableScriptFile::ReadString(tchar *pBuffer, int sizemax)
{
//ADDTOCALLSTACK_INTENSIVE("CCacheableScriptFile::ReadString");
THREAD_UNIQUE_LOCK_RETURN(CCacheableScriptFile::_ReadString(pBuffer, sizemax));
}

void CCacheableScriptFile::_dupeFrom(CCacheableScriptFile *other)
void CCacheableScriptFile::_dupeFrom(CCacheableScriptFile *other)
{
if ( _useDefaultFile() )
if ( _useDefaultFile() )
return;

_strFileName = other->_strFileName;
_fClosed = other->_fClosed;
_fRealFile = false;
_fileContent = other->_fileContent;
}
void CCacheableScriptFile::dupeFrom(CCacheableScriptFile *other)
void CCacheableScriptFile::dupeFrom(CCacheableScriptFile *other)
{
THREAD_UNIQUE_LOCK_SET;
_dupeFrom(other);
Expand All @@ -279,14 +279,14 @@ bool CCacheableScriptFile::HasCache() const
THREAD_SHARED_LOCK_RETURN(_HasCache());
}

bool CCacheableScriptFile::_useDefaultFile() const
bool CCacheableScriptFile::_useDefaultFile() const
{
if ( _IsWriteMode() || ( _GetFullMode() & OF_DEFAULTMODE ))
if ( _IsWriteMode() || ( _GetFullMode() & OF_DEFAULTMODE ))
return true;
return false;
}
/*
bool CCacheableScriptFile::useDefaultFile() const
bool CCacheableScriptFile::useDefaultFile() const
{
THREAD_SHARED_LOCK_RETURN(_useDefaultFile());
}*/
Expand Down
4 changes: 2 additions & 2 deletions src/game/CRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool CRegion::RealizeRegion()
// Yes, this sector overlapped, so add it to the sector list
if ( !pSector->LinkRegion(this) )
{
g_Log.EventError("Linking sector #%d for map %d for region %s failed (fatal for this region).\n", i, m_pt.m_map, GetName());
g_Log.EventError("Linking sector #%d (map %d) for region %s failed (fatal for this region).\n", i, int(m_pt.m_map), GetName());
return false;
}
++m_iLinkedSectors;
Expand Down Expand Up @@ -792,7 +792,7 @@ bool CRegion::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command from
CChar * pChar = pClient->GetChar();
if ( !pChar || ( pChar->GetRegion() != this ))
continue;

CScript script(s.GetArgRaw());
script.CopyParseState(s);
pChar->r_Verb(script, pSrc);
Expand Down
2 changes: 1 addition & 1 deletion src/game/CSectorTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ bool CSectorBase::LinkRegion( CRegion * pRegionNew )
ASSERT(pRegion);
if ( pRegionNew == pRegion )
{
DEBUG_ERR(( "region already linked!\n" ));
DEBUG_ERR(( "Region already linked!\n" ));
return false;
}

Expand Down
7 changes: 4 additions & 3 deletions src/game/CWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ bool CWorld::CheckAvailableSpaceForSave(bool fStatics)
uiPreviousSaveSize += uiCurSavefileSize;
}
else
fSizeErr = true;
fSizeErr = true;
};

if (fStatics)
Expand Down Expand Up @@ -1278,7 +1278,8 @@ bool CWorld::LoadFile( lpctstr pszLoadName, bool fError ) // Load world from scr

while ( s.FindNextSection() )
{
if (! ( ++iLoadStage & 0x1FF )) // don't update too often
// Print the percent state of the current file loading.
if (! ( ++iLoadStage & 0xFF )) // don't update too often
g_Serv.PrintPercent( s.GetPosition(), iLoadSize );

try
Expand Down Expand Up @@ -1414,7 +1415,7 @@ bool CWorld::LoadAll() // Load world from script

// Set all the sector light levels now that we know the time.
// This should not look like part of the load. (CTRIG_EnvironChange triggers should run)

for (int m = 0; m < MAP_SUPPORTED_QTY; ++m)
{
if (!g_MapList.IsMapSupported(m))
Expand Down

0 comments on commit 6e7ea8f

Please sign in to comment.