Пример #1
0
        private uint OnModuleLoadProgressChange(void *pModule, int nAreasLoaded, int nAreasToLoad)
        {
            CNWSModule module = CNWSModule.FromPointer(pModule);

            int index = nAreasLoaded;
            CExoLinkedListNode node = module.m_lstModuleArea.m_pcExoLinkedListInternal.pHead;

            while (node != null && index != 0)
            {
                node = node.pNext;
                index--;
            }

            CResRef?resRef = node != null?CResRef.FromPointer(node.pObject) : null;

            if (resRef != null)
            {
                Log.Debug("Loading area {Area} ({AreaNum}/{AreaCount})", resRef.ToString(), nAreasLoaded + 1, nAreasToLoad);
            }

            uint retVal = loadModuleInProgressHook.CallOriginal(pModule, nAreasLoaded, nAreasToLoad);

            if (resRef != null)
            {
                switch (retVal)
                {
                case 0:
                    Log.Debug("Loaded area {Area} ({AreaNum}/{AreaCount})", resRef.ToString(), nAreasLoaded + 1, nAreasToLoad);
                    break;

                default:
                    Log.Error("Failed to load area {Area}, error code {ErrorCode} ({AreaNum}/{AreaCount})", resRef.ToString(), retVal, nAreasLoaded + 1, nAreasToLoad);
                    break;
                }
            }

            return(retVal);
        }
Пример #2
0
            private static void OnUpdateTime(void *pModule, uint nCalendarDay, uint nTimeOfDay, uint nUpdateDifference)
            {
                CNWSModule module   = CNWSModule.FromPointer(pModule);
                uint       hour     = module.m_nCurrentHour;
                uint       day      = module.m_nCurrentDay;
                uint       month    = module.m_nCurrentMonth;
                uint       year     = module.m_nCurrentYear;
                uint       dayState = module.m_nTimeOfDayState;

                Hook.CallOriginal(pModule, nCalendarDay, nTimeOfDay, nUpdateDifference);

                if (hour != module.m_nCurrentHour)
                {
                    ProcessEvent(new OnCalendarTimeChange
                    {
                        TimeChangeType = TimeChangeType.Hour,
                        OldValue       = hour,
                        NewValue       = module.m_nCurrentHour,
                    });
                }

                if (day != module.m_nCurrentDay)
                {
                    ProcessEvent(new OnCalendarTimeChange
                    {
                        TimeChangeType = TimeChangeType.Day,
                        OldValue       = day,
                        NewValue       = module.m_nCurrentDay,
                    });
                }

                if (month != module.m_nCurrentMonth)
                {
                    ProcessEvent(new OnCalendarTimeChange
                    {
                        TimeChangeType = TimeChangeType.Month,
                        OldValue       = month,
                        NewValue       = module.m_nCurrentMonth,
                    });
                }

                if (year != module.m_nCurrentYear)
                {
                    ProcessEvent(new OnCalendarTimeChange
                    {
                        TimeChangeType = TimeChangeType.Year,
                        OldValue       = year,
                        NewValue       = module.m_nCurrentYear,
                    });
                }

                if (dayState != module.m_nTimeOfDayState)
                {
                    ProcessEvent(new OnCalendarTimeChange
                    {
                        TimeChangeType = TimeChangeType.TimeOfDay,
                        OldValue       = dayState,
                        NewValue       = module.m_nTimeOfDayState,
                    });
                }
            }
Пример #3
0
 internal NwModule(CNWSModule module) : base(module)
 {
     Module = module;
 }