Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
ServerScriptFileSafe.h
Go to the documentation of this file.
1
2// =============================================================================
3// This file is adopted from rorserver at commit 4a7109ae2d9a081ccfdad8cc696dc54efe49acb3
4// Changes from the original are marked with "//RIGSOFRODS"
5// =============================================================================
6
7/*
8This file is part of "Rigs of Rods Server" (Relay mode)
9
10Copyright 2007 Pierre-Michel Ricordel
11Copyright 2014+ Rigs of Rods Community
12
13"Rigs of Rods Server" is free software: you can redistribute it
14and/or modify it under the terms of the GNU General Public License
15as published by the Free Software Foundation, either version 3
16of the License, or (at your option) any later version.
17
18"Rigs of Rods Server" is distributed in the hope that it will
19be useful, but WITHOUT ANY WARRANTY; without even the implied
20warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21See the GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with Foobar. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#pragma once
28
29#ifdef USE_ANGELSCRIPT
30
31namespace RoR { // RIGSOFRODS
32
33// copied from the angelscript library and edited for use in Rigs of Rods Multiplayer Server ~ 01 Jan 2012
34// Copied from rorserver and modified to use `Ogre::DataStream` instead of `FILE*` ~ ohlidalp, 2026-07-17
36public:
38
39 void AddRef() const;
40
41 void Release() const;
42
43 // TODO: Implement the "r+", "w+" and "a+" modes
44 // mode = "r" -> open the file for reading
45 // "w" -> open the file for writing (overwrites existing file)
46 // "a" -> open the file for appending
47 int Open(const std::string &filename, const std::string &mode);
48
49 int Close();
50
51 int GetSize() const;
52
53 bool IsEOF() const;
54
55 // Reading
56 int ReadString(unsigned int length, std::string &str);
57
58 int ReadLine(std::string &str);
59
60 AngelScript::asINT64 ReadInt(AngelScript::asUINT bytes);
61
62 AngelScript::asQWORD ReadUInt(AngelScript::asUINT bytes);
63
64 float ReadFloat();
65
66 double ReadDouble();
67
68 // Writing
69 int WriteString(const std::string &str);
70
71 int WriteInt(AngelScript::asINT64 v, AngelScript::asUINT bytes);
72
73 int WriteUInt(AngelScript::asQWORD v, AngelScript::asUINT bytes);
74
75 int WriteFloat(float v);
76
77 int WriteDouble(double v);
78
79 // Cursor
80 int GetPos() const;
81
82 int SetPos(int pos);
83
84 int MovePos(int delta);
85
86protected:
88
89 mutable int refCount;
90 Ogre::DataStreamPtr m_stream;
91};
92
93void RegisterScriptFile_Native(AngelScript::asIScriptEngine *engine);
94
95} // namespace RoR
96
97#endif // USE_ANGELSCRIPT
Ogre::DataStreamPtr m_stream
int WriteInt(AngelScript::asINT64 v, AngelScript::asUINT bytes)
AngelScript::asQWORD ReadUInt(AngelScript::asUINT bytes)
int WriteUInt(AngelScript::asQWORD v, AngelScript::asUINT bytes)
int Open(const std::string &filename, const std::string &mode)
int WriteString(const std::string &str)
int ReadLine(std::string &str)
AngelScript::asINT64 ReadInt(AngelScript::asUINT bytes)
int ReadString(unsigned int length, std::string &str)
void RegisterScriptFile_Native(AngelScript::asIScriptEngine *engine)