Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
autotestfixture.c
Go to the documentation of this file.
2{
3 private static const string REPORT_FILE_NAME_TEMPLATE = "$mission:Autotest_%1.xml";
4 private static const string DATETIME_FORMAT = "%1%2%3T%4%5%6Z";
5
6 private static string m_WorldName;
7
8 static bool SaveXMLReport(string data, out string errorMessage)
9 {
10 int year, month, day, hour, minute, second;
11 GetYearMonthDayUTC(year, month, day);
12 GetHourMinuteSecondUTC(hour, minute, second);
13 string datetimeUTC = string.Format(DATETIME_FORMAT, year, month.ToStringLen(2), day.ToStringLen(2), hour.ToStringLen(2), minute.ToStringLen(2), second.ToStringLen(2));
14 string filename = string.Format(REPORT_FILE_NAME_TEMPLATE, datetimeUTC);
15
16 FileHandle handle = OpenFile(filename, FileMode.WRITE);
17 if (handle == 0)
18 {
19 errorMessage = string.Format("Cannot open file \"%1\" for writing", filename);
20 return false;
21 }
22
23 FPrint(handle, data);
24 CloseFile(handle);
25
26 return true;
27 }
28
29 static EntityAI SpawnEntityAI(string typeName, int flags = ECE_PLACE_ON_SURFACE)
30 {
31 EntityAI entity = EntityAI.Cast(g_Game.CreateObjectEx(typeName, g_Game.GetPlayer().GetPosition(), ECE_PLACE_ON_SURFACE));
32 return entity;
33 }
34
35 static void SetWorldName()
36 {
37 string worldName = "empty";
38 GetGame().GetWorldName(worldName);
39 worldName.ToLower();
40
41 m_WorldName = worldName;
42 }
43
44 static string GetWorldName()
45 {
46 return m_WorldName;
47 }
48
49 static void LogRPT(string message)
50 {
51 PrintToRPT(string.Format("[Autotest] %1", message));
52 }
53}
const int ECE_PLACE_ON_SURFACE
DayZGame g_Game
Definition dayzgame.c:3868
proto native CGame GetGame()
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
FileMode
Definition ensystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto void FPrint(FileHandle file, void var)
Write to file.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
int[] FileHandle
Definition ensystem.c:390
proto void GetYearMonthDayUTC(out int year, out int month, out int day)
Returns UTC system date.
proto void GetHourMinuteSecondUTC(out int hour, out int minute, out int second)
Returns UTC system time.