MCPcopy Create free account
hub / github.com/demoth/jake2 / AddLateCommands

Method AddLateCommands

qcommon/src/main/java/jake2/qcommon/exec/Cbuf.java:129–170  ·  view source on GitHub ↗

Adds command line parameters as script statements Commands lead with a + and continue until another + or - quake +developer 1 +map amlev1 Returns false if any late commands were added, which will keep the demoloop from immediately starting Apply + commands (like +map) @return true if nothing was ap

(List<String> args)

Source from the content-addressed store, hash-verified

127 * @return true if nothing was applied
128 */
129 public static boolean AddLateCommands(List<String> args) {
130
131 // build the combined string to parse from
132 int length = 0;
133 int argc = args.size();
134 for (int i = 1; i < argc; i++) {
135 length += args.get(i).length();
136 }
137 if (length == 0)
138 return true;
139
140 StringBuilder text = new StringBuilder();
141 for (int i = 1; i < argc; i++) {
142 text.append(args.get(i));
143 if (i != argc - 1)
144 text.append(" ");
145 }
146
147 // pull out the commands
148 StringBuilder build = new StringBuilder();
149 for (int i = 0; i < text.length(); i++) {
150 if (text.charAt(i) == '+') {
151 i++;
152
153 int j;
154 for (j = i; j < text.length() && (text.charAt(j) != '+') && (text.charAt(j) != '-'); j++) {
155 ;
156 }
157
158 build.append(text.substring(i, j));
159 build.append("\n");
160
161 i = j - 1;
162 }
163 }
164
165 boolean isEmpty = (build.length() == 0);
166 if (!isEmpty)
167 AddText(build.toString());
168
169 return isEmpty;
170 }
171
172 /**
173 * Adds command(s) to the tail of the command buffer

Callers 2

InitMethod · 0.95
mainMethod · 0.95

Calls 4

AddTextMethod · 0.95
sizeMethod · 0.80
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected