Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
debug.c
Go to the documentation of this file.
1class Debug
2{
3 private static const string LOG_DEBUG = "Debug";
4 private static const string LOG_DEBUG_ACTION = "Action";
5 private static const string LOG_DEBUG_SYMPTOM = "Symptom";
6 private static const string LOG_DEBUG_INV_MOVE = "Inv Move";
7 private static const string LOG_DEBUG_INV_RESERVATION = "Inv Rrsv";
8 private static const string LOG_DEBUG_INV_HFSM = "HFSM";
9 private static const string LOG_DEBUG_QUICKBAR = "Quickbar";
10 private static const string LOG_DEBUG_BASEBUILDING = "Base Building";
11 private static const string LOG_DEBUG_BLEEDING_CHANCES = "Bleeding";
12 private static const string LOG_DEBUG_TRIGGER = "Trigger";
13 private static const string LOG_DEBUG_PARTICLE = "Particle";
14 private static const string LOG_DEBUG_TF = "TestFramework";
15 private static const string LOG_DEBUG_WEIGHT = "Weight";
16 private static const string LOG_DEBUG_MELEE = "Melee";
17 private static const string LOG_DEBUG_WEATHER = "Weather";
18
19 private static const string LOG_INFO = "Info";
20 private static const string LOG_WARNING = "Warning";
21 private static const string LOG_ERROR = "Error";
22 private static const string LOG_DEFAULT = "n/a";
23
24 private static ref array<Shape> m_DebugShapes;
25
26 static Widget m_DebugLayoutCanvas;
27 static CanvasWidget m_CanvasDebug;
28
29 static string GetDebugName(Managed entity)
30 {
31 if (!entity)
32 return "";
33
34 Object obj;
35 if (CastTo(obj, entity))
36 return obj.GetDebugNameNative();
37
38 return entity.GetDebugName();
39 }
40
41 static void InitCanvas()
42 {
43 if (!m_DebugLayoutCanvas)
44 {
45 m_DebugLayoutCanvas = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_debugcanvas.layout");
46 m_CanvasDebug = CanvasWidget.Cast( m_DebugLayoutCanvas.FindAnyWidget( "CanvasWidget" ) );
47 }
48 }
49
50 static void ClearCanvas()
51 {
52 if (m_CanvasDebug)
53 m_CanvasDebug.Clear();
54 }
55
56 static void CanvasDrawLine(float x1, float y1, float x2, float y2, float width, int color)
57 {
58 InitCanvas();
59 m_CanvasDebug.DrawLine(x1, y1, x2, y2, width, color);
60 }
61
73 static void CanvasDrawPoint(float x1, float y1, int color)
74 {
75 CanvasDrawLine(x1, y1, x1+1, y1, 1, color);
76 }
77
78 static void Init()
79 {
80 m_DebugShapes = new array<Shape>;
81 }
82
83 static void DestroyAllShapes()
84 {
85 for ( int i = 0; i < m_DebugShapes.Count(); ++i )
86 {
87 if ( m_DebugShapes.Get(i) )
88 {
89 m_DebugShapes.Get(i).Destroy();
90 }
91 }
92
93 m_DebugShapes.Clear();
94 }
95
96 static void RemoveShape(out Shape shape)
97 {
98 if (!shape) return;
99 for ( int i = 0; i < m_DebugShapes.Count(); i++ )
100 {
101 Shape found_shape = m_DebugShapes.Get(i);
102
103 if ( found_shape && found_shape == shape )
104 {
105 found_shape.Destroy();
106 m_DebugShapes.Remove(i); // Mandatory! Otherwise the Destroy() function causes crash!
107 shape = null;
108 return;
109 }
110 }
111 }
122 static void Log(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
123 {
124 LogMessage(LOG_DEBUG, plugin, entity, author, label, message);
125 }
126
127 static void ActionLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
128 {
129 LogMessage(LOG_DEBUG_ACTION, plugin, entity, author, label, message);
130 }
131
132 static void SymptomLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
133 {
134 LogMessage(LOG_DEBUG_SYMPTOM, plugin, entity, author, label, message);
135 }
136
137 static void InventoryMoveLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
138 {
139 LogMessage(LOG_DEBUG_INV_MOVE, plugin, entity, author, label, message);
140 }
141
142 static void InventoryReservationLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
143 {
144 LogMessage(LOG_DEBUG_INV_RESERVATION, plugin, entity, author, label, message);
145 }
146
147 static void InventoryHFSMLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
148 {
149 LogMessage(LOG_DEBUG_INV_HFSM, plugin, entity, author, label, message);
150 }
151
152 static void QuickbarLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
153 {
154 LogMessage(LOG_DEBUG_QUICKBAR, plugin, entity, author, label, message);
155 }
156
157 static void BaseBuildingLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
158 {
159 LogMessage(LOG_DEBUG_BASEBUILDING, plugin, entity, author, label, message);
160 }
161
162 static void BleedingChancesLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
163 {
164 LogMessage(LOG_DEBUG_BLEEDING_CHANCES, plugin, entity, author, label, message);
165 }
166
167 static void TriggerLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
168 {
169 LogMessage(LOG_DEBUG_TRIGGER, plugin, entity, author, label, message);
170 }
171
172 static void ParticleLog(string message = LOG_DEFAULT, Managed caller = null, string function = "", Managed entity = null)
173 {
174 LogMessage(LOG_DEBUG_PARTICLE, GetDebugName(caller), GetDebugName(entity), "", function, message);
175 }
176
177 static void TFLog(string message = LOG_DEFAULT, TestFramework caller = null, string function = "")
178 {
179 LogMessage(LOG_DEBUG_TF, GetDebugName(caller), "", "", function, message);
180 }
181
182 static void WeightLog(string message = LOG_DEFAULT, Managed caller = null, string function = "", Managed entity = null)
183 {
184 /*
185 LogMessage(LOG_DEBUG_WEIGHT, GetDebugName(caller), GetDebugName(entity), "", function, message);
186 */
187 }
188
189 static void MeleeLog(Entity entity, string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT)
190 {
191 string logMessage = string.Format("%1: %2", entity.GetSimulationTimeStamp(), message);
192 LogMessage(LOG_DEBUG_MELEE, plugin, GetDebugName(entity), author, label, logMessage);
193 }
194
195 static void WeatherLog(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
196 {
197 if (!LogManager.IsWeatherLogEnabled())
198 {
199 return;
200 }
201
202 LogMessage(LOG_DEBUG_WEATHER, plugin, entity, author, label, message);
203 }
204
215 static void LogInfo(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
216 {
217 LogMessage(LOG_INFO, plugin, entity, author, label, message);
218 }
219
230 static void LogWarning(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
231 {
232 LogMessage(LOG_WARNING, plugin, entity, author, label, message);
233 }
234
245 static void LogError(string message = LOG_DEFAULT, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
246 {
247 LogMessage(LOG_ERROR, plugin, entity, author, label, message);
248 }
249
250 static void LogArrayInt(array<int> arr = NULL, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
251 {
252 if (arr == null)
253 return;
254 for (int i = 0; i < arr.Count(); i++)
255 {
256 LogMessage(LOG_DEBUG, plugin, entity, author, label, arr.Get(i).ToString());
257 }
258 }
259
260 static void LogArrayString(array<string> arr = NULL, string plugin = LOG_DEFAULT, string author = LOG_DEFAULT, string label = LOG_DEFAULT, string entity = LOG_DEFAULT)
261 {
262 if (arr == null)
263 return;
264
265 for (int i = 0; i < arr.Count(); i++)
266 {
267 LogMessage(LOG_DEBUG, plugin, entity, author, label, arr.Get(i));
268 }
269 }
270
271 static void ReceivedLogMessageFromServer(string message)
272 {
273 if (!LogManager.IsLogsEnable())
274 {
275 return;
276 }
277
278 SaveLog(message);
279 }
280
281 static void ClearScriptLogs()
282 {
283 ClearLogs();
284 }
285
286 static Shape DrawBox(vector pos1, vector pos2, int color = 0x1fff7f7f)
287 {
288 return DrawBoxEx(pos1, pos2, color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE);
289 }
290
291 static Shape DrawBoxEx(vector pos1, vector pos2, int color = 0x1fff7f7f, ShapeFlags flags = ShapeFlags.TRANSP|ShapeFlags.NOZWRITE)
292 {
293 Shape shape = Shape.Create(ShapeType.BBOX, color, flags, pos1, pos2);
294 if (( flags & ShapeFlags.ONCE ) == 0)
295 m_DebugShapes.Insert(shape);
296 return shape;
297 }
298
299 static Shape DrawCube(vector pos, float size = 1, int color = 0x1fff7f7f)
300 {
301 vector min = pos;
302 vector max = pos;
303
304 float size_h = size * 0.5;
305
306 min[0] = min[0] - size_h;
307 min[1] = min[1] - size_h;
308 min[2] = min[2] - size_h;
309
310 max[0] = max[0] + size_h;
311 max[1] = max[1] + size_h;
312 max[2] = max[2] + size_h;
313
314 Shape shape = Shape.Create(ShapeType.DIAMOND, color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE, min, max);
315 m_DebugShapes.Insert(shape);
316 return shape;
317 }
318
319 static Shape DrawSphere(vector pos, float size = 1, int color = 0x1fff7f7f, ShapeFlags flags = ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
320 {
321 Shape shape = Shape.CreateSphere(color, flags, pos, size);
322 if (( flags & ShapeFlags.ONCE ) == 0)
323 m_DebugShapes.Insert(shape);
324 return shape;
325 }
326
327 static Shape DrawFrustum(float horizontalAngle, float verticalAngle, float length, int color = 0x1fff7f7f, ShapeFlags flags = ShapeFlags.TRANSP|ShapeFlags.WIREFRAME)
328 {
329 Shape shape = Shape.CreateFrustum(horizontalAngle, verticalAngle, length, color, flags);
330 if (( flags & ShapeFlags.ONCE ) == 0)
331 m_DebugShapes.Insert(shape);
332 return shape;
333 }
334
335 static Shape DrawCylinder(vector pos, float radius, float height = 1, int color = 0x1fff7f7f, ShapeFlags flags = ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE )
336 {
337 Shape shape = Shape.CreateCylinder(color, flags, pos, radius, height);
338 if (( flags & ShapeFlags.ONCE ) == 0)
339 m_DebugShapes.Insert(shape);
340 return shape;
341 }
342
343 static array<Shape> DrawCone(vector pos, float lenght, float halfAngle, float offsetAngle, int color = 0xFFFFFFFF, int flags = 0)
344 {
345 array<Shape> shapes = new array<Shape>;
346
347 vector endL, endR;
348 Math3D.ConePoints(pos, lenght, halfAngle, offsetAngle, endL, endR);
349
350 // Left side
351 shapes.Insert( Debug.DrawLine(pos, endL, color, flags) );
352 // Rigth side
353 shapes.Insert( Debug.DrawLine(pos, endR, color, flags) );
354 // Top side
355 shapes.Insert( Debug.DrawLine(endL, endR, color, flags) );
356 // Middle (height) line
357 shapes.Insert( Debug.DrawLine(pos, pos + Vector(Math.Cos(offsetAngle), 0, Math.Sin(offsetAngle)).Normalized() * lenght, color, flags) );
358
359 return shapes;
360 }
361
362 static void CleanupDrawShapes(array<Shape> shapes)
363 {
364 foreach (Shape shape : shapes)
365 Debug.RemoveShape(shape);
366
367 shapes.Clear();
368 }
369
382 static Shape DrawLine(vector from, vector to, int color = 0xFFFFFFFF, int flags = 0)
383 {
384 vector pts[2]
385 pts[0] = from;
386 pts[1] = to;
387
388 Shape shape = Shape.CreateLines(color, flags, pts, 2);
389 if (( flags & ShapeFlags.ONCE ) == 0)
390 m_DebugShapes.Insert(shape);
391 //m_DebugShapes.Debug();
392 return shape;
393 }
394
395 static Shape DrawLines(vector[] positions, int count, int color = 0xFFFFFFFF, int flags = 0)
396 {
397
398 Shape shape = Shape.CreateLines(color, flags, positions, count);
399 if (( flags & ShapeFlags.ONCE ) == 0)
400 m_DebugShapes.Insert(shape);
401 return shape;
402 }
403
404 static Shape DrawArrow(vector from, vector to, float size = 0.5, int color = 0xFFFFFFFF, int flags = 0)
405 {
406 Shape shape = Shape.CreateArrow(from, to, size, color, flags);
407 m_DebugShapes.Insert(shape);
408 return shape;
409 }
410
411
412
417 static void GetBaseConfigClasses( out TStringArray base_classes )
418 {
419 base_classes.Clear();
420 base_classes.Insert(CFG_VEHICLESPATH);
421 base_classes.Insert(CFG_WEAPONSPATH);
422 base_classes.Insert(CFG_MAGAZINESPATH);
423 base_classes.Insert(CFG_AMMO);
424 base_classes.Insert(CFG_WORLDS);
425 base_classes.Insert(CFG_SURFACES);
426 base_classes.Insert(CFG_SOUND_SETS);
427 base_classes.Insert(CFG_SOUND_SHADERS);
428 base_classes.Insert(CFG_NONAI_VEHICLES);
429 base_classes.Insert(CFG_SOUND_TABLES);
430 }
431
438 static void GetFiltredConfigClasses( string search_string, out TStringArray filtered_classes, bool only_public = true )
439 {
440 TStringArray searching_in = new TStringArray;
441 GetBaseConfigClasses( searching_in );
442
443 filtered_classes.Clear();
444
445 search_string.ToLower();
446
447 for ( int s = 0; s < searching_in.Count(); ++s )
448 {
449 string config_path = searching_in.Get(s);
450
451 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
452 for (int i = 0; i < objects_count; i++)
453 {
454 string childName;
455 GetGame().ConfigGetChildName(config_path, i, childName);
456
457 if ( only_public )
458 {
459 int scope = GetGame().ConfigGetInt( config_path + " " + childName + " scope" );
460 if ( scope == 0 )
461 {
462 continue;
463 }
464 }
465
466 string nchName = childName;
467 nchName.ToLower();
468
469 if ( nchName.Contains(search_string) != -1)
470 {
471 filtered_classes.Insert(childName);
472 }
473 }
474 }
475 }
476
477 //---------------------------------------------------------------
478 //-------private
479
480 private static bool m_EnabledLogs;
481
482 private static string LogMessage(string level, string plugin, string entity, string author, string label, string message)
483 {
484 if (GetGame() == null || !LogManager.IsLogsEnable())
485 return string.Empty;
486
487 bool is_server_log = ( GetGame().IsServer() && GetGame().IsMultiplayer() );
488
489
490 // Formation output to external file
491 // %date{MM-dd HH:mm:ss} | %Enviroment | %Level | %Module | %Entity | %Author | %Label | %Message
492 string date = GetDate();
493 string env = "Client";
494 string msg = string.Empty;
495
496 if ( is_server_log )
497 {
498 env = "Server";
499 }
500
501 msg = string.Format("%1 | %2 | %3 | %4 | %5 | %6 | %7", date, env, level, plugin, entity, label, message);
502
503 if ( is_server_log )
504 {
505 SaveLog(msg);
506
507#ifdef DIAG_DEVELOPER // do not send log to clients on retail
508 Param1<string> msg_p = new Param1<string>(msg);
510#endif
511 }
512 else
513 {
514 SaveLog(msg);
515 }
516
517 return msg;
518 }
519
520 private static void SaveLog(string log_message)
521 {
522 if (log_message.Length() == 0)
523 return;
524
526#ifdef DIAG_DEVELOPER
527#ifndef SERVER
528 CachedObjectsParams.PARAM1_STRING.param1 = log_message;
530#endif
531#endif
532
534#ifdef DIAG_DEVELOPER
536#ifdef LOG_TO_FILE
537 FileHandle fileHandle = OpenFile(GetFileName(), FileMode.APPEND);
538 if (fileHandle != 0)
539 {
540 FPrintln(fileHandle, log_message);
541 CloseFile(fileHandle);
542 }
543#endif
544#endif
545
547#ifdef LOG_TO_RPT
548 PrintToRPT("" + log_message);
549#endif
550
552#ifdef LOG_TO_SCRIPT
553 Print(string.Format("%1", log_message));
554#endif
555 }
556
557 static void ClearLogs()
558 {
559 if (FileExist(GetFileName()))
560 {
561 FileHandle fileHandle = OpenFile(GetFileName(), FileMode.WRITE);
562 if (fileHandle == 0)
563 return;
564
565 FPrintln(fileHandle, "");
566 CloseFile(fileHandle);
567 }
568 }
569
570 static string GetFileName()
571 {
573 }
574
575 private static string GetDate()
576 {
577 int year;
578 int month;
579 int day;
580 int hour;
581 int minute;
582 int second;
583
584 GetYearMonthDay(year, month, day);
585 GetHourMinuteSecond(hour, minute, second);
586
587 string date = month.ToStringLen(2) + "-" + day.ToStringLen(2) + " " + hour.ToStringLen(2) + ":" + minute.ToStringLen(2) + ":" + second.ToStringLen(2);
588
589 return date;
590 }
591};
592
594{
595 static bool m_DoLogs;
596 static bool m_DoActionDebugLog;
597 static bool m_DoSymptomDebugLog;
598 static bool m_DoInventoryMoveLog;
599 static bool m_DoInventoryReservationLog;
600 static bool m_DoInventoryHFSMLog;
601 static bool m_DoSyncLog;
602 static bool m_DoQuickbarLog;
603 static bool m_DoBaseBuildingLog;
604 static bool m_DoWeaponLog;
605 static bool m_DoWeatherLog;
606 static bool m_DoBleedingChanceLog;
607
608 static void Init()
609 {
610 #ifdef ENABLE_LOGGING
611 m_DoLogs = true;
612 #else
613 m_DoLogs = IsCLIParam("doLogs");
614 #endif
615
616 m_DoActionDebugLog = IsCLIParam("doActionLog");
617 m_DoSymptomDebugLog = IsCLIParam("doSymptomLog");
618 m_DoInventoryMoveLog = IsCLIParam("doInvMoveLog");
619 m_DoInventoryReservationLog = IsCLIParam("doInvReservLog");
620 m_DoInventoryHFSMLog = IsCLIParam("doInvHFSMLog");
621 m_DoSyncLog = IsCLIParam("doSyncLog");
622 m_DoQuickbarLog = IsCLIParam("doQuickbarLog");
623 m_DoBaseBuildingLog = IsCLIParam("doBaseBuildingLog");
624 m_DoWeaponLog = IsCLIParam("doWeaponLog");
625 m_DoWeatherLog = IsCLIParam("doWeatherLog");
626 }
627
628 static bool IsLogsEnable()
629 {
630 return m_DoLogs;
631 }
632
633 static void SetLogsEnabled(bool enable)
634 {
635 m_DoLogs = enable;
636 }
637
638 static bool IsActionLogEnable()
639 {
640 return m_DoActionDebugLog;
641 }
642
643 static void ActionLogEnable(bool enable)
644 {
645 m_DoActionDebugLog = enable;
646 }
647
648 static bool IsInventoryMoveLogEnable()
649 {
650 return m_DoInventoryMoveLog;
651 }
652
653 static void InventoryMoveLogEnable(bool enable)
654 {
655 m_DoInventoryMoveLog = enable;
656 }
657
658 static bool IsInventoryReservationLogEnable()
659 {
660 return m_DoInventoryReservationLog;
661 }
662
663 static void InventoryReservationLogEnable(bool enable)
664 {
665 m_DoInventoryReservationLog = enable;
666 }
667
668 static bool IsInventoryHFSMLogEnable()
669 {
670 return m_DoInventoryHFSMLog;
671 }
672
673 static void InventoryHFSMLogEnable(bool enable)
674 {
675 m_DoInventoryHFSMLog = enable;
676 }
677
678 static bool IsSyncLogEnable()
679 {
680 return m_DoSyncLog;
681 }
682
683 static void SyncLogEnable(bool enable)
684 {
685 m_DoSyncLog = enable;
686 }
687
688 static bool IsQuickbarLogEnable()
689 {
690 return m_DoQuickbarLog;
691 }
692
693 static void QuickbarLogEnable(bool enable)
694 {
695 m_DoQuickbarLog = enable;
696 }
697
698 static bool IsBaseBuildingLogEnable()
699 {
700 return m_DoBaseBuildingLog;
701 }
702
703 static void BaseBuildingLogEnable(bool enable)
704 {
705 m_DoBaseBuildingLog = enable;
706 }
707
708 static bool IsSymptomLogEnable()
709 {
710 return m_DoSymptomDebugLog;
711 }
712
713 static void SymptomLogEnable(bool enable)
714 {
715 m_DoSymptomDebugLog = enable;
716 }
717
718 static bool IsWeaponLogEnable()
719 {
720 return m_DoWeaponLog;
721 }
722
723 static void WeaponLogEnable(bool enable)
724 {
725 m_DoWeaponLog = enable;
726 }
727
728 static bool IsWeatherLogEnabled()
729 {
730 return m_DoWeatherLog;
731 }
732
733 static bool IsBleedingChancesLogEnable()
734 {
735 return m_DoBleedingChanceLog;
736 }
737
738 static void BleedingChancesLogEnable(bool enable)
739 {
740 m_DoBleedingChanceLog = enable;
741 }
742}
743
744enum WeightDebugType
745{
746 NONE = 0,
751}
752
753class WeightDebug
754{
756 static WeightDebugType m_VerbosityFlags;
757
758 //-------------------------------------------------------------
759 static WeightDebugData GetWeightDebug(EntityAI entity)
760 {
761 if (!m_WeightDebugData.Get(entity))
762 {
763 WeightDebugData data = new WeightDebugData(entity);
764 m_WeightDebugData.Insert(entity,data);
765 return data;
766 }
767 return m_WeightDebugData.Get(entity);
768 }
769 //-------------------------------------------------------------
770 static void ClearWeightDebug()
771 {
772 m_WeightDebugData.Clear();
773 }
774 //-------------------------------------------------------------
775 static void PrintAll(EntityAI entity)
776 {
777 GameInventory inv = entity.GetInventory();
778 if (!inv)
779 return;
781 inv.EnumerateInventory(InventoryTraversalType.PREORDER, items);
782 for(int i = 0; i < items.Count(); i++)
783 {
784 EntityAI item = items.Get(i);
785 if (m_WeightDebugData.Get(item))
786 {
787 m_WeightDebugData.Get(item).Output();
788 }
789 }
790 }
791 //-------------------------------------------------------------
792 static void SetVerbosityFlags(WeightDebugType type)
793 {
794 m_VerbosityFlags = type;
795 }
796}
797
799{
800 string m_Classname;
801 string m_Weight;
802 int m_InventoryDepth;
803 string m_CalcDetails;
804 //-------------------------------------------------------------
805 void WeightDebugData(EntityAI entity)
806 {
807 m_Classname = entity.GetType();
808 m_InventoryDepth = entity.GetHierarchyLevel();
809 }
810 //-------------------------------------------------------------
811 void SetWeight(float weight)
812 {
813 m_Weight = weight.ToString();
814 }
815 //-------------------------------------------------------------
816 void SetCalcDetails(string details)
817 {
818 m_CalcDetails = details;
819 }
820
821 //-------------------------------------------------------------
822 void AddCalcDetails(string details)
823 {
824 m_CalcDetails += "+ "+details;
825 }
826 //-------------------------------------------------------------
827 void Output()
828 {
829 string spaces;
830 for(int i = 0; i < m_InventoryDepth;i++)
831 spaces+="--------";
832
833 Print(spaces+">" + m_Classname + " Overall entity weight: "+ m_Weight + " Calculation details:" + m_CalcDetails);
834 }
835 //-------------------------------------------------------------
836
837}
class LogManager RECALC_FORCED
class LogManager SET_DIRTY_FLAG
class LogManager NONE
class LogManager DUMP_STACK
class LogManager RECALC_DIRTY
class LogManager m_WeightDebugData
proto native bool IsMultiplayer()
proto native bool IsServer()
Definition debug.c:2
Definition camera.c:2
script counterpart to engine's class Inventory
Definition inventory.c:79
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
TODO doc.
Definition enscript.c:118
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override string GetDebugName()
Dispatcher GetDispatcher()
Definition dispatcher.c:20
const CallID CALL_ID_SEND_LOG
Definition dispatcher.c:3
const CallID CALL_ID_SCR_CNSL_ADD_PRINT
Definition dispatcher.c:6
Param CallMethod(CallID call_id, Param params)
Definition dispatcher.c:36
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6
proto native CGame GetGame()
const string CFG_FILE_SCRIPT_LOG_EXT
Definition constants.c:248
proto void Print(void var)
Prints content of variable to console/log.
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
ShapeType
Definition endebug.c:116
ShapeFlags
Definition endebug.c:126
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
array< string > TStringArray
Definition enscript.c:709
FileMode
Definition ensystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
int[] FileHandle
Definition ensystem.c:390
proto bool FileExist(string name)
Check existence of file.
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const string CFG_SOUND_SETS
Definition constants.c:228
const string CFG_AMMO
Definition constants.c:223
const string CFG_VEHICLESPATH
Definition constants.c:220
const string CFG_NONAI_VEHICLES
Definition constants.c:229
const string CFG_SOUND_SHADERS
Definition constants.c:227
const string CFG_SOUND_TABLES
Definition constants.c:230
const string CFG_SURFACES
Definition constants.c:225
const string CFG_WEAPONSPATH
Definition constants.c:221
const string CFG_WORLDS
Definition constants.c:224
const string CFG_MAGAZINESPATH
Definition constants.c:222
proto void GetYearMonthDay(out int year, out int month, out int day)
Returns system date.
proto void GetHourMinuteSecond(out int hour, out int minute, out int second)
Returns system time.
proto native bool IsCLIParam(string param)
Returns if command line argument is present.