1+ #pragma once
12#ifndef SHADER_XRLC_H
23#define SHADER_XRLC_H
3- #pragma once
44
55struct Shader_xrLC
66{
@@ -57,7 +57,7 @@ class Shader_xrLC_LIB
5757public:
5858 void Load (LPCSTR name)
5959 {
60- IReader* fs = FS.r_open (name);
60+ auto fs = FS.r_open (name);
6161 if (NULL == fs)
6262 {
6363 string256 inf;
@@ -77,40 +77,43 @@ class Shader_xrLC_LIB
7777 }
7878 bool Save (LPCSTR name)
7979 {
80- IWriter* F = FS.w_open (name);
80+ auto F = FS.w_open (name);
8181 if (F)
8282 {
8383 F->w (&*library.begin (), (u32 )library.size () * sizeof (Shader_xrLC));
8484 FS.w_close (F);
8585 return true ;
8686 }
87- else
88- {
89- return false ;
90- }
87+ return false ;
9188 }
9289 void Unload () { library.clear (); }
90+
9391 u32 GetID (LPCSTR name) const
9492 {
9593 for (auto it = library.begin (); it != library.end (); it++)
9694 if (0 == stricmp (name, it->Name ))
9795 return u32 (it - library.begin ());
9896 return u32 (-1 );
9997 }
98+
10099 Shader_xrLC* Get (LPCSTR name)
101100 {
102- for (auto it = library. begin (); it != library. end (); it++ )
103- if (0 == stricmp (name, it-> Name ))
104- return &(*it) ;
105- return NULL ;
101+ for (auto & shader : library)
102+ if (0 == stricmp (name, shader. Name ))
103+ return &shader ;
104+ return nullptr ;
106105 }
107- IC Shader_xrLC* Get (int id) { return &library[id]; }
108- IC const Shader_xrLC* Get (int id) const { return &library[id]; }
106+
107+ Shader_xrLC* Get (int id) { return &library[id]; }
108+
109+ const Shader_xrLC* Get (int id) const { return &library[id]; }
110+
109111 Shader_xrLC* Append (Shader_xrLC* parent = 0 )
110112 {
111113 library.push_back (parent ? Shader_xrLC (*parent) : Shader_xrLC ());
112114 return &library.back ();
113115 }
116+
114117 void Remove (LPCSTR name)
115118 {
116119 for (auto it = library.begin (); it != library.end (); it++)
@@ -120,8 +123,11 @@ class Shader_xrLC_LIB
120123 break ;
121124 }
122125 }
126+
123127 void Remove (int id) { library.erase (library.begin () + id); }
128+
124129 Shader_xrLCVec& Library () { return library; }
130+
125131 const Shader_xrLCVec& Library () const { return library; }
126132};
127133
0 commit comments