hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
789380a3532e395712e1cff1f25aeb53f754ba6d
4,114
h
C
components/invalidation/impl/per_user_topic_registration_request.h
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
components/invalidation/impl/per_user_topic_registration_request.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
components/invalidation/impl/per_user_topic_registration_request.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_INVALIDATION_IMPL_PER_USER_TOPIC_REGISTRATION_REQUEST_H_ #define COMPONENTS_INVALIDATION_IMPL_PER_USER_TOPIC_REGISTRATION_REQUEST_H_ #include <memory> #include <string> #include <utility> #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/time/time.h" #include "components/invalidation/impl/status.h" #include "google_apis/gaia/oauth2_token_service.h" #include "net/http/http_request_headers.h" #include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" namespace syncer { using ParseJSONCallback = base::OnceCallback<void( const std::string& unsafe_json, base::OnceCallback<void(std::unique_ptr<base::Value>)> success_callback, base::OnceCallback<void(const std::string&)> error_callback)>; // A single request to register against per user topic service. class PerUserTopicRegistrationRequest { public: // The request result consists of the request status and name of the private // topic. The |private_topic_name| will be empty in the case of error. using CompletedCallback = base::OnceCallback<void(const Status& status, const std::string& private_topic_name)>; // Builds authenticated PerUserTopicRegistrationRequests. class Builder { public: Builder(); Builder(Builder&&); ~Builder(); // Builds a Request object in order to perform the registration. std::unique_ptr<PerUserTopicRegistrationRequest> Build() const; Builder& SetToken(const std::string& token); Builder& SetScope(const std::string& scope); Builder& SetAuthenticationHeader(const std::string& auth_header); Builder& SetPublicTopicName(const std::string& topic); Builder& SetProjectId(const std::string& project_id); private: net::HttpRequestHeaders BuildHeaders() const; std::string BuildBody() const; std::unique_ptr<network::SimpleURLLoader> BuildURLFetcher( const net::HttpRequestHeaders& headers, const std::string& body, const GURL& url) const; // GCM subscription token obtained from GCM driver (instanceID::getToken()). std::string token_; std::string topic_; std::string project_id_; std::string scope_; std::string auth_header_; DISALLOW_COPY_AND_ASSIGN(Builder); }; ~PerUserTopicRegistrationRequest(); // Starts an async request. The callback is invoked when the request succeeds // or fails. The callback is not called if the request is destroyed. void Start(CompletedCallback callback, ParseJSONCallback parsed_json, network::mojom::URLLoaderFactory* loader_factory); private: friend class PerUserTopicRegistrationRequestTest; PerUserTopicRegistrationRequest(); void OnURLFetchComplete(std::unique_ptr<std::string> response_body); void OnURLFetchCompleteInternal(int net_error, int response_code, std::unique_ptr<std::string> response_body); void OnJsonParseFailure(const std::string& error); void OnJsonParseSuccess(std::unique_ptr<base::Value> parsed_json); // For tests only. Returns the full URL of the request. GURL getUrl() const { return url_; } // The fetcher for subscribing. std::unique_ptr<network::SimpleURLLoader> simple_loader_; // The callback to notify when URLFetcher finished and results are available. // When the request is finished/aborted/destroyed, it's called in the dtor! CompletedCallback request_completed_callback_; // The callback for Parsing JSON. ParseJSONCallback parse_json_; // Full URL. Used in tests only. GURL url_; base::WeakPtrFactory<PerUserTopicRegistrationRequest> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(PerUserTopicRegistrationRequest); }; } // namespace syncer #endif // COMPONENTS_INVALIDATION_IMPL_PER_USER_TOPIC_REGISTRATION_REQUEST_H_
34.864407
80
0.742343
[ "object" ]
7893b800849e4ca123f727121d560259ab6cc940
1,766
h
C
Parser.h
Zemurin/commonItems
cda7c217c7b3433b61a17cd05ce8d3893b711bf7
[ "MIT" ]
7
2018-12-22T03:59:34.000Z
2021-06-10T22:42:37.000Z
Parser.h
IhateTrains/commonItems
759705dc41ff1595db9786d0a9facc0b336888c3
[ "MIT" ]
45
2018-12-04T04:51:20.000Z
2021-08-12T12:20:56.000Z
Parser.h
IhateTrains/commonItems
759705dc41ff1595db9786d0a9facc0b336888c3
[ "MIT" ]
15
2019-01-09T05:59:48.000Z
2020-08-27T09:08:09.000Z
#ifndef PARSER_H #define PARSER_H #include <functional> #include <map> #include <optional> #include <regex> namespace commonItems { typedef std::function<void(const std::string&, std::istream&)> parsingFunction; typedef std::function<void(std::istream&)> parsingFunctionStreamOnly; void absorbBOM(std::istream& theStream); class parser { public: parser() = default; ~parser() = default; parser(const parser&) = default; parser(parser&&) noexcept = default; parser& operator=(const parser&) = default; parser& operator=(parser&&) = default; void registerKeyword(const std::string& keyword, const parsingFunctionStreamOnly& function); void registerKeyword(const std::string& keyword, const parsingFunction& function); // for the few keywords that need to be returned void registerRegex(const std::string& keyword, const parsingFunction& function); void clearRegisteredKeywords() noexcept; void parseStream(std::istream& theStream); void parseFile(std::string_view filename); std::optional<std::string> getNextToken(std::istream& theStream); static std::optional<std::string> getNextTokenWithoutMatching(std::istream& theStream); private: inline bool tryToMatchAgainstKeywords(const std::string& toReturn, const std::string& strippedLexeme, bool isLexemeQuoted, std::istream& theStream); inline bool tryToMatchAgainstRegexes(const std::string& toReturn, const std::string& strippedLexeme, bool isLexemeQuoted, std::istream& theStream); std::map<std::string, parsingFunctionStreamOnly> registeredKeywordStringsStreamOnly; std::map<std::string, parsingFunction> registeredKeywordStrings; std::vector<std::pair<std::regex, parsingFunction>> generatedRegexes; }; } // namespace commonItems #endif // PARSER_H
27.169231
132
0.762741
[ "vector" ]
78a6d7d1a77f530b08dbcd898e03166deb61bf04
4,771
h
C
World/Core/EventBus.h
ishellstrike/MinecraftLike
95e060d3f0b2070d603053801f8fd26a2cffc1f7
[ "MIT" ]
null
null
null
World/Core/EventBus.h
ishellstrike/MinecraftLike
95e060d3f0b2070d603053801f8fd26a2cffc1f7
[ "MIT" ]
null
null
null
World/Core/EventBus.h
ishellstrike/MinecraftLike
95e060d3f0b2070d603053801f8fd26a2cffc1f7
[ "MIT" ]
null
null
null
#pragma once #include <map> #include <memory> #include <vector> #include <boost/format.hpp> #include <glm/glm.hpp> #include <core/Sector.h> #include <core/GameObject.h> #include <Core/orders/OrderBus.h> #include "IngameTime.h" //#include <glm/gtx/string_cast.hpp> using PEvent = std::shared_ptr<class Event>; class Event { public: virtual ~Event() {} template <typename T_> inline static size_t Idfor() { static size_t result(Nextid()); return result; } virtual size_t GetId() const { return -1; } virtual boost::optional<glm::vec3> GetPos() { return {}; } virtual std::string to_string() const { return "unimplemented event. id = " + std::to_string(GetId()); } private: static size_t Nextid() { static size_t next_id(0); return next_id++; } }; template<typename T> struct NumberedEvent : public Event { size_t GetId() const override final { return Idfor<T>(); } }; struct EventSound : public NumberedEvent<EventSound> { }; struct EventOrderStart : public NumberedEvent<EventOrderStart> { EventOrderStart(POrder p) : ord(p) {} POrder ord; }; struct EventOrderDone : public NumberedEvent<EventOrderDone> { EventOrderDone(POrder p) : ord(p) {} POrder ord; std::string to_string() const override { return (boost::format("EventOrderDone: ord = %1%") % ord->to_string()).str(); } }; struct EventOrderCancel : public NumberedEvent<EventOrderCancel> { EventOrderCancel(POrder p) : ord(p) {} POrder ord; std::string to_string() const override { return (boost::format("EventOrderCancel: ord = %1%") % ord->to_string()).str(); } }; struct EventOrderDrop : public NumberedEvent<EventOrderDrop> { EventOrderDrop(POrder p) : ord(p) {} POrder ord; std::string to_string() const override { return (boost::format("EventOrderDrop: ord = %1%") % ord->to_string()).str(); } }; struct EventSectorReady : public NumberedEvent<EventOrderStart> { EventSectorReady(std::shared_ptr<Sector> p) : sec(p) {} std::shared_ptr<Sector> sec; std::string to_string() const override { return (boost::format("EventSectorReady: sec = {%1%,%2%,%3%}") % sec->GetPos().x % sec->GetPos().y % sec->GetPos().z).str(); } }; struct EventMapReady : public NumberedEvent<EventMapReady> { EventMapReady() { } std::string to_string() const override { return (boost::format("EventMapReady:")).str(); } }; struct EventCreatureSpawn : public NumberedEvent<EventCreatureSpawn> { EventCreatureSpawn(PGameObject p) : obj(p) {} PGameObject obj; std::string to_string() const override { return (boost::format("EventCreatureSpawn: obj = %1%") % obj->GetId()).str(); } }; struct EventCreatureDeath : public NumberedEvent<EventCreatureDeath> { EventCreatureDeath(PGameObject p) : obj(p) {} PGameObject obj; WPos pos; std::string to_string() const override { return (boost::format("EventCreatureDeath: obj = %1% pos = ") % obj->GetId()).str(); } }; struct EventItemPlace : public NumberedEvent<EventItemPlace> { EventItemPlace(PGameObject p) : obj(p) {} PGameObject obj; std::string to_string() const override { return (boost::format("EventCreatureSpawn: obj = %1%") % obj->GetId()).str(); } }; struct EventNewDay : public NumberedEvent<EventNewDay> { EventNewDay(IngameDate date) : it(date) {} IngameDate it; std::string to_string() const override { return (boost::format("EventNewDay: %1%") % IngameDateToString(it)).str(); } }; struct EventNewMonth : public NumberedEvent<EventNewMonth> { EventNewMonth(IngameDate date) : it(date) {} IngameDate it; std::string to_string() const override { return (boost::format("EventNewMonth: %1%") % IngameDateToString(it)).str(); } }; struct EventNewYear : public NumberedEvent<EventNewYear> { EventNewYear(IngameDate date) : it(date) {} IngameDate it; std::string to_string() const override { return (boost::format("EventNewYear: %1%") % IngameDateToString(it)).str(); } }; class EventBus { public: void Update() { channels = back_channels; back_channels.clear(); } template<typename _Ty> const std::vector<std::shared_ptr<Event>> &ListenChannel() { return channels[Event::Idfor<_Ty>()]; } template<> const std::vector<std::shared_ptr<Event>> &ListenChannel<Event>() { static std::vector<std::shared_ptr<Event>> all; all.clear(); for (const auto &e : channels) { all.insert(all.begin(), e.second.begin(), e.second.end()); } return all; } template<typename _Ty, typename ... _Types> void Publish(_Types&& ... _Args) { back_channels[Event::Idfor<_Ty>()].push_back(std::make_shared<_Ty>(std::forward<_Types>(_Args)...)); } static EventBus &Get() { static EventBus instance; return instance; } private: std::map<size_t, std::vector<std::shared_ptr<Event>>> back_channels, channels; };
19.879167
126
0.690421
[ "vector" ]
78acef925f81816f8083f124f48404c22d64bd7b
3,944
h
C
src/MumbleKit/MKTextMessage.h
mkrautz/mumblekit
651fc584b9f9a075b487e0ac93130f33404acdaf
[ "BSD-3-Clause" ]
1
2017-05-17T00:18:06.000Z
2017-05-17T00:18:06.000Z
src/MumbleKit/MKTextMessage.h
mkrautz/mumblekit
651fc584b9f9a075b487e0ac93130f33404acdaf
[ "BSD-3-Clause" ]
null
null
null
src/MumbleKit/MKTextMessage.h
mkrautz/mumblekit
651fc584b9f9a075b487e0ac93130f33404acdaf
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (C) 2009-2012 Mikkel Krautz <mikkel@krautz.dk> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Mumble Developers nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @interface MKTextMessage : NSObject /** * Create a new MKTextMessage with the plain text representation given in * msg. * * @param msg The plain text version of the text message. * * @returns Returns a MKTextMessage object that can be sent using an * MKServerModel. */ + (MKTextMessage *) messageWithPlainText:(NSString *)msg; /** * Create a new MKTextMessage with HTML representation given in html. * * @param msg The HTML representing the text message. * * @returns Returns a MKTextMessage object that can be sent using an * MKServerModel. */ + (MKTextMessage *) messageWithHTML:(NSString *)html; /** * Create a new MKTextMessage with the given string. The internal representation * is chosen depending on the content of the message. * * @param str A string representing the message to create. This string can be either * a plain text string, or an HTML string. MKTextMessage will detect this * itself and handle the message accordingly. * * @returns Returns a MKTextMessage object that can be sent using an * MKServerModel. */ + (MKTextMessage *) messageWithString:(NSString *)str; /** * Returns the text message represented in plain text. If the message was * an HTML formatted message, the formatting will be stripped, and a plain * text string will be returned. * * @returns A plain text representation of the text message. If the message * has a plain text representation, that is returned. If the message * is an HTML message, it will be lossily converted to plain text. */ - (NSString *) plainTextString; /** * Returns an HTML representation of the text message. * * @returns Returns an HTML version of the text message. If there is no HTML * version, a plain text version is returned. */ - (NSString *) HTMLString; /** * Returns all links found in the text message. * * @returns Returns an NSArray of NSStrings corresponding to the href attributes of any a tags * found in the text message. */ - (NSArray *) embeddedLinks; /** * Returns all embedded images found in the text message. (Only images with data URIs are * considered valid). * * @returns Returns an NSArray of all images found in the text message. The images are * represented as data URIs. */ - (NSArray *) embeddedImages; @end
37.923077
94
0.729462
[ "object" ]
78bf826add534fee3218954f9b67e1e176ff8e9e
1,744
h
C
components/autofill_assistant/browser/web/js_snippets.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
components/autofill_assistant/browser/web/js_snippets.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
components/autofill_assistant/browser/web/js_snippets.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_JS_SNIPPETS_H_ #define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_JS_SNIPPETS_H_ #include <string> #include <vector> namespace autofill_assistant { // A piece of JavaScript code that might by generated dynamically. class JsSnippet { public: JsSnippet(); ~JsSnippet(); // Return the JavaScript snippet as a string std::string ToString() const; // Adds a line of JavaScript code to snippet. // // IMPORTANT: Only pass strings that originate from hardcoded strings to this // method. void AddLine(const std::string& line); // Adds a single line of Javascript code to snippet. // // The line can be built from multiple string pieces; they'll be concatenated // together. // // IMPORTANT: Only pass strings that originate from hardcoded strings to this // method. void AddLine(const std::vector<std::string>& line); private: std::vector<std::string> lines_; }; // Append JavaScript code to |snippet| that checks if |element_var| is on top. // // The JavaScript snippet returns |on_top| if the element is on top, // |not_on_top| if its center is covered by some other element, or |not_in_view| // if the element is not in the viewport. void AddReturnIfOnTop(JsSnippet* out, const std::string& element_var, const std::string& on_top, const std::string& not_on_top, const std::string& not_in_view); } // namespace autofill_assistant #endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_JS_SNIPPETS_H_
32.296296
80
0.713876
[ "vector" ]
78c1f5f56a787c0cb4321ff7865583a9aca56929
8,976
c
C
src/system.c
herrecito/engine
42dc0288068ac7d215cc5c96d59299c60ea43a49
[ "Unlicense" ]
11
2015-07-29T08:07:20.000Z
2019-07-11T14:20:59.000Z
src/system.c
herrecito/engine
42dc0288068ac7d215cc5c96d59299c60ea43a49
[ "Unlicense" ]
2
2017-05-27T22:00:03.000Z
2020-12-27T17:48:55.000Z
src/system.c
herrecito/engine
42dc0288068ac7d215cc5c96d59299c60ea43a49
[ "Unlicense" ]
null
null
null
#define GLEW_STATIC #include <GL/glew.h> #include <SDL.h> #include <SDL_image.h> #include "geometry.h" #include "buffer.h" #include "system.h" #include "dbg.h" static const char *vertexSource = "#version 330 core\n" "\n" "in vec2 position;\n" "in vec2 texcoord;\n" "\n" "out vec3 Color;\n" "out vec2 Texcoord;\n" "\n" "void main() {\n" " Texcoord = texcoord;\n" " gl_Position = vec4(position, 0.0, 1.0);\n" "}"; static const char *fragmentSource = "#version 330 core\n" "\n" "in vec2 Texcoord;\n" "\n" "out vec4 outColor;\n" "\n" "uniform sampler2D tex;\n" "\n" "void main() {\n" " outColor = texture(tex, Texcoord);\n" "}"; static SDL_Window *window; static SDL_GLContext glcontext; // Flags static int resizef; void S_Fullscreen(int flag) { if (flag) { SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } else { SDL_SetWindowFullscreen(window, 0); } } void S_GrabMouse(int flag) { SDL_SetRelativeMouseMode(flag); } int HandleResize(void *userdata, SDL_Event *ev) { if (ev->type == SDL_WINDOWEVENT) { if (ev->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { resizef = 1; } } return 0; // Ignored } void S_Init(const char *title, int width, int height) { SDL_Init(SDL_INIT_VIDEO); IMG_Init(IMG_INIT_PNG); // Core-Profile OpenGL 3.3 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); // Create window and OpenGL Context window = SDL_CreateWindow( title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL ); glcontext = SDL_GL_CreateContext(window); // Handle resize events SDL_AddEventWatch(HandleResize, NULL); // Disable vsync SDL_GL_SetSwapInterval(0); // Init GLEW glewExperimental = GL_TRUE; glewInit(); // Quad vertices ... float vertices[] = { // Position Texcoords -1, 1, 0, 0, // Top-left 1, 1, 1, 0, // Top-right 1, -1, 1, 1, // Bottom-right -1, -1, 0, 1, // Bottom-left }; // ... elements ... GLuint elements[] = { 0, 1, 2, 2, 3, 0, }; // ... and texture GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); // Vertex Array Object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); // Vertex Buffer Object GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); // Element Buffer Object GLuint ebo; glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW); // Shaders GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexSource, NULL); glCompileShader(vertexShader); GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentSource, NULL); glCompileShader(fragmentShader); GLuint shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glLinkProgram(shaderProgram); glUseProgram(shaderProgram); glDeleteShader(vertexShader); glDeleteShader(fragmentShader); // Vertex attributes GLint posAttrib = glGetAttribLocation(shaderProgram, "position"); glEnableVertexAttribArray(posAttrib); glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); GLint texAttrib = glGetAttribLocation(shaderProgram, "texcoord"); glEnableVertexAttribArray(texAttrib); glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(2 * sizeof(float))); // Clear with black glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); } void S_Quit() { SDL_GL_DeleteContext(glcontext); IMG_Quit(); SDL_Quit(); } Tick S_GetTick() { static int fwd, strafe, turn; Tick t = {0}; SDL_GetRelativeMouseState(&t.relative_mouse_x, NULL); SDL_Event ev; while (SDL_PollEvent(&ev)) { switch (ev.type) { case SDL_KEYDOWN: switch (ev.key.keysym.sym) { case SDLK_UP: case 'w': fwd = 1; break; case SDLK_DOWN: case 's': fwd = -1; break; case 'a': strafe= -1; break; case 'h': case SDLK_LEFT: turn = -1; break; case 'd': strafe = 1; break; case 'l': case SDLK_RIGHT: turn = 1; break; case 'q': exit(0); } break; case SDL_KEYUP: switch (ev.key.keysym.sym) { case SDLK_UP: case SDLK_DOWN: case 'w': case 's': fwd = 0; break; case 'a': case 'd': strafe = 0; break; case 'h': case 'l': case SDLK_RIGHT: case SDLK_LEFT: turn = 0; break; } break; case SDL_QUIT: exit(0); break; } } t.forward = fwd; t.strafe = strafe; t.turn = turn; return t; } uint32_t S_Blit(Buffer *buf) { uint32_t start = S_GetTime(); if (resizef) { resizef = 0; int winwidth, winheight; SDL_GetWindowSize(window, &winwidth, &winheight); glViewport(0, 0, winwidth, winheight); } glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGBA, GL_UNSIGNED_BYTE, buf->pixels ); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); SDL_GL_SwapWindow(window); return S_GetTime() - start; } Vector S_GetMousePos(Buffer *buf) { int mx, my; SDL_GetMouseState(&mx, &my); int winwidth, winheight; SDL_GetWindowSize(window, &winwidth, &winheight); return (Vector){ mx * buf->width / winwidth, my * buf->height / winheight }; } // http://sdl.beuc.net/sdl.wiki/Pixel_Access uint32_t GetPixel(SDL_Surface *surface, int x, int y) { int bpp = surface->format->BytesPerPixel; // Here p is the address to the pixel we want to retrieve. uint8_t *p = (uint8_t *)surface->pixels + y * surface->pitch + x * bpp; switch (bpp) { case 1: return *p; break; case 2: return *(uint16_t *)p; break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { return p[0] << 16 | p[1] << 8 | p[2]; } else { return p[0] | p[1] << 8 | p[2] << 16; } break; case 4: return *(uint32_t *)p; break; default: return 0; // shouldn't happen, but avoids warnings. } } Buffer *S_LoadImage(const char *path) { SDL_Surface *tex_surf = IMG_Load(path); check(tex_surf, "Error loading texture. IMG_GetError(): %s\n", IMG_GetError()); Buffer *t = B_CreateBuffer(tex_surf->w, tex_surf->h); for (int y = 0; y < tex_surf->h; y++) { for (int x = 0; x < tex_surf->w; x++) { uint32_t pixel = GetPixel(tex_surf, x, y); uint8_t red, green, blue; SDL_GetRGB(pixel, tex_surf->format, &red, &green, &blue); t->pixels[y * t->width + x] = BUILDRGB(red, green, blue); } } SDL_FreeSurface(tex_surf); return t; } uint32_t S_GetTime() { return SDL_GetTicks(); } void S_Sleep(uint32_t ms) { SDL_Delay(ms); }
24.259459
80
0.549242
[ "geometry", "object", "vector" ]
78c3d5b1b4c41e78e03853d566c18a52d443fcec
2,555
h
C
Tuvok/Renderer/GL/GLHashTable.h
JensDerKrueger/ImageVis3D
699ab32132c899b7ea227bc87a9de80768ab879f
[ "MIT" ]
null
null
null
Tuvok/Renderer/GL/GLHashTable.h
JensDerKrueger/ImageVis3D
699ab32132c899b7ea227bc87a9de80768ab879f
[ "MIT" ]
null
null
null
Tuvok/Renderer/GL/GLHashTable.h
JensDerKrueger/ImageVis3D
699ab32132c899b7ea227bc87a9de80768ab879f
[ "MIT" ]
null
null
null
#pragma once #ifndef GLHASHTABLE_H #define GLHASHTABLE_H #include "StdTuvokDefines.h" #include "GLObject.h" #include "Basics/Vectors.h" #include <memory> #include <string> //#define GLHASHTABLE_PROFILE // adds some glFinish() commands all over the place namespace tuvok { class GLTexture; class GLHashTable : public GLObject { public: GLHashTable(const UINTVECTOR3& maxBrickCount, uint32_t iTableSize=509, uint32_t iRehashCount=10, bool bUseGLCore=true, std::string const& strPrefixName = ""); virtual ~GLHashTable(); void InitGL(); // might throw void FreeGL(); std::string GetShaderFragment(uint32_t iMountPoint=0); void Enable(); std::vector<UINTVECTOR4> GetData(); std::string const& GetPrefixName() const { return m_strPrefixName; } void ClearData(); virtual uint64_t GetCPUSize() const; virtual uint64_t GetGPUSize() const; private: std::string m_strPrefixName; UINTVECTOR3 m_maxBrickCount; uint32_t m_iTableSize; uint32_t m_iRehashCount; GLTexture* m_pHashTableTex; UINTVECTOR2 m_texSize; std::shared_ptr<uint32_t> m_pRawData; bool m_bUseGLCore; uint32_t m_iMountPoint; UINTVECTOR4 Int2Vector(uint32_t index) const; bool Is2DTexture() const; }; } #endif // GLHASHTABLE_H /* The MIT License Copyright (c) 2012 Interactive Visualization and Data Analysis Group, Saarland University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
32.75641
163
0.72407
[ "vector" ]
78ccf05b248738d177df0cdb8edb93ff5e515ec7
22,310
h
C
source/cosa/include/ansc_tmo_interface.h
lgirdk/ccsp-common-library
8d912984e96f960df6dadb4b0e6bc76c76376776
[ "Apache-2.0" ]
4
2018-02-26T05:41:14.000Z
2019-12-20T07:31:39.000Z
source/cosa/include/ansc_tmo_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
null
null
null
source/cosa/include/ansc_tmo_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
3
2017-07-30T15:35:16.000Z
2020-08-18T20:44:08.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ /********************************************************************** module: ansc_tmo_interface.h For Advanced Networking Service Container (ANSC), BroadWay Service Delivery System --------------------------------------------------------------- description: This wrapper file defines the base class data structure and interface for the Ansc Trunk Manager Objects. --------------------------------------------------------------- environment: platform independent --------------------------------------------------------------- author: Xuechen Yang --------------------------------------------------------------- revision: 08/01/01 initial revision. **********************************************************************/ #ifndef _ANSC_TMO_INTERFACE_ #define _ANSC_TMO_INTERFACE_ /*********************************************************** GENERAL ANSC TRUNK MANAGER OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMO_CREATE) ( ANSC_HANDLE hOwnerContext ); typedef ANSC_STATUS (*PFN_ANSCTMO_REMOVE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ANSCTMO_RESET) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_ANSCTMO_GET_TRUNK) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hCircuit ); typedef ANSC_STATUS (*PFN_ANSCTMO_ADD_TRUNK) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); typedef ANSC_STATUS (*PFN_ANSCTMO_DEL_TRUNK) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); typedef ANSC_STATUS (*PFN_ANSCTMO_DEL_ALL_TRUNKS) ( ANSC_HANDLE hThisObject ); /* * The Component Objects are the extensions to the basic container. Any software module that is * shared between two or more extension objects or controller objects shall be implemented as a * Container Object. The container itself actually can leverage some of functionalities provided * by the Container Objects. */ #define ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ SINGLE_LINK_ENTRY Linkage; \ ANSC_HANDLE hOwnerContext; \ \ PFN_ANSCTMO_CREATE Create; \ PFN_ANSCTMO_REMOVE Remove; \ PFN_ANSCTMO_RESET Reset; \ \ PFN_ANSCTMO_GET_TRUNK GetTrunk; \ PFN_ANSCTMO_ADD_TRUNK AddTrunk; \ PFN_ANSCTMO_DEL_TRUNK DelTrunk; \ PFN_ANSCTMO_DEL_ALL_TRUNKS DelAllTrunks; \ /* end of object class content */ \ typedef struct _ANSC_TRUNK_MANAGER_OBJECT { ANSC_TRUNK_MANAGER_CLASS_CONTENT } ANSC_TRUNK_MANAGER_OBJECT, *PANSC_TRUNK_MANAGER_OBJECT; #define ACCESS_ANSC_TRUNK_MANAGER_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TRUNK_MANAGER_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER IPV4 OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ #define ANSC_TMO_IP4_SORTING_SRC_DST 0x00000001 #define ANSC_TMO_IP4_SORTING_DST_SRC 0x00000002 /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOIP4O_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); typedef ULONG (*PFN_ANSCTMOIP4O_GET_GRAMMAR) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ANSCTMOIP4O_SET_GRAMMAR) ( ANSC_HANDLE hThisObject, ULONG grammar ); /* * Searching an address pair is much harder than searching a single address among a number of IP * address pools, which usually consists of address subnet pools and range pools. For this type * search, we usually devide the searching into two steps: first we identify the most matched pool * for either the source or destination address, then search another address within a much smaller * number of pools. So a hierarchical structure is needed. */ #define ANSC_TMO_IP4_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ ULONG SortingGrammar; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOIP4O_EXTRACT_POOL ExtractSrcAddrPool; \ PFN_ANSCTMOIP4O_EXTRACT_POOL ExtractDstAddrPool; \ \ PFN_ANSCTMOIP4O_GET_GRAMMAR GetSortingGrammar; \ PFN_ANSCTMOIP4O_SET_GRAMMAR SetSortingGrammar; \ /* end of object class content */ \ typedef struct _ANSC_TMO_IP4_OBJECT { ANSC_TMO_IP4_CLASS_CONTENT } ANSC_TMO_IP4_OBJECT, *PANSC_TMO_IP4_OBJECT; #define ACCESS_ANSC_TMO_IP4_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_IP4_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER TCP OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ #define ANSC_TMO_TCP_SORTING_SRC_DST 0x00000001 #define ANSC_TMO_TCP_SORTING_DST_SRC 0x00000002 /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOTCPO_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); typedef ULONG (*PFN_ANSCTMOTCPO_GET_GRAMMAR) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ANSCTMOTCPO_SET_GRAMMAR) ( ANSC_HANDLE hThisObject, ULONG grammar ); /* * Searching a port number pair is much harder than searching a single port among a number of Tcp * port number pools, which usually consists of port number range pools. For this type, we usually * devide the searching into two steps: first we identify the most matched pool for either the * source or destination port number, then search another address within a much smaller number of * pools. So a hierarchical structure is needed. */ #define ANSC_TMO_TCP_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ ULONG SortingGrammar; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOTCPO_EXTRACT_POOL ExtractSrcAddrPool; \ PFN_ANSCTMOTCPO_EXTRACT_POOL ExtractDstAddrPool; \ \ PFN_ANSCTMOTCPO_GET_GRAMMAR GetSortingGrammar; \ PFN_ANSCTMOTCPO_SET_GRAMMAR SetSortingGrammar; \ /* end of object class content */ \ typedef struct _ANSC_TMO_TCP_OBJECT { ANSC_TMO_TCP_CLASS_CONTENT } ANSC_TMO_TCP_OBJECT, *PANSC_TMO_TCP_OBJECT; #define ACCESS_ANSC_TMO_TCP_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_TCP_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER UDP OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ #define ANSC_TMO_UDP_SORTING_SRC_DST 0x00000001 #define ANSC_TMO_UDP_SORTING_DST_SRC 0x00000002 /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOUDPO_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); typedef ULONG (*PFN_ANSCTMOUDPO_GET_GRAMMAR) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ANSCTMOUDPO_SET_GRAMMAR) ( ANSC_HANDLE hThisObject, ULONG grammar ); /* * Searching a port number pair is much harder than searching a single port among a number of Tcp * port number pools, which usually consists of port number range pools. For this type, we usually * devide the searching into two steps: first we identify the most matched pool for either the * source or destination port number, then search another address within a much smaller number of * pools. So a hierarchical structure is needed. */ #define ANSC_TMO_UDP_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ ULONG SortingGrammar; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOUDPO_EXTRACT_POOL ExtractSrcAddrPool; \ PFN_ANSCTMOUDPO_EXTRACT_POOL ExtractDstAddrPool; \ \ PFN_ANSCTMOUDPO_GET_GRAMMAR GetSortingGrammar; \ PFN_ANSCTMOUDPO_SET_GRAMMAR SetSortingGrammar; \ /* end of object class content */ \ typedef struct _ANSC_TMO_UDP_OBJECT { ANSC_TMO_UDP_CLASS_CONTENT } ANSC_TMO_UDP_OBJECT, *PANSC_TMO_UDP_OBJECT; #define ACCESS_ANSC_TMO_UDP_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_UDP_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER ESP OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOESPO_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); /* * Searching a port number pair is much harder than searching a single port among a number of Tcp * port number pools, which usually consists of port number range pools. For this type, we usually * devide the searching into two steps: first we identify the most matched pool for either the * source or destination port number, then search another address within a much smaller number of * pools. So a hierarchical structure is needed. */ #define ANSC_TMO_ESP_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOESPO_EXTRACT_POOL ExtractAddrPool; \ /* end of object class content */ \ typedef struct _ANSC_TMO_ESP_OBJECT { ANSC_TMO_ESP_CLASS_CONTENT } ANSC_TMO_ESP_OBJECT, *PANSC_TMO_ESP_OBJECT; #define ACCESS_ANSC_TMO_ESP_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_ESP_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER AH OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOAHO_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); /* * Searching a port number pair is much harder than searching a single port among a number of Tcp * port number pools, which usually consists of port number range pools. For this type, we usually * devide the searching into two steps: first we identify the most matched pool for either the * source or destination port number, then search another address within a much smaller number of * pools. So a hierarchical structure is needed. */ #define ANSC_TMO_AH_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOAHO_EXTRACT_POOL ExtractAddrPool; \ /* end of object class content */ \ typedef struct _ANSC_TMO_AH_OBJECT { ANSC_TMO_AH_CLASS_CONTENT } ANSC_TMO_AH_OBJECT, *PANSC_TMO_AH_OBJECT; #define ACCESS_ANSC_TMO_AH_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_AH_OBJECT, Linkage) /*********************************************************** ANSC TRUNK MANAGER IPCOMP OBJECT DEFINITION ***********************************************************/ /* * Define some const values that will be used in the container object definition. */ /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ANSCTMOIPCOMPO_EXTRACT_POOL) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hTrunk ); /* * Searching a port number pair is much harder than searching a single port among a number of Tcp * port number pools, which usually consists of port number range pools. For this type, we usually * devide the searching into two steps: first we identify the most matched pool for either the * source or destination port number, then search another address within a much smaller number of * pools. So a hierarchical structure is needed. */ #define ANSC_TMO_IPCOMP_CLASS_CONTENT \ /* duplication of the base object class content */ \ ANSC_TRUNK_MANAGER_CLASS_CONTENT \ /* start of object class content */ \ ANSC_HANDLE hAddrPoolManager; \ \ QUEUE_HEADER TrunkQueue; \ ANSC_LOCK TrunkQueueLock; \ \ PFN_ANSCTMOIPCOMPO_EXTRACT_POOL ExtractAddrPool; \ /* end of object class content */ \ typedef struct _ANSC_TMO_IPCOMP_OBJECT { ANSC_TMO_IPCOMP_CLASS_CONTENT } ANSC_TMO_IPCOMP_OBJECT, *PANSC_TMO_IPCOMP_OBJECT; #define ACCESS_ANSC_TMO_IPCOMP_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_TMO_IPCOMP_OBJECT, Linkage) #endif
42.903846
99
0.48216
[ "object" ]
78ce7e65b659fa3ffdee99d5ef9f34744e0cb686
507
h
C
botctl/bot/types/include/poll_answer.h
culitz/botctl
3201b82aa00b6eb20396f18c45008b777d67f2f5
[ "MIT" ]
null
null
null
botctl/bot/types/include/poll_answer.h
culitz/botctl
3201b82aa00b6eb20396f18c45008b777d67f2f5
[ "MIT" ]
null
null
null
botctl/bot/types/include/poll_answer.h
culitz/botctl
3201b82aa00b6eb20396f18c45008b777d67f2f5
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include "base_object.h" #include "user.h" #include "fields.h" namespace bot::types { class PollAnswer : public BaseObject { public: string poll_id; User user; std::vector<int> option_ids; PollAnswer(); PollAnswer(string&); PollAnswer(Value const&); virtual ~PollAnswer(); protected: virtual void fillDocument(Writer& writer) const override; virtual void fillObject(rapidjson::Value const& document) override; }; }
16.9
54
0.672584
[ "vector" ]
78cf2e74c9d8046219aa7603c87b5959fed80e83
582
h
C
src/passenger.h
mesflores/capacity-r
123b8e7515237027ce756a6ba034466a4732a9d4
[ "BSD-3-Clause" ]
2
2018-12-16T20:41:39.000Z
2018-12-28T02:30:47.000Z
src/passenger.h
mesflores/capacity-r
123b8e7515237027ce756a6ba034466a4732a9d4
[ "BSD-3-Clause" ]
3
2020-02-03T01:44:48.000Z
2020-04-26T22:20:40.000Z
src/passenger.h
mesflores/capacity
123b8e7515237027ce756a6ba034466a4732a9d4
[ "BSD-3-Clause" ]
null
null
null
// passenger.h // type definitions for the passenger object #ifndef _passenger_h #define _passenger_h typedef enum { UNINIT, WAIT, RIDE, TRANSFER } passenger_state; typedef struct passenger_t { int start; // Station ID of start int dest; // Station ID of destination float time; // Last recorded event passenger_state state; // Current state of passenger // next one in the list struct passenger_t* next; } passenger_t; passenger_t* create_passenger(int start, int dest, float time); int should_board(passenger_t* curr_pass); #endif
18.774194
63
0.713058
[ "object" ]
78e0947d1eed2b454a4e6584627d3f95ae29d558
31,498
c
C
libcore/certtools.c
levush/hipl
36e578a237a7ab27fabfe145fa4a8021ee08ca46
[ "BSD-2-Clause" ]
null
null
null
libcore/certtools.c
levush/hipl
36e578a237a7ab27fabfe145fa4a8021ee08ca46
[ "BSD-2-Clause" ]
null
null
null
libcore/certtools.c
levush/hipl
36e578a237a7ab27fabfe145fa4a8021ee08ca46
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2010 Aalto University and RWTH Aachen University. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ /** * @file * certificate building and verification functions to use with HIP */ #include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <openssl/bn.h> #include <openssl/conf.h> #include <openssl/dsa.h> #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/rsa.h> #include <openssl/safestack.h> #include "crypto.h" #include "debug.h" #include "ife.h" #include "message.h" #include "prefix.h" #include "straddr.h" #include "certtools.h" /******************************************************************************* * FUNCTIONS FOR SPKI * *******************************************************************************/ /** * Function that verifies the signature in * the given SPKI cert sent by the "client" * * @param cert points to hip_cert_spki_info that is going to be verified * * @return 0 if signature matches, -1 if error or signature did NOT match * * @note see hip_cert_spki_char2certinfo to convert from wire to hip_cert_spki_info */ int hip_cert_spki_lib_verify(struct hip_cert_spki_info *cert) { int err = 0, start = 0, stop = 0, evpret = 0, keylen = 0, algo = 0; char buf[200]; unsigned char sha_digest[21]; unsigned char *sha_retval; unsigned char *signature_hash = NULL; unsigned char *signature_hash_b64 = NULL; unsigned char *signature_b64 = NULL; unsigned char *signature = NULL; /** RSA */ RSA *rsa = NULL; unsigned long e_code; char *e_hex = NULL; unsigned char *modulus_b64 = NULL; unsigned char *modulus = NULL; /** DSA */ DSA *dsa = NULL; unsigned char *p_bin = NULL, *q_bin = NULL, *g_bin = NULL, *y_bin = NULL; unsigned char *p_b64 = NULL, *q_b64 = NULL, *g_b64 = NULL, *y_b64 = NULL; DSA_SIG *dsa_sig; /* rules for regular expressions */ /* * Rule to get the info if we are using DSA */ char dsa_rule[] = "[d][s][a][-][p][k][c][s][1][-][s][h][a][1]"; /* * Rule to get the info if we are using RSA */ char rsa_rule[] = "[r][s][a][-][p][k][c][s][1][-][s][h][a][1]"; /* * Rule to get DSA p * Look for pattern "(p |" and stop when first "|" * anything in base 64 is accepted inbetween */ char p_rule[] = "[(][p][ ][|][[A-Za-z0-9+/()#=-]*[|]"; /* * Rule to get DSA q * Look for pattern "(q |" and stop when first "|" * anything in base 64 is accepted inbetween */ char q_rule[] = "[(][q][ ][|][[A-Za-z0-9+/()#=-]*[|]"; /* * Rule to get DSA g * Look for pattern "(g |" and stop when first "|" * anything in base 64 is accepted inbetween */ char g_rule[] = "[(][g][ ][|][[A-Za-z0-9+/()#=-]*[|]"; /* * Rule to get DSA y / pub_key * Look for pattern "(y |" and stop when first "|" * anything in base 64 is accepted inbetween */ char y_rule[] = "[(][y][ ][|][[A-Za-z0-9+/()#=-]*[|]"; /* * rule to get the public exponent RSA * Look for the part that says # and after that some hex blob and # */ char e_rule[] = "[#][0-9A-Fa-f]*[#]"; /* * rule to get the public modulus RSA * Look for the part that starts with '|' and after that anything * that is in base 64 char set and then '|' again */ char n_rule[] = "[|][A-Za-z0-9+/()#=-]*[|]"; /* * rule to get the signature hash * Look for the similar than the n_rule */ char h_rule[] = "[|][A-Za-z0-9+/()#=-]*[|]"; /* * rule to get the signature * Look for part that starts ")|" and base 64 blob after it * and stops to '|' char remember to add and subtract 2 from * the indexes below */ char s_rule[] = "[)][|][A-Za-z0-9+/()#=-]*[|]"; /* check the algo DSA or RSA */ HIP_DEBUG("Verifying\nRunning regexps to identify algo\n"); start = stop = 0; algo = hip_cert_regex(dsa_rule, cert->public_key, &start, &stop); if (algo != -1) { HIP_DEBUG("Public-key is DSA\n"); algo = HIP_HI_DSA; goto algo_check_done; } start = stop = 0; algo = hip_cert_regex(rsa_rule, cert->public_key, &start, &stop); if (algo != -1) { HIP_DEBUG("Public-key is RSA\n"); algo = HIP_HI_RSA; goto algo_check_done; } HIP_DEBUG((1 != 1), -1, "Unknown algorithm\n"); algo_check_done: if (algo == HIP_HI_RSA) { /* malloc space for new rsa */ rsa = RSA_new(); HIP_IFEL(!rsa, -1, "Failed to malloc RSA\n"); /* extract the public-key from cert to rsa */ /* public exponent first */ start = stop = 0; HIP_IFEL(hip_cert_regex(e_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex (exponent)\n"); e_hex = malloc(stop - start); HIP_IFEL(!e_hex, -1, "Malloc for e_hex failed\n"); snprintf((char *) e_hex, stop - start - 1, "%s", &cert->public_key[start + 1]); /* public modulus */ start = stop = 0; HIP_IFEL(hip_cert_regex(n_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex (modulus)\n"); modulus_b64 = calloc(1, stop - start + 1); HIP_IFEL(!modulus_b64, -1, "calloc for modulus_b64 failed\n"); modulus = calloc(1, stop - start + 1); HIP_IFEL(!modulus, -1, "calloc for modulus failed\n"); snprintf((char *) modulus_b64, stop - start - 1, "%s", &cert->public_key[start + 1]); /* put the stuff into the RSA struct */ BN_hex2bn(&rsa->e, e_hex); evpret = EVP_DecodeBlock(modulus, modulus_b64, strlen((char *) modulus_b64)); /* EVP returns a multiple of 3 octets, subtract any extra */ keylen = evpret; if (keylen % 4 != 0) { --keylen; keylen = keylen - keylen % 2; } signature = malloc(keylen); HIP_IFEL(!signature, -1, "Malloc for signature failed.\n"); rsa->n = BN_bin2bn(modulus, keylen, 0); } else if (algo == HIP_HI_DSA) { /* malloc space for new dsa */ dsa = DSA_new(); HIP_IFEL(!dsa, -1, "Failed to malloc DSA\n"); /* Extract public key from the cert */ /* dsa->p */ start = stop = 0; HIP_IFEL(hip_cert_regex(p_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex dsa->p\n"); p_b64 = calloc(1, stop - start + 1); HIP_IFEL(!p_b64, -1, "calloc for p_b64 failed\n"); p_bin = calloc(1, stop - start + 1); HIP_IFEL(!p_bin, -1, "calloc for p_bin failed\n"); snprintf((char *) p_b64, stop - start - 1, "%s", &cert->public_key[start + 1]); evpret = EVP_DecodeBlock(p_bin, p_b64, strlen((char *) p_b64)); /* dsa->q */ start = stop = 0; HIP_IFEL(hip_cert_regex(q_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex dsa->q\n"); q_b64 = calloc(1, stop - start + 1); HIP_IFEL(!q_b64, -1, "calloc for q_b64 failed\n"); q_bin = calloc(1, stop - start + 1); HIP_IFEL(!q_bin, -1, "calloc for q_bin failed\n"); snprintf((char *) q_b64, stop - start - 1, "%s", &cert->public_key[start + 1]); evpret = EVP_DecodeBlock(q_bin, q_b64, strlen((char *) q_b64)); /* dsa->g */ start = stop = 0; HIP_IFEL(hip_cert_regex(g_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex dsa->g\n"); g_b64 = calloc(1, stop - start + 1); HIP_IFEL(!g_b64, -1, "calloc for g_b64 failed\n"); g_bin = calloc(1, stop - start + 1); HIP_IFEL(!g_bin, -1, "calloc for g_bin failed\n"); snprintf((char *) g_b64, stop - start - 1, "%s", &cert->public_key[start + 1]); evpret = EVP_DecodeBlock(g_bin, g_b64, strlen((char *) g_b64)); /* dsa->y */ start = stop = 0; HIP_IFEL(hip_cert_regex(y_rule, cert->public_key, &start, &stop), -1, "Failed to run hip_cert_regex dsa->y\n"); y_b64 = calloc(1, stop - start + 1); HIP_IFEL(!y_b64, -1, "calloc for y_b64 failed\n"); y_bin = calloc(1, stop - start + 1); HIP_IFEL(!y_bin, -1, "calloc for y_bin failed\n"); snprintf((char *) y_b64, stop - start - 1, "%s", &cert->public_key[start + 1]); evpret = EVP_DecodeBlock(y_bin, y_b64, strlen((char *) y_b64)); } else if (algo == HIP_HI_ECDSA) { HIP_OUT_ERR(-1, "Call to unimplemented ECDSA case.\n"); } else { HIP_OUT_ERR(-1, "Unknown algorithm\n"); } /* build sha1 digest that will be signed */ HIP_IFEL(!(sha_retval = SHA1((unsigned char *) cert->cert, strlen((char *) cert->cert), sha_digest)), -1, "SHA1 error when creating digest.\n"); /* Get the signature hash and compare it to the sha_digest we just made */ start = stop = 0; HIP_IFEL(hip_cert_regex(h_rule, cert->signature, &start, &stop), -1, "Failed to run hip_cert_regex (signature hash)\n"); signature_hash_b64 = calloc(1, stop - start + 1); HIP_IFEL(!signature_hash_b64, -1, "Failed to calloc signature_hash_b64\n"); signature_hash = malloc(stop - start + 1); HIP_IFEL(!signature_hash, -1, "Failed to malloc signature_hash\n"); snprintf((char *) signature_hash_b64, stop - start - 1, "%s", &cert->signature[start + 1]); evpret = EVP_DecodeBlock(signature_hash, signature_hash_b64, strlen((char *) signature_hash_b64)); HIP_IFEL(memcmp(sha_digest, signature_hash, 20), -1, "Signature hash did not match of the one made from the" "cert sequence in the certificate\n"); /* memset signature and put it into its place */ start = stop = 0; HIP_IFEL(hip_cert_regex(s_rule, cert->signature, &start, &stop), -1, "Failed to run hip_cert_regex (signature)\n"); signature_b64 = calloc(1, stop - start + 1); HIP_IFEL(!signature_b64, -1, "Failed to calloc signature_b64\n"); snprintf((char *) signature_b64, stop - start - 2, "%s", &cert->signature[start + 2]); if (algo == HIP_HI_DSA) { signature = malloc(stop - start + 1); HIP_IFEL(!signature, -1, "Failed to malloc signature (dsa)\n"); } evpret = EVP_DecodeBlock(signature, signature_b64, strlen((char *) signature_b64)); if (algo == HIP_HI_RSA) { /* do the verification */ err = RSA_verify(NID_sha1, sha_digest, SHA_DIGEST_LENGTH, signature, RSA_size(rsa), rsa); e_code = ERR_get_error(); ERR_load_crypto_strings(); ERR_error_string(e_code, buf); /* RSA_verify returns 1 if success. */ cert->success = err == 1 ? 0 : -1; HIP_IFEL((err = err == 1 ? 0 : -1), -1, "RSA_verify error\n"); } else if (algo == HIP_HI_DSA) { /* build the signature structure */ dsa_sig = DSA_SIG_new(); HIP_IFEL(!dsa_sig, 1, "Failed to allocate DSA_SIG\n"); dsa_sig->r = BN_bin2bn(&signature[1], DSA_PRIV, NULL); dsa_sig->s = BN_bin2bn(&signature[1 + DSA_PRIV], DSA_PRIV, NULL); /* verify the DSA signature */ err = DSA_do_verify(sha_digest, SHA_DIGEST_LENGTH, dsa_sig, dsa) == 0 ? 1 : 0; /* DSA_do_verify returns 1 if success. */ cert->success = err == 1 ? 0 : -1; HIP_IFEL((err = err == 1 ? 0 : -1), -1, "DSA_do_verify error\n"); } else if (algo == HIP_HI_ECDSA) { HIP_OUT_ERR(-1, "Call to unimplemented ECDSA case.\n"); } else { HIP_OUT_ERR(-1, "Unknown algorithm\n"); } out_err: free(signature_hash_b64); free(signature_hash); free(modulus_b64); free(modulus); free(e_hex); RSA_free(rsa); DSA_free(dsa); return err; } /** * Function to build the basic cert object of SPKI clears public-key * object and signature in hip_cert_spki_header * * @param minimal_content holds the struct hip_cert_spki_header * containing the minimal needed information for * cert object, also contains the char table where * the cert object is to be stored * * @return always 0 */ static int cert_spki_build_cert(struct hip_cert_spki_info *minimal_content) { char needed[] = "(cert )"; memset(minimal_content->public_key, '\0', sizeof(minimal_content->public_key)); memset(minimal_content->cert, '\0', sizeof(minimal_content->cert)); memset(minimal_content->signature, '\0', sizeof(minimal_content->signature)); sprintf(minimal_content->cert, "%s", needed); return 0; } /** * Function for injecting objects to cert object * * @param to hip_cert_spki_info containing the char table where to insert * @param after is a char pointer for the regcomp after which the inject happens * @param what is char pointer of what to * * @return 0 if ok and negative if error. -1 returned for example when after is NOT found */ static int cert_spki_inject(struct hip_cert_spki_info *to, const char *after, const char *what) { int err = 0, status = 0; regex_t re; regmatch_t pm[1]; char *tmp_cert; tmp_cert = calloc(1, strlen(to->cert) + strlen(what) + 1); if (!tmp_cert) { return -ENOMEM; } /* Compiling the regular expression */ HIP_IFEL(regcomp(&re, after, REG_EXTENDED), -1, "Compilation of the regular expression failed\n"); /* Running the regular expression */ HIP_IFEL((status = regexec(&re, to->cert, 1, pm, 0)), -1, "Handling of regular expression failed\n"); /* Using tmp char table to do the inject (remember the terminators) * first the beginning */ snprintf(tmp_cert, pm[0].rm_eo + 2, "%s", to->cert); /* Then the middle part to be injected */ snprintf(&tmp_cert[pm[0].rm_eo + 1], strlen(what) + 1, "%s", what); /* then glue back the rest of the original at the end */ snprintf(&tmp_cert[(pm[0].rm_eo + strlen(what) + 1)], (strlen(to->cert) - pm[0].rm_eo), "%s", &to->cert[pm[0].rm_eo + 1]); /* move tmp to the result */ sprintf(to->cert, "%s", tmp_cert); out_err: free(tmp_cert); regfree(&re); return err; } /** * Function to build the create minimal SPKI cert (plus socket parameter) * * @param content holds the struct hip_cert_spki_info containing * the minimal needed information for cert object, * also contains the char table where the cert object * is to be stored * @param issuer_type With HIP its HIT * @param issuer HIT in representation encoding 2001:001... * @param subject_type With HIP its HIT * @param subject HIT in representation encoding 2001:001... * @param not_before time in timeval before which the cert should not be used * @param not_after time in timeval after which the cert should not be used * @param hip_user_socket socket, already connected to hipd, to pass through to * hip_send_recv_daemon_info * @return 0 if ok -1 if error */ static int cert_spki_create_cert_sock(struct hip_cert_spki_info *content, const char *issuer_type, struct in6_addr *issuer, const char *subject_type, struct in6_addr *subject, time_t *not_before, time_t *not_after, int hip_user_socket) { int err = 0; char *tmp_issuer = NULL; char *tmp_subject = NULL; char *tmp_before = NULL; char *tmp_after = NULL; struct tm *ts = NULL; char buf_before[80]; char buf_after[80]; char present_issuer[41] = { 0 }; char present_subject[41] = { 0 }; struct hip_common *msg = NULL; const struct hip_cert_spki_info *returned = NULL; /* Malloc needed */ tmp_issuer = calloc(1, 128); if (!tmp_issuer) { goto out_err; /* Why does this return 0? */ } tmp_subject = calloc(1, 128); if (!tmp_subject) { goto out_err; } tmp_before = calloc(1, 128); if (!tmp_before) { goto out_err; } tmp_after = calloc(1, 128); if (!tmp_after) { goto out_err; } HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1, "Malloc for msg failed\n"); /* Make needed transforms to the date */ /* Format and print the time, "yyyy-mm-dd hh:mm:ss" * (not-after "1998-04-15_00:00:00") */ ts = localtime(not_before); strftime(buf_before, sizeof(buf_before), "%Y-%m-%d_%H:%M:%S", ts); ts = localtime(not_after); strftime(buf_after, sizeof(buf_after), "%Y-%m-%d_%H:%M:%S", ts); sprintf(tmp_before, "(not-before \"%s\")", buf_before); sprintf(tmp_after, "(not-after \"%s\")", buf_after); ipv6_addr_copy(&content->issuer_hit, issuer); inet_ntop(AF_INET6, issuer, present_issuer, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, subject, present_subject, INET6_ADDRSTRLEN); sprintf(tmp_issuer, "(hash %s %s)", issuer_type, present_issuer); sprintf(tmp_subject, "(hash %s %s)", subject_type, present_subject); /* Create the cert sequence */ HIP_IFEL(cert_spki_build_cert(content), -1, "cert_spki_build_cert failed\n"); HIP_IFEL(cert_spki_inject(content, "cert", tmp_after), -1, "cert_spki_inject failed to inject\n"); HIP_IFEL(cert_spki_inject(content, "cert", tmp_before), -1, "cert_spki_inject failed to inject\n"); HIP_IFEL(cert_spki_inject(content, "cert", "(subject )"), -1, "cert_spki_inject failed to inject\n"); HIP_IFEL(cert_spki_inject(content, "subject", tmp_subject), -1, "cert_spki_inject failed to inject\n"); HIP_IFEL(cert_spki_inject(content, "cert", "(issuer )"), -1, "cert_spki_inject failed to inject\n"); HIP_IFEL(cert_spki_inject(content, "issuer", tmp_issuer), -1, "cert_spki_inject failed to inject\n"); /* Create the signature and the public-key sequences */ /* Send the daemon the struct hip_cert_spki_header * containing the cert sequence in content->cert. * As a result you should get the struct back with * public-key and signature fields filled */ /* build the msg to be sent to the daemon */ hip_msg_init(msg); HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_CERT_SPKI_SIGN, 0), -1, "Failed to build user header\n"); HIP_IFEL(hip_build_param_cert_spki_info(msg, content), -1, "Failed to build cert_info\n"); /* send and wait */ HIP_DEBUG("Sending request to sign SPKI cert sequence to " "daemon and waiting for answer\n"); hip_send_recv_daemon_info(msg, 0, hip_user_socket); /* get the struct from the message sent back by the daemon */ HIP_IFEL(!(returned = hip_get_param(msg, HIP_PARAM_CERT_SPKI_INFO)), -1, "No hip_cert_spki_info struct found from daemons msg\n"); memcpy(content, returned, sizeof(struct hip_cert_spki_info)); out_err: /* free everything malloced */ free(tmp_before); free(tmp_after); free(tmp_issuer); free(tmp_subject); free(msg); return err; } /** * Function to build the create minimal SPKI cert * * @param content holds the struct hip_cert_spki_info containing * the minimal needed information for cert object, * also contains the char table where the cert object * is to be stored * @param issuer_type With HIP its HIT * @param issuer HIT in representation encoding 2001:001... * @param subject_type With HIP its HIT * @param subject HIT in representation encoding 2001:001... * @param not_before time in timeval before which the cert should not be used * @param not_after time in timeval after which the cert should not be used * @return 0 if ok -1 if error */ int hip_cert_spki_create_cert(struct hip_cert_spki_info *content, const char *issuer_type, struct in6_addr *issuer, const char *subject_type, struct in6_addr *subject, time_t *not_before, time_t *not_after) { return cert_spki_create_cert_sock(content, issuer_type, issuer, subject_type, subject, not_before, not_after, 0); } /** * Function that takes the cert in single char table and constructs * hip_cert_spki_info from it * * @param from char pointer to the whole certificate * @param to hip_cert_spki_info containing the char table where to insert * * @return 0 if ok and negative if error. */ int hip_cert_spki_char2certinfo(char *from, struct hip_cert_spki_info *to) { int start = 0, stop = 0; /* * p_rule looks for string "(public_key " after which there can be * pretty much anything until string "|)))" is encountered. * This is the public-key sequence. */ char p_rule[] = "[(]public_key [ A-Za-z0-9+|/()#=-]*[|][)][)][)]"; /* * c_rule looks for string "(cert " after which there can be * pretty much anything until string '"))' is encountered. * This is the cert sequence. */ char c_rule[] = "[(]cert [ A-Za-z0-9+|/():=_\"-]*[\"][)][)]"; //\" is one char /* * s_rule looks for string "(signature " after which there can be * pretty much anything until string "|))" is encountered. * This is the signature sequence. */ char s_rule[] = "[(]signature [ A-Za-z0-9+/|()=]*[|][)][)]"; /* Look for the public key */ if (hip_cert_regex(p_rule, from, &start, &stop)) { HIP_ERROR("Failed to run hip_cert_regex (public-key)\n"); return -1; } snprintf(to->public_key, stop - start + 1, "%s", &from[start]); /* Look for the cert sequence */ start = stop = 0; if (hip_cert_regex(c_rule, from, &start, &stop)) { HIP_ERROR("Failed to run hip_cert_regex (cert)\n"); return -1; } snprintf(to->cert, stop - start + 1, "%s", &from[start]); /* look for the signature sequence */ start = stop = 0; if (hip_cert_regex(s_rule, from, &start, &stop)) { HIP_ERROR("Failed to run hip_cert_regex (signature)\n"); return -1; } snprintf(to->signature, stop - start + 1, "%s", &from[start]); return 0; } /** * Function that sends the given hip_cert_spki_info to the daemon to * verification * * @param to_verification is the cert to be verified * * @return 0 if ok and negative if error or unsuccessful. * * @note use hip_cert_spki_char2certinfo to build the hip_cert_spki_info */ int hip_cert_spki_send_to_verification(struct hip_cert_spki_info *to_verification) { int err = 0; struct hip_common *msg; const struct hip_cert_spki_info *returned; if (!(msg = malloc(HIP_MAX_PACKET))) { HIP_ERROR("Malloc for msg failed\n"); return -ENOMEM; } hip_msg_init(msg); /* build the msg to be sent to the daemon */ HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_CERT_SPKI_VERIFY, 0), -1, "Failed to build user header\n"); HIP_IFEL(hip_build_param_cert_spki_info(msg, to_verification), -1, "Failed to build cert_info\n"); /* send and wait */ HIP_DEBUG("Sending request to verify SPKI cert to " "daemon and waiting for answer\n"); hip_send_recv_daemon_info(msg, 0, 0); HIP_IFEL(!(returned = hip_get_param(msg, HIP_PARAM_CERT_SPKI_INFO)), -1, "No hip_cert_spki_info struct found from daemons msg\n"); memcpy(to_verification, returned, sizeof(struct hip_cert_spki_info)); out_err: free(msg); return err; } /****************************************************************************** * FUNCTIONS FOR x509v3 * ******************************************************************************/ /** * Function that requests for a certificate from daemon and gives it back. * * @param subject is the subjects HIT * * @param certificate is pointer to a buffer to which this function writes the completed cert * * @return positive on success negative otherwise * * @note The certificate is given in DER encoding */ uint32_t hip_cert_x509v3_request_certificate(struct in6_addr *subject, unsigned char *certificate) { uint32_t err = 0; struct hip_common *msg; const struct hip_cert_x509_resp *p; if (!(msg = malloc(HIP_MAX_PACKET))) { HIP_ERROR("Malloc for msg failed\n"); return -ENOMEM; } hip_msg_init(msg); /* build the msg to be sent to the daemon */ HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_CERT_X509V3_SIGN, 0), -1, "Failed to build user header\n"); HIP_IFEL(hip_build_param_cert_x509_req(msg, subject), -1, "Failed to build cert_info\n"); /* send and wait */ HIP_DEBUG("Sending request to sign x509 cert to " "daemon and waiting for answer\n"); hip_send_recv_daemon_info(msg, 0, 0); /* get the struct from the message sent back by the daemon */ HIP_IFEL(!(p = hip_get_param(msg, HIP_PARAM_CERT_X509_RESP)), -1, "No name x509 struct found\n"); memcpy(certificate, p->der, ntohl(p->der_len)); err = ntohl(p->der_len); out_err: free(msg); return err; } /** * Function that requests for a verification of a certificate from * daemon and tells the result. * * @param certificate is pointer to a certificate to be verified * @param len is the length of the cert in certificate parameter in bytes * * @return 0 on success negative otherwise * * @note give the certificate in PEM encoding */ int hip_cert_x509v3_request_verification(unsigned char *certificate, uint32_t len) { int err = 0; struct hip_common *msg; const struct hip_cert_x509_resp *received; if (!(msg = malloc(HIP_MAX_PACKET))) { HIP_ERROR("Malloc for msg failed\n"); return -ENOMEM; } hip_msg_init(msg); /* build the msg to be sent to the daemon */ HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_CERT_X509V3_VERIFY, 0), -1, "Failed to build user header\n"); HIP_IFEL(hip_build_param_cert_x509_ver(msg, (char *) certificate, len), -1, "Failed to build cert_info\n"); /* send and wait */ HIP_DEBUG("Sending request to verify x509 cert to " "daemon and waiting for answer\n"); hip_send_recv_daemon_info(msg, 0, 0); /* get the struct from the message sent back by the daemon */ HIP_IFEL(!(received = hip_get_param(msg, HIP_PARAM_CERT_X509_RESP)), -1, "No x509 struct found\n"); err = hip_get_msg_err(msg); if (err == 0) { HIP_DEBUG("Verified successfully\n"); } else { HIP_DEBUG("Verification failed\n"); } out_err: free(msg); return err; } /***************************************************************************** * UTILITY FUNCTIONS * *****************************************************************************/ /** * Read configuration section from loaded configuration file. * * @param section_name the name of the section to be retrieved * @param conf the loaded configuration to read from * * @return STACK_OF(CONF_VALUE) pointer if OK, NULL on error * * @note Remember to open the configuration file with hip_cert_open_conf() and * close it after processing with NCONF_free(). */ STACK_OF(CONF_VALUE) *hip_read_conf_section(const char *section_name, CONF *conf) { STACK_OF(CONF_VALUE) *sec; if (!(sec = NCONF_get_section(conf, section_name))) { HIP_ERROR("Section %s was not in the configuration (%s)\n", section_name, HIP_CERT_CONF_PATH); return NULL; } return sec; } /** * Load the indicated configuration file. * * @return CONF pointer if OK, NULL on error */ CONF *hip_open_conf(const char *filename) { CONF *conf; conf = NCONF_new(NCONF_default()); if (!NCONF_load(conf, filename, NULL)) { HIP_ERROR("Error opening the configuration file"); NCONF_free(conf); return NULL; } return conf; } /** * Function that wraps regular expression stuff and gives the answer :) * * @param what is a char pointer to the rule used in the search (POSIX) * @param from where are we looking for it char pointer * @param start will store the start point of the found substr * @param stop will store the end point of the found substr * * @return 0 if ok and negative if error. * * @note Be carefull with the what so you get what you want :) */ int hip_cert_regex(char *what, char *from, int *start, int *stop) { int err = 0, status = 0; regex_t re; regmatch_t answer[1]; *start = *stop = 0; /* Compiling the regular expression */ if (regcomp(&re, what, REG_EXTENDED)) { HIP_ERROR("Compilation of the regular expression failed\n"); return -1; } /* Running the regular expression */ // TODO this might need to be an error!? // this needs to be separated to found, not found, and error -Samu if ((status = regexec(&re, from, 1, answer, 0))) { err = -1; goto out_err; } *start = answer[0].rm_so; *stop = answer[0].rm_eo; out_err: regfree(&re); return err; }
36.753792
93
0.58899
[ "object" ]
78e7006e025d6dbbfc0f84fff85ea42615cd9418
1,503
h
C
Source/PhysBody.h
BooLAW/3DEngine18
0b93691287d95b2de46baf7b2762878961d5f099
[ "MIT" ]
1
2020-04-17T07:13:37.000Z
2020-04-17T07:13:37.000Z
Source/PhysBody.h
BooLAW/3DEngine18
0b93691287d95b2de46baf7b2762878961d5f099
[ "MIT" ]
2
2018-10-10T18:34:38.000Z
2018-10-18T12:32:44.000Z
Source/PhysBody.h
BooLAW/3DEngine18
0b93691287d95b2de46baf7b2762878961d5f099
[ "MIT" ]
null
null
null
#ifndef __PhysBody_H__ #define __PhysBody_H__ #include "Module.h" #include "GameObject.h" #include "Primitive.h" class btRigidBody; class Module; // ================================================= struct PhysBody { friend class ModulePhysics3D; public: PhysBody(btRigidBody* body); PhysBody(GameObject* owner, PSphere* primitive); PhysBody(GameObject* owner, PCube* primitive); PhysBody(GameObject* owner, ComponentType type); PhysBody(); ~PhysBody(); void Push(float x, float y, float z); void GetTransform(float* matrix) const; void SetTransform(float* matrix); void SetPos(float x, float y, float z); void SetAsSensor(bool is_sensor); bool IsSensor() const; btRigidBody* GetRigidBody(); void SetMass(const uint new_mass); uint GetMass()const; void ActivateGravity(const bool active); bool HasGravity()const; bool GetRender()const; private: btRigidBody * body = nullptr; bool is_sensor = false; //Unity Elements------------ //Mass uint mass = 0; //Affected by gravity? bool use_gravity = false; bool has_primitive_render = true; //Collision Detection public: //Constraints bool const_px; bool const_py; bool const_pz; bool const_rx; bool const_ry; bool const_rz; float3 dimensions = { 1,1,1 }; float3* initial_pos = nullptr; bool dead = false; GameObject* owner = nullptr; Primitive* primitive_ptr = nullptr; Mesh* mesh_ptr = nullptr; //-------------------------- public: std::vector<Module*> collision_listeners; }; #endif // __PhysBody3D_H__
21.169014
52
0.695276
[ "mesh", "vector" ]
78f2fa7e2d30643b899fb09784086db17943d62d
1,694
h
C
matlab/mex/TSFParser.h
nicost/TSFProto
64f919c1f0dfb0210863da5355c255f02d92f23e
[ "BSD-2-Clause" ]
null
null
null
matlab/mex/TSFParser.h
nicost/TSFProto
64f919c1f0dfb0210863da5355c255f02d92f23e
[ "BSD-2-Clause" ]
null
null
null
matlab/mex/TSFParser.h
nicost/TSFProto
64f919c1f0dfb0210863da5355c255f02d92f23e
[ "BSD-2-Clause" ]
null
null
null
/**************************************************** * Parser for files storing data in Tagged Spot Format * Written to facilitate opening TSF files in matlab * but should be useful in other circumstances as well * * Nico Stuurman, January 2012. Copyright UCSF, 2012 * * License: BSD-clause3: http://www.opensource.org/licenses/BSD-3-Clause */ #include <google/protobuf/io/zero_copy_stream_impl.h> #include "../../buildcpp/TSFProto.pb.h" #include <vector> class TSFParser { public: TSFParser(std::ifstream* ifs, std::vector<std::string> requestedFields); ~TSFParser(); std::vector<std::string> GetFields(); /** * Returns data as doubles * It is the responsibility of the caller to allocate * enough memory in the pointer data such that all fields * in map "fields" can be returned */ bool GetNextSpot(double* data); TSF::Spot GetNextSpot(); TSF::SpotList GetSpotList() { return spotList_; }; uint64_t GetNrSpotsFromSpotList(); private: bool NextSpot(); bool checkFields(std::vector<std::string> requestedFields); bool initialized_; bool firstSpot_; std::map<std::string, int> fieldMap_; typedef bool (TSF::Spot::*has_function)() const; std::map<int, has_function> fieldFunctionMap_; TSF::SpotList spotList_; TSF::Spot spot_; std::string buffer_; uint32_t mSize_; std::vector<std::string> fields_; std::vector<std::string> requestedFields_; std::vector<int> fieldsNumeric_; google::protobuf::io::IstreamInputStream* input_; google::protobuf::io::CodedInputStream* codedInput_; };
30.25
72
0.641677
[ "vector" ]
91fa0ce0bd644d4c9d00bbb52bdb899d61d134f8
172,840
c
C
decompiled_scripts/ob_jukebox.c
Seanghost117/GTA-V-Decompiled-Scripts
6b09b3b0ad9ee54d0be2bcb892c5abea76d29aaa
[ "Unlicense" ]
null
null
null
decompiled_scripts/ob_jukebox.c
Seanghost117/GTA-V-Decompiled-Scripts
6b09b3b0ad9ee54d0be2bcb892c5abea76d29aaa
[ "Unlicense" ]
null
null
null
decompiled_scripts/ob_jukebox.c
Seanghost117/GTA-V-Decompiled-Scripts
6b09b3b0ad9ee54d0be2bcb892c5abea76d29aaa
[ "Unlicense" ]
1
2020-12-16T17:13:14.000Z
2020-12-16T17:13:14.000Z
#region Local Var var uLocal_0 = 0; var uLocal_1 = 0; int iLocal_2 = 0; int iLocal_3 = 0; int iLocal_4 = 0; int iLocal_5 = 0; int iLocal_6 = 0; int iLocal_7 = 0; int iLocal_8 = 0; int iLocal_9 = 0; int iLocal_10 = 0; int iLocal_11 = 0; var uLocal_12 = 0; var uLocal_13 = 0; float fLocal_14 = 0f; var uLocal_15 = 0; var uLocal_16 = 0; int iLocal_17 = 0; var uLocal_18 = 0; var uLocal_19 = 0; char* sLocal_20 = NULL; var uLocal_21 = 0; var uLocal_22 = 0; float fLocal_23 = 0f; float fLocal_24 = 0f; float fLocal_25 = 0f; var uLocal_26 = 0; var uLocal_27 = 0; int iLocal_28 = 0; float fLocal_29 = 0f; var uLocal_30 = 0; var uLocal_31 = 0; var uLocal_32 = 0; float fLocal_33 = 0f; float fLocal_34 = 0f; var uLocal_35 = 0; var uLocal_36 = 0; var uLocal_37 = 0; var uLocal_38 = 0; var uLocal_39 = 0; var uLocal_40 = 0; int iLocal_41 = 0; int iLocal_42 = 0; int iLocal_43 = 0; int iLocal_44 = 0; var uLocal_45 = 0; var uLocal_46 = 0; var uLocal_47 = 0; var uLocal_48 = 0; var uLocal_49 = 0; var uLocal_50 = 0; var uLocal_51 = 0; var uLocal_52 = 0; var uLocal_53 = 0; var uLocal_54 = 0; var uLocal_55 = 0; var uLocal_56 = 0; var uLocal_57 = 0; var uLocal_58 = 0; var uLocal_59 = 0; var uLocal_60 = 0; var uLocal_61 = 0; float fLocal_62 = 0f; var uLocal_63 = 0; var uLocal_64 = 0; var uLocal_65 = 0; var uLocal_66 = 0; var uLocal_67 = 0; var uLocal_68 = 0; var uLocal_69 = 0; var uLocal_70 = 0; var uLocal_71 = 0; var uLocal_72 = 0; var uLocal_73 = 0; var uLocal_74 = 0; var uLocal_75 = 0; var uLocal_76 = 0; var uLocal_77 = 0; var uLocal_78 = -1; var uLocal_79 = 0; var uLocal_80 = 0; var uLocal_81 = 0; var uLocal_82 = 0; var uLocal_83 = 0; var uLocal_84 = 0; var uLocal_85 = 0; var uLocal_86 = 0; var uLocal_87 = 0; var uLocal_88 = 0; var uLocal_89 = 0; var uLocal_90 = 0; var uLocal_91 = 0; var uLocal_92 = 0; var uLocal_93 = 0; var uLocal_94 = 0; var uLocal_95 = 0; var uLocal_96 = 0; var uLocal_97 = 0; var uLocal_98 = 0; var uLocal_99 = 0; var uLocal_100 = 0; var uLocal_101 = 0; var uLocal_102 = 0; var uLocal_103 = 0; var uLocal_104 = 0; var uLocal_105 = 0; var uLocal_106 = 0; var uLocal_107 = 0; var uLocal_108 = 0; var uLocal_109 = 0; var uLocal_110 = 0; var uLocal_111 = 0; var uLocal_112 = 0; var uLocal_113 = 0; var uLocal_114 = 0; var uLocal_115 = 0; var uLocal_116 = 0; var uLocal_117 = 0; var uLocal_118 = 0; var uLocal_119 = 0; var uLocal_120 = 0; var uLocal_121 = 0; var uLocal_122 = 0; int iLocal_123 = 0; int iLocal_124 = 0; int iLocal_125 = 0; int iLocal_126 = 0; int iLocal_127 = 0; int iLocal_128 = 0; int iLocal_129 = 0; int iLocal_130 = 0; int iLocal_131 = 0; int iLocal_132 = 0; var uLocal_133 = 0; int iLocal_134 = 0; int iLocal_135 = 0; var uLocal_136 = 0; int iLocal_137 = 0; char* sLocal_138 = NULL; int iLocal_139 = 0; int iLocal_140 = 0; var uLocal_141 = 0; var uLocal_142 = 0; var uLocal_143 = 0; var uLocal_144 = 0; var uLocal_145 = 0; var uLocal_146 = 0; struct<3> Local_147 = { 0, 0, 0 } ; struct<3> Local_148 = { 0, 0, 0 } ; struct<3> Local_149 = { 0, 0, 0 } ; struct<5> Local_150 = { 1, 1056964608, -1, -1, 0 } ; struct<3> Local_151[32]; #endregion void __EntryFunction__() { struct<13> Var0; iLocal_2 = 1; iLocal_3 = 134; iLocal_4 = 134; iLocal_5 = 1; iLocal_6 = 1; iLocal_7 = 1; iLocal_8 = 134; iLocal_9 = 1; iLocal_10 = 12; iLocal_11 = 12; fLocal_14 = 0.001f; iLocal_17 = -1; sLocal_20 = "NULL"; fLocal_23 = 80f; fLocal_24 = 140f; fLocal_25 = 180f; iLocal_28 = 3; fLocal_29 = 0f; fLocal_33 = -0.0375f; fLocal_34 = 0.17f; iLocal_41 = 1; iLocal_42 = 65; iLocal_43 = 49; iLocal_44 = 64; fLocal_62 = ((0.05f + 0.275f) - 0.01f); iLocal_126 = -1; iLocal_128 = -1; iLocal_130 = -1; iLocal_137 = 4; sLocal_138 = "anim@amb@clubhouse@jukebox@"; if (unk_0x7B70881748D166CD(unk_0x856D5567211886A2("ob_jukebox")) > 1) { func_206(0); } iLocal_128 = Global_1590682[unk_0x460153A63B9477BC() /*883*/].f_274.f_28; if (func_205(unk_0x460153A63B9477BC())) { iLocal_128 = 126; iLocal_137 = 9; } func_200(); func_191(); if (unk_0xED06FD5709A59F02(3) || Global_2540384.f_1913) { if (Global_2540384.f_1913) { } func_206(0); } func_190(unk_0x460153A63B9477BC(), &Var0); if (func_189(Var0)) { if (unk_0x29EC5130E3AD4D5A(&Var0)) { iLocal_124 = unk_0xAAA938655BBB5286(&Var0); } } if (iLocal_128 == 126) { iLocal_124 = func_182(unk_0x460153A63B9477BC()); unk_0x17E478571720218F("dlc_ch_arcade_music_volume"); unk_0x944B1AEB263532C4("dlc_ch_arcade_music_volume", "ArcadeRadioVolumeDucking", Local_150.f_1); } if (iLocal_124 == func_181()) { func_206(0); } if (unk_0xAFF96FDC3971E7EA()) { if (iLocal_128 == 126) { if (Global_1590682[iLocal_124 /*883*/].f_274.f_350 != iLocal_137 && func_178(iLocal_124)) { func_175(Global_1590682[iLocal_124 /*883*/].f_274.f_350); func_172(1); Local_150.f_1 = 0.5f; Local_150 = 1; Local_150.f_3 = iLocal_125; func_171(); } else { func_172(0); Local_150.f_1 = 0.5f; Local_150 = 0; } } else if (Global_1590682[iLocal_124 /*883*/].f_274.f_348 != iLocal_137) { func_175(Global_1590682[iLocal_124 /*883*/].f_274.f_348); func_172(1); Local_150 = 1; Local_150.f_3 = iLocal_125; func_171(); } else { func_172(0); Local_150 = 0; } } else { func_175(Local_150.f_3); func_172(func_170()); } while (true) { func_200(); if (iLocal_128 == 126) { unk_0x944B1AEB263532C4("dlc_ch_arcade_music_volume", "ArcadeRadioVolumeDucking", Local_150.f_1); } if (iLocal_123 != 0 && !func_169(Local_149, 0f, 0f, 0f, 0)) { if (unk_0xAFF96FDC3971E7EA()) { func_168(); } func_23(); func_21(); func_6(); } else if (iLocal_128 != -1 && iLocal_128 <= 126) { Local_147 = { func_1() }; if ((unk_0xD3137A576BE9EC5C() % 4) == 0) { } if (iLocal_128 == 126) { iLocal_123 = unk_0x5BBA0055476D633A(Local_147, 2f, joaat("ch_prop_arcade_jukebox_01a"), 1, 0, 0); } else { iLocal_123 = unk_0x5BBA0055476D633A(Local_147, 2f, joaat("bkr_prop_clubhouse_jukebox_01a"), 1, 0, 0); } if (unk_0xAE06B9E39EBDE049(iLocal_123)) { Local_148 = { unk_0x3E4D3CCC220BDFB1(iLocal_123, 1) - unk_0x2E6A35AC161797A7(iLocal_123) * Vector(0.6f, 0.6f, 0.6f) }; Local_148.f_2 = (Local_148.f_2 + 0.5f); Local_149 = { unk_0x7EC595B99EA7C4B1(iLocal_123, 0f, -0.12f, -0.0315f) }; } } else { func_206(0); } SYSTEM::WAIT(0); } } Vector3 func_1() { if (func_5(iLocal_128, -1)) { return func_3(iLocal_128); } else if (iLocal_128 == 126) { return func_2(); } return 0f, 0f, 0f; } Vector3 func_2() { return 2720.626f, -381.4199f, -50f; } Vector3 func_3(int iParam0) { if (func_4(iParam0) == 97) { return 1001.093f, -3171.051f, -35.0421f; } else if (func_4(iParam0) == 91) { return 1122.505f, -3152.994f, -38.0211f; } return 0f, 0f, 0f; } int func_4(int iParam0) { switch (iParam0) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: return 1; break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 69: case 68: case 66: case 67: return 8; break; case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 70: case 71: case 72: return 17; break; case 61: case 62: case 63: case 64: case 65: return 61; break; case 73: case 74: case 75: case 76: return 73; break; case 77: case 78: case joaat("MPSV_LP0_31"): case 80: case 81: case 82: return 77; break; case 83: case 84: case 85: return 83; break; case 86: return 86; break; case 87: case 88: case 89: case 90: return 88; break; case 91: case 92: case 93: case 94: case 95: case 96: return 91; break; case 97: case 98: case 99: case 100: case 101: case 102: return 97; break; case 103: case 106: case 109: case 112: case 104: case 107: case 110: case 113: case 105: case 108: case 111: case 114: return 109; break; } return -1; } int func_5(int iParam0, int iParam1) { if (iParam1 == -1) { switch (iParam0) { case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: return 1; break; } } else if (iParam1 == 91) { switch (iParam0) { case 91: case 92: case 93: case 94: case 95: case 96: return 1; break; } } else if (iParam1 == 97) { switch (iParam0) { case 97: case 98: case 99: case 100: case 101: case 102: return 1; break; } } return 0; } void func_6() { if (iLocal_124 == unk_0x460153A63B9477BC() && func_170()) { if (!func_20(&uLocal_145)) { func_19(&uLocal_145, 0, 0); } else if (func_18(&uLocal_145, 180000, 0)) { func_8(iLocal_125); func_7(&uLocal_145, 0, 0); } } } void func_7(var uParam0, bool bParam1, bool bParam2) { if (unk_0x25DDB354A40FFCDB() && !bParam1) { if (!bParam2) { *uParam0 = unk_0x6CAAB7E78B5D978A(); } else { *uParam0 = unk_0x29B9AF1CB5B8175D(); } } else { *uParam0 = unk_0x578C4EF320340AF7(); } uParam0->f_1 = 1; } void func_8(int iParam0) { int iVar0; int iVar1; int iVar2; int iVar3; if (iParam0 == iLocal_137) { return; } if (iLocal_128 == 126) { iVar0 = func_16(func_17(iParam0), -1, 0); iVar1 = (unk_0x5A002C4821A13338() - iLocal_134); func_13(func_17(iParam0), (iVar0 + iVar1), -1, 1, 0); if (iLocal_135 < (iVar0 + iVar1)) { func_11(func_12()); } } else { iVar2 = func_16(func_10(iParam0), -1, 0); iVar3 = (unk_0x5A002C4821A13338() - iLocal_134); func_13(func_10(iParam0), (iVar2 + iVar3), -1, 1, 0); if (iLocal_135 < (iVar2 + iVar3)) { func_11(func_9()); } } iLocal_134 = unk_0x5A002C4821A13338(); } int func_9() { int iVar0; int iVar1; int iVar2; int iVar3; iVar0 = 0; while (iVar0 < 4) { iVar3 = func_16(func_10(iVar0), -1, 0); if (iVar3 > iVar2) { iVar2 = iVar3; iVar1 = iVar0; } iVar0++; } return iVar1; } int func_10(int iParam0) { switch (iParam0) { case 0: return 10254; case 1: return 10255; case 2: return 10256; case 3: return 10257; default: } return 10254; } void func_11(var uParam0) { Global_1590682[unk_0x460153A63B9477BC() /*883*/].f_274.f_349 = uParam0; } int func_12() { int iVar0; int iVar1; int iVar2; int iVar3; iVar2 = 0; while (iVar2 < 9) { iVar3 = func_16(func_17(iVar2), -1, 0); if (iVar3 > iVar1) { iVar1 = iVar3; iVar0 = iVar2; } iVar2++; } return iVar0; } void func_13(int iParam0, int iParam1, int iParam2, int iParam3, bool bParam4) { int iVar0; if (bParam4) { } iVar0 = Global_2551832[iParam0 /*3*/][func_14(iParam2)]; if (iVar0 != 0) { unk_0x6000E4684CB4330B(iVar0, iParam1, iParam3); } } int func_14(var uParam0) { int iVar0; int iVar1; iVar0 = uParam0; if (iVar0 == -1) { iVar1 = func_15(); if (iVar1 > -1) { Global_2551544 = 0; iVar0 = iVar1; } else { iVar0 = 0; Global_2551544 = 1; } } return iVar0; } int func_15() { return Global_1312763; } int func_16(int iParam0, int iParam1, int iParam2) { var uVar0; var uVar1; if (iParam0 != 11771) { if (iParam2 == 0) { } uVar0 = Global_2551832[iParam0 /*3*/][func_14(iParam1)]; if (unk_0xD2F202166691EDB2(uVar0, &uVar1, -1)) { return uVar1; } } return 0; } int func_17(int iParam0) { switch (iParam0) { case 0: return 10254; case 1: return 10255; case 2: return 10256; case 3: return 10257; case 4: return 8824; case 5: return 8825; case 6: return 8826; case 7: return 8827; case 8: return 8828; default: } return 10254; } int func_18(var uParam0, int iParam1, bool bParam2) { if (iParam1 == -1) { return 1; } func_19(uParam0, bParam2, 0); if (unk_0x25DDB354A40FFCDB() && !bParam2) { if (unk_0x44F29CF6A0675F4F(unk_0x624736CA66E14161(unk_0x6CAAB7E78B5D978A(), *uParam0)) >= iParam1) { return 1; } } else if (unk_0x44F29CF6A0675F4F(unk_0x624736CA66E14161(unk_0x578C4EF320340AF7(), *uParam0)) >= iParam1) { return 1; } return 0; } void func_19(var uParam0, bool bParam1, bool bParam2) { if (uParam0->f_1 == 0) { if (unk_0x25DDB354A40FFCDB() && !bParam1) { if (!bParam2) { *uParam0 = unk_0x6CAAB7E78B5D978A(); } else { *uParam0 = unk_0x29B9AF1CB5B8175D(); } } else { *uParam0 = unk_0x578C4EF320340AF7(); } uParam0->f_1 = 1; } } bool func_20(var uParam0) { return uParam0->f_1; } void func_21() { bool bVar0; bVar0 = func_170(); if (Local_150.f_3 != iLocal_125) { func_175(Local_150.f_3); if (iLocal_124 == unk_0x460153A63B9477BC() && Local_150.f_4) { if (iLocal_128 == 126) { func_22(26808, iLocal_125, -1, 1); Global_1590682[iLocal_124 /*883*/].f_274.f_350 = iLocal_125; } else { func_22(9355, iLocal_125, -1, 1); Global_1590682[iLocal_124 /*883*/].f_274.f_348 = iLocal_125; } } } if (unk_0xCE990E643CD9D0E5(uLocal_133, 6) != bVar0) { func_172(bVar0); if ((iLocal_124 == unk_0x460153A63B9477BC() && Local_150.f_4) && !bVar0) { if (iLocal_128 == 126) { func_22(26808, iLocal_137, -1, 1); Global_1590682[iLocal_124 /*883*/].f_274.f_350 = iLocal_137; } else { func_22(9355, iLocal_137, -1, 1); Global_1590682[iLocal_124 /*883*/].f_274.f_348 = iLocal_137; } } } } var func_22(int iParam0, int iParam1, int iParam2, int iParam3) { int iVar0; int iVar1; var uVar2; if (iParam2 == -1) { iParam2 = func_15(); } if (iParam1 < 0) { iParam1 = 255; } iVar0 = 0; iVar1 = 0; if (iParam0 >= 384 && iParam0 < 457) { iVar0 = unk_0x169039D5869899DA((iParam0 - 384), 0, 1, iParam2); iVar1 = ((iParam0 - 384) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 384)) * 8) * 8; } else if (iParam0 >= 457 && iParam0 < 513) { iVar0 = unk_0x169039D5869899DA((iParam0 - 457), 1, 1, iParam2); iVar1 = ((iParam0 - 457) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 457)) * 8) * 8; } else if (iParam0 >= 1281 && iParam0 < 1305) { iVar0 = unk_0x169039D5869899DA((iParam0 - 1281), 0, 0, 0); iVar1 = ((iParam0 - 1281) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 1281)) * 8) * 8; } else if (iParam0 >= 1305 && iParam0 < 1361) { iVar0 = unk_0x169039D5869899DA((iParam0 - 1305), 1, 0, 0); iVar1 = ((iParam0 - 1305) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 1305)) * 8) * 8; } else if (iParam0 >= 1393 && iParam0 < 2919) { iVar0 = unk_0x33259517529FA9DD((iParam0 - 1393), 0, 1, iParam2); iVar1 = ((iParam0 - 1393) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 1393)) * 8) * 8; } else if (iParam0 >= 1361 && iParam0 < 1393) { iVar0 = unk_0x33259517529FA9DD((iParam0 - 1361), 0, 0, 0); iVar1 = ((iParam0 - 1361) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 1361)) * 8) * 8; } else if (iParam0 >= 3879 && iParam0 < 4143) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 3879), 0, 1, iParam2, "_NGPSTAT_INT"); iVar1 = ((iParam0 - 3879) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 3879)) * 8) * 8; } else if (iParam0 >= 4143 && iParam0 < 4207) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 4143), 0, 0, 0, "_NGPSTAT_INT"); iVar1 = ((iParam0 - 4143) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 4143)) * 8) * 8; } else if (iParam0 >= 4399 && iParam0 < 6028) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 4399), 0, 1, iParam2, "_LRPSTAT_INT"); iVar1 = ((iParam0 - 4399) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 4399)) * 8) * 8; } else if (iParam0 >= 6413 && iParam0 < 7262) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 6413), 0, 1, iParam2, "_APAPSTAT_INT"); iVar1 = ((iParam0 - 6413) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 6413)) * 8) * 8; } else if (iParam0 >= 7262 && iParam0 < 7313) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 7262), 0, 1, iParam2, "_LR2PSTAT_INT"); iVar1 = ((iParam0 - 7262) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 7262)) * 8) * 8; } else if (iParam0 >= 7681 && iParam0 < 9361) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 7681), 0, 1, iParam2, "_BIKEPSTAT_INT"); iVar1 = ((iParam0 - 7681) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 7681)) * 8) * 8; } else if (iParam0 >= 9553 && iParam0 < 15265) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 9553), 0, 1, iParam2, "_IMPEXPPSTAT_INT"); iVar1 = ((iParam0 - 9553) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 9553)) * 8) * 8; } else if (iParam0 >= 15265 && iParam0 < 15369) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 15265), 0, 1, iParam2, "_GUNRPSTAT_INT"); iVar1 = ((iParam0 - 15265) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 15265)) * 8) * 8; } else if (iParam0 >= 16010 && iParam0 < 18098) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 16010), 0, 1, iParam2, "_DLCSMUGCHARPSTAT_INT"); iVar1 = ((iParam0 - 16010) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 16010)) * 8) * 8; } else if (iParam0 >= 18162 && iParam0 < 19018) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 18162), 0, 1, iParam2, "_GANGOPSPSTAT_INT"); iVar1 = ((iParam0 - 18162) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 18162)) * 8) * 8; } else if (iParam0 >= 19018 && iParam0 < 22066) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 19018), 0, 1, iParam2, "_BUSINESSBATPSTAT_INT"); iVar1 = ((iParam0 - 19018) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 19018)) * 8) * 8; } else if (iParam0 >= 22194 && iParam0 < 24962) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 22194), 0, 1, iParam2, "_ARENAWARSPSTAT_INT"); iVar1 = ((iParam0 - 22194) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 22194)) * 8) * 8; } else if (iParam0 >= 25538 && iParam0 < 26810) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 25538), 0, 1, iParam2, "_CASINOPSTAT_INT"); iVar1 = ((iParam0 - 25538) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 25538)) * 8) * 8; } else if (iParam0 >= 27258 && iParam0 < 28098) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 27258), 0, 1, iParam2, "_CASINOHSTPSTAT_INT"); iVar1 = ((iParam0 - 27258) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 27258)) * 8) * 8; } else if (iParam0 >= 28483 && iParam0 < 30227) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 28483), 0, 1, iParam2, "_SU20PSTAT_INT"); iVar1 = ((iParam0 - 28483) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 28483)) * 8) * 8; } else if (iParam0 >= 30483 && iParam0 < 30515) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 30483), 0, 1, iParam2, "_HISLANDPSTAT_INT"); iVar1 = ((iParam0 - 30483) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 30483)) * 8) * 8; } else if (iParam0 >= 7641 && iParam0 < 7681) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 7641), 0, 1, iParam2, "_NGDLCPSTAT_INT"); iVar1 = ((iParam0 - 7641) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 7641)) * 8) * 8; } else if (iParam0 >= 7313 && iParam0 < 7321) { iVar0 = unk_0x7F2F9520C57D9D66((iParam0 - 7313), 0, 0, 0, "_NGDLCPSTAT_INT"); iVar1 = ((iParam0 - 7313) - unk_0xCCD6EB3D51BA0D9E((iParam0 - 7313)) * 8) * 8; } uVar2 = unk_0x9972E0F3B8651981(iVar0, iParam1, iVar1, 8, iParam3); return uVar2; } void func_23() { var uVar0; switch (iLocal_140) { case 0: if (func_159() && func_158()) { func_156(); if (iLocal_130 == -1) { func_155(&iLocal_130, 4, "JBOX_INTERACT", 0, 0, 0, 0); } else if ((iLocal_130 != -1 && func_154(iLocal_130, 1)) && !unk_0x4D71E6F618DC5C0E(unk_0x9B0761B4C3EB8BC7())) { func_153(2); func_151(&iLocal_130); func_141(unk_0x460153A63B9477BC(), 0, 256, 0); unk_0xBE20AB8238688965(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 0); unk_0xBE20AB8238688965(&Global_2515369, 4); } unk_0xBE20AB8238688965(&Global_2515369, 3); } else if (iLocal_130 != -1) { func_151(&iLocal_130); unk_0xD2459066EA58CE43(&Global_2515369, 3); } else if (!func_158() && func_159()) { func_140("JBOX_NO_MONEY"); unk_0xD2459066EA58CE43(&Global_2515369, 3); } else { func_156(); unk_0xD2459066EA58CE43(&Global_2515369, 3); } break; case 2: if (Local_150.f_2 == unk_0x460153A63B9477BC() && func_138()) { iLocal_131 = 0; func_153(1); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 0); unk_0xBE20AB8238688965(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 1); func_137(&uLocal_143); } else if (Local_150.f_2 != -1 || !func_138()) { func_153(0); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 0); unk_0xD2459066EA58CE43(&Global_2515369, 4); func_141(unk_0x460153A63B9477BC(), 1, 0, 0); } break; case 1: if (func_132()) { iLocal_127 = 0; unk_0xBE20AB8238688965(&uLocal_133, 1); func_153(3); if (!unk_0x6914A85D2E17013B(1, 0, 0, 0, -1, 0)) { iLocal_139 = 1; } } break; case 3: if (unk_0xCE990E643CD9D0E5(uLocal_133, 4)) { if (func_131()) { unk_0xD2459066EA58CE43(&uLocal_133, 4); } } func_42(); break; case 4: if (unk_0xCE990E643CD9D0E5(uLocal_133, 3)) { unk_0xD2459066EA58CE43(&uLocal_133, 3); func_39(1, -1); } uVar0 = unk_0xAB6BAF5BFCAFB141(iLocal_132); if (!unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "EXIT", 3)) { func_30(unk_0xCE990E643CD9D0E5(uLocal_133, 5)); if (iLocal_126 != -1) { if ((unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "INSERT_COINS", 3) && unk_0x369E69441C066912(uVar0) >= 0.82f) || !unk_0xCE990E643CD9D0E5(uLocal_133, 5)) { func_29(iLocal_126); } } } else if (unk_0x369E69441C066912(uVar0) >= 0.96f) { unk_0xD2459066EA58CE43(&uLocal_133, 5); unk_0xD2459066EA58CE43(&uLocal_133, 4); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 1); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 2); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 3); func_141(unk_0x460153A63B9477BC(), 1, 0, 0); unk_0xD2459066EA58CE43(&Global_2515369, 4); iLocal_139 = 0; if (iLocal_128 == 126) { uLocal_136 = Global_1590682[iLocal_124 /*883*/].f_274.f_348; } else { uLocal_136 = Global_1590682[iLocal_124 /*883*/].f_274.f_350; } unk_0xECBD279FA2E706AE(func_27(func_28()), func_26(func_28()), func_25(), func_24(), 4, uLocal_136, 0); func_153(0); } break; } } int func_24() { if (Global_1676128.f_3 != 0) { return Global_1676128.f_3; } return -1; } int func_25() { if (Global_1676128.f_2 != 0) { return Global_1676128.f_2; } return -1; } int func_26(int iParam0) { if (iParam0 == func_181()) { return -1; } return Global_1630317[iParam0 /*595*/].f_11.f_8[1]; } int func_27(int iParam0) { if (iParam0 == func_181()) { return -1; } return Global_1630317[iParam0 /*595*/].f_11.f_8[0]; } int func_28() { return Global_1630317[unk_0x460153A63B9477BC() /*595*/].f_11; } void func_29(int iParam0) { Local_151[unk_0x460153A63B9477BC() /*3*/].f_1 = iParam0; unk_0xBE20AB8238688965(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 2); } int func_30(bool bParam0) { if (!bParam0) { iLocal_131 = 1; } if (!unk_0xA59F96B50B97E63C(unk_0x9B0761B4C3EB8BC7(), 0)) { switch (iLocal_131) { case 0: if (func_38("INSERT_COINS", 1, 0)) { iLocal_131 = 1; } break; case 1: if (func_38("EXIT", !bParam0, 0)) { unk_0x1082C25039B168F8(sLocal_138); iLocal_131 = 0; return 1; } break; } } func_31(0); return 0; } void func_31(int iParam0) { if (func_37()) { return; } if (!Global_19681.f_1 == 1) { if (func_36(0)) { func_32(iParam0); } unk_0xBE20AB8238688965(&Global_7552, 2); } } void func_32(int iParam0) { if (func_37()) { return; } if (Global_19864) { if (func_35()) { func_34(1, 1); } else { func_34(0, 0); } } if (Global_19681.f_1 == 10 || Global_19681.f_1 == 9) { unk_0xBE20AB8238688965(&Global_7552, 16); } if (unk_0x6B12213471F330A3()) { unk_0xBE4122AC23440E7D(0); } Global_21005 = 5; if (iParam0 == 1) { unk_0xBE20AB8238688965(&Global_7551, 30); } else { unk_0xD2459066EA58CE43(&Global_7551, 30); } if (!func_33()) { Global_19681.f_1 = 3; } } int func_33() { if (Global_19681.f_1 == 1 || Global_19681.f_1 == 0) { return 1; } return 0; } void func_34(bool bParam0, bool bParam1) { if (bParam0) { if (func_36(0)) { Global_19864 = 1; if (bParam1) { unk_0x1F1B1269BB6217F7(&Global_19618); } Global_19609 = { Global_19627[Global_19626 /*3*/] }; unk_0x241AFEE3D5B4FF70(Global_19609); } } else if (Global_19864 == 1) { Global_19864 = 0; Global_19609 = { Global_19634[Global_19626 /*3*/] }; if (bParam1) { unk_0x241AFEE3D5B4FF70(Global_19618); } else { unk_0x241AFEE3D5B4FF70(Global_19609); } } } bool func_35() { return unk_0xCE990E643CD9D0E5(Global_1689730, 5); } int func_36(int iParam0) { if (iParam0 == 1) { if (Global_19681.f_1 > 3) { if (unk_0xCE990E643CD9D0E5(Global_7551, 14)) { return 1; } else { return 0; } } else { return 0; } } if (unk_0x7B70881748D166CD(joaat("cellphone_flashhand")) > 0) { return 1; } if (Global_19681.f_1 > 3) { return 1; } return 0; } bool func_37() { return unk_0xCE990E643CD9D0E5(Global_1689730, 19); } int func_38(char* sParam0, bool bParam1, int iParam2) { var uVar0; uVar0 = unk_0xAB6BAF5BFCAFB141(iLocal_132); unk_0x131ED02492676000(sLocal_138); if (unk_0xC614DDE265D18415(sLocal_138)) { if ((!unk_0xFC5D6FB6EECB392F(uVar0) || unk_0x369E69441C066912(uVar0) >= 0.96f) || bParam1) { if (unk_0xFC5D6FB6EECB392F(iLocal_132)) { unk_0x14C2D70A19403A5F(iLocal_132); iLocal_132 = -1; } iLocal_132 = unk_0xAA579EC5104BFDA9(Local_149, unk_0x090239DEAF625B17(iLocal_123, 2), 2, 0, iParam2, 1065353216, 0, 1065353216); unk_0x54D6514F20DE2E13(unk_0x9B0761B4C3EB8BC7(), iLocal_132, sLocal_138, sParam0, 4f, -2f, 5, 0, 2f, 0); unk_0xB88AF19828BF16ED(iLocal_132); return 1; } } return 0; } void func_39(bool bParam0, int iParam1) { int iVar0; if (!func_41(&iVar0, 0, iParam1)) { return; } if (Global_22550.f_8417) { unk_0x610B4083B1F95914(15); Global_22550.f_8417 = 0; } unk_0x530DC1525CA60B00(0f); if (Global_22550.f_5628[iVar0]) { unk_0x5D52AA94798846BB(9, 0); Global_22550.f_5628[iVar0] = 0; } if (Global_22550.f_5614[iVar0]) { unk_0x2DDA2C702A92866E("CommonMenu"); Global_22550.f_5614[iVar0] = 0; } if (Global_22550.f_5621[iVar0]) { unk_0x2DDA2C702A92866E("MPShopSale"); Global_22550.f_5621[iVar0] = 0; } if (bParam0) { func_40(&(Global_22550.f_5660[iVar0 /*10*/])); Global_22550.f_5721[iVar0] = 0; } else { Global_22550.f_5721[iVar0] = 0; } } void func_40(var uParam0) { if (uParam0->f_9 != 0) { if (unk_0x95EF219D38B20CFF(*uParam0)) { unk_0x2E352DDBBF674246(uParam0); } *uParam0 = 0; uParam0->f_9 = 0; } } int func_41(var uParam0, bool bParam1, int iParam2) { char cVar0[64]; int iVar1; int iVar2; int iVar3; if (iParam2 == -1) { if (unk_0x25DDB354A40FFCDB() && unk_0x82CC259B7B4F4AD9()) { iParam2 = unk_0x1D39C24C852E6DFA(); } } StringCopy(&cVar0, unk_0x6C5C6B207AA78253(), 64); StringIntConCat(&cVar0, iParam2, 64); iVar1 = unk_0x856D5567211886A2(&cVar0); iVar3 = -1; iVar2 = 0; while (iVar2 < 6) { if (Global_22550.f_5721[iVar2] == iVar1) { *uParam0 = iVar2; return 1; } else if (Global_22550.f_5721[iVar2] == 0) { iVar3 = iVar2; } iVar2++; } if (bParam1) { if (iVar3 != -1) { Global_22550.f_5721[iVar3] = iVar1; *uParam0 = iVar3; return 1; } } return 0; } void func_42() { if (!func_130()) { func_99(); if (func_97("SNK_MNU", -1, 1)) { if (unk_0xCE990E643CD9D0E5(uLocal_133, 1)) { func_86(); unk_0xD2459066EA58CE43(&uLocal_133, 1); } else { func_85(iLocal_127, 1, 1); } func_80(); func_44(1, -1, 1, 0, 1, -1082130432, 0, 0, -1); func_43(); unk_0xBE20AB8238688965(&uLocal_133, 3); } } } void func_43() { unk_0xA86915034F55A3BF(); unk_0x689789B905574795(19); } void func_44(bool bParam0, int iParam1, bool bParam2, bool bParam3, bool bParam4, float fParam5, bool bParam6, bool bParam7, int iParam8) { int iVar0; int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; int iVar15; int iVar16; int iVar17; int iVar18; int iVar19; int iVar20; int iVar21; int iVar22; int iVar23; int iVar24; int iVar25; int iVar26; int iVar27; int iVar28; int iVar29; int iVar30; int iVar31; bool bVar32; bool bVar33; float fVar34; float fVar35; float fVar36; float fVar37; struct<3> Var38; bool bVar39; float fVar40; float fVar41; float fVar42; float fVar43; float fVar44; int iVar45; int iVar46; int iVar47; int iVar48; float fVar49; bool bVar50; bool bVar51; bool bVar52; bool bVar53; float fVar54; float fVar55; float fVar56; float fVar57; int iVar58; int iVar59; float fVar60; float fVar61; float fVar62; char cVar63[64]; char cVar64[64]; float fVar65; int iVar66; float fVar67; float fVar68; int iVar69; int iVar70; int iVar71; int iVar72; int iVar73; int iVar74; char cVar75[16]; float fVar76; float fVar77; float fVar78; float fVar79; float fVar80; if (!func_41(&iVar0, 0, iParam1)) { return; } if (iVar0 == -1) { } if (!func_77(0, bParam6)) { return; } unk_0xFCC7EAA298CE7AC2(76, 84); unk_0xFFA39C4568552522(-0.05f, -0.05f, 0f, 0f); fVar55 = 0f; fVar56 = 0f; if (Global_22550) { if (func_75(29, 1, 1, &fVar36, &fVar37, bParam7)) { fVar55 = fVar37; fVar56 = fVar36; fVar55 = (fVar55 + 0f); } else { Global_22550 = 0; } } if (unk_0x856D5567211886A2(&(Global_22550.f_1)) == unk_0x856D5567211886A2("HIDE")) { fVar57 = Global_22548; } else { fVar57 = (((Global_22548 + fVar55) + 0.034722f) + 0f); } if (fParam5 == -1f) { fParam5 = Global_22549; } fVar60 = 1f; if (bParam7) { unk_0x9DD549AAA043F83A(&iVar58, &iVar59); fVar61 = unk_0x8940B46482DD0A7D(0); if (func_74()) { iVar58 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar59) * fVar61)); } fVar62 = (SYSTEM::TO_FLOAT(iVar58) / SYSTEM::TO_FLOAT(iVar59)); fVar60 = (fVar62 / fVar61); if (func_74()) { fVar60 = 1f; } iVar58 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar58) / fVar60)); iVar59 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar59) / fVar60)); } else { unk_0x8BAB7B3A2C7777A5(&iVar58, &iVar59); } if (bParam3) { if (Global_22550.f_5218 <= 1) { func_70(Global_22550.f_5218 + 1, "DFLT_MNU_OPT", 0, 1, 0, 0); Global_22550.f_6014 = 1; } } iVar5 = 0; while (iVar5 < 2) { if (iVar5 == 1 && Global_22550.f_5728) { if (unk_0x856D5567211886A2(&(Global_22550.f_1)) == unk_0x856D5567211886A2("HIDE")) { fVar49 = Global_22548; } else { if (Global_22550) { StringCopy(&cVar63, func_69(29), 64); StringCopy(&cVar64, func_66(29, 1), 64); if (unk_0x856D5567211886A2(&(Global_22550.f_7029[29 /*16*/])) == joaat("CREW_LOGO")) { func_65(Global_22547, Global_22548, fParam5, (fVar55 - 0f), 0, 0, 0, 255); unk_0x177AA645FB4B3A38(&cVar63, &cVar64, (Global_22547 + (fParam5 * 0.5f)), (Global_22548 + ((fVar55 - 0f) * 0.5f)), fVar56, (fVar55 - 0f), 0f, 255, 255, 255, 255, 0); } else { unk_0x177AA645FB4B3A38(&cVar63, &cVar64, (Global_22547 + (fParam5 * 0.5f)), (Global_22548 + ((fVar55 - 0f) * 0.5f)), fParam5, (fVar55 - 0f), 0f, 255, 255, 255, 255, 0); } } if (Global_22550.f_8387) { iVar1 = Global_22550.f_8383; iVar2 = Global_22550.f_8384; iVar3 = Global_22550.f_8385; iVar4 = Global_22550.f_8386; } else { iVar1 = 0; iVar2 = 0; iVar3 = 0; iVar4 = 255; } func_65(Global_22547, (Global_22548 + fVar55), fParam5, 0.034722f, iVar1, iVar2, iVar3, iVar4); fVar49 = (((Global_22548 + fVar55) + 0.034722f) + 0f); if (unk_0x856D5567211886A2(&(Global_22550.f_1)) != 0) { func_64(); unk_0x40A75E32D30C605F(&(Global_22550.f_1)); iVar15 = 0; iVar16 = 0; iVar17 = 0; iVar18 = 0; iVar14 = 0; while (iVar14 < Global_22550.f_68) { if (Global_22550.f_5[iVar14] == 2) { unk_0x42710E9E08FA375A(Global_22550.f_10[iVar15]); iVar15++; } else if (Global_22550.f_5[iVar14] == 3) { unk_0x5BC8B357341A4FEE(Global_22550.f_14[iVar16], Global_22550.f_18[iVar16]); iVar16++; } else if (Global_22550.f_5[iVar14] == 1) { unk_0x6A826E35A3096ED0(&(Global_22550.f_22[iVar17 /*4*/])); iVar17++; } else if (Global_22550.f_5[iVar14] == 8) { unk_0x6A826E35A3096ED0(&(Global_22550.f_22[iVar17 /*4*/])); iVar17++; } else if (Global_22550.f_5[iVar14] == 5) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_35[iVar18 /*16*/])); iVar18++; } else if (Global_22550.f_5[iVar14] == 6) { unk_0x6A826E35A3096ED0(&(Global_22550.f_35[iVar18 /*16*/])); iVar18++; } else if (Global_22550.f_5[iVar14] == 7) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_35[iVar18 /*16*/])); iVar18++; } else if (Global_22550.f_5[iVar14] == 9) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_35[iVar18 /*16*/])); iVar18++; } iVar14++; } unk_0xA434CC17B5517E4E((Global_22547 + 0.00390625f), ((Global_22548 + fVar55) + 0.00416664f), 0); } if (Global_22550.f_5735) { func_64(); func_62((((Global_22547 + fParam5) - 0.00390625f) - func_63("CM_ITEM_COUNT", Global_22550.f_5736, Global_22550.f_5737)), ((Global_22548 + fVar55) + 0.00416664f), "CM_ITEM_COUNT", Global_22550.f_5736, Global_22550.f_5737); } else if (Global_22550.f_5731 > Global_22550.f_5225) { if (Global_22550.f_5734 != 0) { func_64(); func_62((((Global_22547 + fParam5) - 0.00390625f) - func_63("CM_ITEM_COUNT", Global_22550.f_5734, Global_22550.f_5733)), ((Global_22548 + fVar55) + 0.00416664f), "CM_ITEM_COUNT", Global_22550.f_5734, Global_22550.f_5733); } } } iVar6 = Global_22550.f_5738; iVar9 = 0; fVar65 = fVar49; if (Global_22550.f_8397) { iVar1 = Global_22550.f_8393; iVar2 = Global_22550.f_8394; iVar3 = Global_22550.f_8395; iVar4 = Global_22550.f_8396; } else { unk_0x28DD484BAEAF8437(140, &iVar1, &iVar2, &iVar3, &iVar4); } while (iVar9 < Global_22550.f_5225 && iVar6 <= Global_22550.f_5218) { if (iVar6 >= 0) { if (Global_22550.f_5485[iVar6]) { if (Global_22550.f_5356[iVar6] && iVar6 != Global_22550.f_5738) { fVar49 = (fVar49 + 0.00277776f); } fVar54 = 0.034722f; if (Global_22550.f_5745[iVar6] != 0f) { fVar54 = Global_22550.f_5745[iVar6]; } fVar49 = (fVar49 + fVar54); iVar9++; } } iVar6++; } unk_0x177AA645FB4B3A38("CommonMenu", "Gradient_Bgd", (Global_22547 + (fParam5 * 0.5f)), ((fVar65 + ((fVar49 - fVar65) * 0.5f)) - 0.00138888f), fParam5, (fVar49 - fVar65), 0f, 255, 255, 255, 255, 0); if (Global_22550.f_5731 > Global_22550.f_5225) { if (Global_22550.f_8402) { iVar1 = Global_22550.f_8398; iVar2 = Global_22550.f_8399; iVar3 = Global_22550.f_8400; iVar4 = Global_22550.f_8401; } else { iVar1 = 0; iVar2 = 0; iVar3 = 0; iVar4 = 204; } func_65(Global_22547, (fVar49 + 0f), fParam5, 0.034722f, iVar1, iVar2, iVar3, iVar4); Var38 = { unk_0x282B86763E4DCFC4("CommonMenu", "shop_arrows_upANDdown") }; Var38.x = (Var38.x * (0.5f / fVar60)); Var38.f_1 = (Var38.f_1 * (0.5f / fVar60)); if (Global_22550.f_8415) { iVar1 = 0; iVar2 = 0; iVar3 = 0; iVar4 = 255; } else { unk_0x28DD484BAEAF8437(1, &iVar1, &iVar2, &iVar3, &iVar4); } unk_0x177AA645FB4B3A38("CommonMenu", "shop_arrows_upANDdown", (Global_22547 + (fParam5 * 0.5f)), ((fVar49 + 0f) + (0.034722f * 0.5f)), ((Var38.x / 1280f) * fVar60), ((Var38.f_1 / 720f) * fVar60), 0f, iVar1, iVar2, iVar3, iVar4, 0); fVar49 = (fVar49 + (0f + 0.034722f)); } if (unk_0x856D5567211886A2(&(Global_22550.f_4690)) != 0 && Global_22550.f_4766 != -1) { fVar49 = (fVar49 + (0.00277776f * 2f)); fVar40 = (Global_22547 + 0.0046875f); if (Global_22550.f_4768 != 0) { func_75(Global_22550.f_4768, 1, 1, &fVar36, &fVar37, bParam7); fVar40 = (((Global_22547 + fVar36) + (0.00078125f * 4f)) - (0.00078125f * 1f)); } func_61(fVar40); unk_0x989558F5DCFEFA52(&(Global_22550.f_4690)); iVar15 = 0; iVar16 = 0; iVar17 = 0; iVar14 = 0; while (iVar14 < Global_22550.f_4762) { if (Global_22550.f_4696[iVar14] == 2) { unk_0x42710E9E08FA375A(Global_22550.f_4701[iVar15]); iVar15++; } else if (Global_22550.f_4696[iVar14] == 3) { unk_0x5BC8B357341A4FEE(Global_22550.f_4705[iVar16], Global_22550.f_4709[iVar16]); iVar16++; } else if (Global_22550.f_4696[iVar14] == 1) { unk_0x6A826E35A3096ED0(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 5) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 6) { unk_0x6A826E35A3096ED0(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 7) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 9) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } iVar14++; } iVar6 = unk_0x76C71C9B09716523(fVar40, (fVar49 + 0.00277776f)); unk_0x28DD484BAEAF8437(2, &iVar1, &iVar2, &iVar3, &iVar4); func_65(Global_22547, (fVar49 - 0.00277776f), fParam5, 0.00277776f, iVar1, iVar2, iVar3, iVar4); if (Global_22550.f_8407) { iVar1 = Global_22550.f_8403; iVar2 = Global_22550.f_8404; iVar3 = Global_22550.f_8405; iVar4 = Global_22550.f_8406; } else { unk_0x28DD484BAEAF8437(140, &iVar1, &iVar2, &iVar3, &iVar4); } unk_0x177AA645FB4B3A38("CommonMenu", "Gradient_Bgd", (Global_22547 + (fParam5 * 0.5f)), ((fVar49 + ((((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1)))) * 0.5f)) - 0.00138888f), fParam5, (((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1)))), 0f, iVar1, iVar2, iVar3, iVar4, 0); func_61(fVar40); unk_0x40A75E32D30C605F(&(Global_22550.f_4690)); iVar15 = 0; iVar16 = 0; iVar17 = 0; iVar14 = 0; while (iVar14 < Global_22550.f_4762) { if (Global_22550.f_4696[iVar14] == 2) { unk_0x42710E9E08FA375A(Global_22550.f_4701[iVar15]); iVar15++; } else if (Global_22550.f_4696[iVar14] == 3) { unk_0x5BC8B357341A4FEE(Global_22550.f_4705[iVar16], Global_22550.f_4709[iVar16]); iVar16++; } else if (Global_22550.f_4696[iVar14] == 1) { unk_0x6A826E35A3096ED0(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 5) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 6) { unk_0x6A826E35A3096ED0(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 7) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 9) { unk_0x9EFD301E3BE8324E(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } else if (Global_22550.f_4696[iVar14] == 8) { unk_0x6A826E35A3096ED0(&(Global_22550.f_4713[iVar17 /*16*/])); iVar17++; } iVar14++; } unk_0xA434CC17B5517E4E(fVar40, (fVar49 + 0.00277776f), 0); if (Global_22550.f_4768 != 0) { func_75(Global_22550.f_4768, 1, 1, &fVar36, &fVar37, bParam7); func_60(Global_22550.f_4768, 1, &iVar45, &iVar46, &iVar47, &iVar48); unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4768), func_66(Global_22550.f_4768, 1), ((Global_22547 + (fVar36 * 0.5f)) + (0.00078125f * 2f)), ((fVar49 + (fVar37 * 0.5f)) - (0.00138888f * 4f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } fVar49 = (fVar49 + (((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1))))); if (Global_22550.f_4766 > 0) { if ((unk_0x578C4EF320340AF7() - Global_22550.f_4767) > Global_22550.f_4766) { StringCopy(&(Global_22550.f_4690), "", 24); Global_22550.f_4766 = -1; } } } if (unk_0x856D5567211886A2(&(Global_4269680.f_21)) != 0 && Global_4269680.f_65 != -1) { fVar49 = (fVar49 + (0.00277776f * 2f)); fVar40 = (Global_22547 + 0.0046875f); if (Global_4269680.f_67 != 0) { func_75(Global_4269680.f_67, 1, 1, &fVar36, &fVar37, bParam7); fVar40 = (((Global_22547 + fVar36) + (0.00078125f * 4f)) - (0.00078125f * 1f)); } func_61(fVar40); unk_0x989558F5DCFEFA52(&(Global_4269680.f_21)); iVar15 = 0; iVar16 = 0; iVar17 = 0; iVar14 = 0; while (iVar14 < Global_4269680.f_61) { if (Global_4269680.f_25[iVar14] == 2) { unk_0x42710E9E08FA375A(Global_4269680.f_30[iVar15]); iVar15++; } else if (Global_4269680.f_25[iVar14] == 3) { unk_0x5BC8B357341A4FEE(Global_4269680.f_34[iVar16], Global_4269680.f_38[iVar16]); iVar16++; } else if (Global_4269680.f_25[iVar14] == 1) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 5) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 6) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 7) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 9) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 8) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } iVar14++; } iVar6 = unk_0x76C71C9B09716523(fVar40, (fVar49 + 0.00277776f)); unk_0x28DD484BAEAF8437(2, &iVar1, &iVar2, &iVar3, &iVar4); func_65(Global_22547, (fVar49 - 0.00277776f), fParam5, 0.00277776f, iVar1, iVar2, iVar3, iVar4); if (Global_22550.f_8407) { iVar1 = Global_22550.f_8403; iVar2 = Global_22550.f_8404; iVar3 = Global_22550.f_8405; iVar4 = Global_22550.f_8406; } else { unk_0x28DD484BAEAF8437(140, &iVar1, &iVar2, &iVar3, &iVar4); } unk_0x177AA645FB4B3A38("CommonMenu", "Gradient_Bgd", (Global_22547 + (fParam5 * 0.5f)), ((fVar49 + ((((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1)))) * 0.5f)) - 0.00138888f), fParam5, (((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1)))), 0f, iVar1, iVar2, iVar3, iVar4, 0); func_61(fVar40); unk_0x40A75E32D30C605F(&(Global_4269680.f_21)); iVar15 = 0; iVar16 = 0; iVar17 = 0; iVar14 = 0; while (iVar14 < Global_4269680.f_61) { if (Global_4269680.f_25[iVar14] == 2) { unk_0x42710E9E08FA375A(Global_4269680.f_30[iVar15]); iVar15++; } else if (Global_4269680.f_25[iVar14] == 3) { unk_0x5BC8B357341A4FEE(Global_4269680.f_34[iVar16], Global_4269680.f_38[iVar16]); iVar16++; } else if (Global_4269680.f_25[iVar14] == 1) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 8) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 5) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 6) { unk_0x6A826E35A3096ED0(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 7) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } else if (Global_4269680.f_25[iVar14] == 9) { unk_0x9EFD301E3BE8324E(&(Global_4269680.f_42[iVar17 /*6*/])); iVar17++; } iVar14++; } unk_0xA434CC17B5517E4E(fVar40, (fVar49 + 0.00277776f), 0); if (Global_4269680.f_67 != 0) { func_75(Global_4269680.f_67, 1, 1, &fVar36, &fVar37, bParam7); func_60(Global_4269680.f_67, 1, &iVar45, &iVar46, &iVar47, &iVar48); unk_0x177AA645FB4B3A38(func_69(Global_4269680.f_67), func_66(Global_4269680.f_67, 1), ((Global_22547 + (fVar36 * 0.5f)) + (0.00078125f * 2f)), ((fVar49 + (fVar37 * 0.5f)) - (0.00138888f * 4f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } fVar49 = (fVar49 + (((unk_0xBA269EB4693A8C47(0.35f, 0) * IntToFloat(iVar6)) + (0.00138888f * 13f)) + ((0.00138888f * 5f) * IntToFloat((iVar6 - 1))))); if (Global_4269680.f_65 > 0) { if ((unk_0x578C4EF320340AF7() - Global_4269680.f_66) > Global_4269680.f_65) { StringCopy(&(Global_4269680.f_21), "", 16); Global_4269680.f_65 = -1; } } } func_53(iVar58, iParam1, iParam8, 0, 0, 0, bParam4, 1, 0); unk_0xFCC7EAA298CE7AC2(76, 84); unk_0xFFA39C4568552522(-0.05f, -0.05f, 0f, 0f); } if (iVar5 == 1 || !Global_22550.f_5728) { iVar19 = 0; iVar23 = 0; iVar20 = 0; iVar21 = 0; iVar22 = 0; iVar9 = 0; iVar10 = 0; iVar11 = 0; iVar12 = 0; iVar13 = 0; iVar66 = Global_22550.f_5218; if (Global_22550.f_5729) { iVar66 = (Global_22550.f_5732 - 1); } fVar67 = 0f; fVar68 = 0f; iVar7 = 0; while (iVar7 <= iVar66) { fVar54 = 0.034722f; if (Global_22550.f_5745[iVar6] != 0f) { fVar54 = Global_22550.f_5745[iVar6]; } if (Global_22550.f_5729) { iVar6 = Global_22550.f_8038[iVar7]; } else { iVar6 = iVar7; } iVar12 = iVar13; bVar33 = false; if (iVar6 >= Global_22550.f_5738 && iVar9 < Global_22550.f_5225) { bVar33 = true; if (Global_22550.f_5739 == iVar6) { fVar68 = fVar67; } if (Global_22550.f_5356[iVar6]) { iVar12++; } fVar35 = (((fVar57 + fVar67) + (0.00277776f * IntToFloat(iVar12))) + 0.00277776f); } Global_22550.f_5879[iVar6] = fVar35; fVar34 = (Global_22547 + 0.0046875f); bVar39 = false; bVar32 = Global_22550.f_5739 == iVar6; if ((bVar32 && iVar5 == 1) && bVar33) { iVar70 = 255; iVar71 = 255; iVar72 = 255; iVar73 = 255; if (Global_22550.f_8409) { unk_0x28DD484BAEAF8437(Global_22550.f_8408, &iVar70, &iVar71, &iVar72, &iVar73); } else { unk_0x28DD484BAEAF8437(1, &iVar70, &iVar71, &iVar72, &iVar73); } unk_0x177AA645FB4B3A38("CommonMenu", "Gradient_Nav", (Global_22547 + (fParam5 * 0.5f)), (((fVar57 + fVar68) + (0.00277776f * IntToFloat(iVar12))) + (fVar54 * 0.5f)), fParam5, fVar54, 0f, iVar70, iVar71, iVar72, iVar73, 0); Global_22550.f_5877 = fVar35; } iVar8 = 0; while (iVar8 < Global_22550.f_5226) { if (unk_0xCE990E643CD9D0E5(Global_22550.f_5089[iVar6], iVar8) || Global_22550.f_5056[iVar8] == 5) { if (Global_22550.f_5729) { iVar19 = Global_22550.f_8054[((iVar9 * Global_22550.f_5226) + iVar8)]; iVar20 = Global_22550.f_8095[((iVar9 * Global_22550.f_5226) + iVar8)]; iVar21 = Global_22550.f_8136[((iVar9 * Global_22550.f_5226) + iVar8)]; iVar22 = Global_22550.f_8177[((iVar9 * Global_22550.f_5226) + iVar8)]; iVar23 = Global_22550.f_8218[((iVar9 * Global_22550.f_5226) + iVar8)]; } else { Global_22550.f_8054[((iVar9 * Global_22550.f_5226) + iVar8)] = iVar19; Global_22550.f_8095[((iVar9 * Global_22550.f_5226) + iVar8)] = iVar20; Global_22550.f_8136[((iVar9 * Global_22550.f_5226) + iVar8)] = iVar21; Global_22550.f_8177[((iVar9 * Global_22550.f_5226) + iVar8)] = iVar22; Global_22550.f_8218[((iVar9 * Global_22550.f_5226) + iVar8)] = iVar23; } iVar74 = 0; bVar53 = false; if (Global_22550.f_6011[0] != -1) { if ((iVar6 * 5 + iVar8) == Global_22550.f_6008[0]) { bVar53 = true; iVar74 = 0; } } if (Global_22550.f_6011[1] != -1) { if ((iVar6 * 5 + iVar8) == Global_22550.f_6008[1]) { bVar53 = true; iVar74 = 1; } } if (Global_22550.f_5062[iVar8] != -1f) { fVar34 = ((Global_22547 + 0.0046875f) + Global_22550.f_5062[iVar8]); } if ((iVar8 < 4 && Global_22550.f_5062[iVar8 + 1] != -1f) && fVar34 < Global_22550.f_5062[iVar8 + 1]) { fVar44 = (Global_22550.f_5062[iVar8 + 1] - fVar34); } else { fVar44 = (((Global_22547 + Global_22549) - 0.0046875f) - fVar34); } if ((Global_22550.f_5075[iVar8] && Global_22550.f_5874) && bVar32) { bVar52 = true; } else { bVar52 = false; } switch (Global_22550.f_5056[iVar8]) { case 0: break; case 1: iVar24 = iVar19; if (bVar33) { if (!Global_22550.f_5729) { fVar41 = 0f; fVar42 = 0f; iVar25 = 0; iVar26 = 0; iVar27 = 0; iVar28 = 0; iVar29 = 0; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { bVar50 = false; bVar51 = false; iVar14 = 0; while (iVar14 < 4) { if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 5 || Global_22550.f_2124[iVar24 /*5*/][iVar14] == 8) { bVar51 = true; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 9) { bVar50 = true; } iVar14++; } func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, iVar74, bVar51, bVar50); unk_0x456829A212A690D7(&(Global_22550.f_73[iVar24 /*6*/])); } iVar14 = 0; while (iVar14 < 4) { if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 1) { iVar25++; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x6A826E35A3096ED0(&(Global_22550.f_73[(iVar24 + iVar25) /*6*/])); } } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 8) { iVar25++; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x6A826E35A3096ED0(&(Global_22550.f_73[(iVar24 + iVar25) /*6*/])); } } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 5) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 6) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x6A826E35A3096ED0(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 7) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 9) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 2) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x42710E9E08FA375A(Global_22550.f_3918[(iVar20 + iVar26)]); } iVar26++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 3) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { unk_0x5BC8B357341A4FEE(Global_22550.f_4175[(iVar21 + iVar27)], Global_22550.f_4304[(iVar21 + iVar27)]); } iVar27++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 4) { iVar28++; } iVar14++; } if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0) { fVar41 = unk_0x842CB5919E31EB1F(1); } if (iVar28 > 0) { iVar14 = 0; while (iVar14 < iVar28) { if (func_75(Global_22550.f_4433[(iVar22 + iVar14)], bVar32, 0, &fVar36, &fVar37, bParam7)) { fVar42 = (fVar42 + fVar36); if (iVar14 > 0) { fVar42 = (fVar42 - (0.00078125f * 4f)); } if ((Global_22550.f_4433[(iVar22 + iVar14)] == 2 || Global_22550.f_4433[(iVar22 + iVar14)] == 51) || Global_22550.f_4433[(iVar22 + iVar14)] == 61) { fVar42 = (fVar42 - (0.00078125f * 5f)); } } iVar14++; } } fVar40 = 0f; if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 + ((fVar44 - (fVar41 + fVar42)) + (0.00078125f * 1f))); } else if (Global_22550.f_5083[iVar8] == 0) { fVar40 = (fVar40 + (((fVar44 - fVar34) * 0.5f) - ((fVar41 + fVar42) * 0.5f))); } Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar40; Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar41; Global_22550.f_8341[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar42; if (Global_22550.f_5083[iVar8] == 2) { iVar69 = (iVar8 - 1); while (iVar69 >= 0) { if (Global_22550.f_5083[iVar69] == 2) { Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar69)] = (Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar69)] - Global_22550.f_5068[iVar8]); } iVar69 = (iVar69 + -1); } } } else { fVar40 = Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)]; fVar41 = Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)]; fVar42 = Global_22550.f_8341[((iVar9 * Global_22550.f_5226) + iVar8)]; } if (bVar52) { if (func_75(26, 1, 0, &fVar36, &fVar37, bParam7)) { if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 - (fVar36 * 2f)); } fVar43 = (fVar36 * 0.5f); if (func_75(26, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(26, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(26), func_66(26, 1), ((fVar34 + fVar40) + fVar43), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } if (func_75(27, 1, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + fVar36); fVar43 = (fVar36 * 0.5f); if (func_75(27, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(27, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(27), func_66(27, 1), (((fVar34 + fVar40) + fVar43) + (fVar41 + fVar42)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } } iVar25 = 0; iVar26 = 0; iVar27 = 0; iVar28 = 0; iVar29 = 0; iVar31 = 0; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { bVar50 = false; bVar51 = false; iVar14 = 0; while (iVar14 < 4) { if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 5 || Global_22550.f_2124[iVar24 /*5*/][iVar14] == 8) { bVar51 = true; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 9) { bVar50 = true; } iVar14++; } func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, bVar51, bVar50); if (Global_22550.f_8413 && Global_22550.f_8414 == iVar6) { func_50(bVar32); } unk_0x40A75E32D30C605F(&(Global_22550.f_73[iVar24 /*6*/])); } iVar14 = 0; while (iVar14 < 4) { if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 1) { iVar25++; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x6A826E35A3096ED0(&(Global_22550.f_73[(iVar24 + iVar25) /*6*/])); } iVar31 = 1; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 8) { iVar25++; if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x6A826E35A3096ED0(&(Global_22550.f_73[(iVar24 + iVar25) /*6*/])); } iVar31 = 8; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 5) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; iVar31 = 5; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 6) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x6A826E35A3096ED0(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; iVar31 = 6; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 7) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; iVar31 = 7; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 9) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x9EFD301E3BE8324E(&(Global_2462791[(iVar23 + iVar29) /*16*/])); } iVar29++; iVar31 = 9; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 2) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x42710E9E08FA375A(Global_22550.f_3918[(iVar20 + iVar26)]); } iVar26++; iVar31 = 2; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 3) { if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { unk_0x5BC8B357341A4FEE(Global_22550.f_4175[(iVar21 + iVar27)], Global_22550.f_4304[(iVar21 + iVar27)]); } iVar27++; iVar31 = 3; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 4) { if ((Global_22550.f_4433[(iVar22 + iVar28)] == 2 || Global_22550.f_4433[(iVar22 + iVar28)] == 51) || Global_22550.f_4433[(iVar22 + iVar28)] == 61) { if (func_75(Global_22550.f_4433[(iVar22 + iVar28)], bVar32, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + (fVar36 * 0.5f)); if (func_75(Global_22550.f_4433[(iVar22 + iVar28)], bVar32, 1, &fVar36, &fVar37, bParam7)) { func_60(Global_22550.f_4433[(iVar22 + iVar28)], bVar32, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { if (Global_22550.f_5083[iVar8] == 2) { unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[(iVar22 + iVar28)]), func_66(Global_22550.f_4433[(iVar22 + iVar28)], bVar32), (((fVar34 + fVar40) - (0.00078125f * 8f)) + (0.00078125f * 4f)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } else { unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[(iVar22 + iVar28)]), func_66(Global_22550.f_4433[(iVar22 + iVar28)], bVar32), ((fVar34 + fVar40) - (0.00078125f * 8f)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } fVar40 = (fVar40 + (0.00078125f * 3f)); } } } iVar28++; iVar31 = 4; } iVar14++; } if (unk_0x856D5567211886A2(&(Global_22550.f_73[iVar24 /*6*/])) != 0 && iVar5 == 1) { if (iVar31 == 4 && Global_22550.f_5083[iVar8] == 2) { unk_0xA434CC17B5517E4E(((fVar34 + fVar40) + (0.00078125f * 7f)), fVar35, 0); } else { unk_0xA434CC17B5517E4E((fVar34 + fVar40), fVar35, 0); if (func_49() && unk_0x7B70881748D166CD(joaat("fm_mission_creator")) > 0) { if (iVar8 == 0) { func_51(0, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, bVar51, bVar50); StringCopy(&cVar75, "TEST_LABEL", 16); fVar76 = 0f; fVar77 = 55f; fVar78 = 0.0185f; fVar79 = 0.004f; fVar80 = 0.02f; unk_0x151E2F6EE4A34CFE(0f, (0.35f * 0.7f)); unk_0xA11D279671F2289C(255, 255, 255, 150); unk_0x8DDE075026DB7EFD((fVar34 - (fVar80 * 0.6f)), (fVar35 + (fVar78 * 0.75f)), 0.0175f, 0.035f, SYSTEM::FLOOR(fVar76), SYSTEM::FLOOR(fVar76), SYSTEM::FLOOR(fVar76), SYSTEM::FLOOR(fVar77), 0); unk_0x40A75E32D30C605F(&cVar75); unk_0x42710E9E08FA375A((Global_22550.f_5738 + iVar30)); unk_0xA434CC17B5517E4E((fVar34 - fVar80), (fVar35 + fVar79), 0); iVar30++; } } } } if (iVar28 > 0) { fVar40 = (fVar40 + (6f * 0.00078125f)); iVar14 = 0; while (iVar14 < iVar28) { if ((Global_22550.f_4433[(iVar22 + iVar14)] != 2 && Global_22550.f_4433[(iVar22 + iVar14)] != 51) && Global_22550.f_4433[(iVar22 + iVar14)] != 61) { if (func_75(Global_22550.f_4433[(iVar22 + iVar14)], bVar32, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + (fVar36 * 0.5f)); if (iVar5 == 1) { if (func_75(Global_22550.f_4433[(iVar22 + iVar14)], bVar32, 1, &fVar36, &fVar37, bParam7)) { func_60(Global_22550.f_4433[(iVar22 + iVar14)], bVar32, &iVar45, &iVar46, &iVar47, &iVar48); if (Global_22550.f_4433[(iVar22 + iVar14)] == 30) { unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[(iVar22 + iVar14)]), func_66(Global_22550.f_4433[(iVar22 + iVar14)], bVar32), (Global_22547 + (fVar36 * 0.5f)), (((fVar35 + 0.00277776f) + (fVar37 * 0.5f)) - (0.00078125f * 11f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } else if (Global_22550.f_5083[iVar8] == 2) { unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[(iVar22 + iVar14)]), func_66(Global_22550.f_4433[(iVar22 + iVar14)], bVar32), ((((fVar34 + fVar40) + fVar41) - (0.00078125f * 8f)) + (0.00078125f * 4f)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } else { unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[(iVar22 + iVar14)]), func_66(Global_22550.f_4433[(iVar22 + iVar14)], bVar32), (((fVar34 + fVar40) + fVar41) - (0.00078125f * 12f)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } fVar40 = (fVar40 + (12f * 0.00078125f)); } } iVar14++; } } } bVar39 = true; iVar19++; iVar14 = 0; while (iVar14 < 4) { if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 1) { iVar19++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 8) { iVar19++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 2) { iVar20++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 3) { iVar21++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 4) { iVar22++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 5) { iVar23++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 6) { iVar23++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 7) { iVar23++; } else if (Global_22550.f_2124[iVar24 /*5*/][iVar14] == 9) { iVar23++; } iVar14++; } break; case 2: if (bVar33) { if (!Global_22550.f_5729) { func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, 0, 0); if (Global_22550.f_8413 && Global_22550.f_8414 == iVar6) { func_50(bVar32); } unk_0x456829A212A690D7("NUMBER"); unk_0x42710E9E08FA375A(Global_22550.f_3918[iVar20]); fVar41 = unk_0x842CB5919E31EB1F(1); fVar40 = 0f; if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 + ((fVar44 - fVar41) + (0.00078125f * 1f))); } else if (Global_22550.f_5083[iVar8] == 0) { fVar40 = (fVar40 + (((fVar44 - fVar34) * 0.5f) - (fVar41 * 0.5f))); } Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar40; Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar41; } else { fVar40 = Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)]; fVar41 = Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)]; } if (bVar52) { if (func_75(26, 1, 0, &fVar36, &fVar37, bParam7)) { if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 - (fVar36 * 2f)); } fVar43 = (fVar36 * 0.5f); if (func_75(26, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(26, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(26), func_66(26, 1), ((fVar34 + fVar40) + fVar43), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } if (func_75(27, 1, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + fVar36); fVar43 = (fVar36 * 0.5f); if (func_75(27, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(27, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(27), func_66(27, 1), (((fVar34 + fVar40) + fVar43) + (fVar41 + fVar42)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } } if (iVar5 == 1) { func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, 0, 0); func_48((fVar34 + fVar40), fVar35, "NUMBER", Global_22550.f_3918[iVar20], 0); } } bVar39 = true; iVar20++; break; case 3: if (bVar33) { if (!Global_22550.f_5729) { func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, 0, 0); if (Global_22550.f_8413 && Global_22550.f_8414 == iVar6) { func_50(bVar32); } unk_0x456829A212A690D7("NUMBER"); unk_0x5BC8B357341A4FEE(Global_22550.f_4175[iVar21], Global_22550.f_4304[iVar21]); fVar41 = unk_0x842CB5919E31EB1F(1); fVar40 = 0f; if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 + ((fVar44 - fVar41) + (0.00078125f * 1f))); } else if (Global_22550.f_5083[iVar8] == 0) { fVar40 = (fVar40 + (((fVar44 - fVar34) * 0.5f) - (fVar41 * 0.5f))); } Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar40; Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar41; } else { fVar40 = Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)]; fVar41 = Global_22550.f_8300[((iVar9 * Global_22550.f_5226) + iVar8)]; } if (bVar52) { if (func_75(26, 1, 0, &fVar36, &fVar37, 0)) { if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 - (fVar36 * 2f)); } fVar43 = (fVar36 * 0.5f); if (func_75(26, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(26, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(26), func_66(26, 1), ((fVar34 + fVar40) + fVar43), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } if (func_75(27, 1, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + fVar36); fVar43 = (fVar36 * 0.5f); if (func_75(27, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(27, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(27), func_66(27, 1), (((fVar34 + fVar40) + fVar43) + (fVar41 + fVar42)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } } func_51(bVar32, Global_22550.f_1610[iVar24], Global_22550.f_1867[iVar24], bVar53, 0, 0, 0); func_47((fVar34 + fVar40), fVar35, "NUMBER", Global_22550.f_4175[iVar21], Global_22550.f_4304[iVar21]); } bVar39 = true; iVar21++; break; case 4: if (bVar33) { if (func_75(Global_22550.f_4433[iVar22], bVar32, 0, &fVar36, &fVar37, bParam7)) { if (!Global_22550.f_5729) { fVar42 = fVar36; fVar40 = 0f; if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 + ((fVar44 - fVar42) + (0.00078125f * 1f))); } else if (Global_22550.f_5083[iVar8] == 0) { fVar40 = (fVar40 + (((fVar44 - fVar34) * 0.5f) - (fVar42 * 0.5f))); } Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar40; Global_22550.f_8341[((iVar9 * Global_22550.f_5226) + iVar8)] = fVar42; } else { fVar40 = Global_22550.f_8259[((iVar9 * Global_22550.f_5226) + iVar8)]; fVar42 = Global_22550.f_8341[((iVar9 * Global_22550.f_5226) + iVar8)]; } if (bVar52) { if (func_75(26, 1, 0, &fVar36, &fVar37, bParam7)) { if (Global_22550.f_5083[iVar8] == 2) { fVar40 = (fVar40 - (fVar36 * 2f)); } fVar43 = (fVar36 * 0.5f); if (func_75(26, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(26, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(26), func_66(26, 1), ((fVar34 + fVar40) + fVar43), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } if (func_75(27, 1, 0, &fVar36, &fVar37, bParam7)) { fVar40 = (fVar40 + fVar36); fVar43 = (fVar36 * 0.5f); if (func_75(27, 1, 1, &fVar36, &fVar37, bParam7)) { func_60(27, 1, &iVar45, &iVar46, &iVar47, &iVar48); if (iVar5 == 1) { unk_0x177AA645FB4B3A38(func_69(27), func_66(27, 1), (((fVar34 + fVar40) + fVar43) + (fVar41 + fVar42)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), fVar36, fVar37, 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } } if (iVar5 == 1) { if (func_75(Global_22550.f_4433[iVar22], bVar32, 1, &fVar36, &fVar37, bParam7)) { func_60(Global_22550.f_4433[iVar22], bVar32, &iVar45, &iVar46, &iVar47, &iVar48); unk_0x177AA645FB4B3A38(func_69(Global_22550.f_4433[iVar22]), func_66(Global_22550.f_4433[iVar22], bVar32), ((fVar34 + fVar40) + (fVar36 * 0.5f)), ((fVar35 - 0.00277776f) + (fVar54 * 0.5f)), (fVar36 * func_46(Global_22550.f_4433[iVar22])), (fVar37 * func_46(Global_22550.f_4433[iVar22])), 0f, iVar45, iVar46, iVar47, iVar48, 0); } } } } bVar39 = true; iVar22++; break; case 5: bVar39 = true; break; } if (Global_22550.f_5056[iVar8] == 5) { if (Global_22550.f_5068[iVar8] > 0.05f) { fVar34 = (fVar34 + Global_22550.f_5068[iVar8]); } else { fVar34 = (fVar34 + 0.05f); } } else { fVar34 = (fVar34 + Global_22550.f_5068[iVar8]); if (Global_22550.f_5075[iVar8]) { if (func_75(26, 1, 1, &fVar36, &fVar37, bParam7)) { fVar34 = (fVar34 - fVar36); } } } } else { fVar34 = (fVar34 + Global_22550.f_5068[iVar8]); } iVar8++; } if (bVar39) { if (bVar33) { Global_22550.f_8038[iVar9] = iVar6; Global_22550.f_5740 = iVar6; iVar9++; if (Global_22550.f_5356[iVar6]) { iVar13++; } if (Global_22550.f_5745[iVar6] != 0f) { fVar67 = (fVar67 + Global_22550.f_5745[iVar6]); } else { fVar67 = (fVar67 + 0.034722f); } } if (!Global_22550.f_5728) { Global_22550.f_5485[iVar6] = 1; if (Global_22550.f_5227[iVar6]) { if (bVar32) { Global_22550.f_5734 = 0; } } else { iVar11++; if (bVar32) { Global_22550.f_5734 = iVar11; } } iVar10++; } } iVar7++; } if (!Global_22550.f_5728) { Global_22550.f_5730 = ((fVar57 + fVar67) + (0.00277776f * IntToFloat(iVar12))); Global_22550.f_5733 = iVar11; Global_22550.f_5731 = iVar10; Global_22550.f_5728 = 1; } } if (!Global_22550.f_5729) { Global_22550.f_5732 = iVar9; Global_22550.f_5729 = 1; } iVar5++; } Global_22550.f_5876 = fVar49; Global_22550.f_5878 = unk_0x578C4EF320340AF7(); unk_0x530DC1525CA60B00(Global_22550.f_5876); if (!Global_22550.f_8382) { func_31(0); } Global_22550.f_8382 = 0; if (bParam2) { unk_0x4CB4237D8858ADA6(10); } unk_0x4CB4237D8858ADA6(6); unk_0x4CB4237D8858ADA6(7); unk_0x4CB4237D8858ADA6(9); unk_0x4CB4237D8858ADA6(8); if (bParam0) { func_45(1); } unk_0x5C64FD27DB62AF7A(); } void func_45(int iParam0) { Global_1378744.f_1121 = iParam0; } float func_46(int iParam0) { switch (iParam0) { case 35: case 34: case 48: case 47: case 42: case 36: case 37: case 39: case 40: case 38: case 53: case 44: case 45: case 46: return 0.85f; break; } return 1f; } void func_47(float fParam0, float fParam1, char* sParam2, var uParam3, var uParam4) { unk_0x40A75E32D30C605F(sParam2); unk_0x5BC8B357341A4FEE(uParam3, uParam4); unk_0xA434CC17B5517E4E(fParam0, fParam1, 0); } void func_48(float fParam0, float fParam1, char* sParam2, int iParam3, int iParam4) { unk_0x40A75E32D30C605F(sParam2); unk_0x42710E9E08FA375A(iParam3); unk_0xA434CC17B5517E4E(fParam0, fParam1, iParam4); } var func_49() { return unk_0x95C5B896CB42B20E(-1762644250); } void func_50(bool bParam0) { int iVar0; int iVar1; int iVar2; var uVar3; if (bParam0) { unk_0x28DD484BAEAF8437(Global_22550.f_8410[0], &iVar0, &iVar1, &iVar2, &uVar3); } else { unk_0x28DD484BAEAF8437(Global_22550.f_8410[1], &iVar0, &iVar1, &iVar2, &uVar3); } unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, 255); } void func_51(bool bParam0, bool bParam1, bool bParam2, bool bParam3, int iParam4, bool bParam5, bool bParam6) { int iVar0; int iVar1; int iVar2; int iVar3; if (bParam2) { if (bParam3) { func_52(Global_22550.f_6011[iParam4], &iVar0, &iVar1, &iVar2); if ((iVar0 < 20 && iVar1 < 20) && iVar2 < 20) { if (bParam0 == 0) { unk_0x28DD484BAEAF8437(1, &iVar0, &iVar1, &iVar2, &iVar3); } } else if ((iVar0 > 230 && iVar1 > 230) && iVar2 > 230) { if (bParam0) { iVar0 = 0; iVar1 = 0; iVar2 = 0; } } unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, 255); } else if (bParam1) { if (bParam0) { unk_0x28DD484BAEAF8437(14, &iVar0, &iVar1, &iVar2, &iVar3); unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, 255); } else { unk_0x28DD484BAEAF8437(12, &iVar0, &iVar1, &iVar2, &iVar3); unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, 255); } } else if (bParam0) { unk_0xA11D279671F2289C(155, 155, 155, 255); } else { unk_0xA11D279671F2289C(155, 155, 155, 255); } } else if (bParam1) { if (bParam0) { unk_0xA11D279671F2289C(0, 0, 0, SYSTEM::FLOOR((255f * 0.8f))); } else { unk_0x28DD484BAEAF8437(1, &iVar0, &iVar1, &iVar2, &iVar3); unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, iVar3); } } else if (bParam0) { unk_0xA11D279671F2289C(155, 155, 155, 255); } else { unk_0xA11D279671F2289C(155, 155, 155, 255); } unk_0x151E2F6EE4A34CFE(0f, 0.35f); unk_0xBC2BD09DB91678C5(1); if (bParam5) { unk_0x151E2F6EE4A34CFE(0f, 0.425f); unk_0xE9FEE5ECCAD48813(4); } else if (bParam6) { unk_0x151E2F6EE4A34CFE(0f, 0.425f); unk_0xE9FEE5ECCAD48813(6); } else { unk_0xE9FEE5ECCAD48813(0); } unk_0x86520D0C56F68D3F(0f, 1f); unk_0x9CB19F83A6C8E47F(0); unk_0xACADD4647896AEBE(0, 0, 0, 0, 0); unk_0xA5C56390CC2323FE(0, 0, 0, 0, 0); } void func_52(int iParam0, var uParam1, var uParam2, var uParam3) { switch (iParam0) { case 0: *uParam1 = 8; *uParam2 = 8; *uParam3 = 8; break; case 1: *uParam1 = 37; *uParam2 = 37; *uParam3 = 39; break; case 22: *uParam1 = 140; *uParam2 = 146; *uParam3 = 154; break; case 23: *uParam1 = 91; *uParam2 = 93; *uParam3 = 94; break; case 6: *uParam1 = 81; *uParam2 = 84; *uParam3 = 89; break; case 111: *uParam1 = 240; *uParam2 = 240; *uParam3 = 240; break; case 28: *uParam1 = 150; *uParam2 = 8; *uParam3 = 0; break; case 34: *uParam1 = 38; *uParam2 = 3; *uParam3 = 6; break; case 88: *uParam1 = 245; *uParam2 = 137; *uParam3 = 15; break; case 45: *uParam1 = 74; *uParam2 = 22; *uParam3 = 7; break; case 56: *uParam1 = 45; *uParam2 = 58; *uParam3 = 53; break; case 58: *uParam1 = 71; *uParam2 = 120; *uParam3 = 60; break; case 54: *uParam1 = 77; *uParam2 = 98; *uParam3 = 104; break; case 73: *uParam1 = 14; *uParam2 = 49; *uParam3 = 109; break; case 68: *uParam1 = 22; *uParam2 = 34; *uParam3 = 72; break; case 140: *uParam1 = 0; *uParam2 = 174; *uParam3 = 239; break; case 131: *uParam1 = 255; *uParam2 = 183; *uParam3 = 0; break; case 90: *uParam1 = 142; *uParam2 = 140; *uParam3 = 70; break; case 97: *uParam1 = 156; *uParam2 = 141; *uParam3 = 113; break; case 89: *uParam1 = 145; *uParam2 = 115; *uParam3 = 71; break; case 105: *uParam1 = 98; *uParam2 = 68; *uParam3 = 40; break; case 100: *uParam1 = 124; *uParam2 = 27; *uParam3 = 68; break; case 99: *uParam1 = 114; *uParam2 = 42; *uParam3 = 63; break; case 136: *uParam1 = 246; *uParam2 = 151; *uParam3 = 153; break; case 49: *uParam1 = 32; *uParam2 = 32; *uParam3 = 44; break; case 146: *uParam1 = 26; *uParam2 = 1; *uParam3 = 23; break; default: *uParam1 = 255; *uParam2 = 255; *uParam3 = 255; break; } } void func_53(int iParam0, int iParam1, int iParam2, int iParam3, bool bParam4, bool bParam5, bool bParam6, int iParam7, bool bParam8) { int iVar0; int iVar1; int iVar2; int iVar3; int iVar4; if (!func_41(&iVar0, 0, iParam1)) { return; } iParam0 = iParam0; if (iParam3 && !func_77(bParam4, bParam8)) { return; } if (func_58()) { return; } if (unk_0xDFAB5E5CBE16E8B1()) { return; } if (iParam7 == 0) { if (func_56(unk_0x460153A63B9477BC(), 0)) { return; } } if (unk_0xF8EDFF98A9C94C74()) { if (unk_0x913D69ADE739309E() == 0 || unk_0xDFAB5E5CBE16E8B1()) { return; } } if (Global_22550.f_4769 != 0) { if (unk_0x628AF533B14EF310(2)) { iVar1 = 0; while (iVar1 < Global_22550.f_4769) { if (Global_22550.f_5026[iVar1] != 361) { StringCopy(&(Global_22550.f_4771[iVar1 /*16*/]), unk_0xED026A379B794F61(2, Global_22550.f_5026[iVar1], 1), 64); } else if (Global_22550.f_5039[iVar1] != 32) { StringCopy(&(Global_22550.f_4771[iVar1 /*16*/]), unk_0x32F8D6499042A233(2, Global_22550.f_5039[iVar1], 1), 64); } iVar1++; } Global_22550.f_4770 = 0; } if (!Global_22550.f_4770) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "CLEAR_ALL"); unk_0xE1FDD153F5858534(); unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "SET_MAX_WIDTH"); unk_0x49B9B8101B158AEE((1f - (Global_22550.f_5081 / 100f))); unk_0xE1FDD153F5858534(); if (unk_0xF8EDFF98A9C94C74()) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "TOGGLE_MOUSE_BUTTONS"); unk_0xF1B28F753235CE2A(1); unk_0xE1FDD153F5858534(); } iVar1 = 0; while (iVar1 < Global_22550.f_4769) { if (unk_0x856D5567211886A2(&(Global_22550.f_4964[iVar1 /*4*/])) != unk_0x856D5567211886A2("PREV")) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "SET_DATA_SLOT"); unk_0xAD291B8F75D737AD(iVar1); func_55(&(Global_22550.f_4771[iVar1 /*16*/])); iVar2 = iVar1 + 1; while (iVar2 < 12 && unk_0x856D5567211886A2(&(Global_22550.f_4964[iVar2 /*4*/])) == unk_0x856D5567211886A2("PREV")) { func_55(&(Global_22550.f_4771[iVar2 /*16*/])); iVar2++; } if (Global_22550.f_5013[iVar1] == -1) { func_54(&(Global_22550.f_4964[iVar1 /*4*/])); } else { iVar3 = Global_22550.f_5013[iVar1]; if (iParam2 >= 0) { iVar3 = iParam2; } unk_0xB23270F3D5E62FDE(&(Global_22550.f_4964[iVar1 /*4*/])); if (bParam5) { unk_0x7899A951E85F4B28(iVar3, 70); } else { unk_0x42710E9E08FA375A(iVar3); } unk_0x2042E9CA4306F725(); } if (unk_0xF8EDFF98A9C94C74()) { if (Global_22550.f_5026[iVar1] != 361 && unk_0xCE990E643CD9D0E5(Global_22550.f_5052, iVar1)) { unk_0xF1B28F753235CE2A(1); unk_0xAD291B8F75D737AD(Global_22550.f_5026[iVar1]); } else { unk_0xF1B28F753235CE2A(0); unk_0xAD291B8F75D737AD(361); } } unk_0xE1FDD153F5858534(); } iVar1++; } if (unk_0x856D5567211886A2(&(Global_4269680.f_16)) != unk_0x856D5567211886A2("")) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "SET_DATA_SLOT"); unk_0xAD291B8F75D737AD(Global_22550.f_4769); func_55(&Global_4269680); if (Global_4269680.f_20 == -1) { func_54(&(Global_4269680.f_16)); } else { iVar4 = Global_22550.f_5013[iVar1]; if (iParam2 >= 0) { iVar4 = iParam2; } unk_0xB23270F3D5E62FDE(&(Global_4269680.f_16)); if (bParam5) { unk_0x7899A951E85F4B28(iVar4, 70); } else { unk_0x42710E9E08FA375A(iVar4); } unk_0x2042E9CA4306F725(); } unk_0xE1FDD153F5858534(); } unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "SET_BACKGROUND_COLOUR"); unk_0xAD291B8F75D737AD(0); unk_0xAD291B8F75D737AD(0); unk_0xAD291B8F75D737AD(0); unk_0xAD291B8F75D737AD(80); unk_0xE1FDD153F5858534(); unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "DRAW_INSTRUCTIONAL_BUTTONS"); if (Global_22550.f_5082) { unk_0xAD291B8F75D737AD(1); } else { unk_0xAD291B8F75D737AD(0); } unk_0xE1FDD153F5858534(); Global_22550.f_4770 = 1; } iVar1 = 0; while (iVar1 < Global_22550.f_4769) { if (Global_22550.f_5013[iVar1] != -1) { if (iParam2 > 0) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "OVERRIDE_RESPAWN_TEXT"); unk_0xAD291B8F75D737AD(iVar1); unk_0xB23270F3D5E62FDE(&(Global_22550.f_4964[iVar1 /*4*/])); if (bParam5) { unk_0x7899A951E85F4B28(iParam2, 70); } else { unk_0x42710E9E08FA375A(iParam2); } unk_0x2042E9CA4306F725(); unk_0xE1FDD153F5858534(); } } iVar1++; } if (Global_4269680.f_20 != -1) { if (iParam2 > 0) { unk_0x830F007E19C63E14(Global_22550.f_5660[iVar0 /*10*/], "OVERRIDE_RESPAWN_TEXT"); unk_0xAD291B8F75D737AD(iVar1); unk_0xB23270F3D5E62FDE(&(Global_4269680.f_16)); if (bParam5) { unk_0x7899A951E85F4B28(iParam2, 70); } else { unk_0x42710E9E08FA375A(iParam2); } unk_0x2042E9CA4306F725(); unk_0xE1FDD153F5858534(); } } unk_0xFCC7EAA298CE7AC2(76, 66); unk_0xFFA39C4568552522(0f, 0f, 0f, 0f); if (bParam6) { if (!Global_22550.f_8417) { unk_0x36FA9C099416853E(15, 0f, -0.0375f); Global_22550.f_8417 = 1; } } else if (Global_22550.f_8417) { unk_0x610B4083B1F95914(15); Global_22550.f_8417 = 0; } unk_0x5C64FD27DB62AF7A(); if (Global_22550.f_5055) { unk_0xFCC7EAA298CE7AC2(82, 66); unk_0xFFA39C4568552522(0f, 0f, 0f, 0f); unk_0xE6A03BA84586E67B(Global_22550.f_5660[iVar0 /*10*/], Global_22550.f_5053, Global_22550.f_5054, 1f, 1f, 255, 255, 255, 255, 0); unk_0x5C64FD27DB62AF7A(); } else { unk_0x37FC7E88C7659D33(Global_22550.f_5660[iVar0 /*10*/], 255, 255, 255, 255, 0); } } } void func_54(var uParam0) { unk_0xB23270F3D5E62FDE(uParam0); unk_0x2042E9CA4306F725(); } void func_55(var uParam0) { unk_0x54AED56A452DCB4F(uParam0); } bool func_56(int iParam0, int iParam1) { bool bVar0; if (iParam0 == unk_0x460153A63B9477BC()) { bVar0 = func_57(-1, 0) == 8; } else { bVar0 = Global_1590682[iParam0 /*883*/].f_211 == 8; } if (iParam1 == 1) { if (unk_0x166E920FB00B2DBB(iParam0)) { bVar0 = unk_0x6CC163E30ECE0790(iParam0) == 8; } } return bVar0; } int func_57(int iParam0, bool bParam1) { int iVar0; int iVar1; iVar1 = iParam0; if (iVar1 == -1) { iVar1 = func_15(); } if (Global_1312876[iVar1] == 1) { if (bParam1) { } iVar0 = 8; } else { iVar0 = Global_1312757[iVar1]; if (bParam1) { } } return iVar0; } int func_58() { struct<3> Var0; if (Global_19681.f_1 > 3) { return 1; } if (func_59()) { Var0 = { 0f, -500f, 0f }; unk_0x1F1B1269BB6217F7(&Var0); if (Global_19626 == 0) { if (Var0.f_1 > -119f) { return 1; } else { return 0; } } else if (Var0.f_1 > -101f) { return 1; } else { return 0; } } return 0; } int func_59() { if (unk_0x7B70881748D166CD(joaat("cellphone_flashhand")) > 0) { return 1; } return 0; } void func_60(int iParam0, bool bParam1, int iParam2, int iParam3, int iParam4, int iParam5) { unk_0x28DD484BAEAF8437(1, iParam2, iParam3, iParam4, iParam5); *iParam5 = 255; switch (iParam0) { case 28: *iParam2 = 194; *iParam3 = 80; *iParam4 = 80; break; case 15: case 4: case 16: case 26: case 27: case 35: case 34: case 48: case 47: case 42: case 36: case 37: case 53: case 39: case 40: case 38: case 44: case 45: case 46: case 52: case 56: case 57: case 58: case 59: if (bParam1) { *iParam2 = 0; *iParam3 = 0; *iParam4 = 0; } break; case 54: *iParam5 = 100; break; case 62: *iParam5 = 100; break; case 55: unk_0x28DD484BAEAF8437(24, iParam2, iParam3, iParam4, iParam5); *iParam5 = 255; break; } } void func_61(float fParam0) { int iVar0; int iVar1; int iVar2; int iVar3; unk_0x28DD484BAEAF8437(1, &iVar0, &iVar1, &iVar2, &iVar3); unk_0xE9FEE5ECCAD48813(0); unk_0x151E2F6EE4A34CFE(0f, 0.35f); unk_0x7508E89F04871147(2); unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, iVar3); unk_0x86520D0C56F68D3F(fParam0, ((Global_22547 + Global_22549) - 0.0046875f)); unk_0x9CB19F83A6C8E47F(0); unk_0xACADD4647896AEBE(0, 0, 0, 0, 0); unk_0xA5C56390CC2323FE(0, 0, 0, 0, 0); } void func_62(float fParam0, float fParam1, char* sParam2, int iParam3, int iParam4) { unk_0x40A75E32D30C605F(sParam2); unk_0x42710E9E08FA375A(uParam3); unk_0x42710E9E08FA375A(uParam4); unk_0xA434CC17B5517E4E(fParam0, fParam1, 0); } float func_63(char* sParam0, int iParam1, int iParam2) { if (!unk_0x211E6DB3335430B4(sParam0)) { if (unk_0x856D5567211886A2(sParam0) == 0) { return 0f; } } else { return 0f; } func_64(); unk_0x456829A212A690D7(sParam0); unk_0x42710E9E08FA375A(uParam1); unk_0x42710E9E08FA375A(uParam2); return unk_0x842CB5919E31EB1F(1); } void func_64() { int iVar0; int iVar1; int iVar2; int iVar3; unk_0x28DD484BAEAF8437(1, &iVar0, &iVar1, &iVar2, &iVar3); if (Global_22550.f_8392) { iVar0 = Global_22550.f_8388; iVar1 = Global_22550.f_8389; iVar2 = Global_22550.f_8390; iVar3 = Global_22550.f_8391; } unk_0xE9FEE5ECCAD48813(0); unk_0x151E2F6EE4A34CFE(0f, 0.35f); unk_0xA11D279671F2289C(iVar0, iVar1, iVar2, iVar3); unk_0x86520D0C56F68D3F((Global_22547 + 0.0046875f), ((Global_22547 + Global_22549) - 0.0046875f)); unk_0x9CB19F83A6C8E47F(0); unk_0xACADD4647896AEBE(0, 0, 0, 0, 0); unk_0xA5C56390CC2323FE(0, 0, 0, 0, 0); } void func_65(float fParam0, float fParam1, float fParam2, float fParam3, int iParam4, int iParam5, int iParam6, int iParam7) { unk_0x8DDE075026DB7EFD((fParam0 + (fParam2 * 0.5f)), (fParam1 + (fParam3 * 0.5f)), fParam2, fParam3, iParam4, iParam5, iParam6, iParam7, 0); } var func_66(int iParam0, bool bParam1) { char* sVar0[2]; var uVar1; struct<13> Var2; if (!unk_0x7BCC91F3C1CF24E8(&(Global_22550.f_7029[iParam0 /*16*/]))) { if (unk_0x856D5567211886A2(&(Global_22550.f_7029[iParam0 /*16*/])) == joaat("CREW_LOGO")) { Var2 = { func_68(unk_0x460153A63B9477BC()) }; if (unk_0x716812D32AF6C4C0(&Var2, &uVar1)) { return func_67(&uVar1); } } else { return func_67(&(Global_22550.f_7029[iParam0 /*16*/])); } } switch (iParam0) { case 3: sVar0[0] = "MP_hostCrown"; sVar0[1] = "MP_hostCrown"; break; case 21: sVar0[0] = "MP_SpecItem_Coke"; sVar0[1] = "MP_SpecItem_Coke"; break; case 22: sVar0[0] = "MP_SpecItem_Heroin"; sVar0[1] = "MP_SpecItem_Heroin"; break; case 23: sVar0[0] = "MP_SpecItem_Weed"; sVar0[1] = "MP_SpecItem_Weed"; break; case 24: sVar0[0] = "MP_SpecItem_Meth"; sVar0[1] = "MP_SpecItem_Meth"; break; case 25: sVar0[0] = "MP_SpecItem_Cash"; sVar0[1] = "MP_SpecItem_Cash"; break; case 1: sVar0[0] = "shop_NEW_Star"; sVar0[1] = "shop_NEW_Star"; break; case 2: sVar0[0] = "shop_NEW_Star"; sVar0[1] = "shop_NEW_Star"; break; case 4: sVar0[0] = "Shop_Tick_Icon"; sVar0[1] = "Shop_Tick_Icon"; break; case 6: sVar0[0] = "Shop_Box_CrossB"; sVar0[1] = "Shop_Box_Cross"; break; case 7: sVar0[0] = "Shop_Box_BlankB"; sVar0[1] = "Shop_Box_Blank"; break; case 5: sVar0[0] = "Shop_Box_TickB"; sVar0[1] = "Shop_Box_Tick"; break; case 8: sVar0[0] = "shop_NEW_Star"; sVar0[1] = "shop_NEW_Star"; break; case 9: sVar0[0] = "Shop_Clothing_Icon_B"; sVar0[1] = "Shop_Clothing_Icon_A"; break; case 10: sVar0[0] = "Shop_GunClub_Icon_B"; sVar0[1] = "Shop_GunClub_Icon_A"; break; case 17: sVar0[0] = "Shop_Ammo_Icon_B"; sVar0[1] = "Shop_Ammo_Icon_A"; break; case 18: sVar0[0] = "Shop_Armour_Icon_B"; sVar0[1] = "Shop_Armour_Icon_A"; break; case 19: sVar0[0] = "Shop_Health_Icon_B"; sVar0[1] = "Shop_Health_Icon_A"; break; case 20: sVar0[0] = "Shop_MakeUp_Icon_B"; sVar0[1] = "Shop_MakeUp_Icon_A"; break; case 11: sVar0[0] = "Shop_Tattoos_Icon_B"; sVar0[1] = "Shop_Tattoos_Icon_A"; break; case 12: sVar0[0] = "Shop_Garage_Icon_B"; sVar0[1] = "Shop_Garage_Icon_A"; break; case 13: sVar0[0] = "Shop_Garage_Bike_Icon_B"; sVar0[1] = "Shop_Garage_Bike_Icon_A"; break; case 14: sVar0[0] = "Shop_Barber_Icon_B"; sVar0[1] = "Shop_Barber_Icon_A"; break; case 15: sVar0[0] = "shop_Lock"; sVar0[1] = "shop_Lock"; break; case 16: sVar0[0] = "Shop_Tick_Icon"; sVar0[1] = "Shop_Tick_Icon"; break; case 26: sVar0[0] = "arrowleft"; sVar0[1] = "arrowleft"; break; case 27: sVar0[0] = "arrowright"; sVar0[1] = "arrowright"; break; case 28: sVar0[0] = "MP_AlertTriangle"; sVar0[1] = "MP_AlertTriangle"; break; case 29: sVar0[0] = "shop_NEW_Star"; sVar0[1] = "shop_NEW_Star"; break; case 31: sVar0[0] = "Shop_Michael_Icon_B"; sVar0[1] = "Shop_Michael_Icon_A"; break; case 32: sVar0[0] = "Shop_Franklin_Icon_B"; sVar0[1] = "Shop_Franklin_Icon_A"; break; case 33: sVar0[0] = "Shop_Trevor_Icon_B"; sVar0[1] = "Shop_Trevor_Icon_A"; break; case 51: sVar0[0] = "SaleIcon"; sVar0[1] = "SaleIcon"; break; case 52: sVar0[0] = "Shop_Tick_Icon"; sVar0[1] = "Shop_Tick_Icon"; break; case 54: sVar0[0] = "shop_NEW_Star"; sVar0[1] = "shop_NEW_Star"; break; case 55: sVar0[0] = "Shop_Lock_Arena"; sVar0[1] = "Shop_Lock_Arena"; break; case 56: sVar0[0] = "Card_Suit_Clubs"; sVar0[1] = "Card_Suit_Clubs"; break; case 57: sVar0[0] = "Card_Suit_Hearts"; sVar0[1] = "Card_Suit_Hearts"; break; case 58: sVar0[0] = "Card_Suit_Spades"; sVar0[1] = "Card_Suit_Spades"; break; case 59: sVar0[0] = "Card_Suit_Diamonds"; sVar0[1] = "Card_Suit_Diamonds"; break; case 60: sVar0[0] = "Shop_Art_Icon_B"; sVar0[1] = "Shop_Art_Icon_A"; break; case 62: sVar0[0] = "Shop_Art_Icon_B"; sVar0[1] = "Shop_Art_Icon_A"; break; case 61: sVar0[0] = "Shop_Chips_A"; sVar0[1] = "Shop_Chips_B"; break; case 0: sVar0[0] = ""; sVar0[1] = ""; break; } if (bParam1) { return sVar0[0]; } return sVar0[1]; } var func_67(var uParam0) { return uParam0; } struct<13> func_68(int iParam0) { struct<13> Var0; unk_0x2BDD80E79441BD36(iParam0, &Var0, 13); return Var0; } char* func_69(int iParam0) { var uVar0; struct<13> Var1; if (!unk_0x7BCC91F3C1CF24E8(&(Global_22550.f_6020[iParam0 /*16*/]))) { if (unk_0x856D5567211886A2(&(Global_22550.f_6020[iParam0 /*16*/])) == joaat("CREW_LOGO")) { Var1 = { func_68(unk_0x460153A63B9477BC()) }; unk_0x716812D32AF6C4C0(&Var1, &uVar0); return func_67(&uVar0); } else { return func_67(&(Global_22550.f_6020[iParam0 /*16*/])); } } if (iParam0 == 51) { return "MPShopSale"; } return "CommonMenu"; } void func_70(int iParam0, char* sParam1, int iParam2, bool bParam3, int iParam4, bool bParam5) { int iVar0; float fVar1; float fVar2; var uVar3; float fVar4; if (Global_22550.f_5218 > iParam0) { return; } if (Global_22550.f_5218 >= 128) { return; } if (Global_22550.f_5220 >= 256) { return; } if (Global_22550.f_5743 < Global_22550.f_5741) { return; } if (Global_22550.f_5218 != iParam0) { Global_22550.f_5218 = iParam0; Global_22550.f_5219 = 0; } iVar0 = Global_22550.f_5056[Global_22550.f_5219]; if (iVar0 != 1) { while (Global_22550.f_5219 < 4 && iVar0 != 1) { Global_22550.f_5219++; iVar0 = Global_22550.f_5056[Global_22550.f_5219]; } if (iVar0 != 1) { return; } } StringCopy(&(Global_22550.f_73[Global_22550.f_5220 /*6*/]), sParam1, 24); if (!unk_0x7BCC91F3C1CF24E8(sParam1) && !unk_0x3030AE9FCF1BC243(sParam1)) { } Global_22550.f_1610[Global_22550.f_5220] = bParam3; Global_22550.f_1867[Global_22550.f_5220] = iParam4; Global_22550.f_5220++; if (!bParam3) { func_73(Global_22550.f_5218, 1); } else { func_73(Global_22550.f_5218, 0); } if (iParam2 == 0) { fVar1 = func_72(&(Global_22550.f_73[Global_22550.f_5220 /*6*/])); if (Global_22550.f_5075[Global_22550.f_5219]) { func_75(26, 1, 0, &fVar2, &uVar3, 0); fVar1 = (fVar1 + (fVar2 * 2f)); } if (fVar1 > Global_22550.f_5068[Global_22550.f_5219]) { Global_22550.f_5068[Global_22550.f_5219] = fVar1; } } if (bParam5) { if (iParam2 == 0) { fVar4 = func_71(&(Global_22550.f_73[Global_22550.f_5220 /*6*/])); if (fVar4 > Global_22550.f_5745[iParam0]) { Global_22550.f_5745[iParam0] = fVar4; } } } unk_0xBE20AB8238688965(&(Global_22550.f_5089[iParam0]), Global_22550.f_5219); Global_22550.f_5219++; Global_22550.f_5744 = 1; Global_22550.f_5742 = (Global_22550.f_5220 - 1); Global_22550.f_5743 = 0; Global_22550.f_5741 = iParam2; } float func_71(char* sParam0) { if (!unk_0x3030AE9FCF1BC243(sParam0)) { } return unk_0xBA269EB4693A8C47(0.35f, 0); } float func_72(char* sParam0) { if (!unk_0x211E6DB3335430B4(sParam0)) { if (unk_0x856D5567211886A2(sParam0) == 0) { return 0f; } } else { return 0f; } func_51(0, 1, 0, 0, 0, 0, 0); unk_0x456829A212A690D7(sParam0); return unk_0x842CB5919E31EB1F(1); } void func_73(int iParam0, bool bParam1) { int iVar0; iVar0 = SYSTEM::FLOOR((SYSTEM::TO_FLOAT(iParam0) / 32f)); if (bParam1) { unk_0xBE20AB8238688965(&(Global_22550.f_6015[iVar0]), (iParam0 - iVar0 * 32)); } else { unk_0xD2459066EA58CE43(&(Global_22550.f_6015[iVar0]), (iParam0 - iVar0 * 32)); } } int func_74() { int iVar0; int iVar1; float fVar2; unk_0x9DD549AAA043F83A(&iVar0, &iVar1); fVar2 = (SYSTEM::TO_FLOAT(iVar0) / SYSTEM::TO_FLOAT(iVar1)); if (fVar2 > 3.5f) { return 1; } return 0; } int func_75(int iParam0, bool bParam1, bool bParam2, float fParam3, float fParam4, bool bParam5) { char cVar0[64]; char cVar1[64]; int iVar2; int iVar3; float fVar4; float fVar5; float fVar6; struct<3> Var7; StringCopy(&cVar0, func_69(iParam0), 64); StringCopy(&cVar1, func_66(iParam0, bParam1), 64); if (unk_0x856D5567211886A2(&cVar1) != 0) { fVar4 = 1f; if (bParam5) { unk_0x9DD549AAA043F83A(&iVar2, &iVar3); fVar5 = unk_0x8940B46482DD0A7D(0); if (func_74()) { iVar2 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar3) * fVar5)); } fVar6 = (SYSTEM::TO_FLOAT(iVar2) / SYSTEM::TO_FLOAT(iVar3)); fVar4 = (fVar6 / fVar5); if (func_74()) { fVar4 = 1f; } if (unk_0x7B70881748D166CD(joaat("director_mode")) > 0) { unk_0x8BAB7B3A2C7777A5(&iVar2, &iVar3); } iVar2 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar2) / fVar4)); iVar3 = SYSTEM::ROUND((SYSTEM::TO_FLOAT(iVar3) / fVar4)); } else { unk_0x8BAB7B3A2C7777A5(&iVar2, &iVar3); } Var7 = { unk_0x282B86763E4DCFC4(&cVar0, &cVar1) }; Var7.x = (Var7.x * (func_76(iParam0) / fVar4)); Var7.f_1 = (Var7.f_1 * (func_76(iParam0) / fVar4)); if (!bParam2) { Var7.x = (Var7.x - 2f); Var7.f_1 = (Var7.f_1 - 2f); } if (iParam0 == 30) { Var7.x = 288f; Var7.f_1 = 106f; } if (iParam0 == 29 && unk_0x856D5567211886A2(&(Global_22550.f_7029[29 /*16*/])) == joaat("CREW_LOGO")) { Var7.x = 106f; Var7.f_1 = 106f; } *fParam3 = ((Var7.x / IntToFloat(iVar2)) * IntToFloat((iVar2 / iVar3))); *fParam4 = (((Var7.f_1 / IntToFloat(iVar3)) / (Var7.x / IntToFloat(iVar2))) * *fParam3); if (!bParam5) { if (!unk_0xE5EF21F14D0F9D25() && iParam0 != 30) { *fParam3 = (*fParam3 * 1.33f); } } if (iParam0 == 29) { if (*fParam3 > Global_22549) { *fParam4 = (*fParam4 * (Global_22549 / *fParam3)); *fParam3 = Global_22549; } } return 1; } return 0; } float func_76(int iParam0) { switch (iParam0) { case 33: case 4: case 11: case 31: case 20: case 15: case 10: case 12: case 13: case 32: case 9: case 5: case 6: case 7: case 14: case 18: case 19: case 17: case 28: case 26: case 27: case 52: case 56: case 57: case 58: case 59: case 60: case 62: return 0.5f; break; case 61: return 0.8f; break; } return 1f; } int func_77(bool bParam0, bool bParam1) { if (Global_2440049.f_2005.f_701 != 0) { return 1; } if ((((((((!unk_0x87F0CB19476706C3() || (func_79(8, -1) && func_78() != 65)) || (unk_0xCFB49FF4012D7C68() != 0 && !bParam1)) || (unk_0x9CC4D06F5338CA6B() && !bParam0)) || unk_0x954BAB46FBB90036()) || Global_77093) || Global_22550.f_8416) || unk_0x06EBE4F22EC30D45()) || Global_99007.f_1425) { return 0; } return 1; } int func_78() { return Global_1312830; } bool func_79(int iParam0, int iParam1) { switch (iParam0) { case 5: if (iParam1 > -1) { return Global_1377236.f_203[iParam1]; } break; } return unk_0xCE990E643CD9D0E5(Global_1377236.f_1048, iParam0); } void func_80() { switch (iLocal_139) { case 1: func_84(); break; case 0: func_83(); break; case 2: func_81(); break; } } void func_81() { if (!func_170()) { if (iLocal_127 == 0) { func_82("JBOX_CONF_ON", 0, 0); } else { func_82("JBOX_CANC_PUR", 0, 0); } } else if (iLocal_126 == iLocal_137) { if (iLocal_127 == 0) { func_82("JBOX_CONF_OFF", 0, 0); } else { func_82("JBOX_CANC_PUR", 0, 0); } } else if (iLocal_127 == 0) { func_82("JBOX_CONF_PUR", 0, 0); } else { func_82("JBOX_CANC_PUR", 0, 0); } } void func_82(char* sParam0, int iParam1, int iParam2) { int iVar0; StringCopy(&(Global_22550.f_4690), sParam0, 24); Global_22550.f_4762 = 0; Global_22550.f_4763 = 0; Global_22550.f_4764 = 0; Global_22550.f_4765 = 0; Global_22550.f_4766 = iParam1; Global_22550.f_4767 = unk_0x578C4EF320340AF7(); Global_22550.f_4768 = iParam2; iVar0 = 0; while (iVar0 < 4) { Global_22550.f_4696[iVar0] = 0; iVar0++; } } void func_83() { struct<2> Var0; if (iLocal_127 == Local_150.f_3 && func_170()) { func_82("JBOX_PLIST_PLY", 0, 0); } else if (iLocal_127 == iLocal_137) { func_82("JBOX_TOFF", 0, 0); } else { StringCopy(&Var0, "JBOX_PLIST_D_", 16); StringIntConCat(&Var0, iLocal_127, 16); func_82(&Var0, 0, 0); } } void func_84() { func_82("JBOX_TOFF_NM", 0, 0); } void func_85(int iParam0, bool bParam1, int iParam2) { int iVar0; int iVar1; Global_22550.f_5739 = iParam0; Global_22550.f_5874 = iParam2; if (Global_22550.f_5739 < Global_22550.f_5738) { Global_22550.f_5738 = Global_22550.f_5739; } else if ((Global_22550.f_5729 && Global_22550.f_5739 > Global_22550.f_5740) || (!Global_22550.f_5729 && Global_22550.f_5739 >= (Global_22550.f_5738 + Global_22550.f_5225))) { iVar0 = Global_22550.f_5738; while (iVar0 <= Global_22550.f_5739) { if (iVar0 >= 0 && iVar0 < 127) { if (Global_22550.f_5089[iVar0] != 0) { iVar1++; } } iVar0++; } while (iVar1 > Global_22550.f_5225 && Global_22550.f_5738 < 128) { Global_22550.f_5738++; iVar1 = 0; iVar0 = Global_22550.f_5738; while (iVar0 <= Global_22550.f_5739) { if (iVar0 >= 0 && iVar0 < 127) { if (Global_22550.f_5089[iVar0] != 0) { iVar1++; } } iVar0++; } } } Global_22550.f_5728 = 0; Global_22550.f_5729 = 0; if (bParam1) { StringCopy(&(Global_22550.f_4690), "", 24); StringCopy(&(Global_4269680.f_21), "", 16); } } void func_86() { switch (iLocal_139) { case 1: func_96(); break; case 0: func_94(); break; case 2: func_87(); break; } } void func_87() { func_89("JBOX_CONF_T"); func_70(0, "JBOX_MENU_0", 0, 1, 0, 0); func_70(1, "JBOX_MENU_1", 0, 1, 0, 0); func_85(iLocal_127, 1, 1); func_88(201, "ITEM_SELECT", -1, 0); func_88(202, "ITEM_BACK", -1, 0); } void func_88(int iParam0, char* sParam1, int iParam2, bool bParam3) { char* sVar0; sVar0 = unk_0xED026A379B794F61(2, iParam0, 1); if (Global_22550.f_4769 >= 12) { StringCopy(&Global_4269680, sVar0, 64); StringCopy(&(Global_4269680.f_16), sParam1, 16); Global_4269680.f_20 = iParam2; return; return; } if (!bParam3) { unk_0xBE20AB8238688965(&(Global_22550.f_5052), Global_22550.f_4769); } StringCopy(&(Global_22550.f_4771[Global_22550.f_4769 /*16*/]), sVar0, 64); StringCopy(&(Global_22550.f_4964[Global_22550.f_4769 /*4*/]), sParam1, 16); Global_22550.f_5013[Global_22550.f_4769] = iParam2; Global_22550.f_5026[Global_22550.f_4769] = iParam0; Global_22550.f_5039[Global_22550.f_4769] = 32; Global_22550.f_4769++; } void func_89(char* sParam0) { func_93(0, 0); func_92(sParam0); func_91(1, 2, 1, 1, 1); func_90(1, 1, 0, 0, 0); } void func_90(int iParam0, int iParam1, int iParam2, int iParam3, int iParam4) { Global_22550.f_5056[0] = iParam0; Global_22550.f_5056[1] = iParam1; Global_22550.f_5056[2] = iParam2; Global_22550.f_5056[3] = iParam3; Global_22550.f_5056[4] = iParam4; Global_22550.f_5226 = 0; if (iParam0 != 0) { Global_22550.f_5226++; } if (iParam1 != 0) { Global_22550.f_5226++; } if (iParam2 != 0) { Global_22550.f_5226++; } if (iParam3 != 0) { Global_22550.f_5226++; } if (iParam4 != 0) { Global_22550.f_5226++; } } void func_91(int iParam0, int iParam1, int iParam2, int iParam3, int iParam4) { Global_22550.f_5083[0] = iParam0; Global_22550.f_5083[1] = iParam1; Global_22550.f_5083[2] = iParam2; Global_22550.f_5083[3] = iParam3; Global_22550.f_5083[4] = iParam4; } void func_92(char* sParam0) { int iVar0; StringCopy(&(Global_22550.f_1), sParam0, 16); Global_22550.f_68 = 0; Global_22550.f_69 = 0; Global_22550.f_70 = 0; Global_22550.f_71 = 0; Global_22550.f_72 = 0; iVar0 = 0; while (iVar0 < 4) { Global_22550.f_5[iVar0] = 0; iVar0++; } } void func_93(bool bParam0, bool bParam1) { int iVar0; int iVar1; float fVar2; iVar0 = 0; while (iVar0 < 256) { StringCopy(&(Global_22550.f_73[iVar0 /*6*/]), "", 24); iVar1 = 0; while (iVar1 < 4) { Global_22550.f_2124[iVar0 /*5*/][iVar1] = 0; iVar1++; } iVar0++; } iVar0 = 0; while (iVar0 < 32) { StringCopy(&(Global_2462791[iVar0 /*16*/]), "", 64); iVar0++; } iVar0 = 0; while (iVar0 < 256) { Global_22550.f_3918[iVar0] = 0; iVar0++; } iVar0 = 0; while (iVar0 < 128) { Global_22550.f_4175[iVar0] = 0f; iVar0++; } iVar0 = 0; while (iVar0 < 256) { Global_22550.f_4433[iVar0] = 0; iVar0++; } iVar0 = 0; while (iVar0 < 128) { Global_22550.f_5089[iVar0] = 0; Global_22550.f_5227[iVar0] = 0; Global_22550.f_5356[iVar0] = 0; Global_22550.f_5879[iVar0] = 0f; Global_22550.f_5485[iVar0] = 0; Global_22550.f_5745[iVar0] = 0f; iVar0++; } iVar0 = 0; while (iVar0 < 5) { Global_22550.f_5056[iVar0] = 0; Global_22550.f_5068[iVar0] = 0f; Global_22550.f_5062[iVar0] = -1f; Global_22550.f_5075[iVar0] = 0; Global_22550.f_5083[iVar0] = 1; iVar0++; } iVar0 = 0; while (iVar0 < 12) { StringCopy(&(Global_22550.f_4964[iVar0 /*4*/]), "", 16); Global_22550.f_5013[iVar0] = -1; Global_22550.f_5026[iVar0] = 361; Global_22550.f_5039[iVar0] = 32; iVar0++; } iVar0 = 0; while (iVar0 < 63) { StringCopy(&(Global_22550.f_6020[iVar0 /*16*/]), "", 64); StringCopy(&(Global_22550.f_7029[iVar0 /*16*/]), "", 64); iVar0++; } if (bParam1) { iVar0 = 0; while (iVar0 < 256) { Global_22550.f_1610[iVar0] = 0; iVar0++; } } StringCopy(&(Global_4269680.f_16), "", 16); Global_4269680.f_20 = -1; Global_22550 = 0; Global_22550.f_5218 = 0; Global_22550.f_5219 = 0; Global_22550.f_5220 = 0; Global_22550.f_5222 = 0; Global_22550.f_5223 = 0; Global_22550.f_5224 = 0; Global_22550.f_5221 = 0; Global_22550.f_5874 = 0; Global_22550.f_6014 = 0; Global_22550.f_5739 = 0; Global_22550.f_5738 = 0; Global_22550.f_5740 = 0; StringCopy(&(Global_22550.f_4690), "", 24); Global_22550.f_4762 = 0; Global_22550.f_4763 = 0; Global_22550.f_4764 = 0; Global_22550.f_4765 = 0; Global_22550.f_4766 = 0; Global_22550.f_4767 = 0; iVar0 = 0; while (iVar0 < 4) { Global_22550.f_4696[iVar0] = 0; iVar0++; } Global_22550.f_4768 = 0; StringCopy(&(Global_4269680.f_21), "", 16); Global_4269680.f_61 = 0; Global_4269680.f_62 = 0; Global_4269680.f_63 = 0; Global_4269680.f_64 = 0; Global_4269680.f_65 = 0; Global_4269680.f_66 = 0; iVar0 = 0; while (iVar0 < 4) { Global_4269680.f_25[iVar0] = 0; iVar0++; } Global_4269680.f_67 = 0; StringCopy(&(Global_22550.f_1), "", 16); Global_22550.f_5074 = 0f; Global_22550.f_68 = 0; Global_22550.f_69 = 0; Global_22550.f_70 = 0; Global_22550.f_71 = 0; Global_22550.f_72 = 0; iVar0 = 0; while (iVar0 < 4) { Global_22550.f_5[iVar0] = 0; iVar0++; } Global_22550.f_5744 = 0; Global_22550.f_5743 = 0; Global_22550.f_5741 = 0; Global_22550.f_5742 = 0; Global_22550.f_4769 = 0; Global_22550.f_4770 = 0; Global_22550.f_5225 = 10; Global_22550.f_5226 = 0; Global_22550.f_5876 = 0f; Global_22550.f_5877 = 0f; Global_22550.f_5728 = 0; Global_22550.f_5729 = 0; Global_22550.f_5730 = 0f; Global_22550.f_5731 = 0; Global_22550.f_5733 = 0; Global_22550.f_5732 = 0; Global_22550.f_5734 = 0; Global_22550.f_5735 = 0; Global_22550.f_5736 = 0; Global_22550.f_5737 = 0; Global_22550.f_8413 = 0; iVar0 = 0; while (iVar0 < 2) { Global_22550.f_6008[iVar0] = -1; Global_22550.f_6011[iVar0] = -1; iVar0++; } Global_22550.f_5081 = 0f; Global_22550.f_5052 = 0; Global_22550.f_5082 = 0; iVar0 = 0; while (iVar0 < Global_22550.f_6015) { Global_22550.f_6015[iVar0] = 0; iVar0++; } Global_22550.f_8392 = 0; Global_22550.f_8387 = 0; Global_22550.f_8397 = 0; Global_22550.f_8402 = 0; Global_22550.f_8407 = 0; Global_22550.f_8409 = 0; Global_22550.f_8415 = 0; Global_22547 = 0.05f; Global_22548 = 0.05f; Global_22549 = 0.225f; fVar2 = unk_0x8940B46482DD0A7D(0); if (bParam0) { Global_22549 = (0.225f * ((16f / 9f) / fVar2)); } else if (fVar2 < 1.77777f) { Global_22549 = (0.225f * ((16f / 9f) / fVar2)); } else { Global_22549 = 0.225f; } } void func_94() { int iVar0; int iVar1; struct<2> Var2; bool bVar3; func_89("JBOX_MENU_T"); iVar0 = 4; if (iLocal_128 == 126) { iVar0 = 9; } iVar1 = 0; while (iVar1 < iVar0) { StringCopy(&Var2, "JBOX_PLIST_", 16); bVar3 = iVar1 != Local_150.f_3; if (!func_170()) { bVar3 = true; } StringIntConCat(&Var2, iVar1, 16); func_70(iVar1, &Var2, 0, bVar3, 0, 0); if (bVar3) { func_70(iVar1, "JBOX_CHARGE", 0, bVar3, 0, 0); } iVar1++; } if (func_170()) { func_70(iVar1, "JBOX_M_OFF", 0, 1, 0, 0); } func_85(iLocal_127, 1, 1); func_88(201, "ITEM_SELECT", -1, 0); func_88(202, "ITEM_BACK", -1, 0); if (func_170()) { func_95(8, "HUD_INPUT77", -1); } } void func_95(int iParam0, char* sParam1, int iParam2) { char* sVar0; sVar0 = unk_0x32F8D6499042A233(2, iParam0, 1); if (Global_22550.f_4769 >= 12) { StringCopy(&Global_4269680, sVar0, 64); StringCopy(&(Global_4269680.f_16), sParam1, 16); Global_4269680.f_20 = iParam2; return; return; } unk_0xD2459066EA58CE43(&(Global_22550.f_5052), Global_22550.f_4769); StringCopy(&(Global_22550.f_4771[Global_22550.f_4769 /*16*/]), sVar0, 64); StringCopy(&(Global_22550.f_4964[Global_22550.f_4769 /*4*/]), sParam1, 16); Global_22550.f_5013[Global_22550.f_4769] = iParam2; Global_22550.f_5026[Global_22550.f_4769] = 361; Global_22550.f_5039[Global_22550.f_4769] = iParam0; Global_22550.f_4769++; } void func_96() { func_89("JBOX_MENU_T"); func_70(0, "JBOX_M_OFF", 0, 1, 0, 0); func_85(iLocal_127, 1, 1); func_88(201, "ITEM_SELECT", -1, 0); func_88(202, "ITEM_BACK", -1, 0); } bool func_97(char* sParam0, int iParam1, bool bParam2) { int iVar0; bool bVar1; bool bVar2; if (!func_41(&iVar0, 1, iParam1)) { return 0; } bVar1 = true; StringCopy(&(Global_22550.f_5635[iVar0 /*4*/]), sParam0, 16); if (!unk_0x7BCC91F3C1CF24E8(&(Global_22550.f_5635[iVar0 /*4*/]))) { unk_0xBAA4D421B8B8A744(&(Global_22550.f_5635[iVar0 /*4*/]), 9); Global_22550.f_5628[iVar0] = 1; if (!unk_0xD77C5A1792C02DA1(&(Global_22550.f_5635[iVar0 /*4*/]), 9)) { bVar1 = false; } } unk_0x494D5FF88119CDC0("CommonMenu", 0); Global_22550.f_5614[iVar0] = 1; if (!unk_0xC7F5A2E99D75A65C("CommonMenu")) { bVar1 = false; } if (bParam2) { unk_0x494D5FF88119CDC0("MPShopSale", 0); Global_22550.f_5621[iVar0] = 1; if (!unk_0xC7F5A2E99D75A65C("MPShopSale")) { bVar1 = false; } } bVar2 = false; StringCopy(&(Global_22550.f_5660[iVar0 /*10*/].f_1), "instructional_buttons", 24); bVar2 = func_98(&(Global_22550.f_5660[iVar0 /*10*/])); if (!bVar1 || !bVar2) { } return (bVar1 && bVar2); } bool func_98(var uParam0) { switch (uParam0->f_9) { case 0: if (!unk_0x95EF219D38B20CFF(*uParam0)) { *uParam0 = unk_0x5DEA4192B46CB99B(&(uParam0->f_1)); uParam0->f_9 = 1; if (uParam0->f_7) { if (unk_0x95EF219D38B20CFF(*uParam0)) { uParam0->f_8 = unk_0x578C4EF320340AF7(); uParam0->f_9 = 2; } } } else { uParam0->f_8 = unk_0x578C4EF320340AF7(); uParam0->f_9 = 2; } break; case 1: if (unk_0x95EF219D38B20CFF(*uParam0)) { uParam0->f_8 = unk_0x578C4EF320340AF7(); uParam0->f_9 = 2; } break; case 2: if (!unk_0x95EF219D38B20CFF(*uParam0)) { uParam0->f_9 = 0; } break; } return uParam0->f_9 == 2; } void func_99() { int iVar0; int iVar1; bool bVar2; bool bVar3; bool bVar4; bool bVar5; bool bVar6; bool bVar7; bool bVar8; iVar1 = 150; if (unk_0x3430895AB97DE4F3(2)) { iVar1 = 110; } func_127(); unk_0x047901495C0572C0(2, 195, 1); unk_0x047901495C0572C0(2, 196, 1); unk_0x047901495C0572C0(2, 201, 1); unk_0x047901495C0572C0(2, 188, 1); unk_0x047901495C0572C0(2, 187, 1); bVar6 = unk_0x1BD7199394D7F19A(2, 201); bVar7 = (unk_0x1BD7199394D7F19A(2, 202) || unk_0x79800E51B3B6D197(2, 202)); iVar0 = unk_0x0EEB12E4AD6BD29B(2, 196); if (!unk_0xCE990E643CD9D0E5(uLocal_133, 0)) { if (unk_0x3430895AB97DE4F3(2)) { func_118(&bVar2, &bVar3, &bVar6, &bVar7, &bVar4, &bVar5); } else { bVar2 = (iVar0 < 100 || unk_0x22D6FB6153F774D3(2, 188)); bVar3 = (iVar0 > 150 || unk_0x22D6FB6153F774D3(2, 187)); bVar4 = unk_0x22D6FB6153F774D3(2, 52); bVar5 = unk_0x22D6FB6153F774D3(2, 51); } if (((bVar2 || bVar3) || bVar4) || bVar5) { func_19(&uLocal_141, 0, 0); unk_0xBE20AB8238688965(&uLocal_133, 0); } } else if (func_18(&uLocal_141, iVar1, 0)) { func_137(&uLocal_141); unk_0xD2459066EA58CE43(&uLocal_133, 0); } if (bVar3) { iLocal_127++; if (iLocal_127 > func_117()) { iLocal_127 = 0; } unk_0xC4CC25B68A91D144(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } if (bVar2) { iLocal_127 = (iLocal_127 - 1); if (iLocal_127 < 0) { iLocal_127 = func_117(); } unk_0xC4CC25B68A91D144(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } if (iLocal_128 == 126) { if (bVar4) { if (Local_150.f_1 < 1f) { func_116((Local_150.f_1 + 0.5f)); } } if (bVar5) { if (Local_150.f_1 > 0f) { func_116((Local_150.f_1 - 0.5f)); } } } if (bVar6) { bVar8 = false; switch (iLocal_139) { case 1: iLocal_139 = 0; iLocal_127 = 0; iLocal_126 = iLocal_137; func_153(4); unk_0xD2459066EA58CE43(&uLocal_133, 5); break; case 0: if (iLocal_127 != Local_150.f_3 || !func_170()) { iLocal_126 = iLocal_127; iLocal_139 = 2; iLocal_127 = 0; unk_0xBE20AB8238688965(&uLocal_133, 1); unk_0xBE20AB8238688965(&uLocal_133, 4); } else { bVar8 = true; } break; case 2: if (iLocal_127 == 0) { iLocal_131 = 0; func_153(4); if (iLocal_126 != iLocal_137) { unk_0xBE20AB8238688965(&uLocal_133, 5); func_100(iLocal_126); } } else { iLocal_139 = 0; iLocal_127 = 0; unk_0xBE20AB8238688965(&uLocal_133, 1); } break; } if (bVar8) { unk_0xC4CC25B68A91D144(-1, "ERROR", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } else { unk_0xC4CC25B68A91D144(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } } if (bVar7) { unk_0xC4CC25B68A91D144(-1, "BACK", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); switch (iLocal_139) { case 0: iLocal_139 = 0; iLocal_126 = -1; func_153(4); unk_0xD2459066EA58CE43(&uLocal_133, 5); break; case 1: iLocal_127 = 0; iLocal_126 = -1; func_153(4); unk_0xD2459066EA58CE43(&uLocal_133, 5); break; case 2: iLocal_139 = 0; iLocal_127 = 0; iLocal_126 = -1; unk_0xBE20AB8238688965(&uLocal_133, 1); break; } } } void func_100(int iParam0) { var uVar0; int iVar1; if (func_5(iLocal_128, -1)) { uVar0 = unk_0x856D5567211886A2(func_115(iParam0)); } else if (iLocal_128 == 126) { uVar0 = unk_0x856D5567211886A2(func_114(iParam0)); } if (unk_0x6914A85D2E17013B(1, 0, 0, 1, -1, 0)) { if (func_113()) { func_101(1976384368, 1, &iVar1, 0, 0, 1); Global_4264051[iVar1 /*85*/] = uVar0; } else { unk_0x02282973BA229BF2(1, uVar0, 0, 0); } } } void func_101(int iParam0, int iParam1, var uParam2, bool bParam3, bool bParam4, bool bParam5) { int iVar0; if (!func_113()) { return; } iVar0 = 1; if (bParam4) { iVar0 = 4; } else if (bParam3) { iVar0 = 2; } else if (bParam5) { iVar0 = 8; } switch (iParam0) { case -1645229221: case -585718395: case -1359375127: case 454359403: case -982394051: case 1643659499: case -2072289654: case 650665123: case 1654961868: case -876847842: case 68030260: case -2122299283: case 366672791: case 283351220: case 291576838: case 1182673174: case -516219046: case 1036455748: case 277665518: case 2043854386: case 1839532116: case 1022400740: case 1940862352: case -1389227906: case 711665950: case 1704445500: case 1515774909: case 1173654533: case -899802304: case -663944335: case 1208553146: case -613221010: case -671062876: case -407201236: case -754024203: case -1885444887: case 1931729587: case 1064954035: case -180141073: case 2131324797: case 1612072658: case -517447402: case 1948102096: case 1108628223: case -1834046564: case -1239008812: case -222363842: case -1276678868: case 1564537328: case -96593501: case 742499889: case 2050093329: case -1752488069: case 634375935: case 1850983186: case 763367758: case 1941570214: case 665109499: case -1330755006: case 1976384368: case 268924934: case 1869490922: case -336803850: case -1412692765: case 618167454: case 980623936: case 437291904: case -135813048: case -930104477: case -1420909320: case -1733398043: case -1892760262: case -1545737048: case 2039302543: case 402505853: case -1143510182: case 1678112166: case 837955913: case -1532467144: case 1815541181: if (iParam1 > 0 || Global_262145.f_27657) { func_102(uParam2, -1135378931, 537254313, 1474183246, iParam0, iParam1, iVar0, 7); } break; case -31156877: case -1027218631: case -1398318418: case 1652884147: case -57868256: case -1216489292: case -46622315: case -352356931: case -990286235: case 563463121: case 1734805203: case 941287179: case -1186079845: case -1985150258: case -1127021384: case -109201286: case 312105838: case 1982688246: case -661030418: case 1301046174: case -1586170317: case 393059668: case 23796958: case -1077156170: case 1780666425: case -2043695058: case -1922554349: case 1287308202: case 691372038: case 1480707108: case 1512499951: case 562283735: case -154732333: case -1362660491: case 645708827: case 767907967: case -1970151306: case 718859568: case -1955564771: case 892388724: case -1426920838: case 1349151477: case 1620609399: case 1961641934: case 210955503: case -59668082: case 1736933716: case -1468524125: case 111573502: case 1525644423: case 968073639: case 1577781788: case -934465332: case -1194253122: case -212607085: case -815546555: case 1048226110: case 569170531: case -856006867: case 848090538: case -47546905: case -293060240: case 463142405: case 1550217370: case -101307780: case -664597565: case 599804707: case -327918414: case 550898518: case 835976347: case 1347433368: case 1052472386: case -2130199671: case -1227654538: case 1864522104: case 215608230: case -876012764: case -722894325: case 1407278493: case -1579394494: case -27443911: case 1179783540: case 923419301: case -308826175: case 603298940: case -12619854: case -311112675: case 870439158: case -974288740: case -4138654: case -1180954122: case -1918051016: case 844330594: case 1934825517: case 1852024236: case 2099238988: case 1952643559: case -1172900789: case -2015399333: case -1574795641: case -961034881: case 1135468152: case 1265272476: case -634726636: case 696556762: case 403506509: case -883876414: case -1064150715: case -1387253055: case -716963152: case 1138089938: case -561012053: func_102(uParam2, -1135378931, 1445302971, 1474183246, iParam0, iParam1, iVar0, 7); break; } switch (iParam0) { case -1342064661: case -1693570755: case 1868043300: case -697248883: case -1295545795: case 914079366: case 395122350: case -331981076: case 1671535231: case -1896606724: case -1291433573: case 538631715: case 133782822: case 2081885153: case -1314365345: case 1322977732: case 396623013: case 1981664462: case -1921250821: case -1370731547: case 1683798242: case -910968288: if (iParam1 > 0 || Global_262145.f_27657) { func_102(uParam2, -1135378931, 537254313, 1474183246, iParam0, iParam1, iVar0, 7); } break; case 1240683675: case 1241904665: case -1100963799: case -494565059: case 827308208: case -1857685192: case 1698417709: case 1057653594: case 1810506918: case 451427308: case 824622151: case 1253978276: case -1576080766: case 1508411869: case 1428501742: case -1918967151: case 1261538664: case 1180397655: case 1414674366: case 261460130: case -2027658376: case -2017925037: case 1668610896: case -2032529561: case -1224479447: case -319306689: case -466527264: case 1925965142: case 592152676: case 2035612943: case 1568659720: case 1220095570: case 2050320631: case 592672421: case 1775876058: case -842062976: case -518651910: case 14658715: case -604793592: case -823426392: case -1401862980: case -173354274: case 409533976: case -1472522337: case 542574408: case -1261799063: case 784631574: case -2027479156: case -837690641: func_102(uParam2, -1135378931, 1445302971, 1474183246, iParam0, iParam1, iVar0, 7); break; } } int func_102(var uParam0, int iParam1, int iParam2, int iParam3, int iParam4, int iParam5, int iParam6, int iParam7) { bool bVar0; int iVar1; int iVar2; bool bVar3; int iVar4; bool bVar5; bVar0 = false; if (!func_113()) { bVar0 = true; } iVar1 = 1; if (!bVar0) { if (!unk_0x5053392075AA583C(func_15()) || unk_0x701B05C16EF4F48E()) { Global_4265553 = 1; return 0; } if (Global_2463410) { if (iParam3 == 1067618600 || iParam3 == -1303831698) { Global_4265554 = 1; return 0; } } } bVar3 = false; iVar2 = 0; while (iVar2 < 15) { if (Global_4264051[iVar2 /*85*/].f_66.f_2 == 0) { bVar3 = true; } iVar2++; } if (!bVar3) { return 0; } *uParam0 = 15; iVar4 = 2147483647; if ((bVar0 || iVar1) || unk_0x734A68E809CC23F0(&iVar4, iParam3, iParam4, iParam2, iParam5, iParam6)) { if ((bVar0 || iVar1) || unk_0x9F5556ED9A739FBC(iVar4)) { *uParam0 = func_109(iVar4, iParam1, iParam4, iParam2, iParam3, iParam5, 0, iParam6, iParam7, 1, 1); if (iVar1 && !bVar0) { } if (bVar0) { if (*uParam0 != -1) { Global_4264051[*uParam0 /*85*/].f_66.f_8 = 1; Global_4264051[*uParam0 /*85*/].f_66.f_12 = 1; } } Global_4265538 = 1; return 1; } } else { if (iParam7 & 2 != 0) { Global_4265552 = 1; Global_4265555 = iParam4; Global_4265557 = iParam3; Global_4265558 = 1; Global_4265556 = iParam5; } if (iParam7 & 8 != 0) { Global_4265555 = iParam4; Global_4265557 = iParam3; Global_4265558 = 1; Global_4265556 = iParam5; } bVar5 = false; if (bVar5) { func_108(1, iParam4); Global_4265552 = 0; } if (iParam7 & 4 != 0) { func_103(-1, iParam4, iParam6, iParam5, -1); } } return 0; } void func_103(int iParam0, int iParam1, var uParam2, var uParam3, int iParam4) { switch (iParam1) { case 1704445500: unk_0xBE20AB8238688965(&(Global_2425869[unk_0x460153A63B9477BC() /*443*/].f_126.f_71), 0); break; } if (iParam0 != -1) { func_104(iParam0); } } void func_104(int iParam0) { bool bVar0; bVar0 = false; if (!func_113()) { bVar0 = true; } if (iParam0 != -1) { if (func_107(iParam0)) { if (!bVar0) { unk_0x2ABDF07188759AF4(); } } else if (!bVar0) { unk_0x7365588A145923CE(Global_4264051[iParam0 /*85*/].f_66); } func_105(&(Global_4264051[iParam0 /*85*/])); } } void func_105(var uParam0) { uParam0->f_66 = 0; uParam0->f_66 = 2147483647; uParam0->f_66.f_1 = 0; uParam0->f_66.f_2 = 0; uParam0->f_66.f_3 = -1593119440; uParam0->f_66.f_4 = -2085313189; uParam0->f_66.f_5 = 0; uParam0->f_66.f_6 = 1227573907; uParam0->f_66.f_7 = -1161833819; *uParam0 = 0; uParam0->f_1 = 0; uParam0->f_13 = 0; uParam0->f_2 = 0; func_106(&(uParam0->f_14)); func_106(&(uParam0->f_14.f_13)); StringCopy(&(uParam0->f_14.f_26), "", 32); StringCopy(&(uParam0->f_14.f_34), "", 24); StringCopy(&(uParam0->f_14.f_40), "", 16); StringCopy(&(uParam0->f_14.f_44), "", 32); uParam0->f_3 = 0; uParam0->f_4 = 0; uParam0->f_5 = 0; uParam0->f_6 = 0; uParam0->f_7 = 0; uParam0->f_8 = 0; uParam0->f_66.f_8 = 0; uParam0->f_66.f_9 = 0; uParam0->f_66.f_10 = 0; uParam0->f_66.f_11 = 0; uParam0->f_66.f_13 = 0; uParam0->f_66.f_12 = 0; uParam0->f_66.f_14 = 0; uParam0->f_66.f_15 = 0; uParam0->f_66.f_16 = 0; uParam0->f_66.f_18 = 0; } void func_106(var uParam0) { *uParam0 = 0; uParam0->f_1 = 0; uParam0->f_2 = 0; uParam0->f_3 = 0; uParam0->f_4 = 0; uParam0->f_5 = 0; uParam0->f_6 = 0; uParam0->f_7 = 0; uParam0->f_8 = 0; uParam0->f_9 = 0; uParam0->f_10 = 0; uParam0->f_11 = 0; uParam0->f_12 = 0; } int func_107(int iParam0) { if (iParam0 >= 0 && iParam0 < 15) { return Global_4264051[iParam0 /*85*/].f_66.f_5 == 1; } return 0; } void func_108(int iParam0, var uParam1) { Global_2464590 = uParam1; Global_2464589 = iParam0; } int func_109(int iParam0, int iParam1, var uParam2, var uParam3, int iParam4, var uParam5, bool bParam6, var uParam7, var uParam8, int iParam9, int iParam10) { int iVar0; iVar0 = 0; iVar0 = 0; while (iVar0 < 15) { if (Global_4264051[iVar0 /*85*/].f_66.f_2 == 0) { if (!func_113()) { iParam0 = iVar0 + 900; } Global_4264051[iVar0 /*85*/].f_66.f_2 = 1; Global_4264051[iVar0 /*85*/].f_66.f_1 = uParam5; Global_4264051[iVar0 /*85*/].f_66.f_3 = iParam1; Global_4264051[iVar0 /*85*/].f_66.f_4 = uParam2; Global_4264051[iVar0 /*85*/].f_66.f_7 = uParam3; Global_4264051[iVar0 /*85*/].f_66.f_5 = 0; Global_4264051[iVar0 /*85*/].f_66 = iParam0; Global_4264051[iVar0 /*85*/].f_66.f_6 = iParam4; Global_4264051[iVar0 /*85*/].f_66.f_11 = uParam8; Global_4264051[iVar0 /*85*/].f_66.f_10 = uParam7; Global_4264051[iVar0 /*85*/].f_66.f_13 = iParam9; Global_4264051[iVar0 /*85*/].f_66.f_12 = 0; Global_4264051[iVar0 /*85*/].f_66.f_14 = unk_0xD3137A576BE9EC5C(); Global_4264051[iVar0 /*85*/].f_66.f_18 = 0; Global_4265538 = 0; if (bParam6) { Global_4264051[iVar0 /*85*/].f_66.f_5 = 1; } if (iParam1 == -1135378931 && iParam10) { func_110(Global_4264051[iVar0 /*85*/], iVar0); } return iVar0; } iVar0++; } return -1; } void func_110(struct<67> Param0, var uParam1, var uParam2, var uParam3, var uParam4, var uParam5, var uParam6, var uParam7, var uParam8, var uParam9, var uParam10, var uParam11, var uParam12, var uParam13, var uParam14, var uParam15, var uParam16, var uParam17, var uParam18, int iParam19) { struct<3> Var0; int iVar1; if (iParam19 < 0) { return; } Var0.f_2 = 2147483647; Var0.x = 1191422458; Var0.f_1 = unk_0x460153A63B9477BC(); Var0.f_2 = { Param0.f_66 }; Var0.f_2.f_33 = iParam19; iVar1 = func_112(Var0.f_1); if ((Global_262145.f_23581 && !Global_262145.f_23582) && !Global_262145.f_23583) { return; } if (!iVar1 == 0) { func_111(); unk_0xB802750B43D4047C(1, &Var0, 36, iVar1); } } void func_111() { unk_0xBE9B3870B1B370E3("AM_ARENA_SHP"); } var func_112(int iParam0) { var uVar0; if (iParam0 != -1) { unk_0xBE20AB8238688965(&uVar0, iParam0); } return uVar0; } int func_113() { if (unk_0xF8EDFF98A9C94C74()) { return unk_0xC5AA3415F982DC6C(); } return 0; } char* func_114(int iParam0) { switch (iParam0) { case 0: return "HIDDEN_RADIO_BIKER_CLASSIC_ROCK"; case 1: return "HIDDEN_RADIO_BIKER_MODERN_ROCK"; case 2: return "HIDDEN_RADIO_BIKER_HIP_HOP"; case 3: return "HIDDEN_RADIO_BIKER_PUNK"; case 4: return "HIDDEN_RADIO_ARCADE_POP"; case 5: return "HIDDEN_RADIO_ARCADE_DANCE"; case 6: return "HIDDEN_RADIO_ARCADE_EDM"; case 7: return "HIDDEN_RADIO_ARCADE_MIRROR_PARK"; case 8: return "HIDDEN_RADIO_ARCADE_WWFM"; default: } return "HIDDEN_RADIO_BIKER_CLASSIC_ROCK"; } char* func_115(int iParam0) { switch (iParam0) { case 0: return "HIDDEN_RADIO_BIKER_CLASSIC_ROCK"; case 1: return "HIDDEN_RADIO_BIKER_MODERN_ROCK"; case 2: return "HIDDEN_RADIO_BIKER_HIP_HOP"; case 3: return "HIDDEN_RADIO_BIKER_PUNK"; default: } return "HIDDEN_RADIO_BIKER_CLASSIC_ROCK"; } void func_116(float fParam0) { Local_151[unk_0x460153A63B9477BC() /*3*/].f_2 = fParam0; unk_0xBE20AB8238688965(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 3); } int func_117() { int iVar0; iVar0 = 4; if (iLocal_128 == 126) { iVar0 = 9; } switch (iLocal_139) { case 2: return 1; case 0: if (func_170()) { return iVar0; } else { return (iVar0 - 1); } break; case 1: return 0; } return 0; } void func_118(var uParam0, var uParam1, var uParam2, var uParam3, var uParam4, var uParam5) { if (unk_0xF8EDFF98A9C94C74() && !unk_0xDFAB5E5CBE16E8B1()) { if (unk_0x3430895AB97DE4F3(2)) { unk_0x779660A9E5364C4D(0, 1, 1); unk_0x779660A9E5364C4D(0, 2, 1); unk_0x779660A9E5364C4D(2, 200, 1); unk_0x047901495C0572C0(0, 237, 1); unk_0x047901495C0572C0(0, 238, 1); unk_0x047901495C0572C0(0, 241, 1); unk_0x047901495C0572C0(0, 242, 1); if ((Global_4269756 == -1 || Global_4269756 == -4) || Global_4269756 == -6) { unk_0x047901495C0572C0(1, 1, 1); unk_0x047901495C0572C0(1, 2, 1); } else { unk_0x779660A9E5364C4D(1, 1, 1); unk_0x779660A9E5364C4D(1, 2, 1); } func_124(0, 0, 0, 1); func_123(0, -1, 1); } if (func_122()) { if (Global_4269756 == iLocal_127) { *uParam2 = 1; } else { iLocal_127 = Global_4269756; func_85(iLocal_127, 1, 1); } } if (func_121()) { *uParam3 = 1; } if (func_120(0, 0, 0) || unk_0x22D6FB6153F774D3(2, 188)) { *uParam0 = 1; } if (func_119(0, 0, 0) || unk_0x22D6FB6153F774D3(2, 187)) { *uParam1 = 1; } if (unk_0x22D6FB6153F774D3(2, 189)) { *uParam4 = 1; } if (unk_0x22D6FB6153F774D3(2, 190)) { *uParam5 = 1; } } } int func_119(int iParam0, int iParam1, int iParam2) { if (unk_0xC1F43F8D0D5EB664(2)) { if (Global_4269756 == -3) { if ((unk_0x22D6FB6153F774D3(2, 237) && iParam0) || unk_0x1BD7199394D7F19A(2, 237)) { return 1; } } if (iParam2 == 0) { if (unk_0x22D6FB6153F774D3(2, 242) || (unk_0xB9C0D9B37277621D(2, 242) && iParam1)) { return 1; } } } return 0; } int func_120(int iParam0, int iParam1, int iParam2) { if (unk_0xC1F43F8D0D5EB664(2)) { if (Global_4269756 == -2) { if ((unk_0x22D6FB6153F774D3(2, 237) && iParam0) || unk_0x1BD7199394D7F19A(2, 237)) { return 1; } } if (iParam2 == 0) { if (unk_0x22D6FB6153F774D3(2, 241) || (unk_0xB9C0D9B37277621D(2, 241) && iParam1)) { return 1; } } } return 0; } int func_121() { if (unk_0xC1F43F8D0D5EB664(2)) { if (unk_0x1BD7199394D7F19A(2, 238)) { return 1; } } return 0; } int func_122() { if (unk_0xC1F43F8D0D5EB664(2)) { if (Global_4269756 > -1) { if (unk_0x1BD7199394D7F19A(2, 237)) { return 1; } } } return 0; } int func_123(int iParam0, int iParam1, bool bParam2) { if (!unk_0xC1F43F8D0D5EB664(2)) { return 0; } if (unk_0xF0C12886E5C1B20E() || unk_0x06EBE4F22EC30D45()) { return 0; } if (bParam2) { unk_0x670AE643E0B07F1D(); } if (Global_4269756 == -6) { unk_0x80DA25AB4C5012E9(4); if (iParam0 && unk_0x22D6FB6153F774D3(2, 237)) { return 1; } else { Global_4269756 = -1; return 0; } } if (((Global_4269756 > -1 || Global_4269756 == -3) || Global_4269756 == -2) || unk_0x300FEC80FC56D5D9()) { unk_0x80DA25AB4C5012E9(1); return 0; } if (Global_4269756 == -1 && iParam0) { if (unk_0x22D6FB6153F774D3(2, 237)) { unk_0x80DA25AB4C5012E9(4); Global_4269756 = -6; return 1; } else { unk_0x80DA25AB4C5012E9(3); return 0; } } unk_0x80DA25AB4C5012E9(1); return 0; } void func_124(bool bParam0, bool bParam1, bool bParam2, bool bParam3) { float fVar0; float fVar1; float fVar2; float fVar3; float fVar4; float fVar5; float fVar6; float fVar7; float fVar8; float fVar9; int iVar10; int iVar11; int iVar12; int iVar13; fVar6 = (0.034722f / 2f); iVar13 = -1; if (!unk_0xC1F43F8D0D5EB664(2)) { Global_4269756 = -1; return; } unk_0x46448A93D5DC6258(1); fVar0 = Global_22547; fVar2 = (fVar0 + Global_22549); fVar3 = Global_22550.f_5730; fVar1 = (Global_22550.f_5730 - (IntToFloat(Global_22550.f_5732) * 0.034722f)); if (bParam2) { fVar3 = (fVar3 + 0.034722f); fVar1 = (fVar1 + 0.034722f); } if (Global_22550.f_5732 < 1) { fVar1 = (Global_22550.f_5730 - 0.034722f); } unk_0xFCC7EAA298CE7AC2(76, 84); unk_0xFFA39C4568552522(-0.05f, -0.05f, 0f, 0f); fVar4 = fVar0; fVar5 = fVar1; unk_0xE1300BFF7C839435(fVar0, fVar1, &fVar0, &fVar1); unk_0xE1300BFF7C839435(fVar2, fVar3, &fVar2, &fVar3); unk_0x5C64FD27DB62AF7A(); func_126(); if (Global_4269756 == -6) { return; } Global_4269756 = -1; fVar7 = Global_4269750; fVar8 = Global_4269751; if (Global_22550.f_5733 > Global_22550.f_5732) { if (((Global_4269750 >= fVar0 && Global_4269750 <= fVar2) && Global_4269751 >= fVar3) && Global_4269751 < (fVar3 + fVar6)) { Global_4269756 = -2; if (bParam3) { func_125(0); } return; } if (((Global_4269750 >= fVar0 && Global_4269750 <= fVar2) && Global_4269751 >= (fVar3 + fVar6)) && Global_4269751 < (fVar3 + 0.034722f)) { Global_4269756 = -3; if (bParam3) { func_125(0); } return; } } if (((fVar7 >= fVar0 && fVar7 <= fVar2) && fVar8 >= fVar1) && fVar8 <= fVar3) { fVar9 = (fVar8 - fVar1); iVar13 = SYSTEM::FLOOR((fVar9 / 0.034722f)); if (Global_22550.f_5733 == -1) { Global_4269756 = 0; iVar13 = 0; return; } iVar11 = 148; iVar12 = (iVar11 / Global_22550.f_5732); iVar10 = (32 + (iVar11 - (iVar12 * iVar13))); if (bParam3) { if (!bParam1 || iVar13 != 0) { unk_0xFCC7EAA298CE7AC2(76, 84); unk_0xFFA39C4568552522(-0.05f, -0.05f, 0f, 0f); func_65(fVar4, (fVar5 + (IntToFloat(iVar13) * 0.034722f)), Global_22549, (0.034722f - 0.0015f), 255, 255, 255, iVar10); unk_0x5C64FD27DB62AF7A(); } } Global_4269756 = Global_22550.f_8038[iVar13]; return; } if (!bParam0) { if (fVar7 < fVar2) { Global_4269756 = -4; return; } if (fVar8 > 0.9f) { Global_4269756 = -5; return; } } else if (fVar7 < fVar2 && fVar8 < (fVar3 + 0.25f)) { Global_4269756 = -4; return; } Global_4269756 = -1; } void func_125(bool bParam0) { float fVar0; float fVar1; float fVar2; int iVar3; fVar2 = (0.034722f / 2f); if (bParam0) { iVar3 = 48; } else { iVar3 = 210; } fVar0 = Global_22547; fVar1 = Global_22550.f_5730; unk_0xFCC7EAA298CE7AC2(76, 84); unk_0xFFA39C4568552522(-0.05f, -0.05f, 0f, 0f); if (Global_4269756 == -2) { func_65(fVar0, fVar1, Global_22549, fVar2, 255, 255, 255, iVar3); } else if (Global_4269756 == -3) { func_65(fVar0, (fVar1 + fVar2), Global_22549, fVar2, 255, 255, 255, iVar3); } unk_0x5C64FD27DB62AF7A(); } void func_126() { Global_4269752 = Global_4269750; Global_4269753 = Global_4269751; Global_4269750 = unk_0x9A36B66CB7B51691(2, 239); Global_4269751 = unk_0x9A36B66CB7B51691(2, 240); Global_4269754 = (Global_4269750 - Global_4269752); Global_4269755 = (Global_4269751 - Global_4269753); } void func_127() { func_128(1); func_32(1); if (!unk_0x689B0FFC8081E57F() && !unk_0xF0C12886E5C1B20E()) { unk_0xABAEEAE8870E046D(0); unk_0x78BD44DB7D1A8D59(1); unk_0x779660A9E5364C4D(2, 200, 1); } } void func_128(bool bParam0) { if (bParam0) { if (func_129()) { Global_2451787.f_40 = 1; } } else { Global_2451787.f_40 = 0; } } bool func_129() { return unk_0xCE990E643CD9D0E5(Global_2451787.f_2, 11); } bool func_130() { return unk_0xCFB49FF4012D7C68() != 0; } int func_131() { if (!unk_0xA59F96B50B97E63C(unk_0x9B0761B4C3EB8BC7(), 0)) { switch (iLocal_131) { case 0: if (func_38("SELECT_TRACK", 1, 0)) { iLocal_131 = 1; } break; case 1: if (func_38("IDLE", 0, 1)) { iLocal_131 = 0; return 1; } break; } } func_31(0); return 0; } int func_132() { struct<3> Var0; func_127(); switch (iLocal_131) { case 0: func_31(0); Var0 = { unk_0x7EC595B99EA7C4B1(iLocal_123, 0.06f, -0.8958f, 0.2f) }; if (!func_20(&uLocal_143)) { func_19(&uLocal_143, 0, 0); } else if (func_18(&uLocal_143, 2000, 0)) { iLocal_131 = 1; } if (!func_136(unk_0x3E4D3CCC220BDFB1(unk_0x9B0761B4C3EB8BC7(), 1), Var0, 0.8f, 0)) { if (!func_133(unk_0x9B0761B4C3EB8BC7(), 2106541073)) { unk_0x83CAF206A9B8748C(unk_0x9B0761B4C3EB8BC7(), Var0, 1f, 4000, unk_0xEF7858F25585F853(iLocal_123), 0.125f); } } else { iLocal_131 = 1; } break; case 1: if (func_38("ENTER", 1, 0)) { func_137(&uLocal_143); iLocal_131 = 2; } break; case 2: if (func_38("IDLE", 0, 1)) { iLocal_131 = 0; return 1; } break; } return 0; } int func_133(int iParam0, int iParam1) { if (func_134(iParam0)) { if (unk_0x16BC17A8EDC701A2(iParam0, iParam1) == 1 || unk_0x16BC17A8EDC701A2(iParam0, iParam1) == 0) { return 1; } } return 0; } int func_134(int iParam0) { if (func_135(iParam0)) { if (!unk_0x5AEB5DDFFAD43CA5(iParam0)) { return 1; } } return 0; } int func_135(int iParam0) { if (unk_0xAE06B9E39EBDE049(iParam0)) { if (!unk_0xA59F96B50B97E63C(iParam0, 0)) { return 1; } } return 0; } int func_136(struct<3> Param0, struct<3> Param1, float fParam2, bool bParam3) { if (fParam2 < 0f) { fParam2 = 0f; } if (!bParam3) { if (unk_0x0D77CDCF403AEBD2((Param0.x - Param1.x)) <= fParam2) { if (unk_0x0D77CDCF403AEBD2((Param0.f_1 - Param1.f_1)) <= fParam2) { if (unk_0x0D77CDCF403AEBD2((Param0.f_2 - Param1.f_2)) <= fParam2) { return 1; } } } } else if (unk_0x0D77CDCF403AEBD2((Param0.x - Param1.x)) <= fParam2) { if (unk_0x0D77CDCF403AEBD2((Param0.f_1 - Param1.f_1)) <= fParam2) { return 1; } } return 0; } void func_137(var uParam0) { uParam0->f_1 = 0; } int func_138() { if (func_139() == 0) { return 1; } return 0; } int func_139() { return Global_1312485.f_18; } void func_140(char* sParam0) { unk_0x17751E107423AFE9(sParam0); unk_0x1A169149B3D18FCB(0, 1, 1, -1); } void func_141(int iParam0, bool bParam1, int iParam2, int iParam3) { var uVar0; bool bVar1; bool bVar2; bool bVar3; bool bVar4; bool bVar5; bool bVar6; bool bVar7; bool bVar8; bool bVar9; bool bVar10; bool bVar11; bool bVar12; bool bVar13; bool bVar14; bool bVar15; bool bVar16; bool bVar17; bool bVar18; bool bVar19; bool bVar20; bool bVar21; bool bVar22; bool bVar23; bool bVar24; bool bVar25; bool bVar26; var uVar27; int iVar28; if (bParam1) { if (unk_0x4F315B95B1461ED4()) { unk_0xFF8E7A064055ECA6(0); } } if (func_150()) { if (bParam1) { return; } else { iParam3 = 1; } } if (!unk_0x25DDB354A40FFCDB()) { uVar0 = iParam2; unk_0xDDEDC06C88DA4E04(iParam0, bParam1, uVar0); } else { bVar1 = true; bVar2 = iParam2 & 2 != false; bVar3 = iParam2 & 4 != false; bVar4 = iParam2 & 8 != false; bVar5 = iParam2 & 16 != false; bVar6 = iParam2 & 32 != false; bVar7 = iParam2 & 64 != false; bVar8 = iParam2 & 128 != false; bVar9 = iParam2 & 256 != false; bVar10 = iParam2 & 512 != false; bVar11 = iParam2 & 1024 != false; bVar12 = iParam2 & 2048 != false; bVar13 = iParam2 & 4096 != false; bVar14 = iParam2 & 8192 != false; bVar15 = iParam2 & 16384 != false; bVar16 = iParam2 & 32768 != false; bVar17 = iParam2 & 65536 != false; bVar18 = iParam2 & 131072 != false; bVar19 = iParam2 & 262144 != false; bVar20 = iParam2 & 524288 != false; bVar21 = iParam2 & 1048576 != false; bVar22 = iParam2 & 2097152 != false; bVar23 = iParam2 & 4194304 != false; bVar24 = iParam2 & 8388608 != false; bVar25 = iParam2 & 16777216 != false; if (iParam2 & 33554432 != 0 || unk_0xFC559366953F62B3()) { bVar1 = false; } if (!func_138()) { bVar26 = false; if (bParam1 == 1) { bVar26 = true; } if (bVar16 == 0 && !bVar21) { bVar26 = true; } if (bVar10 == 1) { bVar26 = true; } if (bVar26) { return; } } if (bVar18) { } if (unk_0x166E920FB00B2DBB(iParam0) && (unk_0x5A228A6A51E757C8(iParam0) || iParam3 == 1)) { if (iParam3 && unk_0xA59F96B50B97E63C(unk_0x1FA7B77001D60F9D(iParam0), 0)) { return; } uVar27 = unk_0x1FA7B77001D60F9D(iParam0); if (!bVar20) { if ((bVar19 && bParam1 == 0) && unk_0x25DDB354A40FFCDB()) { unk_0x9675999D57D9F953(1); } else if (bVar14 || (!func_56(unk_0x460153A63B9477BC(), 0) && !func_149())) { unk_0x80250B8368A4E611(uVar27, !bVar14, 0); } if (!bVar14) { if (unk_0x25DDB354A40FFCDB() && !bVar19) { unk_0x9675999D57D9F953(0); } Global_2425869[iParam0 /*443*/].f_248 = 0; } } if (bParam1) { if (bVar1) { func_146(0, 0, 0); if (bVar25) { unk_0x701364DD9F501826(); } } if (!func_145(uVar27) && !unk_0xEB1D872D96DDA8E2(uVar27)) { if (!bVar22) { unk_0x58ADF88C51AAFDC5(uVar27, true, 0); } } if (!unk_0xB77B1396EAA80D8F(uVar27)) { if (!bVar21) { unk_0x6A8F948698B360B4(uVar27, false); } unk_0x7C47E49129337557(uVar27, 1); } else if (!bVar21) { unk_0x6A8F948698B360B4(uVar27, false); } unk_0x0DC39BE87E4C5599(uVar27, true); unk_0xBF70D1B666A353F5(iParam0, 0); unk_0x330ACDACFF26728A(iParam0, 0); if (unk_0x36E2FC4B39D3018D(uVar27) && unk_0x51E339346E2220A4(uVar27)) { unk_0x46468389F464E317(uVar27); } unk_0x4478D8ED4673EF14(uVar27, 1); if (unk_0x4DC4117F94CD5B84(unk_0x460153A63B9477BC()) == 0) { func_144(); func_143(); } if (unk_0x5C6122477A723551()) { if (!bVar23) { } } if (unk_0xE9159DB182CF0841()) { } Global_2425869[iParam0 /*443*/].f_249 = 0; if (!bVar24) { bVar3 = true; } if (Global_2405074.f_2674) { Global_2405074.f_2674 = 0; } } else { if (!func_145(uVar27) && !unk_0xEB1D872D96DDA8E2(uVar27)) { if (!bVar22) { unk_0x58ADF88C51AAFDC5(uVar27, !bVar15, 0); } if (!unk_0xB77B1396EAA80D8F(uVar27)) { if (!bVar21) { unk_0x6A8F948698B360B4(uVar27, bVar16); } if (!bVar16) { unk_0x7C47E49129337557(uVar27, 1); } } if (func_142(Global_4456448.f_129348)) { unk_0x6A8F948698B360B4(uVar27, true); } } if (Global_1312872) { bVar10 = false; } if (bVar10) { unk_0xBF70D1B666A353F5(iParam0, 0); } else { unk_0xBF70D1B666A353F5(iParam0, 1); } unk_0x0DC39BE87E4C5599(uVar27, bVar17); if (bVar3) { if (!unk_0x5A898C4DF17FB664(uVar27) && !unk_0x47DBF174A0CB9D55(uVar27, 0)) { unk_0x2BB0EF9DE445EA13(uVar27); } } } iVar28 = 0; if (bVar2) { iVar28 |= 2; } if (bVar3) { iVar28 |= 4; } if (bVar4) { iVar28 |= 8; } if (bVar5) { iVar28 |= 16; } if (bVar6) { iVar28 |= 32; } if (bVar7) { iVar28 |= 64; } if (bVar8) { iVar28 |= 128; } if (bVar9) { iVar28 |= 256; } if (bVar10) { iVar28 |= 512; } if (bVar11) { iVar28 |= 1024; } if (bVar12) { iVar28 |= 2048; } if (bVar13) { iVar28 |= 4096; } unk_0xDDEDC06C88DA4E04(iParam0, bParam1, iVar28); } } } bool func_142(int iParam0) { return iParam0 == 17; } void func_143() { struct<3> Var0; Global_2440049.f_1344 = 0; Global_2440049.f_1345 = 0; Global_2440049.f_1346 = { 9999.9f, 9999.9f, 9999.9f }; Global_2440049.f_1351 = -1; Global_2440049.f_1352 = 0; Global_2405074.f_2685 = { Var0 }; } void func_144() { Global_2405074.f_696 = 0; Global_2405074.f_2728 = 0; Global_2405074.f_512 = 0; Global_2405074.f_601 = 0; Global_2425869[unk_0x460153A63B9477BC() /*443*/].f_211 = 0; Global_2405074.f_2683 = 0; } int func_145(int iParam0) { int iVar0; if (unk_0x47DBF174A0CB9D55(uParam0, 1)) { return 1; } else { iVar0 = unk_0x16BC17A8EDC701A2(uParam0, -1794415470); if (iVar0 == 0) { return 1; } } return 0; } void func_146(int iParam0, int iParam1, int iParam2) { int iVar0; int iVar1; if (unk_0xA59F96B50B97E63C(iParam1, 0)) { } if (iParam0 == 1) { if (unk_0xAE06B9E39EBDE049(iParam1)) { if (unk_0xD0390A93AF3907B8(iParam1)) { if (!unk_0x56B60AE958412839(unk_0x460153A63B9477BC(), unk_0xE4400E48E081F17A(iParam1))) { iVar0 = 1; } } } } if (iVar0 == 0) { if (iParam2 == 1) { if (iParam0 == 1) { func_148(); } else if (!unk_0xCE990E643CD9D0E5(Global_2359302.f_67, 1)) { if (unk_0xCE990E643CD9D0E5(Global_2359302.f_67, 2)) { iVar1 = 0; while (iVar1 < 8) { unk_0x80610B7EA03DE232(iVar1, Global_2359302.f_58[iVar1]); iVar1++; } } unk_0xBE20AB8238688965(&(Global_2359302.f_67), 1); } } if (func_56(unk_0x460153A63B9477BC(), 0)) { unk_0x80B3C69DE260B92D(iParam0, iParam1, 1); } else { unk_0xE86692F29AFB9043(iParam0, iParam1); } unk_0x0F9CBC63296852FD(iParam0, iParam1); func_147(joaat("MPPLY_IS_CHAR_SPECTATING"), iParam0); } } void func_147(int iParam0, int iParam1) { int iVar0; iVar0 = iParam0; if (iVar0 != 0) { unk_0xBD9D9E72ABB288E4(iVar0, iParam1, 1); } } void func_148() { int iVar0; if (!unk_0x509C03DADAEE0A94()) { if (!unk_0xCE990E643CD9D0E5(Global_2359302.f_67, 2)) { iVar0 = 0; while (iVar0 < 8) { Global_2359302.f_58[iVar0] = unk_0xF7B3A1430308F92B(iVar0); iVar0++; } unk_0xBE20AB8238688965(&(Global_2359302.f_67), 2); unk_0xBE20AB8238688965(&(Global_2359302.f_67), 0); } } } bool func_149() { return unk_0xCE990E643CD9D0E5(Global_2359302, 3); } int func_150() { if (Global_1590682[unk_0x460153A63B9477BC() /*883*/].f_35 && !Global_2452679.f_2846.f_215 == -1) { return 1; } return 0; } void func_151(int iParam0) { int iVar0; if (*iParam0 == -1) { return; } iVar0 = func_152(*iParam0); if (iVar0 == -1) { *iParam0 = -1; return; } if (iVar0 > -1 && iVar0 < 6) { if (Global_42356[iVar0 /*32*/]) { Global_42356[iVar0 /*32*/].f_7 = 1; *iParam0 = -1; return; } } *iParam0 = -1; } int func_152(int iParam0) { int iVar0; if (iParam0 < 0) { return -1; } iVar0 = 0; iVar0 = 0; while (iVar0 < 6) { if (Global_42356[iVar0 /*32*/].f_1 == iParam0) { return iVar0; } iVar0++; } return -1; } void func_153(int iParam0) { iLocal_140 = iParam0; } int func_154(int iParam0, bool bParam1) { int iVar0; iVar0 = func_152(iParam0); if (iVar0 == -1) { return 0; } if (!unk_0x5A228A6A51E757C8(unk_0x2639A2323BEA8CC6())) { return 0; } if (func_36(0)) { return 0; } if (unk_0x3EBB66F936A3436E()) { return 0; } if (iVar0 > -1 && iVar0 < 6) { if (Global_42356[iVar0 /*32*/] == 1 && Global_42356[iVar0 /*32*/].f_4 == 1) { if (bParam1) { if (Global_42356[iVar0 /*32*/].f_29) { return 0; } } Global_42356[iVar0 /*32*/].f_5 = 1; Global_42356[iVar0 /*32*/].f_29 = 1; return 1; } else { if (Global_42356[iVar0 /*32*/] == 0) { } if (Global_42356[iVar0 /*32*/].f_7) { } } } return 0; } void func_155(int iParam0, int iParam1, char* sParam2, int iParam3, char* sParam4, int iParam5, int iParam6) { int iVar0; if (unk_0x7B70881748D166CD(joaat("context_controller")) < 1) { } if (unk_0x9CC4D06F5338CA6B()) { if (!*iParam0 == -1) { func_151(iParam0); } return; } if (!*iParam0 == -1) { return; } iVar0 = 0; iVar0 = 0; while (iVar0 < 6) { if (!Global_42356[iVar0 /*32*/]) { Global_42356[iVar0 /*32*/] = 1; Global_42356[iVar0 /*32*/].f_1 = Global_42557; Global_42557++; Global_42356[iVar0 /*32*/].f_4 = 0; Global_42356[iVar0 /*32*/].f_29 = 0; Global_42356[iVar0 /*32*/].f_5 = 0; Global_42356[iVar0 /*32*/].f_2 = iParam1; StringCopy(&(Global_42356[iVar0 /*32*/].f_8), sParam2, 16); Global_42356[iVar0 /*32*/].f_6 = iParam3; Global_42356[iVar0 /*32*/].f_31 = unk_0x354AD085195C5FA6(); Global_42356[iVar0 /*32*/].f_7 = 0; Global_42356[iVar0 /*32*/].f_3 = iParam5; if (!unk_0x7BCC91F3C1CF24E8(sParam4)) { Global_42356[iVar0 /*32*/].f_12 = 1; StringCopy(&(Global_42356[iVar0 /*32*/].f_13), sParam4, 64); Global_42356[iVar0 /*32*/].f_30 = iParam6; } else { Global_42356[iVar0 /*32*/].f_12 = 0; Global_42356[iVar0 /*32*/].f_30 = 0; } *iParam0 = Global_42356[iVar0 /*32*/].f_1; return; } iVar0++; } } void func_156() { if (unk_0xDABD547F0DF2906C() && func_157("JBOX_NO_MONEY")) { unk_0xD289B55B6AADBA10(1); } } var func_157(char* sParam0) { unk_0x69476B1CA6A9FF80(sParam0); return unk_0x1A3A9FFE5CA6F64B(0); } int func_158() { if (func_170() || unk_0x6914A85D2E17013B(1, 0, 0, 0, -1, 0)) { return 1; } return 0; } int func_159() { int iVar0; iVar0 = 1; if (func_205(unk_0x460153A63B9477BC()) && !func_178(iLocal_124)) { iVar0 = 0; } if ((((((((((((((!unk_0xCE990E643CD9D0E5(Global_2515369, 5) && !func_166()) && !func_36(0)) && !func_165()) && !unk_0xB8DB6610D5815003(unk_0x9B0761B4C3EB8BC7(), 0)) && unk_0x3608BB1FB97A8C88(unk_0x9B0761B4C3EB8BC7()) == unk_0x3608BB1FB97A8C88(iLocal_123)) && unk_0xC2169C00B643278B(unk_0x9B0761B4C3EB8BC7(), Local_148, 0.55f, 0.8f, 1.5f, 0, 1, 1)) && !unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "EXIT", 3)) && !func_164(unk_0x460153A63B9477BC())) && !func_163()) && iVar0) && !unk_0xCE990E643CD9D0E5(Global_1678288.f_4, 2)) && func_160(unk_0x9B0761B4C3EB8BC7()) <= 9) && !Global_2405074.f_2674) && !unk_0xCED6B5226244381C(unk_0x9B0761B4C3EB8BC7())) { return 1; } return 0; } int func_160(int iParam0) { int iVar0; int iVar1; if (iParam0 == 0) { return 0; } if (!unk_0xAE06B9E39EBDE049(iParam0)) { return 0; } iVar0 = func_162(iParam0); iVar1 = func_161(iVar0); if (iVar1 == -1) { return -1; } return Global_42588[iVar1 /*5*/].f_3; } int func_161(int iParam0) { int iVar0; iVar0 = 0; iVar0 = 0; while (iVar0 < 16) { if (Global_42588[iVar0 /*5*/] == iParam0) { return iVar0; } iVar0++; } return -1; } int func_162(int iParam0) { int iVar0; if (iParam0 == 0) { return -1; } iVar0 = 0; iVar0 = 0; while (iVar0 < 16) { if (iParam0 == Global_42588[iVar0 /*5*/].f_1) { return Global_42588[iVar0 /*5*/]; } iVar0++; } return -1; } int func_163() { if (Local_150.f_2 != -1) { return 1; } return 0; } int func_164(int iParam0) { if (unk_0xCE990E643CD9D0E5(Global_1590682[iParam0 /*883*/].f_274.f_26, 14)) { return 1; } if (unk_0xCE990E643CD9D0E5(Global_1590682[iParam0 /*883*/].f_274.f_26, 11)) { return 1; } return 0; } bool func_165() { return Global_74030; } int func_166() { if (func_167() != -1) { return 1; } else { return 0; } return 0; } int func_167() { return Global_2462279; } void func_168() { if (func_163()) { if (unk_0xCE990E643CD9D0E5(Local_151[Local_150.f_2 /*3*/], 2)) { if (Local_151[Local_150.f_2 /*3*/].f_1 == iLocal_137) { if (func_170()) { Local_150 = 0; Local_150.f_3 = iLocal_137; if (iLocal_124 == Local_150.f_2) { Local_150.f_4 = 1; } } } else if (Local_150.f_3 != Local_151[Local_150.f_2 /*3*/].f_1) { Local_150.f_3 = Local_151[Local_150.f_2 /*3*/].f_1; if (iLocal_124 == Local_150.f_2) { Local_150.f_4 = 1; } Local_150 = 1; } } if (unk_0xCE990E643CD9D0E5(Local_151[Local_150.f_2 /*3*/], 3)) { if (Local_150.f_1 != Local_151[Local_150.f_2 /*3*/].f_2) { Local_150.f_1 = Local_151[Local_150.f_2 /*3*/].f_2; } } if (!unk_0xCE990E643CD9D0E5(Local_151[Local_150.f_2 /*3*/], 1) && !unk_0xCE990E643CD9D0E5(Local_151[Local_150.f_2 /*3*/], 0)) { Local_150.f_2 = -1; } } else if (unk_0xCE990E643CD9D0E5(Local_151[iLocal_129 /*3*/], 0)) { if (!func_163()) { Local_150.f_2 = iLocal_129; } } if (!func_163()) { if (iLocal_128 == 126) { if (Global_1590682[iLocal_124 /*883*/].f_274.f_350 == Local_150.f_3 && (!func_170() && Global_1590682[iLocal_124 /*883*/].f_274.f_350 == iLocal_137)) { Local_150.f_4 = 0; } } else if (Global_1590682[iLocal_124 /*883*/].f_274.f_348 == Local_150.f_3 && (!func_170() && Global_1590682[iLocal_124 /*883*/].f_274.f_348 == iLocal_137)) { Local_150.f_4 = 0; } } iLocal_129++; if (iLocal_129 == 32) { iLocal_129 = 0; } } bool func_169(struct<3> Param0, struct<3> Param1, bool bParam2) { if (bParam2) { return (Param0.x == Param1.x && Param0.f_1 == Param1.f_1); } return ((Param0.x == Param1.x && Param0.f_1 == Param1.f_1) && Param0.f_2 == Param1.f_2); } bool func_170() { return Local_150 == 1; } void func_171() { int iVar0; int iVar1; if (iLocal_128 == 126) { iVar0 = func_12(); iLocal_134 = unk_0x5A002C4821A13338(); iLocal_135 = func_16(func_17(iVar0), -1, 0); } else { iVar1 = func_9(); iLocal_134 = unk_0x5A002C4821A13338(); iLocal_135 = func_16(func_10(iVar1), -1, 0); } } void func_172(bool bParam0) { if (bParam0) { unk_0xBE20AB8238688965(&uLocal_133, 6); } else { unk_0xD2459066EA58CE43(&uLocal_133, 6); } if (func_5(iLocal_128, -1)) { func_174(iLocal_128, bParam0); } else if (iLocal_128 == 126) { func_173(bParam0); } } void func_173(bool bParam0) { unk_0x309C0E6FCCD30F19("DLC_H3_Arcade_Main_Area_Music_Emitter", bParam0); unk_0x309C0E6FCCD30F19("DLC_H3_Arcade_Planning_Room_Radio_Emitter", bParam0); } void func_174(int iParam0, bool bParam1) { if (func_4(iParam0) == 97) { unk_0x309C0E6FCCD30F19("SE_bkr_biker_dlc_int_02_REC", bParam1); unk_0x309C0E6FCCD30F19("SE_bkr_biker_dlc_int_02_GRG", bParam1); return; } else if (func_4(iParam0) == 91) { unk_0x309C0E6FCCD30F19("SE_bkr_biker_dlc_int_01_BAR", bParam1); unk_0x309C0E6FCCD30F19("SE_bkr_biker_dlc_int_01_GRG", bParam1); unk_0x309C0E6FCCD30F19("SE_bkr_biker_dlc_int_01_REC", bParam1); return; } } void func_175(int iParam0) { if (func_5(iLocal_128, -1)) { if (iParam0 != iLocal_137 && iParam0 != -1) { if (iLocal_124 == unk_0x460153A63B9477BC() && iLocal_134 != 0) { func_8(iLocal_125); } func_177(iLocal_128, iParam0); } if (iParam0 != -1) { iLocal_125 = iParam0; } } else if (iLocal_128 == 126) { if (iParam0 != iLocal_137 && iParam0 != -1) { if (iLocal_124 == unk_0x460153A63B9477BC() && iLocal_134 != 0) { func_8(iLocal_125); } func_176(iParam0); } if (iParam0 != -1) { iLocal_125 = iParam0; } } } void func_176(int iParam0) { var uVar0; uVar0 = func_114(iParam0); unk_0xE00EB2EF00318633("DLC_H3_Arcade_Main_Area_Music_Emitter", uVar0); unk_0xE00EB2EF00318633("DLC_H3_Arcade_Planning_Room_Radio_Emitter", uVar0); } void func_177(int iParam0, int iParam1) { var uVar0; uVar0 = func_115(iParam1); if (func_4(iParam0) == 97) { unk_0xE00EB2EF00318633("SE_bkr_biker_dlc_int_02_REC", uVar0); unk_0xE00EB2EF00318633("SE_bkr_biker_dlc_int_02_GRG", uVar0); return; } else if (func_4(iParam0) == 91) { unk_0xE00EB2EF00318633("SE_bkr_biker_dlc_int_01_BAR", uVar0); unk_0xE00EB2EF00318633("SE_bkr_biker_dlc_int_01_GRG", uVar0); unk_0xE00EB2EF00318633("SE_bkr_biker_dlc_int_01_REC", uVar0); return; } } bool func_178(int iParam0) { return (func_180(iParam0) && func_179(iParam0)); } int func_179(int iParam0) { if (iParam0 != -1) { return unk_0xCE990E643CD9D0E5(Global_1701666[iParam0 /*68*/].f_40, 4); } return 0; } int func_180(int iParam0) { if (iParam0 != func_181()) { return unk_0xCE990E643CD9D0E5(Global_1590682[iParam0 /*883*/].f_274.f_393.f_1, 2); } return 0; } int func_181() { return -1; } int func_182(int iParam0) { int iVar0; if (iParam0 == func_181()) { return iParam0; } if (func_187(iParam0) != -1) { iVar0 = func_186(func_187(iParam0)); if ((iVar0 == 2 || iVar0 == 1) || iVar0 == 0) { if (func_184(iParam0, 0)) { return func_183(iParam0); } return iParam0; } else if (iVar0 == 3) { return func_181(); } return Global_2425869[iParam0 /*443*/].f_314.f_9; } return func_181(); } int func_183(int iParam0) { if (iParam0 != func_181()) { return Global_1630317[iParam0 /*595*/].f_11; } return func_181(); } bool func_184(int iParam0, bool bParam1) { if (!bParam1) { if (func_185(iParam0)) { return 0; } } return Global_1630317[iParam0 /*595*/].f_11 != func_181(); } int func_185(int iParam0) { if (iParam0 != func_181()) { if (Global_1630317[iParam0 /*595*/].f_11 != func_181()) { return Global_1630317[iParam0 /*595*/].f_11 == iParam0; } } return 0; } int func_186(int iParam0) { switch (iParam0) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: return 0; break; case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: return 1; break; case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: return 2; break; case 43: case 42: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 98: case 99: case 100: case 112: case 113: case 114: case 115: case 119: case 116: case 118: case 120: case 121: case 126: case 127: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: return 3; break; case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case joaat("MPSV_LP0_31"): case 80: return 4; break; case 81: return 5; break; case 82: return 6; break; case 83: case 84: case 85: case 86: case 87: return 7; break; case 88: return 8; break; case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: return 9; break; case 101: return 10; break; case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: return 11; break; case 117: return 12; break; case 122: return 13; break; case 123: return 14; break; case 124: return 15; break; case 125: return 16; break; case 128: case 129: case 130: case 131: case 132: case 133: return 17; break; case 145: return 18; break; case 146: return 19; break; case 147: return 20; break; } return -1; } int func_187(int iParam0) { if (iParam0 != func_181()) { if (func_188(iParam0, 1, 1)) { return Global_2425869[iParam0 /*443*/].f_314.f_6; } else if (((Global_1312896 || Global_2405074.f_2673) && iParam0 == unk_0x460153A63B9477BC()) && func_188(iParam0, 1, 0)) { return Global_2425869[iParam0 /*443*/].f_314.f_6; } } return -1; } int func_188(int iParam0, bool bParam1, bool bParam2) { int iVar0; iVar0 = iParam0; if (iVar0 != -1) { if (unk_0x166E920FB00B2DBB(iParam0)) { if (bParam1) { if (!unk_0x5A228A6A51E757C8(iParam0)) { return 0; } } if (bParam2) { if (!Global_2440049.f_3[iVar0]) { return 0; } } return 1; } } return 0; } bool func_189(var uParam0, var uParam1, var uParam2, var uParam3, var uParam4, var uParam5, var uParam6, var uParam7, var uParam8, var uParam9, var uParam10, var uParam11, var uParam12) { return unk_0xF6B8932480699645(&uParam0, 13); } void func_190(int iParam0, var uParam1) { *uParam1 = { Global_1590682[iParam0 /*883*/].f_274.f_65 }; } void func_191() { var uVar0; if (unk_0x25DDB354A40FFCDB() && !unk_0xCE990E643CD9D0E5(uLocal_133, 2)) { uVar0 = Global_1048576.f_1304; if (func_199(unk_0x460153A63B9477BC())) { uVar0 = func_198() + 32; } unk_0xDB4E5F36ED3505EE(); unk_0xA88557896B79E30D(32, 0, uVar0); func_195(0, -1, 0); unk_0x3A396632EB359434(0); unk_0x97D2F2E2C92FD519(&Local_150, 5); unk_0xBB96A3ECD45D0317(&Local_151, 97); if (!func_192()) { func_206(0); } unk_0xBE20AB8238688965(&uLocal_133, 2); } } int func_192() { int iVar0; iVar0 = 0; while (true) { iVar0++; if (!unk_0x25DDB354A40FFCDB()) { return 0; } if (unk_0x331F7CFA5515B989()) { return 1; } if (func_194()) { return 0; } if (func_193(157)) { return 0; } if (iVar0 >= 3600) { return 0; } SYSTEM::WAIT(0); } return 0; } int func_193(int iParam0) { if (unk_0x16F1FCCC54559709(1, iParam0)) { return 1; } return 0; } bool func_194() { return Global_2451787.f_691; } int func_195(int iParam0, int iParam1, bool bParam2) { int iVar0; iVar0 = unk_0x361B374A50D875B4(); while (iVar0 != 2) { if (((iVar0 == 3 || iVar0 == 4) || iVar0 == 5) || iVar0 == 6) { if (!bParam2) { func_197(); } else { return 0; } } if (!func_196()) { if (iParam0 == 0) { if (!unk_0x25DDB354A40FFCDB()) { if (!bParam2) { func_197(); } else { return 0; } } if (func_194()) { if (!bParam2) { func_197(); } else { return 0; } } if (func_193(157)) { if (!bParam2) { func_197(); } else { return 0; } } } else if (!unk_0x3BF0BB5923982C0D()) { if (!bParam2) { func_197(); } else { return 0; } } } SYSTEM::WAIT(0); iVar0 = unk_0x361B374A50D875B4(); } if (iParam1 > -1) { Global_1312519 = iVar0; } if (iParam0 == 0) { if (!unk_0x25DDB354A40FFCDB()) { if (!bParam2) { func_197(); } else { return 0; } } } else if (!unk_0x3BF0BB5923982C0D()) { if (!bParam2) { func_197(); } else { return 0; } } return 1; } bool func_196() { return Global_1312872; } void func_197() { unk_0xD39E529EBE5DB04F(); } int func_198() { var uVar0; uVar0 = Global_2425869[unk_0x460153A63B9477BC() /*443*/].f_314.f_7; return uVar0; } int func_199(int iParam0) { if (iParam0 != func_181()) { if (func_188(iParam0, 1, 1)) { return Global_2425869[iParam0 /*443*/].f_314.f_6 != -1; } else if ((Global_1312896 && iParam0 == unk_0x460153A63B9477BC()) && func_188(iParam0, 1, 0)) { return Global_2425869[iParam0 /*443*/].f_314.f_6 != -1; } } return 0; } void func_200() { if (iLocal_128 == 126) { if (func_202(unk_0x460153A63B9477BC())) { func_206(0); } else if (!unk_0x25DDB354A40FFCDB()) { func_206(0); } else if (unk_0xA59F96B50B97E63C(unk_0x9B0761B4C3EB8BC7(), 0)) { func_206(0); } else if (unk_0xCE990E643CD9D0E5(Global_2515369, 1)) { unk_0xD2459066EA58CE43(&Global_2515369, 1); func_206(0); } else if (unk_0xCE990E643CD9D0E5(Global_1678288.f_6, 10)) { if (iLocal_140 != 0) { if (unk_0xCE990E643CD9D0E5(uLocal_133, 3)) { unk_0xD2459066EA58CE43(&uLocal_133, 3); func_39(1, -1); } unk_0xD2459066EA58CE43(&uLocal_133, 5); unk_0xD2459066EA58CE43(&uLocal_133, 4); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 1); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 2); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 3); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 0); unk_0xD2459066EA58CE43(&Global_2515369, 4); iLocal_139 = 0; func_153(0); } } else if (!func_205(unk_0x460153A63B9477BC())) { func_206(0); } } else if (unk_0xCE990E643CD9D0E5(Global_1590682[unk_0x460153A63B9477BC() /*883*/].f_274.f_26, 14)) { func_206(0); } else if (!unk_0x25DDB354A40FFCDB()) { func_206(0); } else if (unk_0xA59F96B50B97E63C(unk_0x9B0761B4C3EB8BC7(), 0)) { func_206(0); } else if (unk_0xCE990E643CD9D0E5(Global_2515369, 1)) { unk_0xD2459066EA58CE43(&Global_2515369, 1); func_206(0); } else if (func_201()) { if (iLocal_140 != 0) { if (unk_0xCE990E643CD9D0E5(uLocal_133, 3)) { unk_0xD2459066EA58CE43(&uLocal_133, 3); func_39(1, -1); } unk_0xD2459066EA58CE43(&uLocal_133, 5); unk_0xD2459066EA58CE43(&uLocal_133, 4); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 1); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 2); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 3); unk_0xD2459066EA58CE43(&(Local_151[unk_0x460153A63B9477BC() /*3*/]), 0); unk_0xD2459066EA58CE43(&Global_2515369, 4); iLocal_139 = 0; func_153(0); } } else if (iLocal_128 != Global_1590682[unk_0x460153A63B9477BC() /*883*/].f_274.f_28) { func_206(0); } } bool func_201() { return Global_3934113; } int func_202(int iParam0) { if (iParam0 != func_181() && func_188(iParam0, 1, 1)) { if (func_204(iParam0) && !func_203(iParam0)) { return 1; } } return 0; } int func_203(int iParam0) { if (iParam0 != func_181() && func_188(iParam0, 1, 1)) { return unk_0xCE990E643CD9D0E5(Global_2425869[iParam0 /*443*/].f_314, 4); } return 0; } int func_204(int iParam0) { if (iParam0 != func_181() && func_188(iParam0, 1, 1)) { return unk_0xCE990E643CD9D0E5(Global_2425869[iParam0 /*443*/].f_314, 3); } return 0; } int func_205(int iParam0) { if (iParam0 != func_181()) { if (func_188(iParam0, 1, 1)) { if (Global_2425869[iParam0 /*443*/].f_314.f_6 != -1) { return func_186(Global_2425869[iParam0 /*443*/].f_314.f_6) == 17; } } } return 0; } void func_206(bool bParam0) { func_208(0); if (unk_0xCE990E643CD9D0E5(uLocal_133, 3)) { func_39(1, -1); } unk_0xBE20AB8238688965(&Global_2515369, 2); if (iLocal_130 != -1) { func_151(&iLocal_130); } if (iLocal_124 == unk_0x460153A63B9477BC()) { func_8(iLocal_125); } if (unk_0xDABD547F0DF2906C() && func_157("JBOX_NO_MONEY")) { unk_0xD289B55B6AADBA10(1); } unk_0x51C14866CB8A57BF(); func_207(); if (bParam0) { func_141(unk_0x460153A63B9477BC(), 1, 0, 0); } if (iLocal_128 == 126) { unk_0xFA07F8BEBDAAFBA8("dlc_ch_arcade_music_volume"); } unk_0xD39E529EBE5DB04F(); } void func_207() { if (unk_0xAE06B9E39EBDE049(unk_0x9B0761B4C3EB8BC7()) && !unk_0xA59F96B50B97E63C(unk_0x9B0761B4C3EB8BC7(), 0)) { if (((unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "IDLE", 3) || unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "EXIT", 3)) || unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "INSERT_COINS", 3)) || unk_0x9934470AA0A08B57(unk_0x9B0761B4C3EB8BC7(), sLocal_138, "SELECT_TRACK", 3)) { unk_0x2BB0EF9DE445EA13(unk_0x9B0761B4C3EB8BC7()); } } } void func_208(bool bParam0) { if (bParam0) { func_209(); if (Global_19681.f_1 == 10 || Global_19681.f_1 == 9) { unk_0xBE20AB8238688965(&Global_7552, 16); } Global_19681.f_1 = 1; if (func_36(0)) { func_32(0); } } else if (Global_19681.f_1 == 1) { if (!Global_19681.f_1 == 0) { Global_19681.f_1 = 3; } } } void func_209() { if (Global_19681.f_1 == 9 || Global_19681.f_1 == 10) { Global_21058 = 0; Global_21054 = 1; } }
21.057505
667
0.602632
[ "vector" ]
91fac302d52ca61a3c3830c74ce2797d53c42ce3
7,028
h
C
src/extern/inventor/lib/interaction/include/Inventor/draggers/SoJackDragger.h
OpenXIP/xip-libraries
9f0fef66038b20ff0c81c089d7dd0038e3126e40
[ "Apache-2.0" ]
2
2020-05-21T07:06:07.000Z
2021-06-28T02:14:34.000Z
src/extern/inventor/lib/interaction/include/Inventor/draggers/SoJackDragger.h
OpenXIP/xip-libraries
9f0fef66038b20ff0c81c089d7dd0038e3126e40
[ "Apache-2.0" ]
null
null
null
src/extern/inventor/lib/interaction/include/Inventor/draggers/SoJackDragger.h
OpenXIP/xip-libraries
9f0fef66038b20ff0c81c089d7dd0038e3126e40
[ "Apache-2.0" ]
6
2016-03-21T19:53:18.000Z
2021-06-08T18:06:03.000Z
/* * * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like. Any license provided herein, whether implied or * otherwise, applies only to this software file. Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA 94043, or: * * http://www.sgi.com * * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ // -*- C++ -*- /* * Copyright (C) 1990,91,92 Silicon Graphics, Inc. * _______________________________________________________________________ ______________ S I L I C O N G R A P H I C S I N C . ____________ | | $Revision: 1.1.1.1 $ | | Description: | This file defines the jack dragger class, so named because | with the default geometry, it looks like the children's toy. | This dragger allows you to perform rotations,uniform scales | and translations, all in one spiffy gadget. | | Translation is done with a dragPointDragger, rotation with a | rotateSphericalDragger, and scaling with a scaleUniformDragger. | | NOTE TO DEVELOPERS: | For info about the structure of SoJackDragger: | [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure | [2] type: ivNodeKitStructure SoJackDragger. | [3] The program prints a diagram of the scene graph and a table with | information about each part. | | The following parts in this dragger are created at construction time. | 'ResourceName' corresponds to the name of the default geometry for the | part. The dragger's constructor gets the scene graph for 'ResourceName' | by querying the global dictionary ( SoDB::getByName("ResourceName"); ). | | Resource Name: Part Name: | | jackScalerScaler - scaler.scaler | jackScalerScalerActive - scaler.scalerActive | jackScalerFeedback - scaler.feedback | jackScalerFeedbackActive - scaler.feedbackActive | | jackRotatorRotator - rotator.rotator | jackRotatorRotatorActive - rotator.rotatorActive | jackRotatorFeedback - rotator.feedback | jackRotatorFeedbackActive - rotator.feedbackActive | | jackTranslatorLineTranslator - | - translator.xTranslator.translator | - translator.yTranslator.translator | - translator.zTranslator.translator | | jackTranslatorLineTranslatorActive - | - translator.xTranslator.translatorActive | - translator.yTranslator.translatorActive | - translator.zTranslator.translatorActive | | jackTranslatorPlaneTranslator - | - translator.yzTranslator.translator | - translator.xzTranslator.translator | - translator.xyTranslator.translator | | jackTranslatorPlaneTranslatorActive - | - translator.yzTranslator.translatorActive | - translator.xzTranslator.translatorActive | - translator.xyTranslator.translatorActive | | jackTranslatorXFeedback - translator.xFeedback | jackTranslatorYFeedback - translator.yFeedback | jackTranslatorZFeedback - translator.zFeedback | | jackTranslatorXYFeedback - translator.xyFeedback | jackTranslatorXZFeedback - translator.xzFeedback | jackTranslatorYZFeedback - translator.yzFeedback | | Author(s): Paul Isaacs | ______________ S I L I C O N G R A P H I C S I N C . ____________ _______________________________________________________________________ */ #ifndef _SO_JACK_DRAGGER_ #define _SO_JACK_DRAGGER_ #include <Inventor/SbLinear.h> #include <Inventor/draggers/SoDragger.h> #include <Inventor/fields/SoSFVec3f.h> #include <Inventor/fields/SoSFRotation.h> #include <Inventor/sensors/SoSensor.h> class SbDict; class SoFieldSensor; // C-api: prefix=SoJackDrag // C-api: public=rotation,translation,scaleFactor class INVENTOR_API SoJackDragger : public SoDragger { SO_KIT_HEADER(SoJackDragger); // For making the dragger surround what lies above it. SO_KIT_CATALOG_ENTRY_HEADER(surroundScale); // For keeping the dragger even size in all 3 dimensions SO_KIT_CATALOG_ENTRY_HEADER(antiSquish); SO_KIT_CATALOG_ENTRY_HEADER(scaler); SO_KIT_CATALOG_ENTRY_HEADER(rotator); SO_KIT_CATALOG_ENTRY_HEADER(translator); public: // Constructors SoJackDragger(); SoSFRotation rotation; SoSFVec3f translation; SoSFVec3f scaleFactor; SoINTERNAL public: static void initClass(); // initialize the class protected: SoFieldSensor *rotFieldSensor; SoFieldSensor *translFieldSensor; SoFieldSensor *scaleFieldSensor; static void fieldSensorCB( void *, SoSensor * ); static void valueChangedCB( void *, SoDragger * ); static void invalidateSurroundScaleCB( void *, SoDragger * ); // detach/attach any sensors, callbacks, and/or field connections. // Also set geometry of childDraggers to be our default instead of their // regular default, using our resources. // Called by: start/end of SoBaseKit::readInstance // and on new copy by: start/end of SoBaseKit::copy. // Classes that redefine must call setUpConnections(TRUE,TRUE) // at end of constructor. // Returns the state of the node when this was called. virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); virtual void setDefaultOnNonWritingFields(); virtual ~SoJackDragger(); private: static const char geomBuffer[]; }; #endif /* _SO_JACK_DRAGGER_ */
38.404372
80
0.675157
[ "geometry" ]
91ff200ec66e50c6af20ac3447afa85709797fbe
3,929
h
C
include/complate/core/property.h
tmehnert/complate-cpp
8780cff967e25279584d0e1619666783f7ff6b40
[ "Apache-2.0" ]
5
2021-12-18T09:12:51.000Z
2022-01-28T17:43:13.000Z
include/complate/core/property.h
tmehnert/complate-cpp
8780cff967e25279584d0e1619666783f7ff6b40
[ "Apache-2.0" ]
10
2021-10-18T05:45:18.000Z
2021-12-12T11:09:20.000Z
include/complate/core/property.h
tmehnert/complate-cpp
8780cff967e25279584d0e1619666783f7ff6b40
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2021 Torsten Mehnert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <functional> #include <string> #include "value.h" namespace complate { /** * Property of an native C++ object to be used in Javascript. * * This class can be added to a Prototype in order to make Property * aka getter and maybe also a setter available inside Javascript. * * @note Use PrototypeBuilder to build your Prototype more easy. */ class Property { public: /** Getter/Setter signatures. */ using Getter = std::function<Value(void *)>; using Setter = std::function<void(void *, const Value &value)>; /** Constructs a readonly Property. */ Property(std::string name, Getter getter); /** Constructs a writable Property. */ Property(std::string name, Getter getter, Setter setter); Property(const Property &other); ~Property(); /** Constructs a readonly Property from a member function pointer. */ template <typename T, typename R> Property(std::string name, R (T::*getter)() const) : Property(std::move(name), wrap(getter)) {} /** Constructs a readonly Property from a non-const member function pointer. */ template <typename T, typename R> Property(std::string name, R (T::*getter)()) : Property(std::move(name), wrap(getter)) {} /** Constructs a writeable Property from a member function pointer. */ template <typename T, typename R> Property(std::string name, R (T::*getter)() const, void (T::*setter)(const Value &)) : Property(std::move(name), wrap(getter), wrap(setter)) {} /** Constructs a writeable Property from a non-const member function pointer. */ template <typename T, typename R> Property(std::string name, R (T::*getter)(), void (T::*setter)(const Value &)) : Property(std::move(name), wrap(getter), wrap(setter)) {} /** Get the name of the Property. */ [[nodiscard]] const std::string &name() const; /** * Get the value of the Property. * * @param object The pointer to the class instance (this). * @return Value returned by the getter. */ Value get(void *object) const; /** * Get the value of the Property. * * @param object The pointer to the class instance (this). * @param value The value passed to the setter as an argument. */ void set(void *object, const Value &value) const; private: class Impl; /** Pointer to implementation */ std::unique_ptr<Impl> m_impl; /** Wraps a member function pointer getter to accept void* as this */ template <typename T, typename R> static Getter wrap(R (T::*getter)() const) { static_assert(!std::is_void_v<R>, "A getter have to return non-void"); return [getter](void *p) -> Value { return (static_cast<T *>(p)->*getter)(); }; } /** Wraps a non-const member function pointer getter to accept void* as this */ template <typename T, typename R> static Getter wrap(R (T::*getter)()) { static_assert(!std::is_void_v<R>, "A getter have to return non-void"); return [getter](void *p) -> Value { return (static_cast<T *>(p)->*getter)(); }; } /** Wraps a member function pointer setter to accept void* as this */ template <typename T> static Setter wrap(void (T::*setter)(const Value &value)) { return [setter](void *p, const Value &value) { (static_cast<T *>(p)->*setter)(value); }; } }; } // namespace complate
32.204918
80
0.666582
[ "object" ]
62041e248ba2239f2f3c52d62d8780f55f9c5f93
711
c
C
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/pr34856.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
7
2020-05-02T17:34:05.000Z
2021-10-17T10:15:18.000Z
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/pr34856.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
null
null
null
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/pr34856.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
2
2020-07-27T00:22:36.000Z
2021-04-01T09:41:02.000Z
/* { dg-do compile } */ /* { dg-options "-O2" } */ /* { dg-options "-O2 -msse2" { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-O2 -maltivec" { target { powerpc*-*-linux* && powerpc_altivec_ok } } } */ typedef __UINTPTR_TYPE__ uintptr_t; #undef __vector #define __vector __attribute__ ((__vector_size__ (16))) typedef __vector signed char qword; typedef __vector uintptr_t VU; extern short g[192 + 16]; void f (qword); void f1 (unsigned ctr) { VU pin; pin = (VU){(uintptr_t) &g[16]}; do { f ((qword) pin); ctr--; } while (ctr); } /* Ignore a warning that is irrelevant to the purpose of this test. */ /* { dg-prune-output ".*GCC vector passed by reference.*" } */
21.545455
91
0.607595
[ "vector" ]
6212476ab6233f75ed8e5c87092fb513da3e8086
21,658
h
C
fcgi/include/fcgi_utilities_templates.h
adambreland/cpp-as_components
8b65507fa5beba5e1e2e3fbcadf17bf1030a0c70
[ "MIT" ]
null
null
null
fcgi/include/fcgi_utilities_templates.h
adambreland/cpp-as_components
8b65507fa5beba5e1e2e3fbcadf17bf1030a0c70
[ "MIT" ]
null
null
null
fcgi/include/fcgi_utilities_templates.h
adambreland/cpp-as_components
8b65507fa5beba5e1e2e3fbcadf17bf1030a0c70
[ "MIT" ]
null
null
null
// MIT License // // Copyright (c) 2021 Adam J. Breland // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #ifndef AS_COMPONENTS_FCGI_INCLUDE_FCGI_UTILITIES_TEMPLATES_H_ #define AS_COMPONENTS_FCGI_INCLUDE_FCGI_UTILITIES_TEMPLATES_H_ #include "fcgi/include/fcgi_utilities.h" #include <sys/select.h> #include <sys/uio.h> #include <unistd.h> #include <algorithm> #include <cstddef> #include <cstdint> #include <iterator> #include <limits> #include <utility> #include <vector> #include "fcgi/include/fcgi_protocol_constants.h" namespace as_components { namespace fcgi { template<typename ByteIter> void EncodeFourByteLength(std::int_fast32_t length, ByteIter byte_iter) { // TODO Add template type property checking with static asserts. if(length < 128) throw std::invalid_argument {"An invalid length was given."}; // Set the leading bit to 1 to indicate that a four-byte sequence is // present. *byte_iter = (static_cast<uint8_t>(length >> 24) | 0x80U); for(int i {0}; i < 3; i++) { ++byte_iter; *byte_iter = length >> (16 - (8*i)); } } template <typename ByteIter> std::int_fast32_t ExtractFourByteLength(ByteIter byte_iter) noexcept { // TODO Add template type property checking with static_asserts. // Mask out the leading 1 bit which must be present per the FastCGI // name-value pair format. This bit does not encode length information. // It indicates that the byte sequence has four elements instead of one. std::int_fast32_t length {static_cast<std::int_fast32_t>(static_cast<uint8_t>(*byte_iter) & 0x7fU)}; // Perform three shifts by 8 bits to extract all four bytes. for(int i {0}; i < 3; ++i) { length <<= 8; ++byte_iter; length += static_cast<uint8_t>(*byte_iter); } return length; } template<typename ByteSeqPairIter> std::tuple<bool, std::size_t, std::vector<iovec>, int, std::vector<std::uint8_t>, std::size_t, ByteSeqPairIter> EncodeNameValuePairs(ByteSeqPairIter pair_iter, ByteSeqPairIter end, FcgiType type, std::uint16_t Fcgi_id, std::size_t offset) { if(pair_iter == end) return {true, 0U, {}, 0, {}, 0U, end}; constexpr std::size_t size_t_MAX {std::numeric_limits<std::size_t>::max()}; constexpr ssize_t ssize_t_MAX {std::numeric_limits<ssize_t>::max()}; constexpr uint16_t aligned_record_MAX {kMaxRecordContentByteLength - 7U}; // Reduce by 7 to ensure that the length of a "full" record is a // multiple of 8. // Determine the initial values of the break variables. long remaining_iovec_count {sysconf(_SC_IOV_MAX)}; // Use the current Linux default if information cannot be obtained. if(remaining_iovec_count == -1) remaining_iovec_count = 1024; remaining_iovec_count = std::min<long>(remaining_iovec_count, std::numeric_limits<int>::max()); // Reduce by one to ensure that a struct for padding is always available. remaining_iovec_count--; // Reduce by FCGI_HEADER_LEN - 1 = 7 to ensure that padding can always be // added. std::size_t remaining_byte_count {ssize_t_MAX - 7U}; // Lambda functions to simplify the loops below. auto size_iter = [&](int i)->std::size_t { if(i == 0) return pair_iter->first.size(); else return pair_iter->second.size(); }; auto data_iter = [&](int i)->const std::uint8_t* { if(i == 0) return static_cast<const std::uint8_t*>(static_cast<const void*>( pair_iter->first.data())); else return static_cast<const std::uint8_t*>(static_cast<const void*>( pair_iter->second.data())); }; // A binary sequence of headers and length information encoded in the // FastCGI name-value pair format is created and returned to // the caller. A pair which holds an index into iovec_list and an index into // local_buffers is stored whenever a record // is referred to by an iovec_list element. This pair allows pointer values // to be determined once the memory allocated for local_buffers // will no longer change. std::vector<std::uint8_t> local_buffers {}; std::vector<std::pair<std::vector<iovec>::size_type, std::vector<uint8_t>::size_type>> index_pairs {}; // iovec_list will usually hold three instances of iovec for every // name-value pair. The first instance describes name and value length // information. It points to a range of bytes in local_buffers. // The second and third instances hold name and value information, // repsectively. They point to the buffers of containers from a source // std::pair object when such buffers exist. std::vector<iovec> iovec_list {}; std::size_t number_to_write {0U}; std::size_t previous_content_length {0U}; std::vector<uint8_t>::size_type previous_header_offset {0U}; std::size_t nv_pair_bytes_placed {0U}; // Record count may be int as the number of records is always less than the // number of struct iovec instances and this number is less than or equal to // the maximum int value. int record_count {0}; bool incomplete_nv_write {false}; bool name_or_value_too_big {false}; bool overflow_detected {false}; for(/*no-op*/; pair_iter != end; ++pair_iter) { if(!remaining_iovec_count || !remaining_byte_count) break; // Variables for name and value information. std::size_t size_array[3] = {}; // sums starts at zero and holds partial sums of size_array. // It is used to check for potential numeric overflow. std::size_t sums[3] = {}; std::vector<uint8_t>::size_type name_value_buffer_offset {local_buffers.size()}; const std::uint8_t* data_array[2]; // Reset for a new pair. nv_pair_bytes_placed = offset; // Collect information about the name and value byte sequences. for(int i {1}; i < 3; ++i) { size_array[i] = size_iter(i-1); if(size_array[i]) data_array[i-1] = data_iter(i-1); else data_array[i-1] = nullptr; if(size_array[i] <= kNameValuePairSingleByteLength) { // A safe narrowing of size_array[i] from std::size_t to std::uint8_t. local_buffers.push_back(size_array[i]); size_array[0] += 1; } else if(size_array[i] <= kNameValuePairFourByteLength) { // A safe narrowing of size from std::size_t to a representation of // a subset of the range of uint32_t. EncodeFourByteLength(size_array[i], std::back_inserter(local_buffers)); size_array[0] += 4; } else { name_or_value_too_big = true; break; } } sums[1] = size_array[0]; // Check if processing must stop, including because of an overflow from // name and value lengths. if(name_or_value_too_big || size_array[1] > (size_t_MAX - sums[1]) || (sums[2] = size_array[1] + sums[1], size_array[2] > (size_t_MAX - sums[2]))) { if(size_array[0]) { local_buffers.erase(local_buffers.end() - size_array[0], local_buffers.end()); } if(!name_or_value_too_big) overflow_detected = true; break; // Stop iterating over pairs. } else // We can proceed normally to iteratively produce FastCGI records. { std::size_t total_length {size_array[2] + sums[2]}; std::size_t remaining_nv_bytes_to_place {total_length - nv_pair_bytes_placed}; auto determine_index = [&]()->std::size_t { int i {0}; for(/*no-op*/; i < 2; i++) if(nv_pair_bytes_placed < sums[i+1]) return i; return i; }; bool padding_limit_reached {false}; // Start loop which produces records. while(remaining_nv_bytes_to_place && !padding_limit_reached) { if(!previous_content_length) // Start a new record. { // Need enough iovec structs for a header, data, and padding. // Need enough bytes for a header and some data. An iovec struct // and FCGI_HEADER_LEN - 1 bytes were reserved. if((remaining_iovec_count >= 2) && (remaining_byte_count >= (FCGI_HEADER_LEN + 1))) { previous_header_offset = local_buffers.size(); index_pairs.push_back({iovec_list.size(), previous_header_offset}); iovec_list.push_back({nullptr, FCGI_HEADER_LEN}); local_buffers.insert(local_buffers.end(), FCGI_HEADER_LEN, 0); PopulateHeader(local_buffers.data() + previous_header_offset, type, Fcgi_id, 0, 0); number_to_write += FCGI_HEADER_LEN; remaining_byte_count -= FCGI_HEADER_LEN; remaining_iovec_count--; record_count++; } else { incomplete_nv_write = true; // As remaining_nv_bytes_to_place != 0. break; } } // Start loop over the three potential buffers. std::size_t index {determine_index()}; for(/*no-op*/; index < 3; index++) { // Variables which determine how much we can write. std::size_t remaining_content_capacity {aligned_record_MAX - previous_content_length}; std::size_t current_limit {std::min(remaining_byte_count, remaining_content_capacity)}; std::size_t number_to_place {std::min(remaining_nv_bytes_to_place, current_limit)}; // Determine how many we can write for a given buffer. std::size_t local_remaining {size_array[index] - (nv_pair_bytes_placed - sums[index])}; std::size_t local_number_to_place {std::min(local_remaining, number_to_place)}; // Write the determined amount. if(index == 0) // Special processing for name-value length info. { iovec_list.push_back({nullptr, local_number_to_place}); // If we are in the name value length information byte sequence, // i.e. index == 0, then nv_pair_bytes_placed acts as an offset // into a subsequence of these bytes. index_pairs.push_back({iovec_list.size() - 1, name_value_buffer_offset + nv_pair_bytes_placed}); remaining_iovec_count--; } else // Adding an iovec structure for name or value byte sequence. { // Either of size_array[1] or size_array[2] may be zero. For // example, we may add a iovec instance for size_array[0] // that specifies an empty name or value. if(local_number_to_place) { struct iovec new_iovec { const_cast<uint8_t*>(data_array[index-1]) + (size_array[index] - local_remaining), local_number_to_place }; iovec_list.push_back(new_iovec); remaining_iovec_count--; } } // Update tracking variables. nv_pair_bytes_placed += local_number_to_place; remaining_nv_bytes_to_place -= local_number_to_place; number_to_write += local_number_to_place; remaining_byte_count -= local_number_to_place; // Update record information. previous_content_length += local_number_to_place; local_buffers[previous_header_offset + kHeaderContentLengthB1Index] = static_cast<uint8_t>(previous_content_length >> 8); local_buffers[previous_header_offset + kHeaderContentLengthB0Index] = static_cast<uint8_t>(previous_content_length); // Check if a limit was reached. Need at least an iovec struct for // padding. Need enough bytes for padding. These limits were // reserved in the initialization of remaining_iovec_count and // remaining_byte_count. if(!remaining_iovec_count || !remaining_byte_count) { padding_limit_reached = true; if(nv_pair_bytes_placed < total_length) incomplete_nv_write = true; break; } // Check if the record was finished. if(previous_content_length == aligned_record_MAX) { previous_content_length = 0; break; // Need to start a new record. } } } } offset = 0; if(incomplete_nv_write) break; } // Check if padding is needed. // (Safe narrowing.) uint8_t pad_mod(previous_content_length % FCGI_HEADER_LEN); if(pad_mod) { uint8_t pad_mod_complement(FCGI_HEADER_LEN - pad_mod); // Safe narrowing. index_pairs.push_back({iovec_list.size(), local_buffers.size()}); iovec_list.push_back({nullptr, pad_mod_complement}); local_buffers.insert(local_buffers.end(), pad_mod_complement, 0); local_buffers[previous_header_offset + kHeaderPaddingLengthIndex] = pad_mod_complement; number_to_write += pad_mod_complement; } // Since the memory of local_buffers is stable, fill in // iov_base pointers from local_buffers.data(). for(auto pair : index_pairs) iovec_list[pair.first].iov_base = static_cast<void*>(local_buffers.data() + pair.second); // Check for rejection based on a limit or name or value that was too big. return std::make_tuple( !name_or_value_too_big && !overflow_detected, number_to_write, std::move(iovec_list), record_count, std::move(local_buffers), ((incomplete_nv_write) ? nv_pair_bytes_placed : 0), pair_iter ); } namespace partition_byte_sequence_internal { // The content length of a record should be a multiple of 8 whenever possible. // kMaxRecordContentByteLength = 2^16 - 1 // (2^16 - 1) - 7 = 2^16 - 8 = 2^16 - 2^3 = 2^3*(2^13 - 1) = 8*(2^13 - 1) constexpr uint16_t max_aligned_content_length {kMaxRecordContentByteLength - 7}; // The maximum number of bytes that can be written in one call to writev. constexpr ssize_t ssize_t_MAX {std::numeric_limits<ssize_t>::max()}; inline constexpr std::size_t CeilingOfQuotient(std::size_t numerator, std::size_t denominator) { return ((numerator/denominator) + (static_cast<std::size_t>((numerator % denominator) > 0U))); } inline constexpr std::size_t InitializeMaxForSsize_t() { constexpr std::size_t macl {static_cast<std::size_t>( max_aligned_content_length)}; constexpr std::size_t inter_1 {8U*(static_cast<std::size_t>( ssize_t_MAX)/8U)}; constexpr std::size_t inter_2 {CeilingOfQuotient(inter_1, macl)}; return (inter_1 - (8U*inter_2)); } constexpr std::size_t max_for_ssize_t {InitializeMaxForSsize_t()}; const std::size_t max_for_iovec {InitializeMaxForIovec()}; const std::size_t min_max {std::min<std::size_t>( partition_byte_sequence_internal::max_for_ssize_t, max_for_iovec )}; const ssize_t working_ssize_t_max {NeededSsize_t(min_max)}; const std::size_t working_iovec_max {NeededIovec(min_max)}; } // partition_byte_sequence_internal template<typename ByteIter> std::tuple<std::vector<std::uint8_t>, std::vector<struct iovec>, std::size_t, ByteIter> PartitionByteSequence(ByteIter begin_iter, ByteIter end_iter, FcgiType type, std::uint16_t Fcgi_id) { // Verify that ByteIter iterates over units of data which are the size of // a byte. Note that this assertion disallows ByteIter being equal to void*. static_assert(sizeof(std::uint8_t) == sizeof(decltype(*begin_iter)), "A call to PartitionByteSequence<ByteIter> used an iterator type which did " "not iterate over data in units of bytes."); // Disallow unusually small ssize_t. static_assert(std::numeric_limits<ssize_t>::max() >= std::numeric_limits<std::uint16_t>::max()); // Begin processing input. // Determine the number of bytes of the input which will be processed. // Check that ptrdiff_t can to hold the byte length. static_assert( std::numeric_limits<decltype(std::distance(begin_iter, end_iter))>::max() <= std::numeric_limits<std::ptrdiff_t>::max() ); std::ptrdiff_t s_byte_length {std::distance(begin_iter, end_iter)}; if(s_byte_length < 0) { throw std::invalid_argument {"end_iter was before begin_iter or an error " "occurred to a call to std::distance(begin_iter, end_iter) in " "a call to PartitionByteSequence."}; } std::size_t byte_length {static_cast<std::size_t>(s_byte_length)}; ssize_t working_ssize_t {partition_byte_sequence_internal::working_ssize_t_max}; std::size_t working_iovec {partition_byte_sequence_internal::working_iovec_max}; std::size_t bytes_remaining {partition_byte_sequence_internal::min_max}; if(byte_length < bytes_remaining) { bytes_remaining = byte_length; working_ssize_t = partition_byte_sequence_internal::NeededSsize_t(byte_length); working_iovec = partition_byte_sequence_internal::NeededIovec(byte_length); } std::size_t local_length {partition_byte_sequence_internal::NeededLocalData(bytes_remaining)}; // The first FCGI_HEADER_LEN (8) bytes are zero for padding. std::vector<uint8_t> noncontent_record_information(FCGI_HEADER_LEN, 0); noncontent_record_information.reserve(local_length); std::uint8_t* padding_ptr {noncontent_record_information.data()}; std::vector<struct iovec> iovec_list {}; iovec_list.reserve(working_iovec); ssize_t number_to_write {0}; // Handle the special case of no content. if(begin_iter == end_iter) { std::vector<uint8_t>::iterator header_iter {noncontent_record_information.insert(noncontent_record_information.end(), FCGI_HEADER_LEN, 0)}; PopulateHeader(&(*header_iter), type, Fcgi_id, 0, 0); iovec_list.push_back({&(*header_iter), FCGI_HEADER_LEN}); number_to_write += FCGI_HEADER_LEN; } else { // While records can be produced and need to be produced, produce a record // with the largest content length up to the contingent maximum. while(bytes_remaining) { uint16_t current_record_content_length { static_cast<std::uint16_t>( std::min<ssize_t>( static_cast<ssize_t>(bytes_remaining), static_cast<ssize_t>( partition_byte_sequence_internal::max_aligned_content_length) ) ) }; // Check if we need padding. uint8_t padding_length {0U}; if(uint8_t padding_length_complement = current_record_content_length % 8) { padding_length = (padding_length_complement) ? (8 - padding_length_complement) : 0U; } // Update non-content information. std::vector<uint8_t>::iterator header_iter {noncontent_record_information.insert( noncontent_record_information.end(), FCGI_HEADER_LEN, 0)}; std::uint8_t* local_ptr {&(*header_iter)}; PopulateHeader(local_ptr, type, Fcgi_id, current_record_content_length, padding_length); // Update iovec with header. iovec_list.push_back({local_ptr, FCGI_HEADER_LEN}); // The const_cast is necessary as struct iovec contains a void* member // and a client may pass in a const_iterator. iovec_list.push_back({ const_cast<void*>(static_cast<const void*>(&(*begin_iter))), current_record_content_length }); // Update iovec with padding if needed. Update relocation information. if(padding_length) { iovec_list.push_back({padding_ptr, padding_length}); } // Update tracking variables and increment iterator. number_to_write += (FCGI_HEADER_LEN + current_record_content_length + padding_length); bytes_remaining -= current_record_content_length; std::advance(begin_iter, current_record_content_length); } // Check if an error was made in the vector length calculations. if((number_to_write > working_ssize_t) || (iovec_list.size() > working_iovec) || (noncontent_record_information.size() > local_length)) { throw std::logic_error {"An error in the estimation of internal vector " "lengths occurred in a call to PartitionByteSequence."}; } } return std::make_tuple(std::move(noncontent_record_information), std::move(iovec_list), number_to_write, begin_iter); } } // namespace fcgi } // namespace as_components #endif // AS_COMPONENTS_FCGI_INCLUDE_FCGI_UTILITIES_TEMPLATES_H_
39.95941
81
0.668898
[ "object", "vector" ]
6214e78480120cd8c32f85e9f81f352da4a73eb2
8,022
h
C
camera/hal/mediatek/mtkcam/include/mtkcam/feature/utils/p2/P2Util.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
4
2020-07-24T06:54:16.000Z
2021-06-16T17:13:53.000Z
camera/hal/mediatek/mtkcam/include/mtkcam/feature/utils/p2/P2Util.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
1
2021-04-02T17:35:07.000Z
2021-04-02T17:35:07.000Z
camera/hal/mediatek/mtkcam/include/mtkcam/feature/utils/p2/P2Util.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
1
2020-11-04T22:31:45.000Z
2020-11-04T22:31:45.000Z
/* * Copyright (C) 2019 MediaTek Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CAMERA_HAL_MEDIATEK_MTKCAM_INCLUDE_MTKCAM_FEATURE_UTILS_P2_P2UTIL_H_ #define CAMERA_HAL_MEDIATEK_MTKCAM_INCLUDE_MTKCAM_FEATURE_UTILS_P2_P2UTIL_H_ #include <memory> #if MTK_DP_ENABLE // check later #include <DpDataType.h> #endif #include <INormalStream.h> #include <mtkcam/aaa/IHal3A.h> #include <mtkcam/drv/def/Dip_Notify_datatype.h> #include <mtkcam/feature/utils/p2/P2IO.h> #include <mtkcam/feature/utils/p2/P2Pack.h> #include <mtkcam/utils/std/ILogger.h> using NSImageio::NSIspio::EPortIndex; using NSCam::NSIoPipe::EPortCapbility; using NSCam::NSIoPipe::ExtraParam; using NSCam::NSIoPipe::FrameParams; using NSCam::NSIoPipe::Input; using NSCam::NSIoPipe::MCropRect; using NSCam::NSIoPipe::MCrpRsInfo; using NSCam::NSIoPipe::Output; using NSCam::NSIoPipe::PortID; using NSCam::NSIoPipe::PQParam; using NSCam::NSIoPipe::QParams; using NSCam::v4l2::ENormalStreamTag; using NS3Av3::TuningParam; namespace NSCam { namespace Feature { namespace P2Util { enum { CROP_IMGO = 1, CROP_IMG2O = 1, CROP_IMG3O = 1, CROP_WDMAO = 2, CROP_WROTO = 3, }; enum DMAConstrainFlag { DMACONSTRAIN_NONE = 0, DMACONSTRAIN_2BYTEALIGN = 1 << 0, // p2s original usage DMACONSTRAIN_NOSUBPIXEL = 1 << 1, // disable MDP sub-pixel }; class P2ObjPtr { public: _SRZ_SIZE_INFO_* srz4 = NULL; NSCam::NSIoPipe::PQParam* pqParam = NULL; #if MTK_DP_ENABLE // check later DpPqParam* pqWDMA = NULL; DpPqParam* pqWROT = NULL; #endif MBOOL hasPQ = MTRUE; }; class P2Obj { public: mutable _SRZ_SIZE_INFO_ srz4; mutable NSCam::NSIoPipe::PQParam pqParam; #if MTK_DP_ENABLE // check later mutable DpPqParam pqWDMA; mutable DpPqParam pqWROT; #endif P2ObjPtr toPtrTable() const { P2ObjPtr ptr; ptr.srz4 = &srz4; ptr.pqParam = &pqParam; #if MTK_DP_ENABLE ptr.pqWDMA = &pqWDMA; ptr.pqWROT = &pqWROT; #endif ptr.hasPQ = MTRUE; return ptr; } }; // Camera common function MBOOL is4K2K(const MSize& size); MCropRect VISIBILITY_PUBLIC getCropRect(const MRectF& rectF); template <typename T> MBOOL tryGet(const IMetadata& meta, MUINT32 tag, T* val) { MBOOL ret = MFALSE; IMetadata::IEntry entry = meta.entryFor(tag); if (!entry.isEmpty()) { *val = entry.itemAt(0, Type2Type<T>()); ret = MTRUE; } return ret; } template <typename T> MBOOL tryGet(const IMetadata* meta, MUINT32 tag, T* val) { return (meta != NULL) ? tryGet<T>(*meta, tag, val) : MFALSE; } template <typename T> MBOOL trySet(IMetadata* meta, MUINT32 tag, const T& val) { if (meta != NULL) { MBOOL ret = MFALSE; IMetadata::IEntry entry(tag); entry.push_back(val, Type2Type<T>()); ret = (meta->update(tag, entry) == OK); return ret; } else { return MFALSE; } } template <typename T> T getMeta(const IMetadata& meta, MUINT32 tag, const T& val) { T temp; return tryGet(meta, tag, temp) ? temp : val; } template <typename T> T getMeta(const IMetadata* meta, MUINT32 tag, const T& val) { T temp; return tryGet(meta, tag, temp) ? temp : val; } // Tuning function TuningParam VISIBILITY_PUBLIC makeTuningParam(const ILog& log, const P2Pack& p2Pack, std::shared_ptr<NS3Av3::IHal3A> hal3A, NS3Av3::MetaSet_T* inMetaSet, NS3Av3::MetaSet_T* pOutMetaSet, MBOOL resized, std::shared_ptr<IImageBuffer> tuningBuffer, IImageBuffer* lcso); // Metadata function MVOID updateExtraMeta(const P2Pack& p2Pack, IMetadata* outHal); MVOID updateDebugExif(const P2Pack& p2Pack, const IMetadata& inHal, IMetadata* outHal); MBOOL updateCropRegion(IMetadata* outHal, const MRect& rect); // QParams util function EPortCapbility VISIBILITY_PUBLIC toCapability(MUINT32 usage); const char* toName(MUINT32 index); const char* toName(EPortIndex index); const char* toName(const PortID& port); const char* toName(const Input& input); const char* toName(const Output& output); MBOOL is(const PortID& port, EPortIndex index); MBOOL is(const Input& input, EPortIndex index); MBOOL is(const Output& output, EPortIndex index); MBOOL is(const PortID& port, const PortID& rhs); MBOOL is(const Input& input, const PortID& rhs); MBOOL is(const Output& output, const PortID& rhs); MVOID VISIBILITY_PUBLIC printQParams(const ILog& log, const QParams& params); MVOID printTuningParam(const ILog& log, const TuningParam& tuning); MVOID push_in(FrameParams* frame, const PortID& portID, IImageBuffer* buffer); MVOID push_in(FrameParams* frame, const PortID& portID, const P2IO& in); MVOID push_out(FrameParams* frame, const PortID& portID, IImageBuffer* buffer); MVOID push_out(FrameParams* frame, const PortID& portID, IImageBuffer* buffer, EPortCapbility cap, MINT32 transform); MVOID VISIBILITY_PUBLIC push_out(FrameParams* frame, const PortID& portID, const P2IO& out); MVOID push_crop(FrameParams* frame, MUINT32 cropID, const MCropRect& crop, const MSize& size); MVOID VISIBILITY_PUBLIC push_crop(FrameParams* frame, MUINT32 cropID, const MRectF& crop, const MSize& size, const MINT32 dmaConstrainFlag = (DMACONSTRAIN_2BYTEALIGN | DMACONSTRAIN_NOSUBPIXEL)); // QParams function MVOID updateQParams(QParams* qparams, const P2Pack& p2Pack, const P2IOPack& io, const P2ObjPtr& obj, const TuningParam& tuning); QParams VISIBILITY_PUBLIC makeQParams(const P2Pack& p2Pack, ENormalStreamTag tag, const P2IOPack& io, const P2ObjPtr& obj); QParams VISIBILITY_PUBLIC makeQParams(const P2Pack& p2Pack, ENormalStreamTag tag, const P2IOPack& io, const P2ObjPtr& obj, const TuningParam& tuning); MVOID updateFrameParams(FrameParams* frame, const P2Pack& p2Pack, const P2IOPack& io, const P2ObjPtr& obj, const TuningParam& tuning); FrameParams makeFrameParams(const P2Pack& p2Pack, ENormalStreamTag tag, const P2IOPack& io, const P2ObjPtr& obj); FrameParams VISIBILITY_PUBLIC makeFrameParams(const P2Pack& p2Pack, ENormalStreamTag tag, const P2IOPack& io, const P2ObjPtr& obj, const TuningParam& tuning); // DParams uitil function #if MTK_DP_ENABLE DpPqParam* makeDpPqParam(DpPqParam* param, const P2Pack& p2Pack, const Output& out); DpPqParam* makeDpPqParam(DpPqParam* param, const P2Pack& p2Pack, const MUINT32 portCapabitity); #endif } // namespace P2Util } // namespace Feature } // namespace NSCam #endif // CAMERA_HAL_MEDIATEK_MTKCAM_INCLUDE_MTKCAM_FEATURE_UTILS_P2_P2UTIL_H_
33.286307
79
0.639865
[ "transform" ]
621d552f4ae2f2a6ba76e75ff852f433d2c9bb73
1,722
h
C
odk/framework/inc/odkfw_data_requester.h
HpLightcorner/OXYGEN-SDK
4ede0ea07b513032605b32fc86539f081589e58c
[ "MIT" ]
4
2019-12-20T18:21:03.000Z
2020-09-08T05:16:53.000Z
odk/framework/inc/odkfw_data_requester.h
HpLightcorner/OXYGEN-SDK
4ede0ea07b513032605b32fc86539f081589e58c
[ "MIT" ]
13
2020-07-01T19:35:08.000Z
2022-03-18T13:58:06.000Z
odk/framework/inc/odkfw_data_requester.h
HpLightcorner/OXYGEN-SDK
4ede0ea07b513032605b32fc86539f081589e58c
[ "MIT" ]
3
2020-07-28T06:50:56.000Z
2022-02-24T10:32:52.000Z
// Copyright DEWETRON GmbH 2020 #pragma once #define ODK_EXTENSION_FUNCTIONS #include "odkapi_data_set_xml.h" #include "odkapi_message_ids.h" #include "odkbase_message_return_value_holder.h" #include "odkbase_if_host.h" #include "odkbase_basic_values.h" #include "odkbase_api_object_ptr.h" #include "odkfw_stream_reader.h" #include "odkapi_data_set_descriptor_xml.h" #include "odkfw_stream_iterator.h" #include <cstddef> #include <memory> #include <utility> #include <vector> namespace odk { namespace framework { class DataRequestIDManager { public: static uint64_t getNextID() { return m_next_id++; } private: static uint64_t m_next_id; }; class DataRequester : public IfIteratorUpdater { static constexpr uint64_t BLOCK_SIZE = 1000; static constexpr double BLOCK_LENGTH = 0.1; public: DataRequester(odk::IfHost *host, std::uint64_t channel_id, bool user_reduced = false); DataRequester(const DataRequester& ) = delete; ~DataRequester(); void setupDataRequest(); void fetchMoreData(); void updateStreamIterator(StreamIterator* iterator) final; std::shared_ptr<StreamIterator> getIterator(double start, double end); private: odk::IfHost* m_host; double m_current_position; double m_end_position; uint64_t m_channel_id; DataSetDescriptor m_dataset_descriptor; odk::detail::ApiObjectPtr<const IfDataBlockList> m_data_block_list; odk::framework::StreamReader m_stream_reader; std::shared_ptr<StreamIterator> m_iterator; bool m_is_single_value; bool m_user_reduced; }; } }
23.589041
94
0.695122
[ "vector" ]
622fcee576870ad366b83a57a19997a4aa581d45
3,068
h
C
FlingEngine/Graphics/inc/GraphicsPipeline.h
BenjaFriend/EngineBay
402d49dc4378f0672fb66053effa49867b8c6726
[ "MIT" ]
315
2019-07-27T23:24:26.000Z
2022-03-23T18:55:31.000Z
FlingEngine/Graphics/inc/GraphicsPipeline.h
flingengine/FlingEngine
402d49dc4378f0672fb66053effa49867b8c6726
[ "MIT" ]
109
2019-07-14T19:47:03.000Z
2022-02-23T21:34:45.000Z
FlingEngine/Graphics/inc/GraphicsPipeline.h
BenjaFriend/EngineBay
402d49dc4378f0672fb66053effa49867b8c6726
[ "MIT" ]
18
2019-11-03T16:06:26.000Z
2022-01-23T03:32:19.000Z
#pragma once #include "FlingVulkan.h" #include "Shader.h" #include "Vertex.h" #include "MultiSampler.h" namespace Fling { class GraphicsPipeline { public: enum class Depth { None = 0, Read = 1, Write = 2, ReadWrite = Read | Write, }; GraphicsPipeline( std::vector<Shader*> t_Shaders, VkDevice t_LogicalDevice, VkPolygonMode t_Mode = VK_POLYGON_MODE_FILL, Depth t_Depth = Depth::ReadWrite, VkPrimitiveTopology t_Topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VkCullModeFlags t_CullMode = VK_CULL_MODE_BACK_BIT, VkFrontFace t_FrontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE); void BindGraphicsPipeline(const VkCommandBuffer& t_CommandBuffer); void CreateGraphicsPipeline(VkRenderPass& t_RenderPass, Multisampler* t_Sampler); const std::vector<Shader*> GetShaders() const { return m_Shaders; } Depth GetDepth() const { return m_Depth; } VkPrimitiveTopology GetTopology() const { return m_Topology; } VkPolygonMode GetPolygonMode() const { return m_PolygonMode; } VkCullModeFlags GetCullMode() const { return m_CullMode; } VkFrontFace GetFrontFace() const { return m_FrontFace; } const VkDescriptorSetLayout& GetDescriptorSetLayout() const { return m_DescriptorSetLayout; } const VkPipeline& GetPipeline() const { return m_Pipeline; } const VkPipelineLayout& GetPipelineLayout() const { return m_PipelineLayout; } const VkPipelineBindPoint& GetPipelineBindPoint() const { return m_PipelineBindPoint; } ~GraphicsPipeline(); void CreateAttributes(Multisampler* t_Sampler); std::vector<Shader*> m_Shaders; VkDevice m_Device; Depth m_Depth; VkPrimitiveTopology m_Topology; VkPolygonMode m_PolygonMode; VkCullModeFlags m_CullMode; VkFrontFace m_FrontFace; VkPipeline m_Pipeline = VK_NULL_HANDLE; VkPipelineCache m_PipelineCache = VK_NULL_HANDLE; VkPipelineLayout m_PipelineLayout = VK_NULL_HANDLE; VkPipelineBindPoint m_PipelineBindPoint; VkGraphicsPipelineCreateInfo m_PipelineCreateInfo = {}; VkDescriptorSetLayout m_DescriptorSetLayout; VkPipelineVertexInputStateCreateInfo m_VertexInputStateCreateInfo = {}; VkPipelineInputAssemblyStateCreateInfo m_InputAssemblyState = {}; VkPipelineRasterizationStateCreateInfo m_RasterizationState = {}; std::vector<VkPipelineColorBlendAttachmentState> m_ColorBlendAttachmentStates; VkPipelineColorBlendStateCreateInfo m_ColorBlendState = {}; VkPipelineDepthStencilStateCreateInfo m_DepthStencilState = {}; VkPipelineViewportStateCreateInfo m_ViewportState = {}; VkPipelineMultisampleStateCreateInfo m_MultisampleState = {}; VkPipelineDynamicStateCreateInfo m_DynamicState = {}; VkPipelineTessellationStateCreateInfo m_TessellationState = {}; }; }
39.333333
101
0.702412
[ "vector" ]
623548b7313d17bf3293f4d319bd4895b82178a5
1,680
h
C
Example/Pods/IotLinkKit/iot-linkkit/IotLinkKit.framework/Headers/LinkkitDefine.h
konewu/iosSinovoLibrary
6e7c2e5d3cd9abd84f4ad6c39a302d246821d20b
[ "MIT" ]
null
null
null
Example/Pods/IotLinkKit/iot-linkkit/IotLinkKit.framework/Headers/LinkkitDefine.h
konewu/iosSinovoLibrary
6e7c2e5d3cd9abd84f4ad6c39a302d246821d20b
[ "MIT" ]
null
null
null
Example/Pods/IotLinkKit/iot-linkkit/IotLinkKit.framework/Headers/LinkkitDefine.h
konewu/iosSinovoLibrary
6e7c2e5d3cd9abd84f4ad6c39a302d246821d20b
[ "MIT" ]
null
null
null
// // LinkkitDefine.h // IotLinkKit // // Created by 朱永利 on 2018/11/15. // Copyright © 2018年 朱永利. All rights reserved. // #import <Foundation/Foundation.h> //#import <AKLog/AKLog.h> #import <IMSLog/IMSLogMacros.h> #define LinkkitTag @"LinkkitTag" #define LinkkitLogError(frmt,...) IMS_LOG_MACRO(NO, IMSLogFlagError, IMS_LOG_CONTEXT, LinkkitTag, frmt, ##__VA_ARGS__) #define LinkkitLogWarn(frmt,...) IMS_LOG_MACRO(IMS_LOG_ASYNC_ENABLED, IMSLogFlagWarning, IMS_LOG_CONTEXT, LinkkitTag, frmt, ##__VA_ARGS__) #define LinkkitLogInfo(frmt,...) IMS_LOG_MACRO(IMS_LOG_ASYNC_ENABLED, IMSLogFlagInfo, IMS_LOG_CONTEXT, LinkkitTag, frmt, ##__VA_ARGS__) #define LinkkitLogDebug(frmt,...) IMS_LOG_MACRO(IMS_LOG_ASYNC_ENABLED, IMSLogFlagDebug, IMS_LOG_CONTEXT, LinkkitTag, frmt, ##__VA_ARGS__) #define LinkkitLogVerbose(frmt,...) IMS_LOG_MACRO(IMS_LOG_ASYNC_ENABLED, IMSLogFlagDebug, IMS_LOG_CONTEXT, LinkkitTag, frmt, ##__VA_ARGS__) #define LinkkitLogInit() [IMSLog registerTag:LinkkitTag]; typedef void (^LinkkitBooleanResultBlock)(BOOL succeeded, NSError * _Nullable error); typedef void (^LinkkitObjectResultBlock)(NSDictionary * _Nullable object, NSError * _Nullable error); typedef void (^LinkkitArrayResultBlock)(NSArray * _Nullable result, NSError * _Nullable error); typedef void (^LinkkitEmptyResultBlock)(void); FOUNDATION_EXPORT NSString * const LinkkitErrorDomain; /** linkkit错误码 */ typedef NS_ENUM(NSInteger, LinkkitErrorCode) { LinkkitErrorSuccess = 0, ///< 业务成功 LinkkitErrorInvalidParams = 4200,///< 业务入参非法 LinkkitErrorNotSetup = 4201,///< Linkkit未初始化 LinkkitErrorChannelDisconnected = 4202,///< 长连接通道未连接 };
36.521739
142
0.759524
[ "object" ]
6236b631cf0a15138ded4c257aa7ba4585e5e01c
1,065
h
C
ai/DeepCoder/docker/DeepCoder/include/dsl/interpreter.h
quanpan302/test
313c6e310be0ef608543c23bd52a5466047cd378
[ "Apache-2.0" ]
null
null
null
ai/DeepCoder/docker/DeepCoder/include/dsl/interpreter.h
quanpan302/test
313c6e310be0ef608543c23bd52a5466047cd378
[ "Apache-2.0" ]
null
null
null
ai/DeepCoder/docker/DeepCoder/include/dsl/interpreter.h
quanpan302/test
313c6e310be0ef608543c23bd52a5466047cd378
[ "Apache-2.0" ]
null
null
null
#include <vector> #include <unordered_map> #include <experimental/optional> #include "dsl/ast.h" #include "dsl/type.h" #pragma once namespace dsl { struct Value { Value(); Value(int i); Value(const std::vector<int>& l); Type type; std::vector<int> result; std::experimental::optional<int> integer() const; std::experimental::optional<std::vector<int>> list() const; bool is_null() const; bool operator==(const Value& rhs) const; bool operator!=(const Value& rhs) const; }; using Input = std::vector<Value>; using Output = Value; struct Environment { std::unordered_map<Variable, Value> variables; Input input; size_t offset; Environment(const std::unordered_map<Variable, Value> &variables, const Input& input); }; std::experimental::optional<Output> eval(const Program &program, const Input &input); std::experimental::optional<Environment> proceed(const Statement &statement, const Environment &environment); }
27.307692
113
0.64507
[ "vector" ]
6244f70ca49c5fd93a50dab151a41ab71470cd75
2,308
h
C
source/Math/Radix.h
badbrainz/pme
1c8e6f3d154cc59613f5ef3f2f8293f488c64b28
[ "WTFPL" ]
null
null
null
source/Math/Radix.h
badbrainz/pme
1c8e6f3d154cc59613f5ef3f2f8293f488c64b28
[ "WTFPL" ]
null
null
null
source/Math/Radix.h
badbrainz/pme
1c8e6f3d154cc59613f5ef3f2f8293f488c64b28
[ "WTFPL" ]
null
null
null
#ifndef RADIX #define RADIX #define RADIX_LOCAL_RAM enum RadixHint { RADIX_SIGNED, RADIX_UNSIGNED, RADIX_FORCE_DWORD = 0x7fffffff }; class RadixSort { public: RadixSort(); ~RadixSort(); public: RadixSort& Sort(const unsigned int* input, unsigned int nb, bool signedvalues = true); RadixSort& Sort(const float* input, unsigned int nb); inline unsigned int* GetIndices() const { return mIndices; } inline unsigned int* GetRecyclable() const { return mIndices2; } unsigned int GetUsedRam() const; inline unsigned int GetNbTotalCalls() const { return mTotalCalls; } inline unsigned int GetNbHits() const { return mNbHits; } private: RadixSort(const RadixSort& object); RadixSort& operator = (const RadixSort& object); bool Resize(unsigned int nb); void ResetIndices(); void CheckResize(unsigned int n); private: #ifndef RADIX_LOCAL_RAM unsigned int* mHistogram; unsigned int* mOffset; #endif unsigned int mCurrentSize; unsigned int mPreviousSize; unsigned int* mIndices; unsigned int* mIndices2; unsigned int mTotalCalls; unsigned int mNbHits; }; class RadixSort3 { public: RadixSort3(); ~RadixSort3(); public: RadixSort3& Sort(const unsigned int* input, unsigned int nb, RadixHint = RADIX_SIGNED); RadixSort3& Sort(const float* input, unsigned int nb); inline const unsigned int* GetRanks() const { return mRanks; } inline unsigned int* GetRecyclable() const { return mRanks2; } inline unsigned int GetNbTotalCalls() const { return mTotalCalls; } inline unsigned int GetNbHits() const { return mNbHits; } bool SetRankBuffers(unsigned int* ranks0, unsigned int* ranks1); private: void CheckResize(unsigned int nb); bool Resize(unsigned int nb); private: unsigned int mCurrentSize; unsigned int* mRanks; unsigned int* mRanks2; unsigned int mTotalCalls; unsigned int mNbHits; bool mDeleteRanks; }; #endif
20.069565
92
0.608752
[ "object" ]
624fdcd3cdf3484bcecb087024825949d45bff91
736
c
C
lib/wizards/grathlek/area1/uproom6.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/grathlek/area1/uproom6.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/grathlek/area1/uproom6.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
inherit "room/room"; object monster; reset(arg) { if(!monster) { if(arg) return; monster = clone_object("/wizards/grathlek/area1/monsies/cpaladin.c"); move_object(monster, this_object()); } add_exit("north","/wizards/grathlek/area1/uproom5.c"); short_desc = "This is an well lighted room."; long_desc = "This is the room where the light begins.\n"+ "There is a huge meteor on hanging from the ceiling of this room.\n"+ "The light seems to come from the meteor.\n"; items = allocate(4); items[0] = "meteor"; items[1] = "Meteor is hanging from the ceiling of this room.\n"+ "Meteor has a magical glow and light the whole temple."; }
28.307692
83
0.619565
[ "object" ]
625ac0b7f36fb3ae03941907e6ff3471742fb171
446
h
C
Computer-Graphics/Fase-4/engine/Models/headers/textures.h
paulob122/CG_19-20
6962e83ed4867a79b9b07c83da9ab609cd73c909
[ "MIT" ]
null
null
null
Computer-Graphics/Fase-4/engine/Models/headers/textures.h
paulob122/CG_19-20
6962e83ed4867a79b9b07c83da9ab609cd73c909
[ "MIT" ]
null
null
null
Computer-Graphics/Fase-4/engine/Models/headers/textures.h
paulob122/CG_19-20
6962e83ed4867a79b9b07c83da9ab609cd73c909
[ "MIT" ]
null
null
null
#ifndef ENGINE_TEXTURES_H #define ENGINE_TEXTURES_H #include "model-info.h" /* * Initializes textures specified in the models of the * different groups, loading image data, texture ID,... * */ void initTextures(vector<Group>* scene_groups); /* * Initializes textures specified in the models of the * different groups, loading image data, texture ID,... for sky * */ int initModelTextureSky(string texture); #endif //ENGINE_TEXTURES_H
22.3
64
0.746637
[ "vector", "model" ]
625d964babc228b0b3aa1dd63fdc9683764fc4b1
8,078
h
C
src/guidance.v2.02/libs/phylogeny/bestTamura92param.h
jlanga/smsk_selection
08070c6d4a6fbd9320265e1e698c95ba80f81123
[ "MIT" ]
4
2021-07-18T05:20:20.000Z
2022-01-03T10:22:33.000Z
src/guidance.v2.02/libs/phylogeny/bestTamura92param.h
jlanga/smsk_selection
08070c6d4a6fbd9320265e1e698c95ba80f81123
[ "MIT" ]
1
2017-08-21T07:26:13.000Z
2018-11-08T13:59:48.000Z
src/guidance.v2.02/libs/phylogeny/bestTamura92param.h
jlanga/smsk_orthofinder
08070c6d4a6fbd9320265e1e698c95ba80f81123
[ "MIT" ]
2
2021-07-18T05:20:26.000Z
2022-03-31T18:23:31.000Z
// $Id: bestTamura92param.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___BEST_TAMURA92_PARAM #define ___BEST_TAMURA92_PARAM #include "definitions.h" #include "likelihoodComputation.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "multipleStochasticProcess.h" #include "gammaDistribution.h" #include "tree.h" #include "tamura92.h" class bestTamura92ParamFixedTree { public: explicit bestTamura92ParamFixedTree(const tree& et, // find best TrTv and theta const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations = 5, const MDOUBLE epsilonLikelihoodImprovment = 0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization = 0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization = 0.01, const MDOUBLE upperBoundOnTrTv = 5.0); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta() {return _bestTheta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestL; }; class bestTamura92ParamAndBBL{ public: explicit bestTamura92ParamAndBBL(tree& et, //find best TrTv, theta and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const int maxTotalIterations=5, const MDOUBLE epsilonLikelihoodImprovment=0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization=0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization=0.01, const MDOUBLE epsilonLoglikelihoodForBBL=0.01, const MDOUBLE upperBoundOnTrTv=5.0, const int maxBBLIterations=10); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta(int spIndex) {return _bestTheta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestL; }; class bestTamura92ParamAlphaAndBBL { public: explicit bestTamura92ParamAlphaAndBBL( //find best TrTv, theta, Alpha and best branch lengths tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const int maxTotalIterations=5, const MDOUBLE epsilonLikelihoodImprovment= 0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.01, const MDOUBLE upperBoundOnTrTv = 5.0, const int maxBBLIterations=10, const MDOUBLE initAlpha = 1.5, const MDOUBLE upperBoundOnAlpha = 5.0); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta() {return _bestTheta;} MDOUBLE getBestAlpha() {return _bestAlpha;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestAlpha; MDOUBLE _bestL; }; class bestTamura92ParamAlphaAndBBLProportional { public: explicit bestTamura92ParamAlphaAndBBLProportional( //find best TrTv, theta, loca Alpha for each gene, global Alpha and best branch lengths tree& et, vector<sequenceContainer>& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocalKappas, Vdouble initLocalThetas, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundOnTrTv, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches=false, const bool optimizeTree = true, const string branchLengthOptimizationMethod="bblLS", const bool optimizeLocalParams = true, const bool optimizeGlobalAlpha = true, const Vdouble * weights=NULL, const MDOUBLE epsilonLikelihoodImprovment= 0.05, const MDOUBLE epsilonLoglikelihoodForLocalTrTvOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForLocalThetaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForLocalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForGlobalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.01); MDOUBLE getBestTrTv(int spIndex) {return _bestTrTvVec[spIndex];} MDOUBLE getBestTheta(int spIndex) {return _bestThetaVec[spIndex];} MDOUBLE getBestLocalAlpha(int spIndex) {return _bestLocalAlphaVec[spIndex];} MDOUBLE getBestGlobalAlpha() {return _bestGlobalAlpha;} Vdouble getBestL() {return _bestLvec;} private: Vdouble _bestTrTvVec; Vdouble _bestThetaVec; Vdouble _bestLocalAlphaVec; MDOUBLE _bestGlobalAlpha; Vdouble _bestLvec; }; class C_evalTrTvParam{ public: C_evalTrTvParam( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE TrTv) { (static_cast<tamura92*>(_sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(TrTv); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); LOG(5,<<" with TrTv = "<<TrTv<<" logL = "<<res<<endl); return -res; } }; class C_evalLocalTrTvParam{ public: C_evalLocalTrTvParam( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, gammaDistribution* pProportionDist, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp),_pProportionDist(pProportionDist){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; gammaDistribution* _pProportionDist; public: MDOUBLE operator() (MDOUBLE TrTv) { (static_cast<tamura92*>(_sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(TrTv); vector<sequenceContainer> tmpScVec; tmpScVec.push_back(_sc); vector<stochasticProcess> tmpSpVec; tmpSpVec.push_back(_sp); multipleStochasticProcess * tmpMsp = new multipleStochasticProcess(); tmpMsp->setSpVec(tmpSpVec); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,tmpScVec,tmpMsp,_pProportionDist); MDOUBLE res = likeVec[0]; delete(tmpMsp); LOG(5,<<" with TrTv = "<<TrTv<<" logL = "<<res<<endl); return -res; } }; class C_evalLocalTheta{ public: C_evalLocalTheta( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, gammaDistribution* pProportionDist, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp),_pProportionDist(pProportionDist){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; gammaDistribution* _pProportionDist; public: MDOUBLE operator() (MDOUBLE theta) { (static_cast<tamura92*>(_sp.getPijAccelerator()->getReplacementModel()))->changeTheta(theta); vector<sequenceContainer> tmpScVec; tmpScVec.push_back(_sc); vector<stochasticProcess> tmpSpVec; tmpSpVec.push_back(_sp); multipleStochasticProcess * tmpMsp = new multipleStochasticProcess(); tmpMsp->setSpVec(tmpSpVec); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,tmpScVec,tmpMsp,_pProportionDist); MDOUBLE res = likeVec[0]; delete(tmpMsp); LOG(5,<<" with Theta = "<<theta<<" logL = "<<res<<endl); return -res; } }; class C_evalTheta{ public: C_evalTheta( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE theta) { (static_cast<tamura92*>(_sp.getPijAccelerator()->getReplacementModel()))->changeTheta(theta); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); LOG(5,<<" with theta = "<<theta<<" logL = "<<res<<endl); return -res; } }; #endif
33.799163
139
0.751424
[ "vector" ]
626257012198f47f011cc39a0637a393cef3d3fd
5,186
h
C
src/Image/ImageIO.h
LeksiDor/JaraboTransientRendering
62a786f3ba0ac16ee41725d26e15e137239f4c49
[ "MIT" ]
2
2020-09-23T14:17:47.000Z
2021-01-23T02:33:16.000Z
src/Image/ImageIO.h
LeksiDor/JaraboTransientRendering
62a786f3ba0ac16ee41725d26e15e137239f4c49
[ "MIT" ]
null
null
null
src/Image/ImageIO.h
LeksiDor/JaraboTransientRendering
62a786f3ba0ac16ee41725d26e15e137239f4c49
[ "MIT" ]
null
null
null
/* * Copyright (C) 2018, Ibon Guillen (http://giga.cps.unizar.es/~ibon/) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom * the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _IMAGEIO_H_ #define _IMAGEIO_H_ #include "bunnykiller.h" #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <functional> #include <memory> #include <string> #include <vector> /* Configure stb_image */ /* We make stb use the standard C++ allocators so we can pass around its buffers as-is */ namespace { void* terrible_realloc(void* p, size_t oldsz, size_t newsz) { char* newp = new char[newsz](); std::copy((char*) p, (char*) p + oldsz, newp); delete[] ((char*) p); /* This is bad */ return (void*) newp; } ; } /* This is acceptable */ #define STBI_MALLOC(sz) new char[sz]() /* This is bad */ #define STBI_FREE(p) delete[]((char*)p) /* This is terrible */ #define STBI_REALLOC_SIZED(p, oldsz, newsz) terrible_realloc(p, oldsz, newsz) #define STBI_NO_GIF /* The GIF loader requires an unsized realloc */ #define STB_IMAGE_IMPLEMENTATION #include "External/stb/stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "External/stb/stb_image_write.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "External/stb/stb_image_resize.h" #include "Image/Image.h" #include "Image/RGBColor.h" #include "Utils/Filesystem.h" namespace Imaging { template<class T> Image<T> load(const char* filename, unsigned load_channels = 0) { int w, h, c; std::unique_ptr<float[]> data(stbi_loadf(filename, &w, &h, &c, load_channels)); if (!data) { throw std::runtime_error( "Error: failed to read image: \"" + std::string(filename) + "\""); } return Image<T>(std::move(data), w, h, c); } namespace { /* If the image is using internally a type different from float, we need to * convert the data before storing it */ template<class T> class Conversor { private: std::unique_ptr<float[]> m_data; size_t m_size; public: Conversor(const T* data, size_t size) : m_data(new float[size]()), m_size(size) { std::copy_n(data, size, m_data.get()); } inline const float* data() const { return m_data.get(); } inline size_t size() const { return m_size; } }; /* If the image is using internally float, we can return it as-is */ template<> class Conversor<float> { private: const float* m_data; size_t m_size; public: Conversor(const float* data, size_t size) : m_data(data), m_size(size) { } inline const float* data() const { return m_data; } inline size_t size() const { return m_size; } }; } template<class T> void save(const Image<T>& img, const char* filename) { if (img.channels() > 3) { throw std::runtime_error( "Error: trying to save a " + std::to_string(img.channels()) + " channel image. Max supported output channels is 3"); } FILE* file = std::fopen(filename, "w"); if (!file) { throw std::runtime_error( "Error: failed to open output file: \"" + std::string(filename) + "\""); } /* We provide our own write function to stb so we can control the file handle */ auto write_fn = [](void* file, void* data, int size) -> void { std::fwrite(data, sizeof(char), size, (FILE*)file); }; /* Autodetect file format */ std::string ext = Filesystem::file_extension(filename); int res = 1; if (ext == "hdr") { /* Save RGBE file */ Conversor<T> conversor(img.data(), img.size()); res = stbi_write_hdr_to_func(write_fn, (void*) file, (int) img.width(), (int) img.height(), (int) img.channels(), conversor.data()); } else if (ext == "raw") { /* Save binary dump */ size_t count = std::fwrite((const void*) img.data(), sizeof(T), img.size(), (FILE*) file); res = (count == img.size()); } else { throw std::runtime_error("Error: unsupported output file format: \"" + ext + "\""); } if (!res) { throw std::runtime_error( "Error: failed to write to output file: \"" + std::string(filename) + "\""); } std::fclose(file); } }; /* namespace Imaging */ #endif /* _IMAGEIO_H_ */
26.191919
86
0.659661
[ "vector" ]
62678a0b0333d1ef3c455ac44c2fd80714278359
412
h
C
src/AdventOfCode2018/Day03-HowYouSliceIt/Day03-HowYouSliceIt.h
dbartok/advent-of-code-cpp
c8c2df7a21980f8f3e42128f7bc5df8288f18490
[ "MIT" ]
null
null
null
src/AdventOfCode2018/Day03-HowYouSliceIt/Day03-HowYouSliceIt.h
dbartok/advent-of-code-cpp
c8c2df7a21980f8f3e42128f7bc5df8288f18490
[ "MIT" ]
null
null
null
src/AdventOfCode2018/Day03-HowYouSliceIt/Day03-HowYouSliceIt.h
dbartok/advent-of-code-cpp
c8c2df7a21980f8f3e42128f7bc5df8288f18490
[ "MIT" ]
null
null
null
#pragma once #include <AdventOfCodeCommon/DisableLibraryWarningsMacros.h> __BEGIN_LIBRARIES_DISABLE_WARNINGS #include <vector> #include <string> __END_LIBRARIES_DISABLE_WARNINGS namespace AdventOfCode { namespace Year2018 { namespace Day03 { unsigned numOverlappingSquares(const std::vector<std::string>& areaLines); unsigned findSingleNonOperlappingSquare(const std::vector<std::string>& areaLines); } } }
17.913043
83
0.822816
[ "vector" ]
6267b01519d7149c7c890f1eda8ca8ca9dc09021
4,796
h
C
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_Debug4195163081MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_Debug4195163081MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_Debug4195163081MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // UnityEngine.ILogger struct ILogger_t629411471; // System.Object struct Il2CppObject; // UnityEngine.Object struct Object_t3071478659; // System.Exception struct Exception_t3991598821; // System.String struct String_t; // System.Object[] struct ObjectU5BU5D_t1108656482; #include "codegen/il2cpp-codegen.h" #include "UnityEngine_UnityEngine_Vector34282066566.h" #include "UnityEngine_UnityEngine_Color4194546905.h" #include "mscorlib_System_Object4170816371.h" #include "UnityEngine_UnityEngine_Object3071478659.h" #include "mscorlib_System_Exception3991598821.h" #include "mscorlib_System_String7231557.h" // System.Void UnityEngine.Debug::.cctor() extern "C" void Debug__cctor_m37515655 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.ILogger UnityEngine.Debug::get_logger() extern "C" Il2CppObject * Debug_get_logger_m275693158 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::DrawLine(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Color,System.Single,System.Boolean) extern "C" void Debug_DrawLine_m712997666 (Il2CppObject * __this /* static, unused */, Vector3_t4282066566 ___start0, Vector3_t4282066566 ___end1, Color_t4194546905 ___color2, float ___duration3, bool ___depthTest4, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::INTERNAL_CALL_DrawLine(UnityEngine.Vector3&,UnityEngine.Vector3&,UnityEngine.Color&,System.Single,System.Boolean) extern "C" void Debug_INTERNAL_CALL_DrawLine_m4247131229 (Il2CppObject * __this /* static, unused */, Vector3_t4282066566 * ___start0, Vector3_t4282066566 * ___end1, Color_t4194546905 * ___color2, float ___duration3, bool ___depthTest4, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::DrawRay(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Color) extern "C" void Debug_DrawRay_m123146114 (Il2CppObject * __this /* static, unused */, Vector3_t4282066566 ___start0, Vector3_t4282066566 ___dir1, Color_t4194546905 ___color2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::DrawRay(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Color,System.Single,System.Boolean) extern "C" void Debug_DrawRay_m3043129782 (Il2CppObject * __this /* static, unused */, Vector3_t4282066566 ___start0, Vector3_t4282066566 ___dir1, Color_t4194546905 ___color2, float ___duration3, bool ___depthTest4, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::Log(System.Object) extern "C" void Debug_Log_m1731103628 (Il2CppObject * __this /* static, unused */, Il2CppObject * ___message0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogError(System.Object) extern "C" void Debug_LogError_m4127342994 (Il2CppObject * __this /* static, unused */, Il2CppObject * ___message0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogError(System.Object,UnityEngine.Object) extern "C" void Debug_LogError_m214246398 (Il2CppObject * __this /* static, unused */, Il2CppObject * ___message0, Object_t3071478659 * ___context1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogException(System.Exception) extern "C" void Debug_LogException_m248970745 (Il2CppObject * __this /* static, unused */, Exception_t3991598821 * ___exception0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogException(System.Exception,UnityEngine.Object) extern "C" void Debug_LogException_m2264672311 (Il2CppObject * __this /* static, unused */, Exception_t3991598821 * ___exception0, Object_t3071478659 * ___context1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogWarning(System.Object) extern "C" void Debug_LogWarning_m3123317694 (Il2CppObject * __this /* static, unused */, Il2CppObject * ___message0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogWarning(System.Object,UnityEngine.Object) extern "C" void Debug_LogWarning_m4097176146 (Il2CppObject * __this /* static, unused */, Il2CppObject * ___message0, Object_t3071478659 * ___context1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Debug::LogWarningFormat(UnityEngine.Object,System.String,System.Object[]) extern "C" void Debug_LogWarningFormat_m193815327 (Il2CppObject * __this /* static, unused */, Object_t3071478659 * ___context0, String_t* ___format1, ObjectU5BU5D_t1108656482* ___args2, const MethodInfo* method) IL2CPP_METHOD_ATTR;
74.9375
283
0.812552
[ "object" ]
62810ea72a32ede8193021a3abb59db78efe54b4
5,813
h
C
Tools/include/patchStr.h
steakknife/pcgeos
95edd7fad36df400aba9bab1d56e154fc126044a
[ "Apache-2.0" ]
504
2018-11-18T03:35:53.000Z
2022-03-29T01:02:51.000Z
Tools/include/patchStr.h
steakknife/pcgeos
95edd7fad36df400aba9bab1d56e154fc126044a
[ "Apache-2.0" ]
96
2018-11-19T21:06:50.000Z
2022-03-06T10:26:48.000Z
Tools/include/patchStr.h
steakknife/pcgeos
95edd7fad36df400aba9bab1d56e154fc126044a
[ "Apache-2.0" ]
73
2018-11-19T20:46:53.000Z
2022-03-29T00:59:26.000Z
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994 -- All Rights Reserved PROJECT: GEOS Tools MODULE: Patch FILE: patchStr.h AUTHOR: Chris Boyke, Apr 5, 1994 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- chrisb 4/ 5/94 Initial version. DESCRIPTION: Data structures used in patch files. $Id: patchStr.h,v 1.4 97/04/17 17:51:25 dbaumann Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #define swapdw swapl /* from bswap.h */ typedef struct { char PFH_signature[4]; char PFH_geodeName[GEODE_NAME_SIZE]; char PFH_geodeNameExt[GEODE_NAME_EXT_SIZE]; IconToken PFH_token; word PFH_geodeAttr; ReleaseNumber PFH_oldRelease; ProtocolNumber PFH_oldProtocol; ReleaseNumber PFH_newRelease; ProtocolNumber PFH_newProtocol; word PFH_resourceCount; word PFH_newResourceCount; word PFH_flags; word PFH_udataSize; word PFH_classOffset; word PFH_classResource; word PFH_appObjChunkHandle; word PFH_appObjResource; } PatchFileHeader; #define PFH_SIZE (offsetof(PatchFileHeader,PFH_appObjResource) + sizeof(word)) #define PARTIAL_HEADER_OFFSET (offsetof(PatchFileHeader,PFH_oldRelease)) #define PARTIAL_HEADER_SIZE (PFH_SIZE - PARTIAL_HEADER_OFFSET) /* PatchFileHeaderFlags */ #define PFHF_DYNAMIC 0x1 /* The actual data is stored in a PatchElement -- there may be */ /* more than one of these per resource. */ typedef struct PE { struct PE *PE_next; word PE_pos; word PE_flags; /* The low 14 bits are the size of the patch data, the top 2 bits are the type of patch */ } PatchElement; /* Since the sparc pads everything out to be word-aligned, etc. we */ /* have to jump through hoops to get the exact sizes we need */ #define PE_SIZE (offsetof(PatchElement,PE_flags)+sizeof(word)) #define PE_WRITE_OFFSET (offsetof(PatchElement,PE_pos)) #define PE_FINAL_SIZE (PE_SIZE - PE_WRITE_OFFSET) #define MAX_PATCH_SIZE 4095 /* Make this number larger to reduce the number of patches in a file. */ #define PATCH_GRANULARITY 8 typedef word PatchType; #define PT_REPLACE 0x0000 #define PT_DELETE 0x4000 #define PT_INSERT 0x8000 #define PT_INSERT_ZERO 0xC000 #define PE_SIZE_MASK 0x0FFF #define PE_TYPE_MASK 0xC000 /* One of these structures exists for each resource that has data in */ /* the patch file */ typedef struct PRE { struct PRE *PRE_next; PatchElement *PRE_resourcePatches; PatchElement *PRE_relocPatches; word PRE_id; word PRE_size; dword PRE_pos; word PRE_relocSize; word PRE_resourceSizeDiff; /* Rounded to nearest paragraph */ word PRE_maxResourceSize; word PRE_maxRelocSize; word PRE_flags; } PatchedResourceEntry; #define PRE_SIZE (offsetof(PatchedResourceEntry,PRE_flags)+2) #define PRE_WRITE_OFFSET (offsetof(PatchedResourceEntry,PRE_id)) #define PRE_FINAL_SIZE (PRE_SIZE - PRE_WRITE_OFFSET) typedef struct { word GH_geodeHandle; /* handle of geode (0 in file) */ word GH_geodeAttr; /* COPY OF geodehAttributes */ word GH_geodeFileType; /* COPY OF geodehFileType */ ReleaseNumber GH_geodeRelease; ProtocolNumber GH_geodeProtocol; word GH_geodeSerial; /* 12h */ char GH_geodeName[GEODE_NAME_SIZE]; /* Permanent name */ char GH_geodeNameExt[GEODE_NAME_EXT_SIZE]; /* Name extension */ IconToken GH_geodeToken; /* Token for this GEODE */ word GH_geodeRefCount; /* Starting reference count for GEODE*/ word GH_driverTabOff; word GH_driverTabSegment; word GH_libEntryOff; /* Offset of library entry routine */ word GH_libEntrySegment; /* Offset of library entry routine */ word GH_exportLibTabOff; /* Offset (in memory) of library */ /* entry point table */ word GH_exportEntryCount; /* Number of exported entry points */ word GH_libCount; /* Number of imported libraries */ word GH_libOffset; /* Offset (in memory) of library * table. Filled in by kernel */ word GH_resCount; /* 38h */ word GH_resHandleOff; /* 3ah */ word GH_resPosOff; /* 3ch */ word GH_resRelocOff; /* 3eh */ /************end of data in the GeodeHeader2 struct ***************/ word GH_geoHandle; /* handle to geodes .geo file */ word GH_parentProcess; /* handle of parent process */ word GH_nextGeode; /* handle of next geode on list */ word GH_privData; /* special priv data for each geode */ word GH_extraLibOffset; /* offset of extra library table */ word GH_extraLibCount; /* number of extra libraries */ word GH_patchData; /* 4ch */ } CoreBlockHeader; #define GEODE_HEADER_SIZE (offsetof(CoreBlockHeader,GH_patchData) \ + sizeof(word)); typedef struct { CoreBlockHeader PH_geodePart; word PH_appObjectChunkHandle; word PH_appObjectResource; word PH_vmHandle; /* vm handle of state file */ word PH_savedBlockPtr; /* first handle on "saved" chain */ word PH_uiData; /* one word of data for UI */ word PH_uiThread; /* Second, "UI" thread for process, if any. Runs all "ui-object" blocks */ word PH_stdFileHandles[4]; } ProcessHeader; #define PROCESS_HEADER_SIZE (offsetof(ProcessHeader, PH_stdFileHandles) \ + (4 * sizeof(word)));
34.60119
79
0.635472
[ "object" ]
62862abd1ba0cd9256a8dca15cbacf1aa8322cc0
554
h
C
src/btl/trunk/btl/dna_gap.h
akhudek/feast
bb41ac122a9c0542a0fb71eec81ff5e872c556e5
[ "MIT" ]
1
2015-06-15T21:46:07.000Z
2015-06-15T21:46:07.000Z
src/btl/trunk/btl/dna_gap.h
akhudek/feast
bb41ac122a9c0542a0fb71eec81ff5e872c556e5
[ "MIT" ]
null
null
null
src/btl/trunk/btl/dna_gap.h
akhudek/feast
bb41ac122a9c0542a0fb71eec81ff5e872c556e5
[ "MIT" ]
null
null
null
#ifndef BTL_DNA_GAP__ #define BTL_DNA_GAP__ #include <iostream> #include <vector> #include <stdexcept> #include <boost/array.hpp> #include <btl/dna_gap_symbol.h> namespace btl { class dna_gap { public: // useful for template constructions static int const SIZE = 5; // reference our symbol type typedef dna_gap_symbol symbol; // list of alphabet symbols static boost::array<dna_gap_symbol,5> const alphabet; // here we encode constant versions of the symbols static dna_gap_symbol const A, T, C, G, GAP; }; } #endif
18.466667
55
0.716606
[ "vector" ]
628bc1c694b44f98576256f6a2533a0d10ccd049
83,497
c
C
third_party/mesa/MesaLib/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
Scopetta197/chromium
b7bf8e39baadfd9089de2ebdc0c5d982de4a9820
[ "BSD-3-Clause" ]
212
2015-01-31T11:55:58.000Z
2022-02-22T06:35:11.000Z
third_party/mesa/MesaLib/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
1065672644894730302/Chromium
239dd49e906be4909e293d8991e998c9816eaa35
[ "BSD-3-Clause" ]
5
2015-03-27T14:29:23.000Z
2019-09-25T13:23:12.000Z
third_party/mesa/MesaLib/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
1065672644894730302/Chromium
239dd49e906be4909e293d8991e998c9816eaa35
[ "BSD-3-Clause" ]
221
2015-01-07T06:21:24.000Z
2022-02-11T02:51:12.000Z
/************************************************************************** * * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * Copyright 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ /** * Generate SPU per-fragment code (actually per-quad code). * \author Brian Paul * \author Bob Ellison */ #include "pipe/p_defines.h" #include "pipe/p_state.h" #include "rtasm/rtasm_ppc_spe.h" #include "cell_context.h" #include "cell_gen_fragment.h" /** Do extra optimizations? */ #define OPTIMIZATIONS 1 /** * Generate SPE code to perform Z/depth testing. * * \param dsa Gallium depth/stencil/alpha state to gen code for * \param f SPE function to append instruction onto. * \param mask_reg register containing quad/pixel "alive" mask (in/out) * \param ifragZ_reg register containing integer fragment Z values (in) * \param ifbZ_reg register containing integer frame buffer Z values (in/out) * \param zmask_reg register containing result of Z test/comparison (out) * * Returns TRUE if the Z-buffer needs to be updated. */ static boolean gen_depth_test(struct spe_function *f, const struct pipe_depth_stencil_alpha_state *dsa, int mask_reg, int ifragZ_reg, int ifbZ_reg, int zmask_reg) { /* NOTE: we use clgt below, not cgt, because we want to compare _unsigned_ * quantities. This only makes a difference for 32-bit Z values though. */ ASSERT(dsa->depth.enabled); switch (dsa->depth.func) { case PIPE_FUNC_EQUAL: /* zmask = (ifragZ == ref) */ spe_ceq(f, zmask_reg, ifragZ_reg, ifbZ_reg); /* mask = (mask & zmask) */ spe_and(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_NOTEQUAL: /* zmask = (ifragZ == ref) */ spe_ceq(f, zmask_reg, ifragZ_reg, ifbZ_reg); /* mask = (mask & ~zmask) */ spe_andc(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_GREATER: /* zmask = (ifragZ > ref) */ spe_clgt(f, zmask_reg, ifragZ_reg, ifbZ_reg); /* mask = (mask & zmask) */ spe_and(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_LESS: /* zmask = (ref > ifragZ) */ spe_clgt(f, zmask_reg, ifbZ_reg, ifragZ_reg); /* mask = (mask & zmask) */ spe_and(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_LEQUAL: /* zmask = (ifragZ > ref) */ spe_clgt(f, zmask_reg, ifragZ_reg, ifbZ_reg); /* mask = (mask & ~zmask) */ spe_andc(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_GEQUAL: /* zmask = (ref > ifragZ) */ spe_clgt(f, zmask_reg, ifbZ_reg, ifragZ_reg); /* mask = (mask & ~zmask) */ spe_andc(f, mask_reg, mask_reg, zmask_reg); break; case PIPE_FUNC_NEVER: spe_il(f, mask_reg, 0); /* mask = {0,0,0,0} */ spe_move(f, zmask_reg, mask_reg); /* zmask = mask */ break; case PIPE_FUNC_ALWAYS: /* mask unchanged */ spe_il(f, zmask_reg, ~0); /* zmask = {~0,~0,~0,~0} */ break; default: ASSERT(0); break; } if (dsa->depth.writemask) { /* * If (ztest passed) { * framebufferZ = fragmentZ; * } * OR, * framebufferZ = (ztest_passed ? fragmentZ : framebufferZ; */ spe_selb(f, ifbZ_reg, ifbZ_reg, ifragZ_reg, mask_reg); return TRUE; } return FALSE; } /** * Generate SPE code to perform alpha testing. * * \param dsa Gallium depth/stencil/alpha state to gen code for * \param f SPE function to append instruction onto. * \param mask_reg register containing quad/pixel "alive" mask (in/out) * \param fragA_reg register containing four fragment alpha values (in) */ static void gen_alpha_test(const struct pipe_depth_stencil_alpha_state *dsa, struct spe_function *f, int mask_reg, int fragA_reg) { int ref_reg = spe_allocate_available_register(f); int amask_reg = spe_allocate_available_register(f); ASSERT(dsa->alpha.enabled); if ((dsa->alpha.func != PIPE_FUNC_NEVER) && (dsa->alpha.func != PIPE_FUNC_ALWAYS)) { /* load/splat the alpha reference float value */ spe_load_float(f, ref_reg, dsa->alpha.ref_value); } /* emit code to do the alpha comparison, updating 'mask' */ switch (dsa->alpha.func) { case PIPE_FUNC_EQUAL: /* amask = (fragA == ref) */ spe_fceq(f, amask_reg, fragA_reg, ref_reg); /* mask = (mask & amask) */ spe_and(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_NOTEQUAL: /* amask = (fragA == ref) */ spe_fceq(f, amask_reg, fragA_reg, ref_reg); /* mask = (mask & ~amask) */ spe_andc(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_GREATER: /* amask = (fragA > ref) */ spe_fcgt(f, amask_reg, fragA_reg, ref_reg); /* mask = (mask & amask) */ spe_and(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_LESS: /* amask = (ref > fragA) */ spe_fcgt(f, amask_reg, ref_reg, fragA_reg); /* mask = (mask & amask) */ spe_and(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_LEQUAL: /* amask = (fragA > ref) */ spe_fcgt(f, amask_reg, fragA_reg, ref_reg); /* mask = (mask & ~amask) */ spe_andc(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_GEQUAL: /* amask = (ref > fragA) */ spe_fcgt(f, amask_reg, ref_reg, fragA_reg); /* mask = (mask & ~amask) */ spe_andc(f, mask_reg, mask_reg, amask_reg); break; case PIPE_FUNC_NEVER: spe_il(f, mask_reg, 0); /* mask = [0,0,0,0] */ break; case PIPE_FUNC_ALWAYS: /* no-op, mask unchanged */ break; default: ASSERT(0); break; } #if OPTIMIZATIONS /* if mask == {0,0,0,0} we're all done, return */ { /* re-use amask reg here */ int tmp_reg = amask_reg; /* tmp[0] = (mask[0] | mask[1] | mask[2] | mask[3]) */ spe_orx(f, tmp_reg, mask_reg); /* if tmp[0] == 0 then return from function call */ spe_biz(f, tmp_reg, SPE_REG_RA, 0, 0); } #endif spe_release_register(f, ref_reg); spe_release_register(f, amask_reg); } /** * This pair of functions is used inline to allocate and deallocate * optional constant registers. Once a constant is discovered to be * needed, we will likely need it again, so we don't want to deallocate * it and have to allocate and load it again unnecessarily. */ static INLINE void setup_optional_register(struct spe_function *f, int *r) { if (*r < 0) *r = spe_allocate_available_register(f); } static INLINE void release_optional_register(struct spe_function *f, int r) { if (r >= 0) spe_release_register(f, r); } static INLINE void setup_const_register(struct spe_function *f, int *r, float value) { if (*r >= 0) return; setup_optional_register(f, r); spe_load_float(f, *r, value); } static INLINE void release_const_register(struct spe_function *f, int r) { release_optional_register(f, r); } /** * Unpack/convert framebuffer colors from four 32-bit packed colors * (fbRGBA) to four float RGBA vectors (fbR, fbG, fbB, fbA). * Each 8-bit color component is expanded into a float in [0.0, 1.0]. */ static void unpack_colors(struct spe_function *f, enum pipe_format color_format, int fbRGBA_reg, int fbR_reg, int fbG_reg, int fbB_reg, int fbA_reg) { int mask0_reg = spe_allocate_available_register(f); int mask1_reg = spe_allocate_available_register(f); int mask2_reg = spe_allocate_available_register(f); int mask3_reg = spe_allocate_available_register(f); spe_load_int(f, mask0_reg, 0xff); spe_load_int(f, mask1_reg, 0xff00); spe_load_int(f, mask2_reg, 0xff0000); spe_load_int(f, mask3_reg, 0xff000000); spe_comment(f, 0, "Unpack framebuffer colors, convert to floats"); switch (color_format) { case PIPE_FORMAT_B8G8R8A8_UNORM: /* fbB = fbRGBA & mask */ spe_and(f, fbB_reg, fbRGBA_reg, mask0_reg); /* fbG = fbRGBA & mask */ spe_and(f, fbG_reg, fbRGBA_reg, mask1_reg); /* fbR = fbRGBA & mask */ spe_and(f, fbR_reg, fbRGBA_reg, mask2_reg); /* fbA = fbRGBA & mask */ spe_and(f, fbA_reg, fbRGBA_reg, mask3_reg); /* fbG = fbG >> 8 */ spe_roti(f, fbG_reg, fbG_reg, -8); /* fbR = fbR >> 16 */ spe_roti(f, fbR_reg, fbR_reg, -16); /* fbA = fbA >> 24 */ spe_roti(f, fbA_reg, fbA_reg, -24); break; case PIPE_FORMAT_A8R8G8B8_UNORM: /* fbA = fbRGBA & mask */ spe_and(f, fbA_reg, fbRGBA_reg, mask0_reg); /* fbR = fbRGBA & mask */ spe_and(f, fbR_reg, fbRGBA_reg, mask1_reg); /* fbG = fbRGBA & mask */ spe_and(f, fbG_reg, fbRGBA_reg, mask2_reg); /* fbB = fbRGBA & mask */ spe_and(f, fbB_reg, fbRGBA_reg, mask3_reg); /* fbR = fbR >> 8 */ spe_roti(f, fbR_reg, fbR_reg, -8); /* fbG = fbG >> 16 */ spe_roti(f, fbG_reg, fbG_reg, -16); /* fbB = fbB >> 24 */ spe_roti(f, fbB_reg, fbB_reg, -24); break; default: ASSERT(0); } /* convert int[4] in [0,255] to float[4] in [0.0, 1.0] */ spe_cuflt(f, fbR_reg, fbR_reg, 8); spe_cuflt(f, fbG_reg, fbG_reg, 8); spe_cuflt(f, fbB_reg, fbB_reg, 8); spe_cuflt(f, fbA_reg, fbA_reg, 8); spe_release_register(f, mask0_reg); spe_release_register(f, mask1_reg); spe_release_register(f, mask2_reg); spe_release_register(f, mask3_reg); } /** * Generate SPE code to implement the given blend mode for a quad of pixels. * \param f SPE function to append instruction onto. * \param fragR_reg register with fragment red values (float) (in/out) * \param fragG_reg register with fragment green values (float) (in/out) * \param fragB_reg register with fragment blue values (float) (in/out) * \param fragA_reg register with fragment alpha values (float) (in/out) * \param fbRGBA_reg register with packed framebuffer colors (integer) (in) */ static void gen_blend(const struct pipe_blend_state *blend, const struct pipe_blend_color *blend_color, struct spe_function *f, enum pipe_format color_format, int fragR_reg, int fragG_reg, int fragB_reg, int fragA_reg, int fbRGBA_reg) { int term1R_reg = spe_allocate_available_register(f); int term1G_reg = spe_allocate_available_register(f); int term1B_reg = spe_allocate_available_register(f); int term1A_reg = spe_allocate_available_register(f); int term2R_reg = spe_allocate_available_register(f); int term2G_reg = spe_allocate_available_register(f); int term2B_reg = spe_allocate_available_register(f); int term2A_reg = spe_allocate_available_register(f); int fbR_reg = spe_allocate_available_register(f); int fbG_reg = spe_allocate_available_register(f); int fbB_reg = spe_allocate_available_register(f); int fbA_reg = spe_allocate_available_register(f); int tmp_reg = spe_allocate_available_register(f); /* Optional constant registers we might or might not end up using; * if we do use them, make sure we only allocate them once by * keeping a flag on each one. */ int one_reg = -1; int constR_reg = -1, constG_reg = -1, constB_reg = -1, constA_reg = -1; ASSERT(blend->rt[0].blend_enable); /* packed RGBA -> float colors */ unpack_colors(f, color_format, fbRGBA_reg, fbR_reg, fbG_reg, fbB_reg, fbA_reg); /* * Compute Src RGB terms. We're actually looking for the value * of (the appropriate RGB factors) * (the incoming source RGB color), * because in some cases (like PIPE_BLENDFACTOR_ONE and * PIPE_BLENDFACTOR_ZERO) we can avoid doing unnecessary math. */ switch (blend->rt[0].rgb_src_factor) { case PIPE_BLENDFACTOR_ONE: /* factors = (1,1,1), so term = (R,G,B) */ spe_move(f, term1R_reg, fragR_reg); spe_move(f, term1G_reg, fragG_reg); spe_move(f, term1B_reg, fragB_reg); break; case PIPE_BLENDFACTOR_ZERO: /* factors = (0,0,0), so term = (0,0,0) */ spe_load_float(f, term1R_reg, 0.0f); spe_load_float(f, term1G_reg, 0.0f); spe_load_float(f, term1B_reg, 0.0f); break; case PIPE_BLENDFACTOR_SRC_COLOR: /* factors = (R,G,B), so term = (R*R, G*G, B*B) */ spe_fm(f, term1R_reg, fragR_reg, fragR_reg); spe_fm(f, term1G_reg, fragG_reg, fragG_reg); spe_fm(f, term1B_reg, fragB_reg, fragB_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA: /* factors = (A,A,A), so term = (R*A, G*A, B*A) */ spe_fm(f, term1R_reg, fragR_reg, fragA_reg); spe_fm(f, term1G_reg, fragG_reg, fragA_reg); spe_fm(f, term1B_reg, fragB_reg, fragA_reg); break; case PIPE_BLENDFACTOR_INV_SRC_COLOR: /* factors = (1-R,1-G,1-B), so term = (R*(1-R), G*(1-G), B*(1-B)) * or in other words term = (R-R*R, G-G*G, B-B*B) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, fragR_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, fragG_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, fragB_reg, fragB_reg); break; case PIPE_BLENDFACTOR_DST_COLOR: /* factors = (Rfb,Gfb,Bfb), so term = (R*Rfb, G*Gfb, B*Bfb) */ spe_fm(f, term1R_reg, fragR_reg, fbR_reg); spe_fm(f, term1G_reg, fragG_reg, fbG_reg); spe_fm(f, term1B_reg, fragB_reg, fbB_reg); break; case PIPE_BLENDFACTOR_INV_DST_COLOR: /* factors = (1-Rfb,1-Gfb,1-Bfb), so term = (R*(1-Rfb),G*(1-Gfb),B*(1-Bfb)) * or term = (R-R*Rfb, G-G*Gfb, B-B*Bfb) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, fbR_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, fbG_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, fbB_reg, fragB_reg); break; case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* factors = (1-A,1-A,1-A), so term = (R*(1-A),G*(1-A),B*(1-A)) * or term = (R-R*A,G-G*A,B-B*A) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, fragA_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, fragA_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, fragA_reg, fragB_reg); break; case PIPE_BLENDFACTOR_DST_ALPHA: /* factors = (Afb, Afb, Afb), so term = (R*Afb, G*Afb, B*Afb) */ spe_fm(f, term1R_reg, fragR_reg, fbA_reg); spe_fm(f, term1G_reg, fragG_reg, fbA_reg); spe_fm(f, term1B_reg, fragB_reg, fbA_reg); break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* factors = (1-Afb, 1-Afb, 1-Afb), so term = (R*(1-Afb),G*(1-Afb),B*(1-Afb)) * or term = (R-R*Afb,G-G*Afb,b-B*Afb) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, fbA_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, fbA_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, fbA_reg, fragB_reg); break; case PIPE_BLENDFACTOR_CONST_COLOR: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* now, factor = (Rc,Gc,Bc), so term = (R*Rc,G*Gc,B*Bc) */ spe_fm(f, term1R_reg, fragR_reg, constR_reg); spe_fm(f, term1G_reg, fragG_reg, constG_reg); spe_fm(f, term1B_reg, fragB_reg, constB_reg); break; case PIPE_BLENDFACTOR_CONST_ALPHA: /* we'll need the optional constant alpha register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = (Ac,Ac,Ac), so term = (R*Ac,G*Ac,B*Ac) */ spe_fm(f, term1R_reg, fragR_reg, constA_reg); spe_fm(f, term1G_reg, fragG_reg, constA_reg); spe_fm(f, term1B_reg, fragB_reg, constA_reg); break; case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* factor = (1-Rc,1-Gc,1-Bc), so term = (R*(1-Rc),G*(1-Gc),B*(1-Bc)) * or term = (R-R*Rc, G-G*Gc, B-B*Bc) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, constR_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, constG_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, constB_reg, fragB_reg); break; case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* factor = (1-Ac,1-Ac,1-Ac), so term = (R*(1-Ac),G*(1-Ac),B*(1-Ac)) * or term = (R-R*Ac,G-G*Ac,B-B*Ac) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1R_reg, fragR_reg, constA_reg, fragR_reg); spe_fnms(f, term1G_reg, fragG_reg, constA_reg, fragG_reg); spe_fnms(f, term1B_reg, fragB_reg, constA_reg, fragB_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* We'll need the optional {1,1,1,1} register */ setup_const_register(f, &one_reg, 1.0f); /* factor = (min(A,1-Afb),min(A,1-Afb),min(A,1-Afb)), so * term = (R*min(A,1-Afb), G*min(A,1-Afb), B*min(A,1-Afb)) * We could expand the term (as a*min(b,c) == min(a*b,a*c) * as long as a is positive), but then we'd have to do three * spe_float_min() functions instead of one, so this is simpler. */ /* tmp = 1 - Afb */ spe_fs(f, tmp_reg, one_reg, fbA_reg); /* tmp = min(A,tmp) */ spe_float_min(f, tmp_reg, fragA_reg, tmp_reg); /* term = R*tmp */ spe_fm(f, term1R_reg, fragR_reg, tmp_reg); spe_fm(f, term1G_reg, fragG_reg, tmp_reg); spe_fm(f, term1B_reg, fragB_reg, tmp_reg); break; /* These are special D3D cases involving a second color output * from the fragment shader. I'm not sure we can support them * yet... XXX */ case PIPE_BLENDFACTOR_SRC1_COLOR: case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: default: ASSERT(0); } /* * Compute Src Alpha term. Like the above, we're looking for * the full term A*factor, not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ switch (blend->rt[0].alpha_src_factor) { case PIPE_BLENDFACTOR_ZERO: /* factor = 0, so term = 0 */ spe_load_float(f, term1A_reg, 0.0f); break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* fall through */ case PIPE_BLENDFACTOR_ONE: /* factor = 1, so term = A */ spe_move(f, term1A_reg, fragA_reg); break; case PIPE_BLENDFACTOR_SRC_COLOR: /* factor = A, so term = A*A */ spe_fm(f, term1A_reg, fragA_reg, fragA_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA: spe_fm(f, term1A_reg, fragA_reg, fragA_reg); break; case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_SRC_COLOR: /* factor = 1-A, so term = A*(1-A) = A-A*A */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1A_reg, fragA_reg, fragA_reg, fragA_reg); break; case PIPE_BLENDFACTOR_DST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_DST_COLOR: /* factor = Afb, so term = A*Afb */ spe_fm(f, term1A_reg, fragA_reg, fbA_reg); break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_DST_COLOR: /* factor = 1-Afb, so term = A*(1-Afb) = A - A*Afb */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1A_reg, fragA_reg, fbA_reg, fragA_reg); break; case PIPE_BLENDFACTOR_CONST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_CONST_COLOR: /* We need the optional constA_reg register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = Ac, so term = A*Ac */ spe_fm(f, term1A_reg, fragA_reg, constA_reg); break; case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* We need the optional constA_reg register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = 1-Ac, so term = A*(1-Ac) = A-A*Ac */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term1A_reg, fragA_reg, constA_reg, fragA_reg); break; /* These are special D3D cases involving a second color output * from the fragment shader. I'm not sure we can support them * yet... XXX */ case PIPE_BLENDFACTOR_SRC1_COLOR: case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: default: ASSERT(0); } /* * Compute Dest RGB term. Like the above, we're looking for * the full term (Rfb,Gfb,Bfb)*(factor), not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ switch (blend->rt[0].rgb_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* factors = (1,1,1), so term = (Rfb,Gfb,Bfb) */ spe_move(f, term2R_reg, fbR_reg); spe_move(f, term2G_reg, fbG_reg); spe_move(f, term2B_reg, fbB_reg); break; case PIPE_BLENDFACTOR_ZERO: /* factor s= (0,0,0), so term = (0,0,0) */ spe_load_float(f, term2R_reg, 0.0f); spe_load_float(f, term2G_reg, 0.0f); spe_load_float(f, term2B_reg, 0.0f); break; case PIPE_BLENDFACTOR_SRC_COLOR: /* factors = (R,G,B), so term = (R*Rfb, G*Gfb, B*Bfb) */ spe_fm(f, term2R_reg, fbR_reg, fragR_reg); spe_fm(f, term2G_reg, fbG_reg, fragG_reg); spe_fm(f, term2B_reg, fbB_reg, fragB_reg); break; case PIPE_BLENDFACTOR_INV_SRC_COLOR: /* factors = (1-R,1-G,1-B), so term = (Rfb*(1-R), Gfb*(1-G), Bfb*(1-B)) * or in other words term = (Rfb-Rfb*R, Gfb-Gfb*G, Bfb-Bfb*B) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fragR_reg, fbR_reg, fbR_reg); spe_fnms(f, term2G_reg, fragG_reg, fbG_reg, fbG_reg); spe_fnms(f, term2B_reg, fragB_reg, fbB_reg, fbB_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA: /* factors = (A,A,A), so term = (Rfb*A, Gfb*A, Bfb*A) */ spe_fm(f, term2R_reg, fbR_reg, fragA_reg); spe_fm(f, term2G_reg, fbG_reg, fragA_reg); spe_fm(f, term2B_reg, fbB_reg, fragA_reg); break; case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* factors = (1-A,1-A,1-A) so term = (Rfb-Rfb*A,Gfb-Gfb*A,Bfb-Bfb*A) */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fbR_reg, fragA_reg, fbR_reg); spe_fnms(f, term2G_reg, fbG_reg, fragA_reg, fbG_reg); spe_fnms(f, term2B_reg, fbB_reg, fragA_reg, fbB_reg); break; case PIPE_BLENDFACTOR_DST_COLOR: /* factors = (Rfb,Gfb,Bfb), so term = (Rfb*Rfb, Gfb*Gfb, Bfb*Bfb) */ spe_fm(f, term2R_reg, fbR_reg, fbR_reg); spe_fm(f, term2G_reg, fbG_reg, fbG_reg); spe_fm(f, term2B_reg, fbB_reg, fbB_reg); break; case PIPE_BLENDFACTOR_INV_DST_COLOR: /* factors = (1-Rfb,1-Gfb,1-Bfb), so term = (Rfb*(1-Rfb),Gfb*(1-Gfb),Bfb*(1-Bfb)) * or term = (Rfb-Rfb*Rfb, Gfb-Gfb*Gfb, Bfb-Bfb*Bfb) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fbR_reg, fbR_reg, fbR_reg); spe_fnms(f, term2G_reg, fbG_reg, fbG_reg, fbG_reg); spe_fnms(f, term2B_reg, fbB_reg, fbB_reg, fbB_reg); break; case PIPE_BLENDFACTOR_DST_ALPHA: /* factors = (Afb, Afb, Afb), so term = (Rfb*Afb, Gfb*Afb, Bfb*Afb) */ spe_fm(f, term2R_reg, fbR_reg, fbA_reg); spe_fm(f, term2G_reg, fbG_reg, fbA_reg); spe_fm(f, term2B_reg, fbB_reg, fbA_reg); break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* factors = (1-Afb, 1-Afb, 1-Afb), so term = (Rfb*(1-Afb),Gfb*(1-Afb),Bfb*(1-Afb)) * or term = (Rfb-Rfb*Afb,Gfb-Gfb*Afb,Bfb-Bfb*Afb) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fbR_reg, fbA_reg, fbR_reg); spe_fnms(f, term2G_reg, fbG_reg, fbA_reg, fbG_reg); spe_fnms(f, term2B_reg, fbB_reg, fbA_reg, fbB_reg); break; case PIPE_BLENDFACTOR_CONST_COLOR: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* now, factor = (Rc,Gc,Bc), so term = (Rfb*Rc,Gfb*Gc,Bfb*Bc) */ spe_fm(f, term2R_reg, fbR_reg, constR_reg); spe_fm(f, term2G_reg, fbG_reg, constG_reg); spe_fm(f, term2B_reg, fbB_reg, constB_reg); break; case PIPE_BLENDFACTOR_CONST_ALPHA: /* we'll need the optional constant alpha register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = (Ac,Ac,Ac), so term = (Rfb*Ac,Gfb*Ac,Bfb*Ac) */ spe_fm(f, term2R_reg, fbR_reg, constA_reg); spe_fm(f, term2G_reg, fbG_reg, constA_reg); spe_fm(f, term2B_reg, fbB_reg, constA_reg); break; case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* factor = (1-Rc,1-Gc,1-Bc), so term = (Rfb*(1-Rc),Gfb*(1-Gc),Bfb*(1-Bc)) * or term = (Rfb-Rfb*Rc, Gfb-Gfb*Gc, Bfb-Bfb*Bc) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fbR_reg, constR_reg, fbR_reg); spe_fnms(f, term2G_reg, fbG_reg, constG_reg, fbG_reg); spe_fnms(f, term2B_reg, fbB_reg, constB_reg, fbB_reg); break; case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* We need the optional constant color registers */ setup_const_register(f, &constR_reg, blend_color->color[0]); setup_const_register(f, &constG_reg, blend_color->color[1]); setup_const_register(f, &constB_reg, blend_color->color[2]); /* factor = (1-Ac,1-Ac,1-Ac), so term = (Rfb*(1-Ac),Gfb*(1-Ac),Bfb*(1-Ac)) * or term = (Rfb-Rfb*Ac,Gfb-Gfb*Ac,Bfb-Bfb*Ac) * fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2R_reg, fbR_reg, constA_reg, fbR_reg); spe_fnms(f, term2G_reg, fbG_reg, constA_reg, fbG_reg); spe_fnms(f, term2B_reg, fbB_reg, constA_reg, fbB_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* not supported for dest RGB */ ASSERT(0); break; /* These are special D3D cases involving a second color output * from the fragment shader. I'm not sure we can support them * yet... XXX */ case PIPE_BLENDFACTOR_SRC1_COLOR: case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: default: ASSERT(0); } /* * Compute Dest Alpha term. Like the above, we're looking for * the full term Afb*factor, not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ switch (blend->rt[0].alpha_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* factor = 1, so term = Afb */ spe_move(f, term2A_reg, fbA_reg); break; case PIPE_BLENDFACTOR_ZERO: /* factor = 0, so term = 0 */ spe_load_float(f, term2A_reg, 0.0f); break; case PIPE_BLENDFACTOR_SRC_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_SRC_COLOR: /* factor = A, so term = Afb*A */ spe_fm(f, term2A_reg, fbA_reg, fragA_reg); break; case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_SRC_COLOR: /* factor = 1-A, so term = Afb*(1-A) = Afb-Afb*A */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2A_reg, fbA_reg, fragA_reg, fbA_reg); break; case PIPE_BLENDFACTOR_DST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_DST_COLOR: /* factor = Afb, so term = Afb*Afb */ spe_fm(f, term2A_reg, fbA_reg, fbA_reg); break; case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_DST_COLOR: /* factor = 1-Afb, so term = Afb*(1-Afb) = Afb - Afb*Afb */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2A_reg, fbA_reg, fbA_reg, fbA_reg); break; case PIPE_BLENDFACTOR_CONST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_CONST_COLOR: /* We need the optional constA_reg register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = Ac, so term = Afb*Ac */ spe_fm(f, term2A_reg, fbA_reg, constA_reg); break; case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* fall through */ case PIPE_BLENDFACTOR_INV_CONST_COLOR: /* We need the optional constA_reg register */ setup_const_register(f, &constA_reg, blend_color->color[3]); /* factor = 1-Ac, so term = Afb*(1-Ac) = Afb-Afb*Ac */ /* fnms(a,b,c,d) computes a = d - b*c */ spe_fnms(f, term2A_reg, fbA_reg, constA_reg, fbA_reg); break; case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* not supported for dest alpha */ ASSERT(0); break; /* These are special D3D cases involving a second color output * from the fragment shader. I'm not sure we can support them * yet... XXX */ case PIPE_BLENDFACTOR_SRC1_COLOR: case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: default: ASSERT(0); } /* * Combine Src/Dest RGB terms as per the blend equation. */ switch (blend->rt[0].rgb_func) { case PIPE_BLEND_ADD: spe_fa(f, fragR_reg, term1R_reg, term2R_reg); spe_fa(f, fragG_reg, term1G_reg, term2G_reg); spe_fa(f, fragB_reg, term1B_reg, term2B_reg); break; case PIPE_BLEND_SUBTRACT: spe_fs(f, fragR_reg, term1R_reg, term2R_reg); spe_fs(f, fragG_reg, term1G_reg, term2G_reg); spe_fs(f, fragB_reg, term1B_reg, term2B_reg); break; case PIPE_BLEND_REVERSE_SUBTRACT: spe_fs(f, fragR_reg, term2R_reg, term1R_reg); spe_fs(f, fragG_reg, term2G_reg, term1G_reg); spe_fs(f, fragB_reg, term2B_reg, term1B_reg); break; case PIPE_BLEND_MIN: spe_float_min(f, fragR_reg, term1R_reg, term2R_reg); spe_float_min(f, fragG_reg, term1G_reg, term2G_reg); spe_float_min(f, fragB_reg, term1B_reg, term2B_reg); break; case PIPE_BLEND_MAX: spe_float_max(f, fragR_reg, term1R_reg, term2R_reg); spe_float_max(f, fragG_reg, term1G_reg, term2G_reg); spe_float_max(f, fragB_reg, term1B_reg, term2B_reg); break; default: ASSERT(0); } /* * Combine Src/Dest A term */ switch (blend->rt[0].alpha_func) { case PIPE_BLEND_ADD: spe_fa(f, fragA_reg, term1A_reg, term2A_reg); break; case PIPE_BLEND_SUBTRACT: spe_fs(f, fragA_reg, term1A_reg, term2A_reg); break; case PIPE_BLEND_REVERSE_SUBTRACT: spe_fs(f, fragA_reg, term2A_reg, term1A_reg); break; case PIPE_BLEND_MIN: spe_float_min(f, fragA_reg, term1A_reg, term2A_reg); break; case PIPE_BLEND_MAX: spe_float_max(f, fragA_reg, term1A_reg, term2A_reg); break; default: ASSERT(0); } spe_release_register(f, term1R_reg); spe_release_register(f, term1G_reg); spe_release_register(f, term1B_reg); spe_release_register(f, term1A_reg); spe_release_register(f, term2R_reg); spe_release_register(f, term2G_reg); spe_release_register(f, term2B_reg); spe_release_register(f, term2A_reg); spe_release_register(f, fbR_reg); spe_release_register(f, fbG_reg); spe_release_register(f, fbB_reg); spe_release_register(f, fbA_reg); spe_release_register(f, tmp_reg); /* Free any optional registers that actually got used */ release_const_register(f, one_reg); release_const_register(f, constR_reg); release_const_register(f, constG_reg); release_const_register(f, constB_reg); release_const_register(f, constA_reg); } static void gen_logicop(const struct pipe_blend_state *blend, struct spe_function *f, int fragRGBA_reg, int fbRGBA_reg) { /* We've got four 32-bit RGBA packed pixels in each of * fragRGBA_reg and fbRGBA_reg, not sets of floating-point * reds, greens, blues, and alphas. * */ ASSERT(blend->logicop_enable); switch(blend->logicop_func) { case PIPE_LOGICOP_CLEAR: /* 0 */ spe_zero(f, fragRGBA_reg); break; case PIPE_LOGICOP_NOR: /* ~(s | d) */ spe_nor(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_AND_INVERTED: /* ~s & d */ /* andc R, A, B computes R = A & ~B */ spe_andc(f, fragRGBA_reg, fbRGBA_reg, fragRGBA_reg); break; case PIPE_LOGICOP_COPY_INVERTED: /* ~s */ spe_complement(f, fragRGBA_reg, fragRGBA_reg); break; case PIPE_LOGICOP_AND_REVERSE: /* s & ~d */ /* andc R, A, B computes R = A & ~B */ spe_andc(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_INVERT: /* ~d */ /* Note that (A nor A) == ~(A|A) == ~A */ spe_nor(f, fragRGBA_reg, fbRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_XOR: /* s ^ d */ spe_xor(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_NAND: /* ~(s & d) */ spe_nand(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_AND: /* s & d */ spe_and(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_EQUIV: /* ~(s ^ d) */ spe_xor(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); spe_complement(f, fragRGBA_reg, fragRGBA_reg); break; case PIPE_LOGICOP_NOOP: /* d */ spe_move(f, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_OR_INVERTED: /* ~s | d */ /* orc R, A, B computes R = A | ~B */ spe_orc(f, fragRGBA_reg, fbRGBA_reg, fragRGBA_reg); break; case PIPE_LOGICOP_COPY: /* s */ break; case PIPE_LOGICOP_OR_REVERSE: /* s | ~d */ /* orc R, A, B computes R = A | ~B */ spe_orc(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_OR: /* s | d */ spe_or(f, fragRGBA_reg, fragRGBA_reg, fbRGBA_reg); break; case PIPE_LOGICOP_SET: /* 1 */ spe_load_int(f, fragRGBA_reg, 0xffffffff); break; default: ASSERT(0); } } /** * Generate code to pack a quad of float colors into four 32-bit integers. * * \param f SPE function to append instruction onto. * \param color_format the dest color packing format * \param r_reg register containing four red values (in/clobbered) * \param g_reg register containing four green values (in/clobbered) * \param b_reg register containing four blue values (in/clobbered) * \param a_reg register containing four alpha values (in/clobbered) * \param rgba_reg register to store the packed RGBA colors (out) */ static void gen_pack_colors(struct spe_function *f, enum pipe_format color_format, int r_reg, int g_reg, int b_reg, int a_reg, int rgba_reg) { int rg_reg = spe_allocate_available_register(f); int ba_reg = spe_allocate_available_register(f); /* Convert float[4] in [0.0,1.0] to int[4] in [0,~0], with clamping */ spe_cfltu(f, r_reg, r_reg, 32); spe_cfltu(f, g_reg, g_reg, 32); spe_cfltu(f, b_reg, b_reg, 32); spe_cfltu(f, a_reg, a_reg, 32); /* Shift the most significant bytes to the least significant positions. * I.e.: reg = reg >> 24 */ spe_rotmi(f, r_reg, r_reg, -24); spe_rotmi(f, g_reg, g_reg, -24); spe_rotmi(f, b_reg, b_reg, -24); spe_rotmi(f, a_reg, a_reg, -24); /* Shift the color bytes according to the surface format */ if (color_format == PIPE_FORMAT_B8G8R8A8_UNORM) { spe_roti(f, g_reg, g_reg, 8); /* green <<= 8 */ spe_roti(f, r_reg, r_reg, 16); /* red <<= 16 */ spe_roti(f, a_reg, a_reg, 24); /* alpha <<= 24 */ } else if (color_format == PIPE_FORMAT_A8R8G8B8_UNORM) { spe_roti(f, r_reg, r_reg, 8); /* red <<= 8 */ spe_roti(f, g_reg, g_reg, 16); /* green <<= 16 */ spe_roti(f, b_reg, b_reg, 24); /* blue <<= 24 */ } else { ASSERT(0); } /* Merge red, green, blue, alpha registers to make packed RGBA colors. * Eg: after shifting according to color_format we might have: * R = {0x00ff0000, 0x00110000, 0x00220000, 0x00330000} * G = {0x0000ff00, 0x00004400, 0x00005500, 0x00006600} * B = {0x000000ff, 0x00000077, 0x00000088, 0x00000099} * A = {0xff000000, 0xaa000000, 0xbb000000, 0xcc000000} * OR-ing all those together gives us four packed colors: * RGBA = {0xffffffff, 0xaa114477, 0xbb225588, 0xcc336699} */ spe_or(f, rg_reg, r_reg, g_reg); spe_or(f, ba_reg, a_reg, b_reg); spe_or(f, rgba_reg, rg_reg, ba_reg); spe_release_register(f, rg_reg); spe_release_register(f, ba_reg); } static void gen_colormask(struct spe_function *f, uint colormask, enum pipe_format color_format, int fragRGBA_reg, int fbRGBA_reg) { /* We've got four 32-bit RGBA packed pixels in each of * fragRGBA_reg and fbRGBA_reg, not sets of floating-point * reds, greens, blues, and alphas. Further, the pixels * are packed according to the given color format, not * necessarily RGBA... */ uint r_mask; uint g_mask; uint b_mask; uint a_mask; /* Calculate exactly where the bits for any particular color * end up, so we can mask them correctly. */ switch(color_format) { case PIPE_FORMAT_B8G8R8A8_UNORM: /* ARGB */ a_mask = 0xff000000; r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff; break; case PIPE_FORMAT_A8R8G8B8_UNORM: /* BGRA */ b_mask = 0xff000000; g_mask = 0x00ff0000; r_mask = 0x0000ff00; a_mask = 0x000000ff; break; default: ASSERT(0); } /* For each R, G, B, and A component we're supposed to mask out, * clear its bits. Then our mask operation later will work * as expected. */ if (!(colormask & PIPE_MASK_R)) { r_mask = 0; } if (!(colormask & PIPE_MASK_G)) { g_mask = 0; } if (!(colormask & PIPE_MASK_B)) { b_mask = 0; } if (!(colormask & PIPE_MASK_A)) { a_mask = 0; } /* Get a temporary register to hold the mask that will be applied * to the fragment */ int colormask_reg = spe_allocate_available_register(f); /* The actual mask we're going to use is an OR of the remaining R, G, B, * and A masks. Load the result value into our temporary register. */ spe_load_uint(f, colormask_reg, r_mask | g_mask | b_mask | a_mask); /* Use the mask register to select between the fragment color * values and the frame buffer color values. Wherever the * mask has a 0 bit, the current frame buffer color should override * the fragment color. Wherever the mask has a 1 bit, the * fragment color should persevere. The Select Bits (selb rt, rA, rB, rM) * instruction will select bits from its first operand rA wherever the * the mask bits rM are 0, and from its second operand rB wherever the * mask bits rM are 1. That means that the frame buffer color is the * first operand, and the fragment color the second. */ spe_selb(f, fragRGBA_reg, fbRGBA_reg, fragRGBA_reg, colormask_reg); /* Release the temporary register and we're done */ spe_release_register(f, colormask_reg); } /** * This function is annoyingly similar to gen_depth_test(), above, except * that instead of comparing two varying values (i.e. fragment and buffer), * we're comparing a varying value with a static value. As such, we have * access to the Compare Immediate instructions where we don't in * gen_depth_test(), which is what makes us very different. * * There's some added complexity if there's a non-trivial state->mask * value; then stencil and reference both must be masked * * The return value in the stencil_pass_reg is a bitmask of valid * fragments that also passed the stencil test. The bitmask of valid * fragments that failed would be found in * (fragment_mask_reg & ~stencil_pass_reg). */ static void gen_stencil_test(struct spe_function *f, const struct pipe_stencil_state *state, const unsigned ref_value, uint stencil_max_value, int fragment_mask_reg, int fbS_reg, int stencil_pass_reg) { /* Generate code that puts the set of passing fragments into the * stencil_pass_reg register, taking into account whether each fragment * was active to begin with. */ switch (state->func) { case PIPE_FUNC_EQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (s == reference) */ spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { /* stencil_pass = fragment_mask & ((s&mask) == (reference&mask)) */ uint tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_equal_uint(f, stencil_pass_reg, tmp_masked_stencil, state->valuemask & ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_NOTEQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & ~(s == reference) */ spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { /* stencil_pass = fragment_mask & ~((s&mask) == (reference&mask)) */ int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_equal_uint(f, stencil_pass_reg, tmp_masked_stencil, state->valuemask & ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_LESS: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (reference < s) */ spe_compare_greater_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { /* stencil_pass = fragment_mask & ((reference&mask) < (s & mask)) */ int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_greater_uint(f, stencil_pass_reg, tmp_masked_stencil, state->valuemask & ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_GREATER: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (reference > s) */ /* There's no convenient Compare Less Than Immediate instruction, so * we'll have to do this one the harder way, by loading a register and * comparing directly. Compare Logical Greater Than Word (clgt) * treats its operands as unsigned - no sign extension. */ int tmp_reg = spe_allocate_available_register(f); spe_load_uint(f, tmp_reg, ref_value); spe_clgt(f, stencil_pass_reg, tmp_reg, fbS_reg); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); } else { /* stencil_pass = fragment_mask & ((reference&mask) > (s&mask)) */ int tmp_reg = spe_allocate_available_register(f); int tmp_masked_stencil = spe_allocate_available_register(f); spe_load_uint(f, tmp_reg, state->valuemask & ref_value); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_clgt(f, stencil_pass_reg, tmp_reg, tmp_masked_stencil); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_GEQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (reference >= s) * = fragment_mask & ~(s > reference) */ spe_compare_greater_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { /* stencil_pass = fragment_mask & ~((s&mask) > (reference&mask)) */ int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_greater_uint(f, stencil_pass_reg, tmp_masked_stencil, state->valuemask & ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_LEQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (reference <= s) ] * = fragment_mask & ~(reference > s) */ /* As above, we have to do this by loading a register */ int tmp_reg = spe_allocate_available_register(f); spe_load_uint(f, tmp_reg, ref_value); spe_clgt(f, stencil_pass_reg, tmp_reg, fbS_reg); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); } else { /* stencil_pass = fragment_mask & ~((reference&mask) > (s&mask)) */ int tmp_reg = spe_allocate_available_register(f); int tmp_masked_stencil = spe_allocate_available_register(f); spe_load_uint(f, tmp_reg, ref_value & state->valuemask); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_clgt(f, stencil_pass_reg, tmp_reg, tmp_masked_stencil); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); spe_release_register(f, tmp_masked_stencil); } break; case PIPE_FUNC_NEVER: /* stencil_pass = fragment_mask & 0 = 0 */ spe_load_uint(f, stencil_pass_reg, 0); break; case PIPE_FUNC_ALWAYS: /* stencil_pass = fragment_mask & 1 = fragment_mask */ spe_move(f, stencil_pass_reg, fragment_mask_reg); break; } /* The fragments that passed the stencil test are now in stencil_pass_reg. * The fragments that failed would be (fragment_mask_reg & ~stencil_pass_reg). */ } /** * This function generates code that calculates a set of new stencil values * given the earlier values and the operation to apply. It does not * apply any tests. It is intended to be called up to 3 times * (for the stencil fail operation, for the stencil pass-z fail operation, * and for the stencil pass-z pass operation) to collect up to three * possible sets of values, and for the caller to combine them based * on the result of the tests. * * stencil_max_value should be (2^n - 1) where n is the number of bits * in the stencil buffer - in other words, it should be usable as a mask. */ static void gen_stencil_values(struct spe_function *f, uint stencil_op, uint stencil_ref_value, uint stencil_max_value, int fbS_reg, int newS_reg) { /* The code below assumes that newS_reg and fbS_reg are not the same * register; if they can be, the calculations below will have to use * an additional temporary register. For now, mark the assumption * with an assertion that will fail if they are the same. */ ASSERT(fbS_reg != newS_reg); /* The code also assumes that the stencil_max_value is of the form * 2^n-1 and can therefore be used as a mask for the valid bits in * addition to a maximum. Make sure this is the case as well. * The clever math below exploits the fact that incrementing a * binary number serves to flip all the bits of a number starting at * the LSB and continuing to (and including) the first zero bit * found. That means that a number and its increment will always * have at least one bit in common (the high order bit, if nothing * else) *unless* the number is zero, *or* the number is of a form * consisting of some number of 1s in the low-order bits followed * by nothing but 0s in the high-order bits. The latter case * implies it's of the form 2^n-1. */ ASSERT(stencil_max_value > 0 && ((stencil_max_value + 1) & stencil_max_value) == 0); switch(stencil_op) { case PIPE_STENCIL_OP_KEEP: /* newS = S */ spe_move(f, newS_reg, fbS_reg); break; case PIPE_STENCIL_OP_ZERO: /* newS = 0 */ spe_zero(f, newS_reg); break; case PIPE_STENCIL_OP_REPLACE: /* newS = stencil reference value */ spe_load_uint(f, newS_reg, stencil_ref_value); break; case PIPE_STENCIL_OP_INCR: { /* newS = (s == max ? max : s + 1) */ int equals_reg = spe_allocate_available_register(f); spe_compare_equal_uint(f, equals_reg, fbS_reg, stencil_max_value); /* Add Word Immediate computes rT = rA + 10-bit signed immediate */ spe_ai(f, newS_reg, fbS_reg, 1); /* Select from the current value or the new value based on the equality test */ spe_selb(f, newS_reg, newS_reg, fbS_reg, equals_reg); spe_release_register(f, equals_reg); break; } case PIPE_STENCIL_OP_DECR: { /* newS = (s == 0 ? 0 : s - 1) */ int equals_reg = spe_allocate_available_register(f); spe_compare_equal_uint(f, equals_reg, fbS_reg, 0); /* Add Word Immediate with a (-1) value works */ spe_ai(f, newS_reg, fbS_reg, -1); /* Select from the current value or the new value based on the equality test */ spe_selb(f, newS_reg, newS_reg, fbS_reg, equals_reg); spe_release_register(f, equals_reg); break; } case PIPE_STENCIL_OP_INCR_WRAP: /* newS = (s == max ? 0 : s + 1), but since max is 2^n-1, we can * do a normal add and mask off the correct bits */ spe_ai(f, newS_reg, fbS_reg, 1); spe_and_uint(f, newS_reg, newS_reg, stencil_max_value); break; case PIPE_STENCIL_OP_DECR_WRAP: /* newS = (s == 0 ? max : s - 1), but we'll pull the same mask trick as above */ spe_ai(f, newS_reg, fbS_reg, -1); spe_and_uint(f, newS_reg, newS_reg, stencil_max_value); break; case PIPE_STENCIL_OP_INVERT: /* newS = ~s. We take advantage of the mask/max value to invert only * the valid bits for the field so we don't have to do an extra "and". */ spe_xor_uint(f, newS_reg, fbS_reg, stencil_max_value); break; default: ASSERT(0); } } /** * This function generates code to get all the necessary possible * stencil values. For each of the output registers (fail_reg, * zfail_reg, and zpass_reg), it either allocates a new register * and calculates a new set of values based on the stencil operation, * or it reuses a register allocation and calculation done for an * earlier (matching) operation, or it reuses the fbS_reg register * (if the stencil operation is KEEP, which doesn't change the * stencil buffer). * * Since this function allocates a variable number of registers, * to avoid incurring complex logic to free them, they should * be allocated after a spe_allocate_register_set() call * and released by the corresponding spe_release_register_set() call. */ static void gen_get_stencil_values(struct spe_function *f, const struct pipe_stencil_state *stencil, const unsigned ref_value, const uint depth_enabled, int fbS_reg, int *fail_reg, int *zfail_reg, int *zpass_reg) { uint zfail_op; /* Stenciling had better be enabled here */ ASSERT(stencil->enabled); /* If the depth test is not enabled, it is treated as though it always * passes, which means that the zfail_op is not considered - a * failing stencil test triggers the fail_op, and a passing one * triggers the zpass_op * * As an optimization, override calculation of the zfail_op values * if they aren't going to be used. By setting the value of * the operation to PIPE_STENCIL_OP_KEEP, its value will be assumed * to match the incoming stencil values, and no calculation will * be done. */ if (depth_enabled) { zfail_op = stencil->zfail_op; } else { zfail_op = PIPE_STENCIL_OP_KEEP; } /* One-sided or front-facing stencil */ if (stencil->fail_op == PIPE_STENCIL_OP_KEEP) { *fail_reg = fbS_reg; } else { *fail_reg = spe_allocate_available_register(f); gen_stencil_values(f, stencil->fail_op, ref_value, 0xff, fbS_reg, *fail_reg); } /* Check the possibly overridden value, not the structure value */ if (zfail_op == PIPE_STENCIL_OP_KEEP) { *zfail_reg = fbS_reg; } else if (zfail_op == stencil->fail_op) { *zfail_reg = *fail_reg; } else { *zfail_reg = spe_allocate_available_register(f); gen_stencil_values(f, stencil->zfail_op, ref_value, 0xff, fbS_reg, *zfail_reg); } if (stencil->zpass_op == PIPE_STENCIL_OP_KEEP) { *zpass_reg = fbS_reg; } else if (stencil->zpass_op == stencil->fail_op) { *zpass_reg = *fail_reg; } else if (stencil->zpass_op == zfail_op) { *zpass_reg = *zfail_reg; } else { *zpass_reg = spe_allocate_available_register(f); gen_stencil_values(f, stencil->zpass_op, ref_value, 0xff, fbS_reg, *zpass_reg); } } /** * Note that fbZ_reg may *not* be set on entry, if in fact * the depth test is not enabled. This function must not use * the register if depth is not enabled. */ static boolean gen_stencil_depth_test(struct spe_function *f, const struct pipe_depth_stencil_alpha_state *dsa, const struct pipe_stencil_ref *stencil_ref, const uint facing, const int mask_reg, const int fragZ_reg, const int fbZ_reg, const int fbS_reg) { /* True if we've generated code that could require writeback to the * depth and/or stencil buffers */ boolean modified_buffers = FALSE; boolean need_to_calculate_stencil_values; boolean need_to_writemask_stencil_values; struct pipe_stencil_state *stencil; /* Registers. We may or may not actually allocate these, depending * on whether the state values indicate that we need them. */ int stencil_pass_reg, stencil_fail_reg; int stencil_fail_values, stencil_pass_depth_fail_values, stencil_pass_depth_pass_values; int stencil_writemask_reg; int zmask_reg; int newS_reg; unsigned ref_value; /* Stenciling is quite complex: up to six different configurable stencil * operations/calculations can be required (three each for front-facing * and back-facing fragments). Many of those operations will likely * be identical, so there's good reason to try to avoid calculating * the same values more than once (which unfortunately makes the code less * straightforward). * * To make register management easier, we start a new * register set; we can release all the registers in the set at * once, and avoid having to keep track of exactly which registers * we allocate. We can still allocate and free registers as * desired (if we know we no longer need a register), but we don't * have to spend the complexity to track the more difficult variant * register usage scenarios. */ spe_comment(f, 0, "Allocating stencil register set"); spe_allocate_register_set(f); /* The facing we're given is the fragment facing; it doesn't * exactly match the stencil facing. If stencil is enabled, * but two-sided stencil is *not* enabled, we use the same * stencil settings for both front- and back-facing fragments. * We only use the "back-facing" stencil for backfacing fragments * if two-sided stenciling is enabled. */ if (facing == CELL_FACING_BACK && dsa->stencil[1].enabled) { stencil = &dsa->stencil[1]; ref_value = stencil_ref->ref_value[1]; } else { stencil = &dsa->stencil[0]; ref_value = stencil_ref->ref_value[0]; } /* Calculate the writemask. If the writemask is trivial (either * all 0s, meaning that we don't need to calculate any stencil values * because they're not going to change the stencil anyway, or all 1s, * meaning that we have to calculate the stencil values but do not * need to mask them), we can avoid generating code. Don't forget * that we need to consider backfacing stencil, if enabled. * * Note that if the backface stencil is *not* enabled, the backface * stencil will have the same values as the frontface stencil. */ if (stencil->fail_op == PIPE_STENCIL_OP_KEEP && stencil->zfail_op == PIPE_STENCIL_OP_KEEP && stencil->zpass_op == PIPE_STENCIL_OP_KEEP) { need_to_calculate_stencil_values = FALSE; need_to_writemask_stencil_values = FALSE; } else if (stencil->writemask == 0x0) { /* All changes are writemasked out, so no need to calculate * what those changes might be, and no need to write anything back. */ need_to_calculate_stencil_values = FALSE; need_to_writemask_stencil_values = FALSE; } else if (stencil->writemask == 0xff) { /* Still trivial, but a little less so. We need to write the stencil * values, but we don't need to mask them. */ need_to_calculate_stencil_values = TRUE; need_to_writemask_stencil_values = FALSE; } else { /* The general case: calculate, mask, and write */ need_to_calculate_stencil_values = TRUE; need_to_writemask_stencil_values = TRUE; /* While we're here, generate code that calculates what the * writemask should be. If backface stenciling is enabled, * and the backface writemask is not the same as the frontface * writemask, we'll have to generate code that merges the * two masks into a single effective mask based on fragment facing. */ spe_comment(f, 0, "Computing stencil writemask"); stencil_writemask_reg = spe_allocate_available_register(f); spe_load_uint(f, stencil_writemask_reg, dsa->stencil[facing].writemask); } /* At least one-sided stenciling must be on. Generate code that * runs the stencil test on the basic/front-facing stencil, leaving * the mask of passing stencil bits in stencil_pass_reg. This mask will * be used both to mask the set of active pixels, and also to * determine how the stencil buffer changes. * * This test will *not* change the value in mask_reg (because we don't * yet know whether to apply the two-sided stencil or one-sided stencil). */ spe_comment(f, 0, "Running basic stencil test"); stencil_pass_reg = spe_allocate_available_register(f); gen_stencil_test(f, stencil, ref_value, 0xff, mask_reg, fbS_reg, stencil_pass_reg); /* Generate code that, given the mask of valid fragments and the * mask of valid fragments that passed the stencil test, computes * the mask of valid fragments that failed the stencil test. We * have to do this before we run a depth test (because the * depth test should not be performed on fragments that failed the * stencil test, and because the depth test will update the * mask of valid fragments based on the results of the depth test). */ spe_comment(f, 0, "Computing stencil fail mask and updating fragment mask"); stencil_fail_reg = spe_allocate_available_register(f); spe_andc(f, stencil_fail_reg, mask_reg, stencil_pass_reg); /* Now remove the stenciled-out pixels from the valid fragment mask, * so we can later use the valid fragment mask in the depth test. */ spe_and(f, mask_reg, mask_reg, stencil_pass_reg); /* We may not need to calculate stencil values, if the writemask is off */ if (need_to_calculate_stencil_values) { /* Generate code that calculates exactly which stencil values we need, * without calculating the same value twice (say, if two different * stencil ops have the same value). This code will work for one-sided * and two-sided stenciling (so that we take into account that operations * may match between front and back stencils), and will also take into * account whether the depth test is enabled (if the depth test is off, * we don't need any of the zfail results, because the depth test always * is considered to pass if it is disabled). Any register value that * does not need to be calculated will come back with the same value * that's in fbS_reg. * * This function will allocate a variant number of registers that * will be released as part of the register set. */ spe_comment(f, 0, facing == CELL_FACING_FRONT ? "Computing front-facing stencil values" : "Computing back-facing stencil values"); gen_get_stencil_values(f, stencil, ref_value, dsa->depth.enabled, fbS_reg, &stencil_fail_values, &stencil_pass_depth_fail_values, &stencil_pass_depth_pass_values); } /* We now have all the stencil values we need. We also need * the results of the depth test to figure out which * stencil values will become the new stencil values. (Even if * we aren't actually calculating stencil values, we need to apply * the depth test if it's enabled.) * * The code generated by gen_depth_test() returns the results of the * test in the given register, but also alters the mask_reg based * on the results of the test. */ if (dsa->depth.enabled) { spe_comment(f, 0, "Running stencil depth test"); zmask_reg = spe_allocate_available_register(f); modified_buffers |= gen_depth_test(f, dsa, mask_reg, fragZ_reg, fbZ_reg, zmask_reg); } if (need_to_calculate_stencil_values) { /* If we need to writemask the stencil values before going into * the stencil buffer, we'll have to use a new register to * hold the new values. If not, we can just keep using the * current register. */ if (need_to_writemask_stencil_values) { newS_reg = spe_allocate_available_register(f); spe_comment(f, 0, "Saving current stencil values for writemasking"); spe_move(f, newS_reg, fbS_reg); } else { newS_reg = fbS_reg; } /* Merge in the selected stencil fail values */ if (stencil_fail_values != fbS_reg) { spe_comment(f, 0, "Loading stencil fail values"); spe_selb(f, newS_reg, newS_reg, stencil_fail_values, stencil_fail_reg); modified_buffers = TRUE; } /* Same for the stencil pass/depth fail values. If this calculation * is not needed (say, if depth test is off), then the * stencil_pass_depth_fail_values register will be equal to fbS_reg * and we'll skip the calculation. */ if (stencil_pass_depth_fail_values != fbS_reg) { /* We don't actually have a stencil pass/depth fail mask yet. * Calculate it here from the stencil passing mask and the * depth passing mask. Note that zmask_reg *must* have been * set above if we're here. */ uint stencil_pass_depth_fail_mask = spe_allocate_available_register(f); spe_comment(f, 0, "Loading stencil pass/depth fail values"); spe_andc(f, stencil_pass_depth_fail_mask, stencil_pass_reg, zmask_reg); spe_selb(f, newS_reg, newS_reg, stencil_pass_depth_fail_values, stencil_pass_depth_fail_mask); spe_release_register(f, stencil_pass_depth_fail_mask); modified_buffers = TRUE; } /* Same for the stencil pass/depth pass mask. Note that we * *can* get here with zmask_reg being unset (if the depth * test is off but the stencil test is on). In this case, * we assume the depth test passes, and don't need to mask * the stencil pass mask with the Z mask. */ if (stencil_pass_depth_pass_values != fbS_reg) { if (dsa->depth.enabled) { uint stencil_pass_depth_pass_mask = spe_allocate_available_register(f); /* We'll need a separate register */ spe_comment(f, 0, "Loading stencil pass/depth pass values"); spe_and(f, stencil_pass_depth_pass_mask, stencil_pass_reg, zmask_reg); spe_selb(f, newS_reg, newS_reg, stencil_pass_depth_pass_values, stencil_pass_depth_pass_mask); spe_release_register(f, stencil_pass_depth_pass_mask); } else { /* We can use the same stencil-pass register */ spe_comment(f, 0, "Loading stencil pass values"); spe_selb(f, newS_reg, newS_reg, stencil_pass_depth_pass_values, stencil_pass_reg); } modified_buffers = TRUE; } /* Almost done. If we need to writemask, do it now, leaving the * results in the fbS_reg register passed in. If we don't need * to writemask, then the results are *already* in the fbS_reg, * so there's nothing more to do. */ if (need_to_writemask_stencil_values && modified_buffers) { /* The Select Bytes command makes a fine writemask. Where * the mask is 0, the first (original) values are retained, * effectively masking out changes. Where the mask is 1, the * second (new) values are retained, incorporating changes. */ spe_comment(f, 0, "Writemasking new stencil values"); spe_selb(f, fbS_reg, fbS_reg, newS_reg, stencil_writemask_reg); } } /* done calculating stencil values */ /* The stencil and/or depth values have been applied, and the * mask_reg, fbS_reg, and fbZ_reg values have been updated. * We're all done, except that we've allocated a fair number * of registers that we didn't bother tracking. Release all * those registers as part of the register set, and go home. */ spe_comment(f, 0, "Releasing stencil register set"); spe_release_register_set(f); /* Return TRUE if we could have modified the stencil and/or * depth buffers. */ return modified_buffers; } /** * Generate depth and/or stencil test code. * \param cell context * \param dsa depth/stencil/alpha state * \param f spe function to emit * \param facing either CELL_FACING_FRONT or CELL_FACING_BACK * \param mask_reg register containing the pixel alive/dead mask * \param depth_tile_reg register containing address of z/stencil tile * \param quad_offset_reg offset to quad from start of tile * \param fragZ_reg register containg fragment Z values */ static void gen_depth_stencil(struct cell_context *cell, const struct pipe_depth_stencil_alpha_state *dsa, const struct pipe_stencil_ref *stencil_ref, struct spe_function *f, uint facing, int mask_reg, int depth_tile_reg, int quad_offset_reg, int fragZ_reg) { const enum pipe_format zs_format = cell->framebuffer.zsbuf->format; boolean write_depth_stencil; /* framebuffer's combined z/stencil values register */ int fbZS_reg = spe_allocate_available_register(f); /* Framebufer Z values register */ int fbZ_reg = spe_allocate_available_register(f); /* Framebuffer stencil values register (may not be used) */ int fbS_reg = spe_allocate_available_register(f); /* 24-bit mask register (may not be used) */ int zmask_reg = spe_allocate_available_register(f); /** * The following code: * 1. fetch quad of packed Z/S values from the framebuffer tile. * 2. extract the separate the Z and S values from packed values * 3. convert fragment Z values from float in [0,1] to 32/24/16-bit ints * * The instructions for doing this are interleaved for better performance. */ spe_comment(f, 0, "Fetch Z/stencil quad from tile"); switch(zs_format) { case PIPE_FORMAT_Z24_UNORM_S8_USCALED: /* fall through */ case PIPE_FORMAT_Z24X8_UNORM: /* prepare mask to extract Z vals from ZS vals */ spe_load_uint(f, zmask_reg, 0x00ffffff); /* convert fragment Z from [0,1] to 32-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); /* Load: fbZS_reg = memory[depth_tile_reg + offset_reg] */ spe_lqx(f, fbZS_reg, depth_tile_reg, quad_offset_reg); /* right shift 32-bit fragment Z to 24 bits */ spe_rotmi(f, fragZ_reg, fragZ_reg, -8); /* extract 24-bit Z values from ZS values by masking */ spe_and(f, fbZ_reg, fbZS_reg, zmask_reg); /* extract 8-bit stencil values by shifting */ spe_rotmi(f, fbS_reg, fbZS_reg, -24); break; case PIPE_FORMAT_S8_USCALED_Z24_UNORM: /* fall through */ case PIPE_FORMAT_X8Z24_UNORM: /* convert fragment Z from [0,1] to 32-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); /* Load: fbZS_reg = memory[depth_tile_reg + offset_reg] */ spe_lqx(f, fbZS_reg, depth_tile_reg, quad_offset_reg); /* right shift 32-bit fragment Z to 24 bits */ spe_rotmi(f, fragZ_reg, fragZ_reg, -8); /* extract 24-bit Z values from ZS values by shifting */ spe_rotmi(f, fbZ_reg, fbZS_reg, -8); /* extract 8-bit stencil values by masking */ spe_and_uint(f, fbS_reg, fbZS_reg, 0x000000ff); break; case PIPE_FORMAT_Z32_UNORM: /* Load: fbZ_reg = memory[depth_tile_reg + offset_reg] */ spe_lqx(f, fbZ_reg, depth_tile_reg, quad_offset_reg); /* convert fragment Z from [0,1] to 32-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); /* No stencil, so can't do anything there */ break; case PIPE_FORMAT_Z16_UNORM: /* XXX This code for 16bpp Z is broken! */ /* Load: fbZS_reg = memory[depth_tile_reg + offset_reg] */ spe_lqx(f, fbZS_reg, depth_tile_reg, quad_offset_reg); /* Copy over 4 32-bit values */ spe_move(f, fbZ_reg, fbZS_reg); /* convert Z from [0,1] to 16-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); spe_rotmi(f, fragZ_reg, fragZ_reg, -16); /* No stencil */ break; default: ASSERT(0); /* invalid format */ } /* If stencil is enabled, use the stencil-specific code * generator to generate both the stencil and depth (if needed) * tests. Otherwise, if only depth is enabled, generate * a quick depth test. The test generators themselves will * report back whether the depth/stencil buffer has to be * written back. */ if (dsa->stencil[0].enabled) { /* This will perform the stencil and depth tests, and update * the mask_reg, fbZ_reg, and fbS_reg as required by the * tests. */ ASSERT(fbS_reg >= 0); spe_comment(f, 0, "Perform stencil test"); /* Note that fbZ_reg may not be set on entry, if stenciling * is enabled but there's no Z-buffer. The * gen_stencil_depth_test() function must ignore the * fbZ_reg register if depth is not enabled. */ write_depth_stencil = gen_stencil_depth_test(f, dsa, stencil_ref, facing, mask_reg, fragZ_reg, fbZ_reg, fbS_reg); } else if (dsa->depth.enabled) { int zmask_reg = spe_allocate_available_register(f); ASSERT(fbZ_reg >= 0); spe_comment(f, 0, "Perform depth test"); write_depth_stencil = gen_depth_test(f, dsa, mask_reg, fragZ_reg, fbZ_reg, zmask_reg); spe_release_register(f, zmask_reg); } else { write_depth_stencil = FALSE; } if (write_depth_stencil) { /* Merge latest Z and Stencil values into fbZS_reg. * fbZ_reg has four Z vals in bits [23..0] or bits [15..0]. * fbS_reg has four 8-bit Z values in bits [7..0]. */ spe_comment(f, 0, "Store quad's depth/stencil values in tile"); if (zs_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || zs_format == PIPE_FORMAT_Z24X8_UNORM) { spe_shli(f, fbS_reg, fbS_reg, 24); /* fbS = fbS << 24 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ } else if (zs_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || zs_format == PIPE_FORMAT_X8Z24_UNORM) { spe_shli(f, fbZ_reg, fbZ_reg, 8); /* fbZ = fbZ << 8 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ } else if (zs_format == PIPE_FORMAT_Z32_UNORM) { spe_move(f, fbZS_reg, fbZ_reg); /* fbZS = fbZ */ } else if (zs_format == PIPE_FORMAT_Z16_UNORM) { spe_move(f, fbZS_reg, fbZ_reg); /* fbZS = fbZ */ } else if (zs_format == PIPE_FORMAT_S8_USCALED) { ASSERT(0); /* XXX to do */ } else { ASSERT(0); /* bad zs_format */ } /* Store: memory[depth_tile_reg + quad_offset_reg] = fbZS */ spe_stqx(f, fbZS_reg, depth_tile_reg, quad_offset_reg); } /* Don't need these any more */ spe_release_register(f, fbZS_reg); spe_release_register(f, fbZ_reg); spe_release_register(f, fbS_reg); spe_release_register(f, zmask_reg); } /** * Generate SPE code to implement the fragment operations (alpha test, * depth test, stencil test, blending, colormask, and final * framebuffer write) as specified by the current context state. * * Logically, this code will be called after running the fragment * shader. But under some circumstances we could run some of this * code before the fragment shader to cull fragments/quads that are * totally occluded/discarded. * * XXX we only support PIPE_FORMAT_S8_USCALED_Z24_UNORM z/stencil buffer right now. * * See the spu_default_fragment_ops() function to see how the per-fragment * operations would be done with ordinary C code. * The code we generate here though has no branches, is SIMD, etc and * should be much faster. * * \param cell the rendering context (in) * \param facing whether the generated code is for front-facing or * back-facing fragments * \param f the generated function (in/out); on input, the function * must already have been initialized. On exit, whatever * instructions within the generated function have had * the fragment ops appended. */ void cell_gen_fragment_function(struct cell_context *cell, const uint facing, struct spe_function *f) { const struct pipe_depth_stencil_alpha_state *dsa = cell->depth_stencil; const struct pipe_stencil_ref *stencil_ref = &cell->stencil_ref; const struct pipe_blend_state *blend = cell->blend; const struct pipe_blend_color *blend_color = &cell->blend_color; const enum pipe_format color_format = cell->framebuffer.cbufs[0]->format; /* For SPE function calls: reg $3 = first param, $4 = second param, etc. */ const int x_reg = 3; /* uint */ const int y_reg = 4; /* uint */ const int color_tile_reg = 5; /* tile_t * */ const int depth_tile_reg = 6; /* tile_t * */ const int fragZ_reg = 7; /* vector float */ const int fragR_reg = 8; /* vector float */ const int fragG_reg = 9; /* vector float */ const int fragB_reg = 10; /* vector float */ const int fragA_reg = 11; /* vector float */ const int mask_reg = 12; /* vector uint */ ASSERT(facing == CELL_FACING_FRONT || facing == CELL_FACING_BACK); /* offset of quad from start of tile * XXX assuming 4-byte pixels for color AND Z/stencil!!!! */ int quad_offset_reg; int fbRGBA_reg; /**< framebuffer's RGBA colors for quad */ if (cell->debug_flags & CELL_DEBUG_ASM) { spe_print_code(f, TRUE); spe_indent(f, 8); spe_comment(f, -4, facing == CELL_FACING_FRONT ? "Begin front-facing per-fragment ops" : "Begin back-facing per-fragment ops"); } spe_allocate_register(f, x_reg); spe_allocate_register(f, y_reg); spe_allocate_register(f, color_tile_reg); spe_allocate_register(f, depth_tile_reg); spe_allocate_register(f, fragZ_reg); spe_allocate_register(f, fragR_reg); spe_allocate_register(f, fragG_reg); spe_allocate_register(f, fragB_reg); spe_allocate_register(f, fragA_reg); spe_allocate_register(f, mask_reg); quad_offset_reg = spe_allocate_available_register(f); fbRGBA_reg = spe_allocate_available_register(f); /* compute offset of quad from start of tile, in bytes */ { int x2_reg = spe_allocate_available_register(f); int y2_reg = spe_allocate_available_register(f); ASSERT(TILE_SIZE == 32); spe_comment(f, 0, "Compute quad offset within tile"); spe_rotmi(f, y2_reg, y_reg, -1); /* y2 = y / 2 */ spe_rotmi(f, x2_reg, x_reg, -1); /* x2 = x / 2 */ spe_shli(f, y2_reg, y2_reg, 4); /* y2 *= 16 */ spe_a(f, quad_offset_reg, y2_reg, x2_reg); /* offset = y2 + x2 */ spe_shli(f, quad_offset_reg, quad_offset_reg, 4); /* offset *= 16 */ spe_release_register(f, x2_reg); spe_release_register(f, y2_reg); } /* Generate the alpha test, if needed. */ if (dsa->alpha.enabled) { gen_alpha_test(dsa, f, mask_reg, fragA_reg); } /* generate depth and/or stencil test code */ if (dsa->depth.enabled || dsa->stencil[0].enabled) { gen_depth_stencil(cell, dsa, stencil_ref, f, facing, mask_reg, depth_tile_reg, quad_offset_reg, fragZ_reg); } /* Get framebuffer quad/colors. We'll need these for blending, * color masking, and to obey the quad/pixel mask. * Load: fbRGBA_reg = memory[color_tile + quad_offset] * Note: if mask={~0,~0,~0,~0} and we're not blending or colormasking * we could skip this load. */ spe_comment(f, 0, "Fetch quad colors from tile"); spe_lqx(f, fbRGBA_reg, color_tile_reg, quad_offset_reg); if (blend->rt[0].blend_enable) { spe_comment(f, 0, "Perform blending"); gen_blend(blend, blend_color, f, color_format, fragR_reg, fragG_reg, fragB_reg, fragA_reg, fbRGBA_reg); } /* * Write fragment colors to framebuffer/tile. * This involves converting the fragment colors from float[4] to the * tile's specific format and obeying the quad/pixel mask. */ { int rgba_reg = spe_allocate_available_register(f); /* Pack four float colors as four 32-bit int colors */ spe_comment(f, 0, "Convert float quad colors to packed int framebuffer colors"); gen_pack_colors(f, color_format, fragR_reg, fragG_reg, fragB_reg, fragA_reg, rgba_reg); if (blend->logicop_enable) { spe_comment(f, 0, "Compute logic op"); gen_logicop(blend, f, rgba_reg, fbRGBA_reg); } if (blend->rt[0].colormask != PIPE_MASK_RGBA) { spe_comment(f, 0, "Compute color mask"); gen_colormask(f, blend->rt[0].colormask, color_format, rgba_reg, fbRGBA_reg); } /* Mix fragment colors with framebuffer colors using the quad/pixel mask: * if (mask[i]) * rgba[i] = rgba[i]; * else * rgba[i] = framebuffer[i]; */ spe_selb(f, rgba_reg, fbRGBA_reg, rgba_reg, mask_reg); /* Store updated quad in tile: * memory[color_tile + quad_offset] = rgba_reg; */ spe_comment(f, 0, "Store quad colors into color tile"); spe_stqx(f, rgba_reg, color_tile_reg, quad_offset_reg); spe_release_register(f, rgba_reg); } //printf("gen_fragment_ops nr instructions: %u\n", f->num_inst); spe_bi(f, SPE_REG_RA, 0, 0); /* return from function call */ spe_release_register(f, fbRGBA_reg); spe_release_register(f, quad_offset_reg); if (cell->debug_flags & CELL_DEBUG_ASM) { char buffer[1024]; sprintf(buffer, "End %s-facing per-fragment ops: %d instructions", facing == CELL_FACING_FRONT ? "front" : "back", f->num_inst); spe_comment(f, -4, buffer); } }
38.126484
106
0.646466
[ "vector" ]
d10e7396427c70ae455b4c09b55679d9e40e0f29
320
h
C
WRFile.h
andresbanegas/Lab-8_AndresCruz
f2a9f03f6e7c63a3a860bb0dd9db2d93e02635a4
[ "MIT" ]
null
null
null
WRFile.h
andresbanegas/Lab-8_AndresCruz
f2a9f03f6e7c63a3a860bb0dd9db2d93e02635a4
[ "MIT" ]
null
null
null
WRFile.h
andresbanegas/Lab-8_AndresCruz
f2a9f03f6e7c63a3a860bb0dd9db2d93e02635a4
[ "MIT" ]
null
null
null
#ifndef WRFILE_H #define WRFILE_H #include "Partida.h" #include <fstream> #include <string> #include <vector> using namespace std; class WRFile{ private: fstream file; public: WRFile(); void escribirArchivo(string,string,vector<string>); vector<Partida*> leerArchivo(); }; #endif
18.823529
59
0.665625
[ "vector" ]
d119076eec7356cc705cabf50ddf44b620057a6a
986
h
C
usr/libexec/locationd/CLFenceManagerProtocol.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
11
2019-11-06T04:48:48.000Z
2022-02-09T17:48:15.000Z
usr/libexec/locationd/CLFenceManagerProtocol.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
1
2020-04-16T01:41:56.000Z
2020-04-16T04:32:00.000Z
usr/libexec/locationd/CLFenceManagerProtocol.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
3
2019-12-22T20:17:53.000Z
2021-01-25T09:47:49.000Z
/* * This header is generated by classdump-dyld 1.0 * on Tuesday, November 5, 2019 at 3:11:45 PM Mountain Standard Time * Operating System: Version 13.0 (Build 17J586) * Image Source: /usr/libexec/locationd * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @protocol CLFenceManagerProtocol <CLNotifierServiceProtocol> @required -(void)doAsync:(/*^block*/id)arg1; -(void)doAsync:(/*^block*/id)arg1 withReply:(/*^block*/id)arg2; -(BOOL)syncgetDoSync:(/*^block*/id)arg1; -(void)getFencesForBundleID:(id)arg1 withReply:(/*^block*/id)arg2; -(void)simulateFenceWithBundleID:(id)arg1 andFenceID:(id)arg2 eventType:(unsigned char)arg3 atLocation:(id)arg4; -(void)addFence:(/*^block*/id)arg1; -(BOOL)syncgetHasMonitoredFences:(id)arg1; -(void)removeFence:(/*^block*/id)arg1; -(void)requestRegionState:(/*^block*/id)arg1; -(BOOL)syncgetFences:(vector<CLFenceManager_Type::Fence, std::__1::allocator<CLFenceManager_Type::Fence> >*)arg1 forKey:(id)arg2; @end
39.44
129
0.748479
[ "vector" ]
d122a84eb0ff05ebbeba0fd44f8eee8aa4428f2f
2,620
h
C
src/map_reduce/map_reduce_config.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
255
2018-12-14T05:59:29.000Z
2020-11-04T12:15:32.000Z
src/map_reduce/map_reduce_config.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
35
2018-12-25T03:02:48.000Z
2020-11-19T03:33:25.000Z
src/map_reduce/map_reduce_config.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
54
2018-12-14T06:09:21.000Z
2020-11-21T08:29:31.000Z
// BSD 3-Clause License // Copyright (c) 2020, Chenyu // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, // this // list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef _SRC_MAPREDUCE_CONFIG_H_ #define _SRC_MAPREDUCE_CONFIG_H_ #include <glog/logging.h> #include <fstream> #include <iostream> #include <string> namespace DAGSfM { struct MapReduceConfig { size_t num_machine = 0; std::vector<std::string> server_ips; std::vector<uint16_t> server_ports; std::vector<std::string> image_paths; bool ReadConfig(std::string& filename) { size_t n; std::string ip; uint16_t port; std::string image_path; std::ifstream config_file(filename); if (!config_file.is_open()) { LOG(ERROR) << "Can't open file " << filename; return false; } config_file >> n; CHECK_GT(n, 0) << "No server provided!"; server_ips.reserve(n); server_ports.reserve(n); image_paths.reserve(n); for (size_t i = 0; i < n; i++) { config_file >> ip >> port >> image_path; server_ips.push_back(ip); server_ports.push_back(port); image_paths.push_back(image_path); } return true; } }; } // namespace DAGSfM #endif
31.190476
79
0.723664
[ "vector" ]
d12c859a8464b29a5f0a99825f958d1cc3f17bcd
1,342
c
C
third_party/Phigs/PVT/PVT_c/V2LIB/lnplpt.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
18
2017-07-08T02:34:02.000Z
2022-01-08T03:42:48.000Z
third_party/Phigs/PVT/PVT_c/V2LIB/lnplpt.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
null
null
null
third_party/Phigs/PVT/PVT_c/V2LIB/lnplpt.c
n1ckfg/Telidon
f4e2c693ec7d67245974b73a602d5d40df6a6d69
[ "MIT" ]
3
2018-02-03T04:44:00.000Z
2020-08-05T15:31:18.000Z
/* lnplpt.f -- translated by f2c (version of 22 July 1992 22:54:52). You must link the resulting object file with the libraries: -lF77 -lI77 -lm -lc (in that order) */ #include "f2c.h" #ifndef NO_PROTO /* Subroutine */ int lnplpt_(real *lx, real *ly, real *lz, real *al, real *bl, real *cl, real *ap, real *bp, real *cp, real *dp, real *xi, real *yi, real *zi) #else /* NO_PROTO */ /* Subroutine */ int lnplpt_(lx, ly, lz, al, bl, cl, ap, bp, cp, dp, xi, yi, zi) real *lx, *ly, *lz, *al, *bl, *cl, *ap, *bp, *cp, *dp, *xi, *yi, *zi; #endif /* NO_PROTO */ { static real u; #ifndef NO_PROTO extern doublereal dotprd_(real *, real *, real *, real *, real *, real *); #else /* NO_PROTO */ extern doublereal dotprd_(); #endif /* NO_PROTO */ #ifndef NO_PROTO #endif /* not NO_PROTO */ /* Given a line and a plane, find point of intersection. */ /* Input parameters */ /* LX,LY,LZ : point on the line */ /* AL,BL,CL : direction of line */ /* AP,BP,CP,DP : co-efficients of plane */ /* Output parameters */ /* XI,YI,ZI : point of intersection */ u = -(doublereal)(dotprd_(ap, bp, cp, lx, ly, lz) + *dp) / dotprd_(ap, bp, cp, al, bl, cl); *xi = *lx + *al * u; *yi = *ly + *bl * u; *zi = *lz + *cl * u; #ifndef NO_PROTO return 0; #endif /* not NO_PROTO */ } /* lnplpt_ */
29.822222
78
0.577496
[ "object" ]
d136fab3af875f18068d59b379df3cf9e4d5b003
6,869
h
C
ns-allinone-3.35/ns-3.35/src/wifi/model/wifi-default-ack-manager.h
usi-systems/cc
487aa9e322b2b01b6af3a92e38545c119e4980a3
[ "Apache-2.0" ]
1
2022-03-22T08:08:35.000Z
2022-03-22T08:08:35.000Z
ns-3-dev/src/wifi/model/wifi-default-ack-manager.h
Marquez607/Wireless-Perf-Sim
1086759b6dbe7da192225780d5fe6a3da0c5eb07
[ "MIT" ]
null
null
null
ns-3-dev/src/wifi/model/wifi-default-ack-manager.h
Marquez607/Wireless-Perf-Sim
1086759b6dbe7da192225780d5fe6a3da0c5eb07
[ "MIT" ]
null
null
null
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Stefano Avallone <stavallo@unina.it> */ #ifndef WIFI_DEFAULT_ACK_MANAGER_H #define WIFI_DEFAULT_ACK_MANAGER_H #include "wifi-ack-manager.h" namespace ns3 { class WifiTxParameters; class WifiMacQueueItem; /** * \ingroup wifi * * WifiDefaultAckManager is the default ack manager. */ class WifiDefaultAckManager : public WifiAckManager { public: /** * \brief Get the type ID. * \return the object TypeId */ static TypeId GetTypeId (void); WifiDefaultAckManager (); virtual ~WifiDefaultAckManager (); virtual std::unique_ptr<WifiAcknowledgment> TryAddMpdu (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams) override; virtual std::unique_ptr<WifiAcknowledgment> TryAggregateMsdu (Ptr<const WifiMacQueueItem> msdu, const WifiTxParameters& txParams) override; /** * Get the maximum distance between the starting sequence number of the Block * Ack agreement which the given MPDU belongs to and each of the sequence numbers * of the given MPDU and of all the QoS data frames included in the given TX * parameters. * * \param mpdu the given MPDU * \param txParams the given TX parameters * \return the maximum distance between the starting sequence number of the Block * Ack agreement which the given MPDU belongs to and each of the sequence * numbers of the given MPDU and of all the QoS data frames included in * the given TX parameters */ uint16_t GetMaxDistFromStartingSeq (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams) const; protected: /** * Determine whether the (A-)MPDU containing the given MPDU and the MPDUs (if any) * included in the given TX parameters requires an immediate response (Normal Ack, * Block Ack or Block Ack Request followed by Block Ack). * * \param mpdu the given MPDU. * \param txParams the given TX parameters. * \return true if the given PSDU requires an immediate response */ bool IsResponseNeeded (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams) const; private: /** * Compute the information about the acknowledgment of the current multi-user frame * (as described by the given TX parameters) if the given MPDU is added. If the * computed information is the same as the current one, a null pointer is returned. * Otherwise, the computed information is returned. * This method can only be called if the selected acknowledgment method for DL * multi-user frames consists of a sequence of BlockAckReq and BlockAck frames. * * \param mpdu the given MPDU * \param txParams the TX parameters describing the current multi-user frame * \return the new acknowledgment method or a null pointer if the acknowledgment method * is unchanged */ virtual std::unique_ptr<WifiAcknowledgment> GetAckInfoIfBarBaSequence (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams); /** * Compute the information about the acknowledgment of the current multi-user frame * (as described by the given TX parameters) if the given MPDU is added. If the * computed information is the same as the current one, a null pointer is returned. * Otherwise, the computed information is returned. * This method can only be called if the selected acknowledgment method for DL * multi-user frames consists of a MU-BAR Trigger Frame sent as single-user frame. * * \param mpdu the given MPDU * \param txParams the TX parameters describing the current multi-user frame * \return the new acknowledgment method or a null pointer if the acknowledgment method * is unchanged */ virtual std::unique_ptr<WifiAcknowledgment> GetAckInfoIfTfMuBar (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams); /** * Compute the information about the acknowledgment of the current multi-user frame * (as described by the given TX parameters) if the given MPDU is added. If the * computed information is the same as the current one, a null pointer is returned. * Otherwise, the computed information is returned. * This method can only be called if the selected acknowledgment method for DL * multi-user frames consists of MU-BAR Trigger Frames aggregated to the PSDUs of * the MU PPDU. * * \param mpdu the given MPDU * \param txParams the TX parameters describing the current multi-user frame * \return the new acknowledgment method or a null pointer if the acknowledgment method * is unchanged */ virtual std::unique_ptr<WifiAcknowledgment> GetAckInfoIfAggregatedMuBar (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams); /** * Calculate the acknowledgment method for the TB PPDUs solicited by the given * Trigger Frame. * * \param mpdu the given Trigger Frame * \param txParams the current TX parameters (just the TXVECTOR needs to be set) * \return the acknowledgment method for the TB PPDUs solicited by the given Trigger Frame */ virtual std::unique_ptr<WifiAcknowledgment> TryUlMuTransmission (Ptr<const WifiMacQueueItem> mpdu, const WifiTxParameters& txParams); bool m_useExplicitBar; //!< true for sending BARs, false for using Implicit BAR policy double m_baThreshold; //!< Threshold to determine when a BlockAck must be requested WifiAcknowledgment::Method m_dlMuAckType; //!< Type of the ack sequence for DL MU PPDUs uint8_t m_maxMcsForBlockAckInTbPpdu; //!< Max MCS used to send a BlockAck in a TB PPDU }; } //namespace ns3 #endif /* WIFI_DEFAULT_ACK_MANAGER_H */
45.190789
109
0.689329
[ "object" ]
d14492b94fbff2c28125d552d988f2cceeda51a4
3,314
h
C
std/Vector.h
Null-LLC/Echo
07165b71332fed8e4dd641bd0bdddb38534abdf0
[ "MIT" ]
7
2021-08-15T01:35:56.000Z
2022-01-11T10:34:35.000Z
std/Vector.h
Null-LLC/Echo
07165b71332fed8e4dd641bd0bdddb38534abdf0
[ "MIT" ]
1
2021-11-06T07:20:31.000Z
2021-11-07T10:13:46.000Z
std/Vector.h
Null-LLC/Echo
07165b71332fed8e4dd641bd0bdddb38534abdf0
[ "MIT" ]
1
2021-12-07T07:04:47.000Z
2021-12-07T07:04:47.000Z
#pragma once template <class T> class Vector { public: typedef T * iterator; Vector(); Vector(unsigned int size); Vector(unsigned int size, const T & initial); Vector(const Vector<T> & v); ~Vector(); unsigned int capacity() const; unsigned int size() const; bool empty() const; iterator begin(); iterator end(); T & front(); T & back(); void push_back(const T & value); void pop_back(); void reserve(unsigned int capacity); void resize(unsigned int size); T & operator[](unsigned int index); Vector<T> & operator=(const Vector<T> &); void clear(); private: unsigned int my_size; unsigned int my_capacity; T * buffer; }; // Your code goes here ... template<class T> Vector<T>::Vector() { my_capacity = 0; my_size = 0; buffer = 0; } template<class T> Vector<T>::Vector(const Vector<T> & v) { my_size = v.my_size; my_capacity = v.my_capacity; buffer = new T[my_size]; for (unsigned int i = 0; i < my_size; i++) buffer[i] = v.buffer[i]; } template<class T> Vector<T>::Vector(unsigned int size) { my_capacity = size; my_size = size; buffer = new T[size]; } template<class T> Vector<T>::Vector(unsigned int size, const T & initial) { my_size = size; my_capacity = size; buffer = new T [size]; for (unsigned int i = 0; i < size; i++) buffer[i] = initial; //T(); } template<class T> Vector<T> & Vector<T>::operator = (const Vector<T> & v) { delete[ ] buffer; my_size = v.my_size; my_capacity = v.my_capacity; buffer = new T [my_size]; for (unsigned int i = 0; i < my_size; i++) buffer[i] = v.buffer[i]; return *this; } template<class T> typename Vector<T>::iterator Vector<T>::begin() { return buffer; } template<class T> typename Vector<T>::iterator Vector<T>::end() { return buffer + size(); } template<class T> T& Vector<T>::front() { return buffer[0]; } template<class T> T& Vector<T>::back() { return buffer[my_size - 1]; } template<class T> void Vector<T>::push_back(const T & v) { if (my_size >= my_capacity) reserve(my_capacity +5); buffer [my_size++] = v; } template<class T> void Vector<T>::pop_back() { my_size--; } template<class T> void Vector<T>::reserve(unsigned int capacity) { if(buffer == 0) { my_size = 0; my_capacity = 0; } T * Newbuffer = new T [capacity]; //assert(Newbuffer); unsigned int l_Size = capacity < my_size ? capacity : my_size; //copy (buffer, buffer + l_Size, Newbuffer); for (unsigned int i = 0; i < l_Size; i++) Newbuffer[i] = buffer[i]; my_capacity = capacity; delete[] buffer; buffer = Newbuffer; } template<class T> unsigned int Vector<T>::size()const// { return my_size; } template<class T> void Vector<T>::resize(unsigned int size) { reserve(size); my_size = size; } template<class T> T& Vector<T>::operator[](unsigned int index) { return buffer[index]; } template<class T> unsigned int Vector<T>::capacity()const { return my_capacity; } template<class T> Vector<T>::~Vector() { delete[ ] buffer; } template <class T> void Vector<T>::clear() { my_capacity = 0; my_size = 0; buffer = 0; }
18.10929
66
0.602293
[ "vector" ]
d14edf4b159713d9fd2d38a92e4f6070ef71d787
5,039
h
C
include/builder.h
rodrigovb96/cpp-torch
8ce7edb687b174bd114a96c0758e8379c8c77c1d
[ "Apache-2.0" ]
55
2016-10-26T16:10:18.000Z
2021-01-26T00:44:35.000Z
include/builder.h
rodrigovb96/cpp-torch
8ce7edb687b174bd114a96c0758e8379c8c77c1d
[ "Apache-2.0" ]
10
2017-04-17T12:31:54.000Z
2018-11-23T10:49:07.000Z
include/builder.h
rodrigovb96/cpp-torch
8ce7edb687b174bd114a96c0758e8379c8c77c1d
[ "Apache-2.0" ]
25
2016-10-06T13:49:24.000Z
2021-05-01T16:36:02.000Z
#pragma once #include "torch/Tensor.h" #include "nn/Layer.h" #include <string> #include <map> #include <vector> #include <memory> #include <assert.h> #include <math.h> namespace cpptorch { class object_table; class object_torch; class object_torch_tensor; template<typename T> class object_torch_storage; enum object_type { object_type_nil, object_type_number, object_type_string, object_type_boolean, object_type_table, object_type_torch, object_type_torch_tensor, object_type_torch_storage, }; class object { public: object(object_type t = object_type_nil) : type_(t) {} virtual ~object() {} operator bool() const; operator int() const; operator long() const; operator float() const; operator double() const; inline const object_table* to_table() const; inline const object_torch* to_torch() const; inline const object_torch_tensor* to_tensor() const; template<typename T> inline const object_torch_storage<T>* to_storage() const; object_type type_; }; class object_number : public object { public: object_number() : object(object_type_number) {} double num_; }; class object_boolean : public object { public: object_boolean() : object(object_type_boolean) {} bool val_; }; class object_string : public object { public: object_string() : object(object_type_string) {} std::string str_; }; class object_table : public object { public: object_table() : object(object_type_table) {} const object* get(const std::string &key) const { auto it = kv_.find(key); return it == kv_.end() ? nullptr : it->second.get(); } const object* get(size_t key) const { return key < array_.size() ? array_[key].get() : nullptr; } std::map<std::string, std::shared_ptr<object>> kv_; std::vector<std::shared_ptr<object>> array_; }; class object_torch : public object { public: object_torch(object_type t = object_type_torch) : object(t) {} int version_; int index_; std::string class_name_; std::shared_ptr<object> data_; }; class object_torch_tensor : public object_torch { public: object_torch_tensor() : object_torch(object_type_torch_tensor), size_(nullptr), stride_(nullptr) {} ~object_torch_tensor() { if (size_) { free(size_); size_ = nullptr; } if (stride_) { free(stride_); stride_ = nullptr; } } int dimension_; long *size_, *stride_; long storage_offset_; }; template<typename T> class object_torch_storage : public object_torch { public: object_torch_storage() : object_torch(object_type_torch_storage), storage_(nullptr) {} ~object_torch_storage() { if (storage_) { free(storage_); storage_ = nullptr; } } long size_; T *storage_; }; // load module utils API std::shared_ptr<object> load(std::istream &is); template<typename T, GPUFlag F=GPU_None> API Tensor<T, F> read_tensor(const object *obj); template<typename T, GPUFlag F=GPU_None> API std::shared_ptr<nn::Layer<T, F>> read_net(const object *obj); } inline cpptorch::object::operator bool() const { assert(type_ == object_type_boolean); return (static_cast<const object_boolean*>(this))->val_; } inline cpptorch::object::operator int() const { return (int)round((double)*this); } inline cpptorch::object::operator long() const { return (long)round((double)*this); } inline cpptorch::object::operator float() const { return (float)(double)*this; } inline cpptorch::object::operator double() const { assert(type_ == object_type_number); return (static_cast<const object_number*>(this))->num_; } inline const cpptorch::object_table* cpptorch::object::to_table() const { assert(type_ == object_type_table); return static_cast<const cpptorch::object_table*>(this); } inline const cpptorch::object_torch* cpptorch::object::to_torch() const { assert(type_ == object_type_torch); return static_cast<const cpptorch::object_torch*>(this); } inline const cpptorch::object_torch_tensor* cpptorch::object::to_tensor() const { assert(type_ == object_type_torch_tensor); return static_cast<const cpptorch::object_torch_tensor*>(this); } template<typename T> inline const cpptorch::object_torch_storage<T>* cpptorch::object::to_storage() const { assert(type_ == object_type_torch_storage); return static_cast<const cpptorch::object_torch_storage<T>*>(this); }
24.461165
107
0.618774
[ "object", "vector" ]
d160915106f1f299bb2c327f07cf13bed188bddb
2,605
h
C
include/SPTK/input/input_source_from_vector.h
takenori-y/SPTK
573df2dd032c39db2aa24de012d2fe9a44f96280
[ "Apache-2.0" ]
91
2017-12-25T14:13:17.000Z
2022-03-15T14:33:23.000Z
include/SPTK/input/input_source_from_vector.h
takenori-y/SPTK
573df2dd032c39db2aa24de012d2fe9a44f96280
[ "Apache-2.0" ]
4
2020-09-28T03:58:29.000Z
2021-12-14T01:23:13.000Z
include/SPTK/input/input_source_from_vector.h
takenori-y/SPTK
573df2dd032c39db2aa24de012d2fe9a44f96280
[ "Apache-2.0" ]
16
2018-03-12T07:08:09.000Z
2022-03-22T02:38:13.000Z
// ------------------------------------------------------------------------ // // Copyright 2021 SPTK Working Group // // // // Licensed under the Apache License, Version 2.0 (the "License"); // // you may not use this file except in compliance with the License. // // You may obtain a copy of the License at // // // // http://www.apache.org/licenses/LICENSE-2.0 // // // // Unless required by applicable law or agreed to in writing, software // // distributed under the License is distributed on an "AS IS" BASIS, // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // // limitations under the License. // // ------------------------------------------------------------------------ // #ifndef SPTK_INPUT_INPUT_SOURCE_FROM_VECTOR_H_ #define SPTK_INPUT_INPUT_SOURCE_FROM_VECTOR_H_ #include <vector> // std::vector #include "SPTK/input/input_source_interface.h" #include "SPTK/utils/sptk_utils.h" namespace sptk { /** * Use vector as input source. */ class InputSourceFromVector : public InputSourceInterface { public: /** * @param[in] zero_padding If true, pad with zero in the last reading. * @param[in] read_size Read size. * @param[in] input_vector Input vector. */ InputSourceFromVector(bool zero_padding, int read_size, std::vector<double>* input_vector); virtual ~InputSourceFromVector() { } /** * @return Size of data. */ virtual int GetSize() const { return read_size_; } /** * @return Size of vector. */ int VectorSize() const { return vector_size_; } /** * @return True if this object is valid. */ virtual bool IsValid() const { return is_valid_; } /** * @param[out] buffer Read data. * @return True on success, false on failure. */ virtual bool Get(std::vector<double>* buffer); private: const bool zero_padding_; const int read_size_; const int vector_size_; const std::vector<double>* input_vector_; int position_; bool is_valid_; DISALLOW_COPY_AND_ASSIGN(InputSourceFromVector); }; } // namespace sptk #endif // SPTK_INPUT_INPUT_SOURCE_FROM_VECTOR_H_
30.290698
78
0.543186
[ "object", "vector" ]
2f62b7a2479c9ce32fcbc8f246f5c2aa76be2e56
7,358
h
C
util/Util.h
Toysoft/ciderpress
640959dad551ba75a48bd3c49629579730ead351
[ "BSD-3-Clause" ]
84
2015-01-01T00:27:18.000Z
2022-03-28T22:55:56.000Z
util/Util.h
Toysoft/ciderpress
640959dad551ba75a48bd3c49629579730ead351
[ "BSD-3-Clause" ]
49
2015-01-11T19:58:57.000Z
2022-01-08T00:27:12.000Z
util/Util.h
Toysoft/ciderpress
640959dad551ba75a48bd3c49629579730ead351
[ "BSD-3-Clause" ]
19
2015-06-06T15:23:18.000Z
2022-01-12T23:26:43.000Z
/* * CiderPress * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * See the file LICENSE for distribution terms. */ /* * Miscellaneous utility classes. */ #ifndef UTIL_UTIL_H #define UTIL_UTIL_H #include <sal.h> /* * Gripper for a resizable window. */ class CGripper: public CScrollBar { protected: afx_msg LRESULT OnNcHitTest(CPoint point); DECLARE_MESSAGE_MAP() }; /* * Transfer a buffer of data into a rich edit control. */ class RichEditXfer { public: RichEditXfer(const void* buf, long len) : fBuf((char*)buf), fLen(len) {} static DWORD CALLBACK EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG* pcb); const char* fBuf; long fLen; private: DECLARE_COPY_AND_OPEQ(RichEditXfer) }; /* * Buffer that expands as data is added to it with stdio-style calls. */ class ExpandBuffer { public: ExpandBuffer(long initialSize = 65536) { ASSERT(initialSize > 0); fInitialSize = initialSize; fWorkBuf = NULL; fWorkCount = fWorkMax = 0; } virtual ~ExpandBuffer(void) { if (fWorkBuf != NULL) { LOGI("ExpandBuffer: fWorkBuf not seized; freeing"); delete[] fWorkBuf; } } /* * Allocate the initial buffer. */ virtual int CreateWorkBuf(void); void Reset(void) { delete[] fWorkBuf; fWorkBuf = NULL; fWorkCount = fWorkMax = 0; } // Copy printf-formatted output into the output buffer. void Printf(_Printf_format_string_ const char* format, ...); // Write binary data to the buffer. void Write(const unsigned char* buf, long len); // Put a single character in. void Putc(char ch); // Seize control of the buffer. It will be the caller's duty to call // delete[] to free it. virtual void SeizeBuffer(char** ppBuf, long* pLen); protected: /* * Grow the buffer to the next incremental size. We keep doubling it until * we reach out maximum rate of expansion. * * Returns 0 on success, -1 on failure. */ virtual int GrowWorkBuf(void); enum { kWorkBufMaxIncrement = 4*1024*1024, // limit increase to 4MB jumps }; long fInitialSize; // initial size of the work buffer char* fWorkBuf; // work in progress long fWorkCount; // quantity of data in buffer long fWorkMax; // maximum size of buffer private: DECLARE_COPY_AND_OPEQ(ExpandBuffer) }; /* * ==================================== * Windows helpers * ==================================== */ /* * Enable or disable a control. */ void EnableControl(CDialog* pDlg, int id, bool enable=true); /* * Move a control so it maintains its same position relative to the bottom * and right edges. */ void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw = true); /* * Make a control larger by the same delta as the parent window. */ void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw = true); /* * Stretch and move a control. */ void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY, int stretchX, int stretchY, bool redraw = true); /* * Move a control so it maintains its same position relative to the bottom * and right edges. */ HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw = true); /* * Make a control larger by the same delta as the parent window. */ HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw = true); /* * Stretch and move a control. */ HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, int stretchX, int stretchY, bool redraw = true); /* * Get the check state of a button in a dialog. */ int GetDlgButtonCheck(CWnd* pWnd, int id); /* * Set the check state of a button in a dialog. */ void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal); /* * Create a font, using defaults for most things. */ void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, int pointSize); /* * Get a Win32 error string for an error code returned by GetLastError. */ void GetWin32ErrorString(DWORD err, CString* pStr); /* * Post a failure message in a message box. */ void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID); /* * Post a failure message in a message box. */ void ShowFailureMsg(CWnd* pWnd, int msgId, int titleStrID); /* * Returns "true" if we're running on Win9x (Win95, Win98, WinME), "false" * if not (could be WinNT/2K/XP or even Win31 with Win32s). */ bool IsWin9x(void); /* * Wrapper for CString::LoadString that checks the return value and logs a * complaint if the load fails. */ void CheckedLoadString(CString* pString, UINT nID); /* * ==================================== * Miscellaneous functions * ==================================== */ /* * Pull a pascal string out of a buffer and stuff it into "*pStr". * * Returns the length of the string found, or -1 on error. */ int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr); /* * Dump a block of stuff to the log file. */ void LogHexDump(const void* buf, long len); /* * Compute a percentage. */ int ComputePercent(LONGLONG part, LONGLONG full); /* * Format a time_t into a string. * * (Should take format as an argument, so we can use global format set by * user preferences.) */ void FormatDate(time_t when, CString* pStr); /* * Case-insensitive version of strstr(), pulled from the MSDN stuff that * comes with VC++6.0. * * The isalpha() stuff is an optimization, so they can skip the tolower() * in the outer loop comparison. */ const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2); /* * Break a string down into its component parts. * * "mangle" will be mangled (various bits stomped by '\0'), "argv" will * receive pointers to the strings, and "*pArgc" will hold the number of * arguments in the vector. The initial value of "*pArgc" should hold the * maximum "argv" capacity (including program name in argv[0]). * * The argv pointers will point into "mangle"; no new storage will be * allocated. */ void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc); /* * Convert parts of the Mac OS Roman filename to lower case. * * If the name already has lowercase characters, do nothing. */ void InjectLowercase(CStringA* pStr); /* * Test to see if a sub-string matches a value in a set of strings. The set * comes from a semicolon-delimited string. */ bool MatchSemicolonList(const CString set, const CString match); /* * Like strcpy(), but allocate with new[] instead. * * If "str" is NULL, or "new" fails, this returns NULL. * * TODO: this should be "StrdupNew()". */ char* StrcpyNew(const char* str); /* time_t values for bad dates */ #define kDateNone ((time_t) -2) #define kDateInvalid ((time_t) -1) // should match return from mktime() #endif /*UTIL_UTIL_H*/
26.092199
83
0.628839
[ "vector" ]
2f71c53a64a999c39718046fb0137dcb858bf8f2
514
h
C
GameEngine/QuadTree.h
laura-96/GameEngine
9bf5be938e8899d6a083041dae8b52737293f534
[ "MIT" ]
null
null
null
GameEngine/QuadTree.h
laura-96/GameEngine
9bf5be938e8899d6a083041dae8b52737293f534
[ "MIT" ]
null
null
null
GameEngine/QuadTree.h
laura-96/GameEngine
9bf5be938e8899d6a083041dae8b52737293f534
[ "MIT" ]
null
null
null
#ifndef __QuadTree_H__ #define __QuadTree_H__ #include <vector> #include "MathGeoLib/include/MathGeoLib.h" #include "Globals.h" #include "GameObject.h" #define QUADTREE_MAX_ITEMS 2 class QuadTreeNode { public: math::AABB box; std::vector<GameObject*> objects; QuadTreeNode* parent; QuadTreeNode* children[4]; public: QuadTreeNode(math::AABB limits) { box.Enclose(limits); box.Distance((*objects.begin())->GetPosition()); } }; class QuadTree { private: QuadTreeNode* root; }; #endif
11.953488
50
0.715953
[ "vector" ]
2f810cd3e50bd489052cb203681226d9b4f5cfdf
3,350
h
C
src/common/hmm/PhoneticRulesManager.h
atk-/bavieca-0014
031216739b4800285af717f22f44ecda54675139
[ "Apache-2.0" ]
null
null
null
src/common/hmm/PhoneticRulesManager.h
atk-/bavieca-0014
031216739b4800285af717f22f44ecda54675139
[ "Apache-2.0" ]
null
null
null
src/common/hmm/PhoneticRulesManager.h
atk-/bavieca-0014
031216739b4800285af717f22f44ecda54675139
[ "Apache-2.0" ]
null
null
null
/*---------------------------------------------------------------------------------------------* * Copyright (C) 2012 Daniel Bolaños - www.bltek.com - Boulder Language Technologies * * * * www.bavieca.org is the website of the Bavieca Speech Recognition Toolkit * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * *---------------------------------------------------------------------------------------------*/ #ifndef PHONETICRULESMANAGER_H #define PHONETICRULESMANAGER_H #define PHONETIC_RULE_NO 0 #define PHONETIC_RULE_YES 1 #define MAX_RULE_NAME_LENGTH 128 #include <string.h> using namespace std; #include <string> #include <vector> #include "Global.h" namespace Bavieca { class FileInput; class FileOutput; class IOBase; class PhoneSet; typedef struct { char *strName; // rule name bool *bPhone; // whether the phone is in the set of phones of the rule unsigned int iRule; // rule identifier } PhoneticRule; typedef vector<PhoneticRule*> VPhoneticRule; /** @author daniel <dani.bolanos@gmail.com> */ class PhoneticRulesManager { private: string m_strFile; // file containing phonetic rules unsigned char m_iFileFormat; // file format VPhoneticRule m_vPhoneticRule; // vector of phonetic rules PhoneSet *m_phoneSet; public: // constructor PhoneticRulesManager(const char *strFile, PhoneSet *phoneSet); // constructor PhoneticRulesManager(); // destructor ~PhoneticRulesManager(); // load the phonetic rules (text format) void load(); // store the phonetic rules (binary format) void store(FileOutput &file); // load the phonetic rules (binary format) static PhoneticRulesManager *load(FileInput &file, PhoneSet *phoneSet); // destroy the phonetic rules void destroy(); // print phonetic rules statistics void print(); // return the phonetic rules inline VPhoneticRule *getRules() { return &m_vPhoneticRule; } // return a phonetic rule by its index inline PhoneticRule *getRule(unsigned int iIndex) { return m_vPhoneticRule[iIndex]; } }; }; // end-of-namespace #endif
31.603774
97
0.524776
[ "vector" ]
2f8916334114ddc5dc8b5d2b5ee2206184f846f6
12,037
c
C
new/libr/cons/canvas_line.c
benbenwt/lisa_docker
0b851223dbaecef9b27c418eae05890fea752d49
[ "Apache-2.0" ]
null
null
null
new/libr/cons/canvas_line.c
benbenwt/lisa_docker
0b851223dbaecef9b27c418eae05890fea752d49
[ "Apache-2.0" ]
1
2021-12-17T00:14:27.000Z
2021-12-17T00:14:27.000Z
new/libr/cons/canvas_line.c
benbenwt/lisa_docker
0b851223dbaecef9b27c418eae05890fea752d49
[ "Apache-2.0" ]
null
null
null
/* radare - LGPL - Copyright 2013-2021 - pancake */ #include <r_cons.h> #define W(y) r_cons_canvas_write(c,y) #define G(x,y) r_cons_canvas_gotoxy(c,x,y) #define useUtf8 (r_cons_singleton ()->use_utf8) #define useUtf8Curvy (r_cons_singleton ()->use_utf8_curvy) #define DOTTED_LINE_HORIZ "┄" #define DOTTED_LINE_VERT "┊" #define DASHED_LINE_VERT "╵" #define DASHED_LINE_HORIZ "╴" enum { APEX_DOT = 0, DOT_APEX, REV_APEX_APEX, DOT_DOT, NRM_DOT, NRM_APEX, DOT_NRM, REV_APEX_NRM, NRM_NRM }; static char* utf8_line_vert (int dot_style) { if (r_cons_singleton ()->dotted_lines) { switch (dot_style) { case DOT_STYLE_NORMAL: return RUNECODESTR_LINE_VERT; case DOT_STYLE_CONDITIONAL: return DOTTED_LINE_VERT; case DOT_STYLE_BACKEDGE: return DASHED_LINE_VERT; } } return RUNECODESTR_LINE_VERT; } static char* utf8_line_horiz (int dot_style) { if (r_cons_singleton ()->dotted_lines) { switch (dot_style) { case DOT_STYLE_NORMAL: return RUNECODESTR_LINE_HORIZ; case DOT_STYLE_CONDITIONAL: return DOTTED_LINE_HORIZ; case DOT_STYLE_BACKEDGE: return DASHED_LINE_HORIZ; } } return RUNECODESTR_LINE_HORIZ; } static void apply_line_style(RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style, int isvert) { RCons *cons = r_cons_singleton (); switch (style->color) { case LINE_UNCJMP: c->attr = cons->context->pal.graph_trufae; break; case LINE_TRUE: c->attr = cons->context->pal.graph_true; break; case LINE_FALSE: c->attr = cons->context->pal.graph_false; break; case LINE_NONE: default: c->attr = cons->context->pal.graph_trufae; break; } if (!c->color) { c->attr = Color_RESET; } if (style->ansicolor) { c->attr = style->ansicolor; } switch (style->symbol) { case LINE_UNCJMP: if (G (x, y)) { if (isvert) { W ("v"); } else { W (">"); } } break; case LINE_TRUE: if (G (x, y)) { W ("t"); //\\"); } break; case LINE_FALSE: if (G (x, y)) { W ("f"); } break; case LINE_NOSYM_VERT: if (G (x, y)) { W (useUtf8 ? utf8_line_vert (style->dot_style) : "|"); } break; case LINE_NOSYM_HORIZ: if (G (x, y)) { W (useUtf8 ? utf8_line_horiz (style->dot_style) : "-"); } break; case LINE_NONE: default: break; } } static void draw_horizontal_line (RConsCanvas *c, int x, int y, int width, int style, int dot_style) { const char *l_corner = "?", *r_corner = "?"; int i; if (width < 1) { return; } /* do not render offscreen horizontal lines */ if (y + c->sy < 0) { return; } if (y + c->sy > c->h) { return; } switch (style) { case APEX_DOT: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_BL; r_corner = RUNECODESTR_CURVE_CORNER_TR; } else { l_corner = RUNECODESTR_CORNER_BL; r_corner = RUNECODESTR_CORNER_TR; } } else { l_corner = "'"; r_corner = "."; } break; case DOT_APEX: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_TL; r_corner = RUNECODESTR_CURVE_CORNER_BR; } else { l_corner = RUNECODESTR_CORNER_TL; r_corner = RUNECODESTR_CORNER_BR; } } else { l_corner = "."; r_corner = "'"; } break; case REV_APEX_APEX: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_BL; r_corner = RUNECODESTR_CURVE_CORNER_BR; } else { l_corner = RUNECODESTR_CORNER_BL; r_corner = RUNECODESTR_CORNER_BR; } } else { l_corner = "`"; r_corner = "'"; } break; case DOT_DOT: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_TL; r_corner = RUNECODESTR_CURVE_CORNER_TR; } else { l_corner = RUNECODESTR_CORNER_TL; r_corner = RUNECODESTR_CORNER_TR; } } else { l_corner = r_corner = "."; } break; case NRM_DOT: if (useUtf8) { l_corner = utf8_line_horiz (dot_style); if (useUtf8Curvy) { r_corner = RUNECODESTR_CURVE_CORNER_TR; } else { r_corner = RUNECODESTR_CORNER_TR; } } else { l_corner = "-"; r_corner = "."; } break; case NRM_APEX: if (useUtf8) { l_corner = utf8_line_horiz (dot_style); if (useUtf8Curvy) { r_corner = RUNECODESTR_CURVE_CORNER_BR; } else { r_corner = RUNECODESTR_CORNER_BR; } } else { l_corner = "-"; r_corner = "'"; } break; case DOT_NRM: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_TL; } else { l_corner = RUNECODESTR_CORNER_TL; } r_corner = utf8_line_horiz (dot_style); } else { l_corner = "."; r_corner = "-"; } break; case REV_APEX_NRM: if (useUtf8) { if (useUtf8Curvy) { l_corner = RUNECODESTR_CURVE_CORNER_BL; } else { l_corner = RUNECODESTR_CORNER_BL; } r_corner = utf8_line_horiz (dot_style); } else { l_corner = "`"; r_corner = "-"; } break; case NRM_NRM: default: if (useUtf8) { l_corner = r_corner = utf8_line_horiz (dot_style); } else { l_corner = r_corner = "-"; } break; } if (G (x, y)) { W (l_corner); } const char *hline = useUtf8 ? utf8_line_horiz (dot_style) : "-"; r_cons_break_push (NULL, NULL); for (i = x + 1; i < x + width - 1; i++) { if (r_cons_is_breaked ()) { break; } if (G (i, y)) { W (hline); } } r_cons_break_pop (); if (G (x + width - 1, y)) { W (r_corner); } } static void draw_vertical_line(RConsCanvas *c, int x, int y, int height, int dot_style) { int i; /* do not render offscreen vertical lines */ if (x + c->sx < 0) { return; } if (x + c->sx > c->w) { return; } const char *vline = useUtf8 ? utf8_line_vert (dot_style) : "|"; r_cons_break_push (NULL, NULL); for (i = y; i < y + height; i++) { if (r_cons_is_breaked ()) { break; } if (G (x, i)) { W (vline); } } r_cons_break_pop (); } R_API void r_cons_canvas_line_diagonal(RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style) { if (x == x2 || y == y2) { style->dot_style = DOT_STYLE_NORMAL; r_cons_canvas_line_square (c, x, y +1, x2, y2, style); return; } apply_line_style (c, x, y, x2, y2, style, 1); if (y2 < y) { int tmp = y2; y2 = y; y = tmp; tmp = x2; x2 = x; x = tmp; } char chizzle[2] = {0}; // = '.';//my nizzle // destination int dx = abs (x2-x); int dy = abs (y2-y); // source int sx = (x < x2) ? 1 : -1; int sy = (y < y2) ? 1 : -1; int err = (dx > (dy?dx:-dy)) / 2; int e2; // TODO: find if there's any collision in this line loop: e2 = err; if (e2 > -dx) { *chizzle = '_'; err -= dy; x+=sx; } if (e2 < dy) { *chizzle='|'; err += dx; y += sy; } if ((e2 < dy) && (e2 > -dx)) { if (sy > 0) { *chizzle = (sx > 0)?'\\':'/'; } else { *chizzle = (sx > 0)?'/':'\\'; } } if (!(x == x2 && y == y2)) { int i = (*chizzle == '_' && sy < 0) ? 1 : 0; if (G(x, y - i)) { if (useUtf8) { switch (*chizzle) { case '/': W("╯"); break; case '\\': W("└"); break; case '|': W("│"); break; case '_': W("─"); break; default: W("?"); break; } } else { W(chizzle); } } goto loop; } if (dx) { if (dy && (dx / dy) < 1) { if (G(x, y)) { W("|"); } } if (G(x, y + 1)) { W("|"); } } c->attr = Color_RESET; } R_API void r_cons_canvas_line_square (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style) { int min_x = R_MIN (x, x2); int diff_x = R_ABS (x - x2); int diff_y = R_ABS (y - y2); apply_line_style (c, x, y, x2, y2, style, 1); // -- // TODO: find if there's any collision in this line if (y2 - y > 1) { int hl = diff_y / 2 - 1; int hl2 = diff_y - hl; int w = diff_x == 0 ? 0 : diff_x + 1; int apex_style = min_x == x ? APEX_DOT : DOT_APEX; draw_vertical_line (c, x, y + 1, hl, style->dot_style); draw_vertical_line (c, x2, y + hl + 1, hl2, style->dot_style); draw_horizontal_line (c, min_x, y + hl + 1, w, apex_style, style->dot_style); } else { if (y2 == y) { draw_horizontal_line (c, min_x, y, diff_x + 1, DOT_DOT, style->dot_style); } else { if (x != x2) { draw_horizontal_line (c, min_x, y, diff_x + 1, REV_APEX_APEX, style->dot_style); } draw_vertical_line (c, x2, y2, diff_y, style->dot_style); } } c->attr = Color_RESET; } R_API void r_cons_canvas_line_square_defined (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style, int bendpoint, int isvert) { if (!c->linemode) { r_cons_canvas_line (c, x, y, x2, y2, style); return; } int min_x = R_MIN (x, x2); int diff_x = R_ABS (x - x2); int diff_y = R_ABS (y - y2); int min_y = R_MIN (y, y2); apply_line_style (c, x, y, x2, y2, style, isvert); if (isvert) { if (x2 == x) { draw_vertical_line (c, x, y + 1, diff_y + 1, style->dot_style); } else if (y2 - y > 1) { int h1 = 1 + bendpoint; int h2 = diff_y - h1; int w = diff_x == 0 ? 0 : diff_x + 1; int apex_style = min_x == x ? APEX_DOT : DOT_APEX; draw_vertical_line (c, x, y + 1, h1, style->dot_style); draw_horizontal_line (c, min_x, y + bendpoint + 2, w, apex_style, style->dot_style); draw_vertical_line (c, x2, y + h1 + 1 + 1, h2, style->dot_style); } else { //TODO: currently copy-pasted if (y2 == y) { draw_horizontal_line (c, min_x, y, diff_x + 1, DOT_DOT, style->dot_style); } else { if (x != x2) { draw_horizontal_line (c, min_x, y, diff_x + 1, REV_APEX_APEX, style->dot_style); } draw_vertical_line (c, x2, y2, diff_y-2, style->dot_style); } } } else { if (y2 == y) { draw_horizontal_line (c, min_x + 1, y, diff_x, NRM_NRM, style->dot_style); } else if (x2 - x > 1) { int w1 = 1 + bendpoint; int w2 = diff_x - w1; //int h = diff_x;// == 0 ? 0 : diff_x + 1; //int style = min_x == x ? APEX_DOT : DOT_APEX; //draw_vertical_line (c, x, y + 1, h1); draw_horizontal_line (c, x + 1, y, w1 + 1, y2 > y ? NRM_DOT : NRM_APEX, style->dot_style); //draw_horizontal_line (c, min_x, y + bendpoint + 2, w, style); draw_vertical_line (c, x + 1 + w1, min_y + 1, diff_y - 1, style->dot_style); //draw_vertical_line (c, x2, y + h1 + 1 + 1, h2); draw_horizontal_line (c, x + 1 + w1, y2, w2, y2 < y ? DOT_NRM : REV_APEX_NRM, style->dot_style); } } c->attr = Color_RESET; } R_API void r_cons_canvas_line_back_edge (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style, int ybendpoint1, int xbendpoint, int ybendpoint2, int isvert) { if (!c->linemode) { r_cons_canvas_line (c, x, y, x2, y2, style); return; } int min_x1 = R_MIN (x, xbendpoint); int min_x2 = R_MIN (x2, xbendpoint); int diff_x1 = R_ABS (x - xbendpoint); int diff_x2 = R_ABS (x2 - xbendpoint); int diff_y = R_ABS ((y + ybendpoint1 + 1) - (y2 - ybendpoint2- 1)); int w1 = diff_x1 == 0 ? 0 : diff_x1 + 1; int w2 = diff_x2 == 0 ? 0 : diff_x2 + 1; apply_line_style (c, x, y, x2, y2, style, isvert); if (isvert) { draw_vertical_line (c, x, y + 1, ybendpoint1 + 1, style->dot_style); draw_horizontal_line (c, min_x1, y + ybendpoint1 + 2, w1, REV_APEX_APEX, style->dot_style); draw_vertical_line (c, xbendpoint, y2 - ybendpoint2 + 1, diff_y - 1, style->dot_style); draw_horizontal_line (c, min_x2, y2 - ybendpoint2, w2, DOT_DOT, style->dot_style); draw_vertical_line (c, x2, y2 - ybendpoint2 + 1, ybendpoint2 + 1, style->dot_style); } else { int miny1 = R_MIN (y, xbendpoint); int miny2 = R_MIN (y2, xbendpoint); int diff_y1 = R_ABS (y - xbendpoint); int diff_y2 = R_ABS (y2 - xbendpoint); draw_horizontal_line (c, x + 1, y, 1 + ybendpoint1 + 1, xbendpoint > y ? NRM_DOT : NRM_APEX, style->dot_style); draw_vertical_line (c, x + 1 + ybendpoint1 + 1, miny1 + 1, diff_y1 - 1, style->dot_style); draw_horizontal_line (c, x2 - ybendpoint2, xbendpoint, (x + 1 + ybendpoint1 + 1) - (x2 - ybendpoint2) + 1, xbendpoint > y ? REV_APEX_APEX : DOT_DOT, style->dot_style); draw_vertical_line (c, x2 - ybendpoint2, miny2 + 1, diff_y2 - 1, style->dot_style); draw_horizontal_line (c, x2 - ybendpoint2, y2, ybendpoint2 + 1, xbendpoint > y ? DOT_NRM : REV_APEX_NRM, style->dot_style); } }
24.465447
175
0.608208
[ "render" ]
2f90daaab7d0137eed9954cf93da9728d551d1c6
5,457
h
C
Header/DYHeader/DYHeader.h
Deng11Sc/publicManager
8f387eb19fba0dd8298d8976b394a323f6c53532
[ "MIT" ]
null
null
null
Header/DYHeader/DYHeader.h
Deng11Sc/publicManager
8f387eb19fba0dd8298d8976b394a323f6c53532
[ "MIT" ]
null
null
null
Header/DYHeader/DYHeader.h
Deng11Sc/publicManager
8f387eb19fba0dd8298d8976b394a323f6c53532
[ "MIT" ]
null
null
null
// // DYHeader.h // MerryS // // Created by SongChang on 2018/1/8. // Copyright © 2018年 SongChang. All rights reserved. // #ifndef DYHeader_h #define DYHeader_h #define CC_Height CGRectGetHeight([[UIScreen mainScreen] bounds]) #define CC_Width CGRectGetWidth([[UIScreen mainScreen] bounds]) #define CC_SCREEN_MIN MIN(CC_Height,CC_Width) #define CC_SCREEN_MAX MAX(CC_Height,CC_Width) /** 定义版本判定 */ #define iOS7_Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f) #define iOS8_Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) #define iOS9_Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f) #define iOS9_1_Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f) #define iOS10_Later ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) #define iOS11_Later ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) /* * 适配坐标 , 以(375, 667)为基准 */ #define selfWidthRate ([UIScreen mainScreen].bounds.size.width / 375.0) #define selfHeightRate ([UIScreen mainScreen].bounds.size.height / 667.0) #define DYRate(rect) CGRectMake(rect.origin.x *selfWidthRate, rect.origin.y *selfHeightRate, rect.size.width *selfWidthRate, rect.size.height *selfHeightRate) #define DYRate_X(x) selfWidthRate *x #define DYRate_Y(y) selfHeightRate *y #define DYRate_Width(w) selfWidthRate *w #define DYRate_height(h) selfHeightRate *h ///颜色,不透明 #define kUIColorFromRGB(rgbValue) \ [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0] ///颜色,加透明度 #define kUIColorFromRGB_Alpa(rgbValue, alpa) \ [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:alpa] //当前版本号 #define kCurrentSystemVersion [NSString stringWithFormat:@"%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] /** 用户设备的id */ #define nn_udid [[[[UIDevice currentDevice] identifierForVendor] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""] #define CC_CurrentVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] #ifndef __OPTIMIZE__ #define NSLog(...) NSLog(__VA_ARGS__) #else #define NSLog(...) ; #endif /// #ifndef weakify #if DEBUG #if __has_feature(objc_arc) #define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object; #else #define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object; #endif #else #if __has_feature(objc_arc) #define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object; #else #define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object; #endif #endif #endif #ifndef strongify #if DEBUG #if __has_feature(objc_arc) #define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object; #else #define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object; #endif #else #if __has_feature(objc_arc) #define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object; #else #define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object; #endif #endif #endif #define AVOSCloudId @"5ac868f54773f7005d7590e3" #define SELF_USER_ID [NSString isEmptyString:[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-uniqueId"]]?@"":[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-uniqueId"] #define SELF_USER_NAME [NSString isEmptyString:[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-nickName"]]?@"":[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-nickName"] #define SELF_USER_IMAGEURL [NSString isEmptyString:[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-imageUrl"]]?@"":[[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo-imageUrl"] #define CC_EMPTY(str1) ([NSString isEmptyString:str1]?@"":str1) #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "DYUIHeader.h" #import "UIView+Configure.h" #import "MBProgressHUD.h" #import "UIView+Support.h" #import "NSObject+Warning.h" #import "UIResponder+Router.h" #import "NSString+Common.h" #import "CCUploadManager.h" //需要pod依赖的全局变量 #import <MJRefresh/MJRefresh.h> #import <AVOSCloud/AVOSCloud.h> #import <Masonry/Masonry.h> #import "UIImageView+WebCache.h" //需要pod依赖才不会报错的依赖 #import "CC_LeanCloudNet.h" #import "CCLeanCloudUrl.h" #import "NSObject+FMDB.h" #define DYLocalizedString(key, comment) NSLocalizedStringFromTable(key,@"InfoPlist", comment) /* pod 'IQKeyboardManager' pod 'SDWebImage', '~>3.8' pod 'AFNetworking', '~> 3.0' pod 'Masonry' pod 'FMDB' pod 'MJExtension' pod 'MJRefresh' pod 'MBProgressHUD', '~> 1.0.0' pod 'AVOSCloud' # 数据存储、短信、云引擎调用等基础服务模块 pod 'WebViewJavascriptBridge', git: 'https://github.com/HYC192/WebViewJavascriptBridge.git' pod 'TOCropViewController', git: 'https://github.com/liu3619376/TOCropViewController.git' pod 'JPush' pod "Qiniu", "~> 7.1" */ #endif /* DYHeader_h */
36.139073
203
0.714862
[ "object" ]
2fa4e5fc91670cb6af2fd678166a04dd138d36e9
1,889
h
C
include/renderer/VertexBuffer2D.h
jjerome/Niski
58bcc1303cdb6676c051d55e9d7a248dfea65cde
[ "MIT" ]
1
2017-09-19T16:33:06.000Z
2017-09-19T16:33:06.000Z
include/renderer/VertexBuffer2D.h
jjerome/Niski
58bcc1303cdb6676c051d55e9d7a248dfea65cde
[ "MIT" ]
null
null
null
include/renderer/VertexBuffer2D.h
jjerome/Niski
58bcc1303cdb6676c051d55e9d7a248dfea65cde
[ "MIT" ]
null
null
null
#ifndef __RENDERER_VERTEXBUFFER2D_H__ #define __RENDERER_VERTEXBUFFER2D_H__ #include <vector> #include "utils/Color.h" #include "math/Rectangle.h" #include "renderer/Renderer.h" #include "renderer/VertexBuffer2D.h" #ifdef ENABLE_DIRECTX # include <d3d9.h> # include <d3d9types.h> #endif #if defined(_WIN32) || defined(_WIN64) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include <windows.h> #endif namespace Niski { namespace Renderer { class VertexBuffer2D { public: struct VertexFormat2D { float x, y, z, rhw; uint32_t color; float u, v; }; enum PrimitiveType { invalidPrimitiveType = 0, pointList, lineList, lineStrip, triangleList, triangleStrip, triangleFan }; public: static const int32_t FVF; static const int32_t maxVerts = 256; public: VertexBuffer2D(void); ~VertexBuffer2D(void); void pushVertex(int32_t x, int32_t y, float u = 0.0f, float v = 0.0f); void pushVertex(float x, float y, float u = 0.0f, float v = 0.0f); void pushVertex(double x, double y, float u = 0.0f, float v = 0.0f); void pushTexturedRectangle(Niski::Math::Rect2D& rect, float u, float v, float u2, float v2); void pushRectangle(Niski::Math::Rect2D& rect); void setColor(const Niski::Utils::Color& color); Niski::Utils::Color getColor(void) const; size_t numVertices(void); VertexFormat2D* getFirstVertex(void); void flushVertices(void); void setPrimitiveType(PrimitiveType primitiveType) { primitiveType_ = primitiveType; } PrimitiveType getPrimitiveType(void) const { return primitiveType_; } void render(Niski::Renderer::Renderer& renderer); private: int16_t vertexCount_; VertexFormat2D vertices_[maxVerts]; PrimitiveType primitiveType_; Niski::Utils::Color color_; }; } } #endif
22.488095
98
0.690312
[ "render", "vector" ]
2fa4fcf02494b613de931784c9b2114bdbeb4ca5
18,200
h
C
SocketClient/FYClient.h
mikhailmulyar/SocketClient
54c2ef1e338fc39c7321172dfa0101cf50cd8aa7
[ "MIT" ]
null
null
null
SocketClient/FYClient.h
mikhailmulyar/SocketClient
54c2ef1e338fc39c7321172dfa0101cf50cd8aa7
[ "MIT" ]
null
null
null
SocketClient/FYClient.h
mikhailmulyar/SocketClient
54c2ef1e338fc39c7321172dfa0101cf50cd8aa7
[ "MIT" ]
null
null
null
// // FYClient.h // SocketClient // // Created by Marius Rackwitz on 07.05.13. // Copyright (c) 2013 Marius Rackwitz. All rights reserved. // // // The MIT License // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // /** @refs // [45] http://svn.cometd.com/trunk/bayeux/bayeux.html#toc_45 */ #import <Foundation/Foundation.h> #import "FYClientDelegate.h" #import "FYError.h" #import "FYMessage.h" #import "SRWebSocket.h" /** Bayeux protocol meta channels */ const struct FYMetaChannels { __unsafe_unretained NSString *Handshake; __unsafe_unretained NSString *Connect; __unsafe_unretained NSString *Disconnect; __unsafe_unretained NSString *Subscribe; __unsafe_unretained NSString *Unsubscribe; } FYMetaChannels; /** Relevant Bayeux connection types */ const struct FYConnectionTypes { __unsafe_unretained NSString *LongPolling; // Fallback - should be implemented, is actually not __unsafe_unretained NSString *CallbackPolling; // Not implemented __unsafe_unretained NSString *WebSocket; // Implemented } FYConnectionTypes; extern NSArray *FYSupportedConnectionTypes(); /** Default reconnect interval on `message.attempt.reconnect = retry` if no "interval" attempt was given by the server. */ extern const NSTimeInterval FYClientRetryTimeInterval; /** Default reconnect interval on web socket connection lost. This time is waited by default until a new connect try occurs. */ extern const NSTimeInterval FYClientReconnectTimeInterval; /** Callback for successful connection. */ typedef void(^FYClientConnectSuccessBlock)(FYClient *); /** Callback for user-defined channel subscriptions. */ typedef void(^FYMessageCallback)(NSDictionary *userInfo); /** The FYClient object is used to setup and manage requests to servers using the Bayeux protocol. This class provides helper methods that simplify the connection, response and subscription handling. The client implementation is atleast conditionally compliant by satisfying all MUST or REQUIRED level requirements as specified in [The Bayeux Specification](http://svn.cometd.com/trunk/bayeux/bayeux.html). */ @interface FYClient : NSObject /** Base URL to which the underlying web socket connection will be connected. */ @property (nonatomic, retain, readonly) NSURL *baseURL; /** [FYMessage clientId] which was received by Bayeux handshake. */ @property (nonatomic, retain, readonly) NSString *clientId; /** Flag for behavior of connectOnSuccess:. If property's value is YES, then the client wait for successful connect of the socket connection. If property's value is NO, then the client will send the Bayeux handshake message while establishing the socket connection and could use an own HTTP-POST connection as documented in the sequence chart. This can cause problems with some server implementations. Default is YES. */ @property (nonatomic, assign) BOOL maySendHandshakeAsync; /** Flag for behavior of connectOnSuccess:. If property's value is NO, then the client wait for successful confirmation of the Bayeux connect message and then executes the success block. If property's value is YES, the client will execute success block on success of the Bayeux handshake message. This can speed up the connection process. Default is YES. */ @property (nonatomic, assign) BOOL awaitOnlyHandshake; /** Check if client is connected */ @property (nonatomic, assign, readonly, getter=isConnected) BOOL connected; /** Check if a client is reconnecting, currently. If there was already a reconnect, which failed on socket layer (or on any other way without receiving a Bayeux connect answer), then the re-subscript success handlers can got chained internally. This can cause multiple channel subscription messages. These will not be neccessary and would not cause any errors, but they could cause some more latency, theoretically. This is avoided by using this property value, internally. */ @property (nonatomic, assign, readonly, getter=isReconnecting) BOOL reconnecting; /** Last received or last modified retryTimeInterval to be used between the receive of a successful connect message and a new request on the channel /meta/connect. */ @property (nonatomic, assign) NSTimeInterval retryTimeInterval; /** Reconnect interval on web socket connection lost. This time is waited by default until a new connect try occurs. A negative value will disable all reconnect tries when connection was lost. */ @property (nonatomic, assign) NSTimeInterval reconnectTimeInterval; /** Delegate to handle state transitions and errors, should be set direct after initialization of an <FYClient> object. */ @property (nonatomic, weak) id<FYClientDelegate> delegate; /** Dispatch queue on which delegate calls are executed. */ @property (nonatomic) dispatch_queue_t delegateQueue; /** Dispatch queue on which callback block call are executed. */ @property (nonatomic) dispatch_queue_t callbackQueue; /** All subscripted channels */ @property (nonatomic, copy, readonly) NSArray *subscriptedChannels; /** Underlying web socket implementation */ @property (nonatomic, retain, readonly) SRWebSocket* webSocket; /** Initializer Initialize a new instance with a fixed base URL. @param baseURL server URL whose scheme has to fulfill ```/ws(s)?|http(s)?/```. */ - (id)initWithURL:(NSURL *)baseURL; /** Calling persist will cause that the client must not be retained by yourself until a explicit disconnect occurs. */ - (id)persist; /** Open a web socket connection and connect the receiver to its bound server. This will be used after an instance of 'FYClient' was initialized and its 'delegate' property was set, e.g: FYClient* client = [[FYClient alloc] initWithURL:[NSURL URLWithString:"ws://localhost:8000/faye"]]; client.delegate = self; [client connect]; Internal the following steps will be done to establish a connection: ┌──────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ BC ----------- I ----------- U ----------- P ----------- O ----------- BS │ │ ┆ ┆ ┆ ┆ ┆ ┆ │ │ (1) ╟───close────>║ ┆ ┆ ┆ ┆ │ │ ║ ~ wait ┆ ┆ ┆ ┆ │ │ ║   <───╢ ┆ ┆ ┆ ┆ │ │ (2) ╟─reset ┆ ┆ ┆ ┆ ┆ │ │ ║ ┆ ┆ ┆ ┆ ┆ │ │ (3) ╟╌╌╌╌open╌╌╌╌>║ ┆ ┆ ┆ ┆ │ │ ║ ╟╌╌╌╌╌╌╌╌╌╌╌╌req(upgrade):GET╌╌╌╌╌╌╌╌╌╌╌╌>║ ┆ │ │ ║ ║ ┆ ┆ ║ ┆ │ │ ║ ║ ┆ ┆ ║ ┆ │ │ ║ ║ ┆ ┆ ║ ┆ │ │ (6) ╟╌╌╌╌╌╌╌╌m(handshk)╌╌╌╌╌╌╌╌>║ ┆ ║ ┆ │ │ ║ ║ ╟╌╌╌req(m(handshk)):POST╌╌>╓║ ┆ │ │ ║ ║ ║ ┆ ╟╫─m(handshk)─>║ │ │ ║ ║ ║ ┆ ║║ ║ │ │ ~ ~ ~ ~ ~ ~ wait │ │ ║ ║ ║ ┆ ║║ ║ │ │ (4) ║ ╟<╌╌╌╌╌╌╌╌╌╌╌res(upgrade):101╌╌╌╌╌╌╌╌╌╌╌╌║╢ ║ │ │ ║ ║ ║ ┆ ║║ ║ │ │ (5) ╟<──confirm───╢ ║ ┆ ║║ ║ │ │ ║ ║ ║ ┆ ║║ ║ │ │ ║ ║ ║ ┆ ╟<──m(success)─╢ │ │ ║ ║ ╟<╌╌res(m(handshk,1)):200╌╌╢║ ║ │ │ (7) ╟<───────m(success)─────────╢ ┆ ╙║ ║ │ │ ║ ║ ┆ ┆ ║ ║ │ │ (8) ╟─m(connect)─>║ ┆ ┆ ║ ┆ │ │ ║ ╟╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌m(connect)╌╌╌╌╌╌╌╌╌╌╌╌╌╌>║ ┆ │ │ ║ ║ ┆ ┆ ╟─m(connect)─>║ │ │ ║ ║ ┆ ┆ ║ ║ │ │ ~ ~ ~ ~ ~ ~ wait │ │ ║ ║ ┆ ┆ ║ ║ │ │ ║ ║ ┆ ┆ ╟<─m(success)─╢ │ │ ║ ╟<╌╌╌╌╌╌╌╌╌╌╌╌╌╌m(connect,1)╌╌╌╌╌╌╌╌╌╌╌╌╌╌╢ ║ │ │ (9) ╟<─m(success)─╢ ┆ ┆ ║ ║ │ │ ║ ║ ┆ ┆ ║ ║ │ │ │ └──────────────────────────────────────────────────────────────────────────────────────────┘ #### Entities: BC: Bayeux client I: Web socket implementation (SocketRocket) U: HTTP User Agent implementation (Foundation) P: Proxy O: Origin server BS: Bayeux server  : No one #### Graphical syntax: ╌╌╌>: Asynchronous ───>: Synchronous ┆: No process ║: Process #### Steps: 1. Close any existing web socket connection 2. Reset client's internal state information 3. Open a new web socket connection with underlying implementation GET /faye HTTP/1.1 Host: <HOST>:<PORT> Origin: http://<HOST>:<PORT> Sec-WebSocket-Key: YSBrZXkgdG9rZW4= Upgrade: websocket Connection: Upgrade Sec-WebSocket-Version: <VERSION> 4. Underlying web socket implementation await that connection was opened by origin server HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: c29tZSBhY2NlcHQgdG9rZW4= 5. Client await confirmation that connection was opened by underlying web socket implementation [SRWebSocketDelegate webSocketDidOpen:] 6. Send handshake to the Bayeux server [{ "channel": "handshake", "supportedConnectionTypes": [ "websocket", ... 7. Await successful confirmation of handshake message [{ "channel": "handshake", "successful": 1, ... 8. Send connect when 5. and 7. were confirmed. (They run in parallel.) [{ "channel": "connect", "connectionType": "websocket", ... 9. Await successful confirmation of connect message [{ "channel": "connect", "successful": 1, ... */ - (void)connect; /** Open a web socket connection and connect the receiver to its bound server with an extension object. Extended variant of `connect`. @param extension An extension as an arbitrary JSON encodeable object according to [`ext` documentation][45]. If argument is 'nil', then this method will do the same as [FYClient connect]. */ - (void)connectWithExtension:(NSDictionary *)extension; /** Open a web socket connection and connect the receiver to its bound server with an extension object and a block which is executed on success. Extended variant of `connect`. @param block Will be asynchronically called on success of operation. Receiver is given as argument to the block. Will be executed on callbackQueue. */ - (void)connectOnSuccess:(FYClientConnectSuccessBlock)block; /** Open a web socket connection and connect the receiver to its bound server with an extension object and a block which is executed on success. Extended variant of `connect`. @param extension An extension as an arbitrary JSON encodeable object according to If argument is 'nil', then this method will do the same as [FYClient connectOnSuccess:]. @param block Will be asynchronically called on success of operation. Receiver is given as argument to the block. Will be executed on callbackQueue. */ - (void)connectWithExtension:(NSDictionary *)extension onSuccess:(FYClientConnectSuccessBlock)block; /** Disconnect an instance from its bound server and closes its underlying web socket connection. */ - (void)disconnect; /** Reconnect could be used to try to establish the connection state before the last disconnect. This includes to re-subscript all prior subscripted channels. The channel callbacks are kept. The reconnect implementation is using connectWithExtension:onSuccess:, internally. It uses the given connectionExtension. On success it will re-subscript all prior subscripted channels (as returned by subscriptedChannels). The same channel callbacks will be kept. But this implementation will not re-execute the connect success handler, which was maybe given originally. If you would do a repetive initialization, which is not bound to incoming messages, then you should place it in your implementation of [FYClientDelegate clientConnected:] which is guarenteed to be called on each connect, also on reconnect. */ - (void)reconnect; /** Register interest in a channel and request that messages published to that channel are delivered to receiver. @param channel Subscribe to a channel name or a channel pattern @param callback Will be called on receive of a message on given `channel` on main thread */ - (void)subscribeChannel:(NSString *)channel callback:(FYMessageCallback)callback; /** Register interest in a channel and request that messages published to that channel are delivered to receiver. @param channel Subscribe to a channel name or a channel pattern @param callback Will be called on receive of a message on given `channel` on main thread @param extension An extension as an arbitrary JSON encodeable object according to [`ext` documentation][45]. */ - (void)subscribeChannel:(NSString *)channel callback:(FYMessageCallback)callback extension:(NSDictionary *)extension; /** Register interest in a channel and request that messages published to that channel are delivered to receiver. @param channels Subscribe to an array of channel names and channel patterns @param callback Will be called on receive of a message on given 'channel' on main thread */ - (void)subscribeChannels:(NSArray *)channels callback:(FYMessageCallback)callback; /** Register interest in a channel and request that messages published to that channel are delivered to receiver. @param channels Subscribe to an array of channel names and channel patterns @param callback Will be called on receive of a message on given 'channel' on main thread @param extension An extension as an arbitrary JSON encodeable object according to [`ext` documentation][45]. */ - (void)subscribeChannels:(NSArray *)channels callback:(FYMessageCallback)callback extension:(NSDictionary *)extension; /** Cancel interest in a channel and request that messages published to that channel are not delivered. @param channel Subscribe to a channel name or a channel pattern */ - (void)unsubscribeChannel:(NSString *)channel; /** Cancel interest in a channel and request that messages published to that channel are not delivered. @param channels Subscribe to an array of channel names and channel patterns */ - (void)unsubscribeChannels:(NSArray *)channels; /** Cancel interest in all channels and request that messages published to that channels are not delivered. */ - (void)unsubscribeAll; /** Publish events on a channel by sending event messages. A publish message COULD with this implementation NOT be sent from an unconnected client. @param userInfo The message as an arbitrary JSON encodeable object @param channel Subscribe to a channel name or a channel pattern */ - (void)publish:(NSDictionary *)userInfo onChannel:(NSString *)channel; /** Publish events on a channel by sending event messages with an extension object. A publish message COULD with this implementation NOT be sent from an unconnected client. @param userInfo The message as an arbitrary JSON encodeable object @param channel Subscribe to a channel name or a channel pattern @param extension An extension as an arbitrary JSON encodeable object according to [`ext` documentation][45]. */ - (void)publish:(NSDictionary *)userInfo onChannel:(NSString *)channel withExtension:(NSDictionary *)extension; @end
40.807175
119
0.604011
[ "object" ]
2fba28b9c5627c65b0aabfb434ec375b5ddc08d3
2,588
h
C
Common/Foundation/Exception/ApplicationException.h
achilex/MgDev
f7baf680a88d37659af32ee72b9a2046910b00d8
[ "PHP-3.0" ]
2
2017-04-19T01:38:30.000Z
2020-07-31T03:05:32.000Z
Common/Foundation/Exception/ApplicationException.h
achilex/MgDev
f7baf680a88d37659af32ee72b9a2046910b00d8
[ "PHP-3.0" ]
null
null
null
Common/Foundation/Exception/ApplicationException.h
achilex/MgDev
f7baf680a88d37659af32ee72b9a2046910b00d8
[ "PHP-3.0" ]
1
2021-12-29T10:46:12.000Z
2021-12-29T10:46:12.000Z
// // Copyright (C) 2004-2011 by Autodesk, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // #ifndef MG_APPLICATION_EXCEPTION_H_ #define MG_APPLICATION_EXCEPTION_H_ /// \ingroup Exceptions_Module /////////////////////////////////////////////////////////////////////////////// /// \brief /// Base class for all exceptions representing an application error. /// /// \remarks /// This exception is not thrown directly. /// Instead an exception derived from it is used, such as /// MgConnectionFailedException. /// class MG_FOUNDATION_API MgApplicationException : public MgException { EXTERNAL_API: /////////////////////////////////////////////////////////////////////////// /// \brief /// Destructor for a MgApplicationException object. /// virtual ~MgApplicationException() throw(); protected: /////////////////////////////////////////////////////////////////////////// /// \brief /// Construct a MgApplicationException object. /// /// \param methodName /// Name of the method where the exception occurred. /// \param lineNumber /// Line number where the exception occurred. /// \param fileName /// File name where the exception occurred. /// \param whatArguments /// Collection of arguments used to format the message that describes what the exception is. /// \param whyMessageId /// ID of the message that describes why the exception occurs. /// \param whyArguments /// Collection of arguments used to format the message that describes why the exception occurs. /// MgApplicationException(CREFSTRING methodName, INT32 lineNumber, CREFSTRING fileName, MgStringCollection* whatArguments, CREFSTRING whyMessageId, MgStringCollection* whyArguments) throw(); INTERNAL_API: DECLARE_EXCEPTION_ABSTRACT(MgApplicationException) CLASS_ID: static const INT32 m_cls_id = Foundation_Exception_MgApplicationException; }; #endif
34.506667
99
0.662287
[ "object" ]
2fbd76fbe81a588d6de0ec622c4ecf45e80ba3ea
1,964
h
C
src/script/routine.h
seedhartha/revan
b9a98007ca2f510b42894ecd09fb623571b433dc
[ "MIT" ]
37
2020-06-27T18:50:48.000Z
2020-08-02T14:13:51.000Z
src/script/routine.h
seedhartha/revan
b9a98007ca2f510b42894ecd09fb623571b433dc
[ "MIT" ]
null
null
null
src/script/routine.h
seedhartha/revan
b9a98007ca2f510b42894ecd09fb623571b433dc
[ "MIT" ]
1
2020-07-14T13:32:15.000Z
2020-07-14T13:32:15.000Z
/* * Copyright (c) 2020-2022 The reone project contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ #pragma once #include "types.h" #include "variable.h" namespace reone { namespace script { struct ExecutionContext; class Routine { public: Routine( std::string name, VariableType retType, Variable defRetValue, std::vector<VariableType> argTypes, std::function<Variable(const std::vector<Variable> &, ExecutionContext &ctx)> fn) : _name(std::move(name)), _returnType(retType), _defaultReturnValue(std::move(defRetValue)), _argumentTypes(std::move(argTypes)), _func(std::move(fn)) { } Variable invoke(const std::vector<Variable> &args, ExecutionContext &ctx) const; int getArgumentCount() const; VariableType getArgumentType(int index) const; const std::string &name() const { return _name; } VariableType returnType() const { return _returnType; } private: std::string _name; VariableType _returnType {VariableType::Void}; Variable _defaultReturnValue; std::vector<VariableType> _argumentTypes; std::function<Variable(const std::vector<Variable> &, ExecutionContext &ctx)> _func; Variable onException(const std::string &msg, const std::exception &ex) const; }; } // namespace script } // namespace reone
30.215385
91
0.705193
[ "vector" ]
4a91c5c7bf8d515899f272f502a4b3341490eec9
5,366
h
C
src/rs_driver/common/common_header.h
damienzh/rs_driver
a98d73253a91461e6a2be0d12f54165b2fd5d8a1
[ "BSD-3-Clause" ]
55
2020-06-10T10:19:06.000Z
2022-03-15T02:36:45.000Z
src/rs_driver/common/common_header.h
damienzh/rs_driver
a98d73253a91461e6a2be0d12f54165b2fd5d8a1
[ "BSD-3-Clause" ]
24
2020-07-15T12:21:44.000Z
2022-03-04T09:42:09.000Z
src/rs_driver/common/common_header.h
damienzh/rs_driver
a98d73253a91461e6a2be0d12f54165b2fd5d8a1
[ "BSD-3-Clause" ]
39
2020-06-29T03:44:23.000Z
2022-03-22T09:56:58.000Z
/********************************************************************************************************************* Copyright (c) 2020 RoboSense All rights reserved By downloading, copying, installing or using the software you agree to this license. If you do not agree to this license, do not download, install, copy or use the software. License Agreement For RoboSense LiDAR SDK Library (3-clause BSD License) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the names of the RoboSense, nor Suteng Innovation Technology, nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *********************************************************************************************************************/ #pragma once #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif /*Common*/ #include <cstdint> #include <string> #include <vector> #include <iostream> #include <fstream> #include <sstream> #include <ctime> #include <cmath> #include <memory> #include <array> #include <algorithm> #include <functional> #include <iterator> #include <chrono> #include <queue> #include <thread> #include <atomic> #include <condition_variable> #include <future> #include <stdexcept> #include <mutex> #include <type_traits> #include <numeric> #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> #include <rs_driver/macro/version.h> /*Linux*/ #ifdef __linux__ #include <arpa/inet.h> #include <netdb.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #elif _WIN32 #include <winsock2.h> #include <windows.h> #endif /*Eigen*/ #ifdef ENABLE_TRANSFORM #include <Eigen/Dense> #endif #if defined(_WIN32) #include <io.h> #include <windows.h> inline void setConsoleColor(WORD c) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hConsole, c); } #endif /*Pcap*/ #include <pcap.h> /*Camera*/ typedef std::pair<std::string, double> CameraTrigger; /*Packet Length*/ const size_t MECH_PKT_LEN = 1248; const size_t MEMS_MSOP_LEN = 1210; const size_t MEMS_DIFOP_LEN = 256; /*Output style*/ #ifndef RS_INFOL #if defined(_WIN32) inline std::ostream& _RS_INFOL() { setConsoleColor(FOREGROUND_GREEN); return std::cout; } #define RS_INFOL _RS_INFOL() #else #define RS_INFOL (std::cout << "\033[32m") #endif #endif #ifndef RS_INFO #if defined(_WIN32) inline std::ostream& _RS_INFO() { setConsoleColor(FOREGROUND_GREEN | FOREGROUND_INTENSITY); return std::cout; } #define RS_INFO _RS_INFO() #else #define RS_INFO (std::cout << "\033[1m\033[32m") #endif #endif #ifndef RS_WARNING #if defined(_WIN32) inline std::ostream& _RS_WARNING() { setConsoleColor(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); return std::cout; } #define RS_WARNING _RS_WARNING() #else #define RS_WARNING (std::cout << "\033[1m\033[33m") #endif #endif #ifndef RS_ERROR #if defined(_WIN32) inline std::ostream& _RS_ERROR() { setConsoleColor(FOREGROUND_RED | FOREGROUND_INTENSITY); return std::cout; } #define RS_ERROR _RS_ERROR() #else #define RS_ERROR (std::cout << "\033[1m\033[31m") #endif #endif #ifndef RS_DEBUG #if defined(_WIN32) inline std::ostream& _RS_DEBUG() { setConsoleColor(FOREGROUND_GREEN); return std::cout; } #define RS_DEBUG _RS_DEBUG() #else #define RS_DEBUG (std::cout << "\033[1m\033[36m") #endif #endif #ifndef RS_TITLE #if defined(_WIN32) inline std::ostream& _RS_TITLE() { setConsoleColor(FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); return std::cout; } #define RS_TITLE _RS_TITLE() #else #define RS_TITLE (std::cout << "\033[1m\033[35m") #endif #endif #ifndef RS_MSG #if defined(_WIN32) inline std::ostream& _RS_MSG() { setConsoleColor(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY); return std::cout; } #define RS_MSG _RS_MSG() #else #define RS_MSG (std::cout << "\033[1m\033[37m") #endif #endif #ifndef RS_REND #if defined(_WIN32) inline std::ostream& RS_REND(std::ostream& stream) { stream << std::endl; setConsoleColor(-1); return stream; } #else #define RS_REND "\033[0m" << std::endl #endif #endif
26.048544
120
0.729407
[ "vector" ]
4aa838d6a073a5948256a7e03d0ebe99b3eb94b2
2,310
h
C
Interaction/mafInteractorExtractIsosurface.h
FusionBox2/MAF2
b576955f4f6b954467021f12baedfebcaf79a382
[ "Apache-2.0" ]
1
2018-01-23T09:13:40.000Z
2018-01-23T09:13:40.000Z
Interaction/mafInteractorExtractIsosurface.h
gradicosmo/MAF2
86ddf1f52a2de4479c09fd3f43dc321ff412af42
[ "Apache-2.0" ]
null
null
null
Interaction/mafInteractorExtractIsosurface.h
gradicosmo/MAF2
86ddf1f52a2de4479c09fd3f43dc321ff412af42
[ "Apache-2.0" ]
3
2020-09-24T16:04:53.000Z
2020-09-24T16:50:30.000Z
/*========================================================================= Program: MAF2 Module: mafInteractorExtractIsosurface Authors: Paolo Quadrani & Marco Petrone Copyright (c) B3C All rights reserved. See Copyright.txt or http://www.scsitaly.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #ifndef __mafInteractorExtractIsosurface_h #define __mafInteractorExtractIsosurface_h #include "mafInteractorCameraMove.h" #include "mafMTime.h" //---------------------------------------------------------------------------- // forward declarations : //---------------------------------------------------------------------------- class vtkCellPicker; class vtkCamera; /** implements mouse move of camera in the scene. This class implements a mouse move of the renderer camera in the scene. The interaction modality is a mouse manipulation, where movements of the mouse are mapped into movements of the camera. More details to be written...*/ class MAF_EXPORT mafInteractorExtractIsosurface : public mafInteractorCameraMove { public: mafTypeMacro(mafInteractorExtractIsosurface,mafInteractorCameraMove); /** Start the interaction with the selected object */ virtual int StartInteraction(mafDeviceButtonsPadMouse *mouse); /** redefined to set the picking iso-value flag */ virtual void OnMouseMove(); /** redefined to set the picking iso-value flag */ virtual void OnLeftButtonDown(mafEventInteraction *e); /** redefined to set the picking iso-value flag and if it is true, call PickIsoValue() */ virtual void OnButtonUp(mafEventInteraction *e); protected: mafInteractorExtractIsosurface(); virtual ~mafInteractorExtractIsosurface(); /** send the picked point to the listener */ void PickIsoValue(mafDevice *device); bool m_PickValue; private: mafInteractorExtractIsosurface(const mafInteractorExtractIsosurface&); // Not implemented. void operator=(const mafInteractorExtractIsosurface&); // Not implemented. /** test friend */ friend class mafInteractorExtractIsosurfaceTest; }; #endif
34.477612
93
0.679654
[ "object" ]
4aa9ba1248f49b3c81c07ff4ac04704b71f45a12
18,215
h
C
admin/wmi/wbem/winmgmt/wmicooker/wmicooker.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
admin/wmi/wbem/winmgmt/wmicooker/wmicooker.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
admin/wmi/wbem/winmgmt/wmicooker/wmicooker.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
#pragma warning( disable: 4049 ) /* more than 64k source lines */ /* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 6.00.0334 */ /* Compiler settings for wmicooker.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 440 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __wmicooker_h__ #define __wmicooker_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __IWMIRefreshableCooker_FWD_DEFINED__ #define __IWMIRefreshableCooker_FWD_DEFINED__ typedef interface IWMIRefreshableCooker IWMIRefreshableCooker; #endif /* __IWMIRefreshableCooker_FWD_DEFINED__ */ #ifndef __IWMISimpleObjectCooker_FWD_DEFINED__ #define __IWMISimpleObjectCooker_FWD_DEFINED__ typedef interface IWMISimpleObjectCooker IWMISimpleObjectCooker; #endif /* __IWMISimpleObjectCooker_FWD_DEFINED__ */ #ifndef __IWMISimpleCooker_FWD_DEFINED__ #define __IWMISimpleCooker_FWD_DEFINED__ typedef interface IWMISimpleCooker IWMISimpleCooker; #endif /* __IWMISimpleCooker_FWD_DEFINED__ */ /* header files for imported files */ #include "unknwn.h" #include "wbemcli.h" #ifdef __cplusplus extern "C"{ #endif void * __RPC_USER MIDL_user_allocate(size_t); void __RPC_USER MIDL_user_free( void * ); #ifndef __IWMIRefreshableCooker_INTERFACE_DEFINED__ #define __IWMIRefreshableCooker_INTERFACE_DEFINED__ /* interface IWMIRefreshableCooker */ /* [uuid][object][local][restricted] */ EXTERN_C const IID IID_IWMIRefreshableCooker; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("13ED7E55-8D63-41b0-9086-D0C5C17364C8") IWMIRefreshableCooker : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE AddInstance( /* [in] */ IWbemServices *pService, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pCookingInstance, /* [out] */ IWbemObjectAccess **ppRefreshableInstance, /* [out] */ long *plId) = 0; virtual HRESULT STDMETHODCALLTYPE AddEnum( /* [in] */ IWbemServices *pService, /* [string][in] */ LPCWSTR szCookingClass, /* [in] */ IWbemHiPerfEnum *pRefreshableEnum, /* [out] */ long *plId) = 0; virtual HRESULT STDMETHODCALLTYPE Remove( /* [in] */ long lId) = 0; virtual HRESULT STDMETHODCALLTYPE Refresh( void) = 0; }; #else /* C style interface */ typedef struct IWMIRefreshableCookerVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IWMIRefreshableCooker * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IWMIRefreshableCooker * This); ULONG ( STDMETHODCALLTYPE *Release )( IWMIRefreshableCooker * This); HRESULT ( STDMETHODCALLTYPE *AddInstance )( IWMIRefreshableCooker * This, /* [in] */ IWbemServices *pService, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pCookingInstance, /* [out] */ IWbemObjectAccess **ppRefreshableInstance, /* [out] */ long *plId); HRESULT ( STDMETHODCALLTYPE *AddEnum )( IWMIRefreshableCooker * This, /* [in] */ IWbemServices *pService, /* [string][in] */ LPCWSTR szCookingClass, /* [in] */ IWbemHiPerfEnum *pRefreshableEnum, /* [out] */ long *plId); HRESULT ( STDMETHODCALLTYPE *Remove )( IWMIRefreshableCooker * This, /* [in] */ long lId); HRESULT ( STDMETHODCALLTYPE *Refresh )( IWMIRefreshableCooker * This); END_INTERFACE } IWMIRefreshableCookerVtbl; interface IWMIRefreshableCooker { CONST_VTBL struct IWMIRefreshableCookerVtbl *lpVtbl; }; #ifdef COBJMACROS #define IWMIRefreshableCooker_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define IWMIRefreshableCooker_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define IWMIRefreshableCooker_Release(This) \ (This)->lpVtbl -> Release(This) #define IWMIRefreshableCooker_AddInstance(This,pService,pCookingClass,pCookingInstance,ppRefreshableInstance,plId) \ (This)->lpVtbl -> AddInstance(This,pService,pCookingClass,pCookingInstance,ppRefreshableInstance,plId) #define IWMIRefreshableCooker_AddEnum(This,pService,szCookingClass,pRefreshableEnum,plId) \ (This)->lpVtbl -> AddEnum(This,pService,szCookingClass,pRefreshableEnum,plId) #define IWMIRefreshableCooker_Remove(This,lId) \ (This)->lpVtbl -> Remove(This,lId) #define IWMIRefreshableCooker_Refresh(This) \ (This)->lpVtbl -> Refresh(This) #endif /* COBJMACROS */ #endif /* C style interface */ HRESULT STDMETHODCALLTYPE IWMIRefreshableCooker_AddInstance_Proxy( IWMIRefreshableCooker * This, /* [in] */ IWbemServices *pService, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pCookingInstance, /* [out] */ IWbemObjectAccess **ppRefreshableInstance, /* [out] */ long *plId); void __RPC_STUB IWMIRefreshableCooker_AddInstance_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMIRefreshableCooker_AddEnum_Proxy( IWMIRefreshableCooker * This, /* [in] */ IWbemServices *pService, /* [string][in] */ LPCWSTR szCookingClass, /* [in] */ IWbemHiPerfEnum *pRefreshableEnum, /* [out] */ long *plId); void __RPC_STUB IWMIRefreshableCooker_AddEnum_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMIRefreshableCooker_Remove_Proxy( IWMIRefreshableCooker * This, /* [in] */ long lId); void __RPC_STUB IWMIRefreshableCooker_Remove_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMIRefreshableCooker_Refresh_Proxy( IWMIRefreshableCooker * This); void __RPC_STUB IWMIRefreshableCooker_Refresh_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); #endif /* __IWMIRefreshableCooker_INTERFACE_DEFINED__ */ #ifndef __IWMISimpleObjectCooker_INTERFACE_DEFINED__ #define __IWMISimpleObjectCooker_INTERFACE_DEFINED__ /* interface IWMISimpleObjectCooker */ /* [uuid][object][local][restricted] */ EXTERN_C const IID IID_IWMISimpleObjectCooker; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("A239BDF1-0AB1-45a0-8764-159115689589") IWMISimpleObjectCooker : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE SetClass( /* [in] */ WCHAR *wszCookingClassName, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pRawClass) = 0; virtual HRESULT STDMETHODCALLTYPE SetCookedInstance( /* [in] */ IWbemObjectAccess *pCookedInstance, /* [out] */ long *plId) = 0; virtual HRESULT STDMETHODCALLTYPE BeginCooking( /* [in] */ long lId, /* [in] */ IWbemObjectAccess *pSampleInstance, /* [in] */ unsigned long dwRefresherId) = 0; virtual HRESULT STDMETHODCALLTYPE StopCooking( /* [in] */ long lId) = 0; virtual HRESULT STDMETHODCALLTYPE Recalc( /* [in] */ unsigned long dwRefresherId) = 0; virtual HRESULT STDMETHODCALLTYPE Remove( /* [in] */ long lId) = 0; virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0; }; #else /* C style interface */ typedef struct IWMISimpleObjectCookerVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IWMISimpleObjectCooker * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IWMISimpleObjectCooker * This); ULONG ( STDMETHODCALLTYPE *Release )( IWMISimpleObjectCooker * This); HRESULT ( STDMETHODCALLTYPE *SetClass )( IWMISimpleObjectCooker * This, /* [in] */ WCHAR *wszCookingClassName, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pRawClass); HRESULT ( STDMETHODCALLTYPE *SetCookedInstance )( IWMISimpleObjectCooker * This, /* [in] */ IWbemObjectAccess *pCookedInstance, /* [out] */ long *plId); HRESULT ( STDMETHODCALLTYPE *BeginCooking )( IWMISimpleObjectCooker * This, /* [in] */ long lId, /* [in] */ IWbemObjectAccess *pSampleInstance, /* [in] */ unsigned long dwRefresherId); HRESULT ( STDMETHODCALLTYPE *StopCooking )( IWMISimpleObjectCooker * This, /* [in] */ long lId); HRESULT ( STDMETHODCALLTYPE *Recalc )( IWMISimpleObjectCooker * This, /* [in] */ unsigned long dwRefresherId); HRESULT ( STDMETHODCALLTYPE *Remove )( IWMISimpleObjectCooker * This, /* [in] */ long lId); HRESULT ( STDMETHODCALLTYPE *Reset )( IWMISimpleObjectCooker * This); END_INTERFACE } IWMISimpleObjectCookerVtbl; interface IWMISimpleObjectCooker { CONST_VTBL struct IWMISimpleObjectCookerVtbl *lpVtbl; }; #ifdef COBJMACROS #define IWMISimpleObjectCooker_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define IWMISimpleObjectCooker_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define IWMISimpleObjectCooker_Release(This) \ (This)->lpVtbl -> Release(This) #define IWMISimpleObjectCooker_SetClass(This,wszCookingClassName,pCookingClass,pRawClass) \ (This)->lpVtbl -> SetClass(This,wszCookingClassName,pCookingClass,pRawClass) #define IWMISimpleObjectCooker_SetCookedInstance(This,pCookedInstance,plId) \ (This)->lpVtbl -> SetCookedInstance(This,pCookedInstance,plId) #define IWMISimpleObjectCooker_BeginCooking(This,lId,pSampleInstance,dwRefresherId) \ (This)->lpVtbl -> BeginCooking(This,lId,pSampleInstance,dwRefresherId) #define IWMISimpleObjectCooker_StopCooking(This,lId) \ (This)->lpVtbl -> StopCooking(This,lId) #define IWMISimpleObjectCooker_Recalc(This,dwRefresherId) \ (This)->lpVtbl -> Recalc(This,dwRefresherId) #define IWMISimpleObjectCooker_Remove(This,lId) \ (This)->lpVtbl -> Remove(This,lId) #define IWMISimpleObjectCooker_Reset(This) \ (This)->lpVtbl -> Reset(This) #endif /* COBJMACROS */ #endif /* C style interface */ HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_SetClass_Proxy( IWMISimpleObjectCooker * This, /* [in] */ WCHAR *wszCookingClassName, /* [in] */ IWbemObjectAccess *pCookingClass, /* [in] */ IWbemObjectAccess *pRawClass); void __RPC_STUB IWMISimpleObjectCooker_SetClass_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_SetCookedInstance_Proxy( IWMISimpleObjectCooker * This, /* [in] */ IWbemObjectAccess *pCookedInstance, /* [out] */ long *plId); void __RPC_STUB IWMISimpleObjectCooker_SetCookedInstance_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_BeginCooking_Proxy( IWMISimpleObjectCooker * This, /* [in] */ long lId, /* [in] */ IWbemObjectAccess *pSampleInstance, /* [in] */ unsigned long dwRefresherId); void __RPC_STUB IWMISimpleObjectCooker_BeginCooking_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_StopCooking_Proxy( IWMISimpleObjectCooker * This, /* [in] */ long lId); void __RPC_STUB IWMISimpleObjectCooker_StopCooking_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_Recalc_Proxy( IWMISimpleObjectCooker * This, /* [in] */ unsigned long dwRefresherId); void __RPC_STUB IWMISimpleObjectCooker_Recalc_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_Remove_Proxy( IWMISimpleObjectCooker * This, /* [in] */ long lId); void __RPC_STUB IWMISimpleObjectCooker_Remove_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IWMISimpleObjectCooker_Reset_Proxy( IWMISimpleObjectCooker * This); void __RPC_STUB IWMISimpleObjectCooker_Reset_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); #endif /* __IWMISimpleObjectCooker_INTERFACE_DEFINED__ */ #ifndef __IWMISimpleCooker_INTERFACE_DEFINED__ #define __IWMISimpleCooker_INTERFACE_DEFINED__ /* interface IWMISimpleCooker */ /* [uuid][object][local][restricted] */ EXTERN_C const IID IID_IWMISimpleCooker; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("510ADF6E-D481-4a64-B74A-CC712E11AA34") IWMISimpleCooker : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE CookRawValues( /* [in] */ DWORD dwCookingType, /* [in] */ DWORD dwNumSamples, /* [size_is][in] */ __int64 *anTimeStamp, /* [size_is][in] */ __int64 *anRawValue, /* [size_is][in] */ __int64 *anBase, /* [in] */ __int64 nTimeFrequency, /* [out] */ __int64 *pnResult) = 0; }; #else /* C style interface */ typedef struct IWMISimpleCookerVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IWMISimpleCooker * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IWMISimpleCooker * This); ULONG ( STDMETHODCALLTYPE *Release )( IWMISimpleCooker * This); HRESULT ( STDMETHODCALLTYPE *CookRawValues )( IWMISimpleCooker * This, /* [in] */ DWORD dwCookingType, /* [in] */ DWORD dwNumSamples, /* [size_is][in] */ __int64 *anTimeStamp, /* [size_is][in] */ __int64 *anRawValue, /* [size_is][in] */ __int64 *anBase, /* [in] */ __int64 nTimeFrequency, /* [out] */ __int64 *pnResult); END_INTERFACE } IWMISimpleCookerVtbl; interface IWMISimpleCooker { CONST_VTBL struct IWMISimpleCookerVtbl *lpVtbl; }; #ifdef COBJMACROS #define IWMISimpleCooker_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define IWMISimpleCooker_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define IWMISimpleCooker_Release(This) \ (This)->lpVtbl -> Release(This) #define IWMISimpleCooker_CookRawValues(This,dwCookingType,dwNumSamples,anTimeStamp,anRawValue,anBase,nTimeFrequency,pnResult) \ (This)->lpVtbl -> CookRawValues(This,dwCookingType,dwNumSamples,anTimeStamp,anRawValue,anBase,nTimeFrequency,pnResult) #endif /* COBJMACROS */ #endif /* C style interface */ HRESULT STDMETHODCALLTYPE IWMISimpleCooker_CookRawValues_Proxy( IWMISimpleCooker * This, /* [in] */ DWORD dwCookingType, /* [in] */ DWORD dwNumSamples, /* [size_is][in] */ __int64 *anTimeStamp, /* [size_is][in] */ __int64 *anRawValue, /* [size_is][in] */ __int64 *anBase, /* [in] */ __int64 nTimeFrequency, /* [out] */ __int64 *pnResult); void __RPC_STUB IWMISimpleCooker_CookRawValues_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); #endif /* __IWMISimpleCooker_INTERFACE_DEFINED__ */ /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
30.30782
128
0.652869
[ "object" ]
4ab5ca6e93258225289a5100f8d476fdab7b350a
5,061
h
C
mulberryAR/VVISION/engine/vvision/Utils/types.h
polobymulberry/mulberryAR
ae2c207563da7bbf4c382ee27a78558d5c482333
[ "MIT" ]
18
2017-02-17T09:28:10.000Z
2021-08-09T04:43:39.000Z
mulberryAR/VVISION/engine/vvision/Utils/types.h
jjzhang166/mulberryAR
ae2c207563da7bbf4c382ee27a78558d5c482333
[ "MIT" ]
1
2018-04-13T02:38:33.000Z
2018-12-25T06:12:56.000Z
mulberryAR/VVISION/engine/vvision/Utils/types.h
jjzhang166/mulberryAR
ae2c207563da7bbf4c382ee27a78558d5c482333
[ "MIT" ]
12
2017-03-22T09:08:18.000Z
2021-06-27T12:48:14.000Z
/* types.h * * Virtual Vision Engine . Copyright (C) 2012 Abdallah DIB. * All rights reserved. Email: Abdallah.dib@virtual-vison.net * Web: <http://www.virutal-vision.net/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>.*/ #ifndef VVISION_base_h #define VVISION_base_h #include "vmath.h" #import <stdlib.h> #import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/glext.h> #include <vector> #include <string> #include <iostream> #include <map> using namespace std; namespace vvision { /** different primitive type*/ enum PRIMITIVE_TYPE { /** triangles*/ kPRIMITIVE_TYPE_TRIANGLE = GL_TRIANGLES, /** triangles trip*/ kPRIMITIVE_TYPE_TRIANGLE_STRIP = GL_TRIANGLE_STRIP, /** triangles fan*/ kPRIMITIVE_TYPE_TRIANGLE_FAN = GL_TRIANGLE_FAN, /** lines*/ kPRIMITIVE_TYPE_LINES = GL_LINES, /** line loop*/ kPRIMITIVE_TYPE_LINE_LOOP = GL_LINE_LOOP, /** line strip*/ kPRIMITIVE_TYPE_LINE_STRIP = GL_LINE_STRIP, /** points*/ kPRIMITIVE_TYPE_POINTS = GL_POINTS }; #ifdef ZERO____ /** determines which attribs will be mapped to the current shadrer ( the attribs used for shadow mapping generator are less than attribs required for rendering)*/ enum SHADER_VERTEX_ATTRIBUTE { /** normal attrib location*/ kSHADER_VERTEX_ATTRIBUTE_NORMAL = 1 << 0, /** texture attrib location*/ kSHADER_VERTEX_ATTRIBUTE_TEXTURE = 1 << 1, /** tangent attrib location*/ kSHADER_VERTEX_ATTRIBUTE_TANGENT = 1 << 2, /** color attrib location*/ kSHADER_VERTEX_ATTRIBUTE_COLOR = 1 << 3 }; #endif /** different data type*/ enum DATA_TYPE { /** byte*/ kDATA_TYPE_BYTE = GL_BYTE, /** unsigned byte */ kDATA_TYPE_UNSIGNED_BYTE = GL_UNSIGNED_BYTE, /** float 32 bits*/ kDATA_TYPE_FLOAT = GL_FLOAT }; /** different gl buffer types*/ enum GL_BUFFER_TYPE { /** array buffer*/ kGL_BUFFER_TYPE_ARRAY = GL_ARRAY_BUFFER, /** element buffer*/ kGL_BUFFER_TYPE_ELEMENT = GL_ELEMENT_ARRAY_BUFFER }; /** hint for the gl driver on how if the buffer is static of updated frequently*/ enum GL_BUFFER_USAGE_HINT { /** static buffer */ kGL_BUFFER_USAGE_HINT_STATIC = GL_STATIC_DRAW, /** dynamic*/ kGL_BUFFER_USAGE_HINT_DYNAMIC = GL_DYNAMIC_DRAW, }; /** shader attribute index*/ enum { /** vertex attrib*/ ATTRIB_VERTEX, /** color attrib*/ ATTRIB_COLOR, /** normal attrib*/ ATTRIB_NORMAL, /** texture 0 coord attrib*/ ATTRIB_TEXTURE0, /** texture 1 coord attrib*/ ATTRIB_TEXTURE1, /** tangent coord attrib*/ ATTRIB_TANGENT, /** bone index attrib*/ ATTRIB_BONES_INDICES, /** bone weight attrib*/ ATTRIB_BONES_WEIGHTS, /** attrib number*/ NUM_ATTRIBUTES }; /* 8 bit unsigned variable.*/ typedef unsigned char uchar8; /* 8 bit signed variable.*/ typedef signed char schar8; /** 8 bit character variable. */ typedef char char8; /** 16 bit unsigned variable. */ typedef unsigned short ushort16; /** 16 bit signed variable.*/ typedef signed short sshort16; /** 32 bit unsigned variable.*/ typedef unsigned int uint32; /** 32 bit signed variable.*/ typedef signed int sint32; /** 32 bit signed variable.*/ typedef int int32; /** 32 bit floating point variable.*/ typedef float float32; /** 64 bit floating point variable.*/ typedef double float64; #define SAFE_DELETE(ptr) \ if(ptr != NULL) \ {delete ptr; ptr = NULL;} //maximum finite value #define VV_MAXIMUM_FLOAT std::numeric_limits<float32>::max( ) #define VV_MAXIMUM_DOUBLE std::numeric_limits<float64>::max( ) #define VV_MAXIMUM_INTEGER std::numeric_limits<int32>::max( ) #define VV_MAXIMUM_CHAR std::numeric_limits<char8>::max( ) #define VV_MAXIMUM_SHOR_INT std::numeric_limits<sshort16>::max( ) } #endif
26.920213
166
0.610551
[ "vector" ]
4ac9d6d423338dbcdf16b7ca3c850d1fd42840e7
36,258
h
C
src/OSC_Sim.h
kostergroup/Excimontec
7fb0929a9a22ff92db722161caa68e07fd0e5cde
[ "MIT" ]
19
2017-05-03T07:40:46.000Z
2021-08-03T05:58:57.000Z
src/OSC_Sim.h
kostergroup/Excimontec
7fb0929a9a22ff92db722161caa68e07fd0e5cde
[ "MIT" ]
100
2018-07-05T18:44:10.000Z
2022-02-06T10:42:59.000Z
src/OSC_Sim.h
MikeHeiber/Excimontec
19a568f3a5871efad0db54f5bb950bb9e2bc6b65
[ "MIT" ]
11
2018-01-13T09:41:52.000Z
2021-08-23T08:33:58.000Z
// Copyright (c) 2017-2019 Michael C. Heiber // This source file is part of the Excimontec project, which is subject to the MIT License. // For more information, see the LICENSE file that accompanies this software. // The Excimontec project can be found on Github at https://github.com/MikeHeiber/Excimontec #ifndef EXCIMONTEC_OSC_SIM_H #define EXCIMONTEC_OSC_SIM_H #include "Simulation.h" #include "Site.h" #include "Exciton.h" #include "Parameters.h" #include "Polaron.h" #include "Version.h" #include <algorithm> #include <fstream> #include <iostream> #include <list> #include <numeric> #include <random> #include <string> #include <utility> #include <vector> namespace Excimontec { //! \brief This class extends the KMC_Lattice::Simulation class to create a functioning KMC simulation object for organic semiconductor devices. //! \copyright MIT License. For more information, see the LICENSE file that accompanies this software package. //! \author Michael C. Heiber //! \date 2017-2019 class OSC_Sim : public KMC_Lattice::Simulation { public: //! \brief Constructs an empty simulation object that is uninitialized. OSC_Sim(); //! Default virtual destructor. virtual ~OSC_Sim(); //! \brief Initializes the simulation object so that it is ready to execute a simulation test. //! \param params specifies all of the input parameters needed to run the simulation. //! \param id defines the desired ID number of the simulation object. //! \return true if the initialization is successful. //! \return false if there are any errors during initialization. bool init(const Parameters& params, const int id); //! \brief Calculates the events for all objects in the simulation. void calculateAllEvents(); //! \brief Calculates the transit time probability histogram using the data generated by the time-of-flight charge transport test. //! \param data is a vector of transit times for all extracted polarons. //! \param counts is the total number of polarons tested. //! \returns A pair vector where the first value is the bin position and the second value is the probability. std::vector<std::pair<double, double>> calculateTransitTimeHist(const std::vector<double>& data, const int counts) const; //! \brief Calculate the mobility data using the transit time data generated by the time-of-flight charge transport test. //! \param transit_times is a vector of transit times for all extracted polarons. //! \return A vector of calculated mobility values for each extracted polaron. std::vector<double> calculateMobilityData(const std::vector<double>& transit_times) const; //! \brief Checks whether the simulation test specified by the input parameters is finished. //! \return true if the simulation test is finished. //! \return false if the simulation test is not yet finished. bool checkFinished() const; //! \brief Creates an Exciton on a randomly selected unoccupied site. //! \param spin specifies the spin state of the created exciton. (true for singlet and false for triplet) void createExciton(const bool spin); //! \brief Attempts to create an Exciton on the specified lattice site. //! An error is generated if the specified lattice site is already occupied or if the coordinates are not in the lattice. //! \param coords is the coordinates where the exciton will be created. //! \param spin specifies the spin state of the created exciton. (true for singlet and false for triplet) void createExciton(const KMC_Lattice::Coords& coords, const bool spin); //! \brief Attempts to create an electron (negatively charged Polaron) on the specified lattice site. //! An error is generated if the specified lattice site is already occupied or if the coordinates are not in the lattice. //! \param coords is the coordinates where the electron will be created. void createElectron(const KMC_Lattice::Coords& coords); //! \brief Attempts to create a hole (positively charged Polaron) on the specified lattice site. //! An error is generated if the specified lattice site is already occupied or if the coordinates are not in the lattice. //! \param coords is the coordinates where the hole will be created. void createHole(const KMC_Lattice::Coords& coords); //! \brief Attempts to execute the next event in the KMC simulation. //! An error is generated if an event cannot be executed. //! \return true if the next event is executed successfully. //! \return false if the next event cannot be executed. bool executeNextEvent(); //! \brief Exports the relative lattice site energies to a text file. //! \param filename is the name of the file that will be created in the working directory. void exportEnergies(std::string filename); //! \brief Exports the absolute lattice site energies for the given carrier type to a text file. //! \param filename is the name of the file that will be created in the working directory. //! \param charge designates whether electron or hole energies are output void exportEnergies(std::string filename, bool charge); //! \brief Gets the charge extraction map data generated by the time-of-flight charge transport or internal quantum efficiency tests. //! \param charge specifies whether to get electron or hole polaron extraction data. //! \return A string vector that can be separately output to a file. std::vector<std::string> getChargeExtractionMap(const bool charge) const; //! \brief Gets the radial autocorrelation data for the lattice site energies that is generated when using the correlated Gaussian DOS model. //! \return A pair vector where the first value is the radial distance and the second is the autocorrelation probability value. std::vector<std::pair<double, double>> getDOSCorrelationData() const; //! \brief Gets the transient average Exciton energy data generated by the dynamics test. //! \returns A vector of data representing how the average exciton energy in units of eV changes over time. std::vector<double> getDynamicsExcitonEnergies() const; //! \brief Gets the transient average electron (negatively charged Polaron) energy data generated during the dynamics test. //! \returns A vector of data representing how the average electron energy in units of eV changes over time. std::vector<double> getDynamicsElectronEnergies() const; //! \brief Gets the transient average electron (positively charged Polaron) energy data generated during the dynamics test. //! \returns A vector of data representing how the average hole energy in units of eV changes over time. std::vector<double> getDynamicsHoleEnergies() const; //! \brief Gets the transient singlet exciton counts data generated by the dynamics test. //! \returns A vector of data representing how the number of singlet excitons in the simulation changes over time. std::vector<int> getDynamicsTransientSinglets() const; //! \brief Gets the transient triplet exciton counts data generated by the dynamics test. //! \returns A vector of data representing how the number of triplet excitons in the simulation changes over time. std::vector<int> getDynamicsTransientTriplets() const; //! \brief Gets the transient electron (negatively charged Polaron) counts data generated during the dynamics test. //! \returns A vector of data representing how the number of electrons in the simulation changes over time. std::vector<int> getDynamicsTransientElectrons() const; //! \brief Gets the transient hole (positively charged Polaron) counts data generated during the dynamics test. //! \returns A vector of data representing how the number of holes in the simulation changes over time. std::vector<int> getDynamicsTransientHoles() const; //! \brief Gets the transient time data generated during the dynamics test. //! \returns A vector of data representing the time points for the transient data. std::vector<double> getDynamicsTransientTimes() const; //! \brief Gets the transient exciton mean squared displacement velocity data generated during the dynamics test. //! The mean squared displacement velocity is equivalent to the diffusion coefficient for excitons. //! \returns A vector of data representing how the exciton mean squared displacement velocity changes over time. std::vector<double> getDynamicsExcitonMSDV() const; //! \brief Gets the transient electron (negatively charged Polaron) mean squared displacement velocity data generated by the dynamics test. //! The mean squared displacement velocity equals the diffusion coefficient at zero-bias conditions //! or can be used to calculate the mobility using the applied internal electrical potential. //! \returns A vector of data representing how the electron mean squared displacement velocity changes over time. std::vector<double> getDynamicsElectronMSDV() const; //! \brief Gets the transient hole (positively charged Polaron) mean squared displacement velocity data generated by the dynamics test. //! The mean squared displacement velocity equals the diffusion coefficient at zero-bias conditions //! or can be used to calculate the mobility using the applied internal electrical potential. //! \returns A vector of data representing how the hole mean squared displacement velocity changes over time. std::vector<double> getDynamicsHoleMSDV() const; //! \brief Gets the exciton diffusion distance data generated during the exciton diffusion test. //! \return A vector of data representing the displacement distance of each exciton tested. std::vector<double> getExcitonDiffusionData() const; //! \brief Gets the Exciton hop distance data generated during the exciton diffusion test. //! /return A vector of data representing the hop distance of all exciton hop events in lattice units. std::vector<int> getExcitonHopLengthData() const; //! \brief Gets the exciton lifetime data generated during the exciton diffusion test. //! \return A vector of data representing the lifetime of each exciton tested. std::vector<double> getExcitonLifetimeData() const; //! \brief Gets the internal electric field due to applied internal potential. //! \return the internal electric field in units of V/cm. double getInternalField() const; //! \brief Gets the number of excitons that have been created in the simulation. //! \return the number of excitons that have been created since the simulation object was initialized. int getN_excitons_created() const; //! \brief Gets the number of excitons that have been created on the specified site type in the simulation. //! \param site_type specifies the site type, where 1 is for donor sites and 2 is for acceptor sites. //! \return The number of excitons that have been created on the specified site type since the simulation object was initialized. int getN_excitons_created(const short site_type) const; //! \brief Gets the number of singlet excitons that have dissociated. //! \return The number of singlet excitons that have dissociated since the simulation object was initialized. int getN_singlet_excitons_dissociated() const; //! \brief Gets the number of triplet excitons that have dissociated. //! \return The number of triplet excitons that have dissociated since the simulation object was initialized. int getN_triplet_excitons_dissociated() const; //! \brief Gets the number of singlet excitons that have recombined. //! \return The number of singlet excitons that have recombined since the simulation object was initialized. int getN_singlet_excitons_recombined() const; //! \brief Gets the number of triplet excitons that have recombined. //! \return The number of triplet excitons that have recombined since the simulation object was initialized. int getN_triplet_excitons_recombined() const; //! \brief Gets the number of singlet-singlet annihilation events that have occurred. //! \return The number of singlet-singlet annihilation events that have occurred since the simulation object was initialized. int getN_singlet_singlet_annihilations() const; //! \brief Gets the number of singlet-triplet annihilation events that have occurred. //! \return The number of singlet-triplet annihilation events that have occurred since the simulation object was initialized. int getN_singlet_triplet_annihilations() const; //! \brief Gets the number of triplet-triplet annihilation events that have occurred. //! \return The number of triplet-triplet annihilation events that have occurred since the simulation object was initialized. int getN_triplet_triplet_annihilations() const; //! \brief Gets the number of singlet-polaron annihilation events that have occurred. //! \return The number of singlet-polaron annihilation events that have occurred since the simulation object was initialized. int getN_singlet_polaron_annihilations() const; //! \brief Gets the number of triplet-polaron annihilation events that have occurred. //! \return The number of triplet-polaron annihilation events that have occurred since the simulation object was initialized. int getN_triplet_polaron_annihilations() const; //! \brief Gets the number of electrons (negatively charged polarons) that have been created in the simulation. //! \return The number of electrons that have been created since the simulation object was initialized. int getN_electrons_created() const; //! \brief Gets the number of electrons (negatively charged polarons) that have been collected (extracted) at electrodes in the simulation. //! \return The number of electrons that have been collected (extracted) since the simulation object was initialized. int getN_electrons_collected() const; //! \brief Gets the number of electrons (negatively charged polarons) that have recombined with holes (positively charged polarons) in the simulation. //! \return The number of electron-hole pairs that have recombined since the simulation object was initialized. int getN_electrons_recombined() const; //! \brief Gets the number of events that have been executed. //! \return The number of events that have been executed since the simulation object was initialized. long int getN_events_executed() const; //! \brief Gets the number of holes (positively charged polarons) that have been created in the simulation. //! \return The number of holes that have been created since the simulation object was initialized. int getN_holes_created() const; //! \brief Gets the number of holes (positively charged polarons) that have been collected (extracted) at electrodes in the simulation. //! \return The number of holes that have been collected (extracted) since the simulation object was initialized. int getN_holes_collected() const; //! \brief Gets the number of holes (positively charged polarons) that have recombined with electrons (negatively charged polarons) in the simulation. //! \return The number of electron-hole pairs that have recombined since the simulation object was initialized. int getN_holes_recombined() const; //! \brief Gets the number of geminate electron-hole recombination events that have occurred in the simulation. //! Geminate recombination occurs between an electron and hole originating from the same exciton. //! \return The number of geminate electron-hole recombination events that have occurred since the simulation object was initialized. int getN_geminate_recombinations() const; //! \brief Gets the number of bimolecular electron-hole recombination events that have occurred in the simulation. //! Bimolecular recombination occurs between an electron and hole originating from different excitons. //! \return The number of bimolecular electron-hole recombination events that have occurred since the simulation object was initialized. int getN_bimolecular_recombinations() const; //! \brief Gets the number of transient test cycles that have been performed. //! During the time-of-flight charge transport test and the dynamics test, //! multiple transient cycles may be used to reach the target number of tested objects. //! \return The number of transient test cycles that have been performed since the simulation object was initialized. int getN_transient_cycles() const; //! \brief Gets the name of event type that was last performed. //! \return The event_type name of the previously executed event. std::string getPreviousEventType() const; //! \brief Gets the energies of the lattice sites with the specified type. //! \param site_type specifies the site type, where 1 is for donor sites and 2 is for acceptor sites. //! \return A vector of data representing the lattice site energies of sites with the specified type in units of eV. std::vector<float> getSiteEnergies(const short site_type) const; //! \brief Gets the site energy of the lattice site at the specified coordinates. //! An error is generated if the specified lattice site is not in the lattice. //! \param coords is the coordinates of the specified lattice site. //! \return The energy of the specified site in units of eV. //! \return NAN if the coordinates correspond to a site that is not in the lattice. float getSiteEnergy(const KMC_Lattice::Coords& coords); //! \brief Gets the site type of the lattice site at the specified coordinates. //! An error is generated if the specified lattice site is not in the lattice. //! \param coords is the coordinates of the specified lattice site. //! \return The type of the specified site, where 1 is for a donor site and 2 is for an acceptor site. //! \return -1 if the coordinates correspond to a site that is not in the lattice. short getSiteType(const KMC_Lattice::Coords& coords); //! \brief Gets the average steady state current density calculated during the steady state charge transport test. //! \return The average current density in units of mA cm^-2. double getSteadyCurrentDensity() const; //! \brief Gets the density of occupied states calculated during the steady state charge transport test. //! \return A pair vector where the first value is the state energy and the second in the density of occupied states. std::vector<std::pair<double, double>> getSteadyDOOS() const; //! \brief Gets the density of occupied states calculated during the steady state charge transport test. // This function calculates the state energies including the Coulomb potential due to interactions between the polarons. //! \return A pair vector where the first value is the state energy and the second in the density of occupied states. std::vector<std::pair<double, double>> getSteadyDOOS_Coulomb() const; //! \brief Gets the density of states calculated during the steady state charge transport test. //! \return A pair vector where the first value is the state energy and the second in the density of states. std::vector<std::pair<double, double>> getSteadyDOS(); //! \brief Gets the density of states calculated during the steady state charge transport test. // This function calculates the state energies including the Coulomb potential due to interactions between the polarons. //! \return A pair vector where the first value is the state energy and the second in the density of states. std::vector<std::pair<double, double>> getSteadyDOS_Coulomb() const; //! \brief Gets the average equilibration energy of the polarons calculated during the steady state charge transport test. //! The average equilibration energy corresponds to the average of the density of occupied states at steady state, quasi-equilibrium conditions. //! \return The calculated average equilibration energy of the polarons in units of eV. double getSteadyEquilibrationEnergy() const; //! \brief Gets the average equilibration energy of the polarons calculated during the steady state charge transport test. //! The average equilibration energy corresponds to the average of the density of occupied states at steady state, quasi-equilibrium conditions. //! This function returns the equilibration energy calculated including the Coulomb potential due to interactions between the polarons. //! \return The calculated average equilibration energy of the polarons in units of eV. double getSteadyEquilibrationEnergy_Coulomb() const; //! \brief Gets the average steady state charge carrier mobility calculated during the steady state charge transport test. //! \return The average charge carrier mobility in units of cm^2 V^-1 s^-1. double getSteadyMobility() const; //! \brief Gets the average transport energy of the polarons calculated during the steady state charge transport test. //! \return The average transport energy of the polarons in units of eV. double getSteadyTransportEnergy() const; //! \brief Gets the average transport energy of the polarons calculated during the steady state charge transport test. //! This returns the transport energy calculated including the Coulomb potential energy due to interactions between the polarons. //! \return The average transport energy of the polarons in units of eV. double getSteadyTransportEnergy_Coulomb() const; //! \brief Gets the transient polaron counts data generated during the time-of-flight charge transport test. //! \returns A vector of data representing how the number of polarons in the simulation changes over time. std::vector<int> getToFTransientCounts() const; //! \brief Gets the transient average polaron energy data generated during the time-of-flight charge transport test. //! \returns A vector of data representing how the average polaron energy in units of eV changes over time. std::vector<double> getToFTransientEnergies() const; //! \brief Gets the transient time data generated during the time-of-flight charge transport test. //! \returns A vector of data representing the time points for the transient data. std::vector<double> getToFTransientTimes() const; //! \brief Gets the transient average polaron velocity data generated during the time-of-flight charge transport test. //! The average polaron velocity can be used to calculate the current density and the charge carrier mobility. //! \return A vector of data representing how the average polaron velocity in units of cm/s changes over time. std::vector<double> getToFTransientVelocities() const; //! \brief Gets the transit time data generate during the time-of-flight charge transport test. //! \return A vector of data representing the transit time of all extracted polarons. std::vector<double> getTransitTimeData() const; //! \brief Prints a message to the command line about the current status of the simulation test. void outputStatus(); //! \brief Regenerates the site energies for all sites in the lattice. void reassignSiteEnergies(); protected: private: class Site_OSC : public KMC_Lattice::Site { public: float getEnergy() const { return energy; } short getType() const { return type; } void setEnergy(const float energy_input) { energy = energy_input; } void setType(const short site_type) { type = (char)site_type; } private: float energy; char type = 0; // type 1 represent donor, type 2 represents acceptor }; struct ExcitonEventCalcVars { int range; int dim; Exciton::Hop hop_event; std::vector<Exciton::Hop> hops_temp; Exciton::Dissociation diss_event; std::vector<Exciton::Dissociation> dissociations_temp; Exciton::Exciton_Annihilation ee_annihilation_event; std::vector<Exciton::Exciton_Annihilation> ee_annihilations_temp; Exciton::Polaron_Annihilation ep_annihilation_event; std::vector<Exciton::Polaron_Annihilation> ep_annihilations_temp; std::vector<bool> hops_valid; std::vector<bool> dissociations_valid; std::vector<bool> ee_annihilations_valid; std::vector<bool> ep_annihilations_valid; // precalculated distances vector that contains the distances to nearby sites used for event execution time calculations std::vector<double> distances; // precalculated isInDissRange and isInFRETRange vectors that contains booleans to indicate whether the nearby sites are within range for the different exciton events to be possible. std::vector<bool> isInDissRange; std::vector<bool> isInFRETRange; ExcitonEventCalcVars() {} ExcitonEventCalcVars(OSC_Sim* sim_ptr) { range = (int)ceil(((sim_ptr->params.FRET_cutoff > sim_ptr->params.Exciton_dissociation_cutoff) ? (sim_ptr->params.FRET_cutoff) : (sim_ptr->params.Exciton_dissociation_cutoff)) / sim_ptr->lattice.getUnitSize()); dim = (2 * range + 1); hop_event = Exciton::Hop(sim_ptr); hops_temp.assign(dim*dim*dim, hop_event); diss_event = Exciton::Dissociation(sim_ptr); dissociations_temp.assign(dim*dim*dim, diss_event); ee_annihilation_event = Exciton::Exciton_Annihilation(sim_ptr); ee_annihilations_temp.assign(dim*dim*dim, ee_annihilation_event); ep_annihilation_event = Exciton::Polaron_Annihilation(sim_ptr); ep_annihilations_temp.assign(dim*dim*dim, ep_annihilation_event); hops_valid.assign(dim*dim*dim, false); dissociations_valid.assign(dim*dim*dim, false); ee_annihilations_valid.assign(dim*dim*dim, false); ep_annihilations_valid.assign(dim*dim*dim, false); // precalculated distances vector that contains the distances to nearby sites used for event execution time calculations distances.assign(dim*dim*dim, 0.0); // precalculated isInDissRange and isInFRETRange vectors that contains booleans to indicate whether the nearby sites are within range for the different exciton events to be possible. isInDissRange.assign(dim*dim*dim, false); isInFRETRange.assign(dim*dim*dim, false); // Initialize distances, isInDissRange, and isInFRETRange vectors for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { for (int k = -range; k <= range; k++) { int index = (i + range)*dim*dim + (j + range)*dim + (k + range); distances[index] = sim_ptr->lattice.getUnitSize()*sqrt((double)(i*i + j * j + k * k)); if (!((distances[index] - 0.0001) > sim_ptr->params.Exciton_dissociation_cutoff)) { isInDissRange[index] = true; } if (!((distances[index] - 0.0001) > sim_ptr->params.FRET_cutoff)) { isInFRETRange[index] = true; } } } } } }; ExcitonEventCalcVars exciton_event_calc_vars; struct PolaronEventCalcVars { int range; int dim; Polaron::Hop hop_event; std::vector<Polaron::Hop> hops_temp; Polaron::Recombination rec_event; std::vector<Polaron::Recombination> recombinations_temp; std::vector<bool> hops_valid; std::vector<bool> recombinations_valid; // precalculated distances vector that contains the distances to nearby sites used for event execution time calculations std::vector<double> distances; std::vector<double> E_deltas; // precalculated isInRange vector that contains booleans to indicate if the nearby sites are within range for polaron events to be possible. std::vector<bool> isInRange; PolaronEventCalcVars() {} PolaronEventCalcVars(OSC_Sim* sim_ptr) { range = (int)ceil(sim_ptr->params.Polaron_hopping_cutoff / sim_ptr->lattice.getUnitSize()); dim = (2 * range + 1); hop_event = Polaron::Hop(sim_ptr); hops_temp.assign(dim*dim*dim, hop_event); rec_event = Polaron::Recombination(sim_ptr); recombinations_temp.assign(dim*dim*dim, rec_event); hops_valid.assign(dim*dim*dim, false); recombinations_valid.assign(dim*dim*dim, false); // precalculated distances vector that contains the distances to nearby sites used for event execution time calculations distances.assign(dim*dim*dim, 0.0); E_deltas.assign(dim*dim*dim, 0.0); // precalculated isInRange vector that contains booleans to indicate if the nearby sites are within range for polaron events to be possible. isInRange.assign(dim*dim*dim, false); // Initialize distances and isInRange vectors for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { for (int k = -range; k <= range; k++) { int index = (i + range)*dim*dim + (j + range)*dim + (k + range); distances[index] = sim_ptr->lattice.getUnitSize()*sqrt((double)(i*i + j * j + k * k)); if (!((distances[index] - 0.0001) > sim_ptr->params.Polaron_hopping_cutoff)) { isInRange[index] = true; } } } } } }; PolaronEventCalcVars polaron_event_calc_vars; // Input Parameters Parameters params; // Additional Derived Parameters double Transient_start; double Transient_end; int Transient_pnts_per_decade; bool isLightOn; double R_exciton_generation_donor; double R_exciton_generation_acceptor; double Transient_step_size; double Transient_creation_time; int Transient_index_prev; int Transient_singlet_counts_prev; int Transient_triplet_counts_prev; int Transient_electron_counts_prev; int Transient_hole_counts_prev; int Coulomb_range; double AvgDielectric; double Image_interaction_prefactor; int N_initial_excitons; // Site Data Structure std::vector<Site_OSC> sites; // Object Data Structures std::list<Exciton> excitons; std::list<Polaron> electrons; std::list<Polaron> holes; // Event Data Structures std::string previous_event_type = ""; double previous_event_time = 0; std::list<Exciton::Creation> exciton_creation_events; std::list<KMC_Lattice::Event*>::const_iterator exciton_creation_it; std::list<Exciton::Hop> exciton_hop_events; std::list<Exciton::Recombination> exciton_recombination_events; std::list<Exciton::Dissociation> exciton_dissociation_events; std::list<Exciton::Exciton_Annihilation> exciton_exciton_annihilation_events; std::list<Exciton::Polaron_Annihilation> exciton_polaron_annihilation_events; std::list<Exciton::Intersystem_Crossing> exciton_intersystem_crossing_events; std::list<Polaron::Hop> electron_hop_events; std::list<Polaron::Hop> hole_hop_events; std::list<Polaron::Recombination> polaron_recombination_events; std::list<Polaron::Extraction> electron_extraction_events; std::list<Polaron::Extraction> hole_extraction_events; // Additional Data Structures std::vector<double> Coulomb_table; std::vector<double> E_potential; std::vector<std::pair<double, double>> DOS_correlation_data; std::vector<double> exciton_lifetimes; std::vector<double> exciton_diffusion_distances; std::vector<int> exciton_hop_distances; // saved in lattice units squared std::vector<int> transient_exciton_tags; std::vector<int> transient_electron_tags; std::vector<int> transient_hole_tags; std::vector<int> ToF_positions_prev; std::vector<double> transient_exciton_energies_prev; std::vector<double> transient_electron_energies_prev; std::vector<double> transient_hole_energies_prev; std::vector<double> transient_exciton_msdv; std::vector<double> transient_electron_msdv; std::vector<double> transient_hole_msdv; std::vector<int> electron_extraction_data; std::vector<int> hole_extraction_data; std::vector<std::pair<double, double>> steady_DOOS; std::vector<std::pair<double, double>> steady_DOOS_Coulomb; std::vector<std::pair<double, double>> steady_DOS; std::vector<std::pair<double, double>> steady_DOS_Coulomb; std::vector<double> transient_times; std::vector<double> transient_velocities; std::vector<double> transient_exciton_energies; std::vector<double> transient_electron_energies; std::vector<double> transient_hole_energies; std::vector<double> transit_times; std::vector<int> transient_singlet_counts; std::vector<int> transient_triplet_counts; std::vector<int> transient_electron_counts; std::vector<int> transient_hole_counts; int Steady_hops_per_DOS_sample = 1000000; int Steady_hops_per_DOOS_sample = 1000; int Steady_DOS_sampling_counter = 0; int Steady_DOOS_sampling_counter = 0; double DOS_bin_size = 1e-2; double Steady_equilibration_time = 0.0; double Steady_equilibration_energy_sum = 0.0; double Steady_equilibration_energy_sum_Coulomb = 0.0; double Transport_energy_weighted_sum = 0.0; double Transport_energy_weighted_sum_Coulomb = 0.0; double Transport_energy_sum_of_weights = 0.0; // Additional Counters int N_donor_sites = 0; int N_acceptor_sites = 0; int N_excitons_created = 0; int N_excitons_created_donor = 0; int N_excitons_created_acceptor = 0; int N_singlet_excitons_recombined = 0; int N_triplet_excitons_recombined = 0; int N_singlet_excitons_dissociated = 0; int N_triplet_excitons_dissociated = 0; int N_singlet_singlet_annihilations = 0; int N_singlet_triplet_annihilations = 0; int N_triplet_triplet_annihilations = 0; int N_singlet_polaron_annihilations = 0; int N_triplet_polaron_annihilations = 0; int N_exciton_intersystem_crossings = 0; int N_exciton_reverse_intersystem_crossings = 0; int N_excitons_quenched = 0; int N_excitons = 0; int N_singlets = 0; int N_triplets = 0; int N_electrons_created = 0; int N_electrons_recombined = 0; int N_electrons_collected = 0; int N_electrons = 0; long int N_events_executed = 0; int N_holes_created = 0; int N_holes_recombined = 0; int N_holes_collected = 0; int N_holes = 0; int N_geminate_recombinations = 0; int N_bimolecular_recombinations = 0; int N_electron_surface_recombinations = 0; int N_hole_surface_recombinations = 0; int N_transient_cycles = 0; // Additional Functions double calculateCoulomb(const std::list<Polaron>::const_iterator polaron_it, const KMC_Lattice::Coords& coords) const; double calculateCoulomb(const bool charge, const KMC_Lattice::Coords& coords) const; void calculateDOSCorrelation(); void calculateDOSCorrelation(const double cutoff_radius); KMC_Lattice::Coords calculateRandomExcitonCreationCoords(); void calculateExcitonEvents(Exciton* exciton_ptr); void calculateObjectListEvents(const std::vector<KMC_Lattice::Object*>& object_ptr_vec); void calculatePolaronEvents(Polaron* polaron_ptr); void createCorrelatedDOS(const double correlation_length); bool createImportedMorphology(); void deleteObject(KMC_Lattice::Object* object_ptr); // Exciton Event Execution Functions bool executeExcitonCreation(); bool executeExcitonHop(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executeExcitonRecombination(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executeExcitonDissociation(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executeExcitonIntersystemCrossing(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executeExcitonExcitonAnnihilation(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executeExcitonPolaronAnnihilation(const std::list<KMC_Lattice::Event*>::const_iterator event_it); // General Event Functions bool executeObjectHop(const std::list<KMC_Lattice::Event*>::const_iterator event_it); // Polaron Event Execution Functions bool executePolaronHop(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executePolaronRecombination(const std::list<KMC_Lattice::Event*>::const_iterator event_it); bool executePolaronExtraction(const std::list<KMC_Lattice::Event*>::const_iterator event_it); KMC_Lattice::Coords generateExciton(); void generateExciton(const KMC_Lattice::Coords& coords, const bool spin, int tag = 0); void generateElectron(const KMC_Lattice::Coords& coords, int tag); void generateHole(const KMC_Lattice::Coords& coords, int tag); void generateDynamicsExcitons(); void generateSteadyPolarons(); void generateToFPolarons(); std::list<Exciton>::iterator getExcitonIt(const KMC_Lattice::Object* object_ptr); std::list<Polaron>::iterator getPolaronIt(const KMC_Lattice::Object* object_ptr); bool initializeArchitecture(); void removeExciton(std::list<Exciton>::iterator exciton_it); bool siteContainsHole(const KMC_Lattice::Coords& coords); void updateSteadyData(); void updateSteadyDOS(std::vector<std::pair<double, double>>& density_of_states, double state_energy); void updateTransientData(); }; } #endif // EXCIMONTEC_OSC_SIM_H
55.781538
214
0.766617
[ "object", "vector", "model" ]
4ace41945a9df3ce8c06f018838d5ba8597e0715
8,280
c
C
src/socket.c
scartezini/proxy
81afd59757ec0b59ee851e85a7d893c8e4acf3e6
[ "MIT" ]
null
null
null
src/socket.c
scartezini/proxy
81afd59757ec0b59ee851e85a7d893c8e4acf3e6
[ "MIT" ]
null
null
null
src/socket.c
scartezini/proxy
81afd59757ec0b59ee851e85a7d893c8e4acf3e6
[ "MIT" ]
null
null
null
#include "../include/socket.h" #include "../include/decoder.h" #include "../include/cache.h" int *openSocket(int port){ int *sockfd; struct sockaddr_in servaddr; /* Define um socket para o servidor */ sockfd = (int *) malloc(sizeof(int)); /* chama a funcao socket para especificar o tipo do protocolo */ if((*sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){ printf("Failed to make socket"); exit(-3); } /*populando os dados do servidor*/ bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; /* Aceita qualquer faixa de IP que a maquina possa responder. */ servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); /* define a porta */ /* vincula um socket a um endereco */ if(bind(*sockfd, (Sockaddr *) &servaddr, sizeof(servaddr)) < 0){ printf("Failed to bind socket in server"); exit(-4); } return sockfd; } void in_thread(int *sockfd){ struct sockaddr_in client; socklen_t clientlen; struct sockthread *sockthread; pthread_t tid; if(pthread_mutex_init(&lock, NULL) != 0){ printf("\n mutex init failed\n"); exit(-5); } while(keepRunning){ sockthread = (struct sockthread *) malloc(sizeof(struct sockthread)); /* iptr aceita a escuta do cliente */ sockthread->iptr = accept(*sockfd, (Sockaddr *) &client, &clientlen); // log inet_ntoa(client.sin_addr); strcpy(sockthread->client,inet_ntoa(client.sin_addr)); /* cria uma thread */ pthread_create(&tid, NULL, &start_thread, sockthread); } return; } void *start_thread(void *arg){ int connfd; char client[16]; struct sockthread sockthread; sockthread = *((struct sockthread*) arg); connfd = sockthread.iptr; strcpy(client,sockthread.client); pthread_detach(pthread_self()); start(connfd,client); close(connfd); return NULL; } void start(int connfd,char *client){ char buffer[BUFFSIZE], path[BUFFSIZE], host[HOSTSIZE]; char response[BUFFSIZE], file[HOSTSIZE], cache[BUFFSIZE]; char method[9], version[10]; int status, filter, n; memset(buffer,'\0',BUFFSIZE); if((n = recv(connfd,buffer,BUFFSIZE,0)) <= 0){ printf("Failed in receiver\n"); return; } status = decodeHTTP(buffer,path,method,version,host); logMessage(client,host,path,method, 0); filter = filterHost(host); //erro na requisiçaõ retorna avisando um erro if(filter < 0 || status < 0){ //error makeHTTP(response,1); logMessage(client,"web-proxy","",NULL, 500); send(connfd,response,strlen(response),0); return; } //host esta na blacklist responde uma mensagem informando isso if(filter == 2){ // blacklist makeHTTP(response,2); logMessage(client,host,path,"blacklist", 1); send(connfd,response,strlen(response),0); return; } //gera o nome da requisição para indentificar em cache fileName(file,host,path,method,version); int length; int lSize; //se estiver e cache ira tratar a pag em cache if(!(lSize = readCache(file,cache))){ makeReqModified(buffer,cache); //make http req logMessage("web-proxy",host,path,"If-Modified-Since",2); //faz uma requisição para verificar em a pag em cache ainda é valida length = request(buffer,host,response); int code; code = grepHttpCode(response); logMessage("web-proxy",host,path,NULL,code); //se for valida usar a pag em cache if(code == 304) {// 304 Not Modified memcpy(response,cache,lSize); length = lSize; } }else{ //se a pag nao estiver em cache fazer a requisição length = request(buffer,host,response); } //escrever a pag em cache writeCache(file,response,length); //passar no filtro de termos se nao estiver na whitelist if(filter != 1){ // no whitelist //se nao passar no filtro retornar um erro if(filterTerms(response)){ makeHTTP(response,3); logMessage(client,host,path,"denyterms", 1); } } logMessage(client,host,path,NULL,grepHttpCode(response)); //responde para quem fez a requisição send(connfd,response,length,0); } int request(char* buffer,char* host, char * response){ int servfd; if((servfd = establishConnection(getHostInfo(host))) == -1){ printf("Failed in establishConnection\n"); return -1; } if(send(servfd, buffer, strlen(buffer),0) < 0){ printf("Error\n"); return -1; } memset(response,0,BUFFSIZE); int length = recv_timeout(servfd,4,response); close(servfd); return length; } int establishConnection(struct addrinfo *info){ if(info == NULL){ return -1; } int clientfd; for(;info != NULL;info = info->ai_next){ if((clientfd = socket(info ->ai_family, info->ai_socktype, info->ai_protocol)) < 0){ continue; } if(connect(clientfd, info->ai_addr, info->ai_addrlen) < 0){ continue; } freeaddrinfo(info); return clientfd; } freeaddrinfo(info); return -1; } int dnsResolve(char* host,char* ip){ struct hostent *he; struct in_addr **addr_list; int i; if ((he = gethostbyname(host)) == NULL) { printf("Filed in get host name\n"); return -1; } addr_list = (struct in_addr **) he->h_addr_list; for(i = 0; addr_list[i] != NULL; i++) { //Return the first one; strcpy(ip , inet_ntoa(*addr_list[i])); return 0; } return 0; } struct addrinfo *getHostInfo(char *host){ int r; struct addrinfo hints, *host_addrinfo; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */ hints.ai_protocol = 0; /* Any protocol */ hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; if((r = getaddrinfo(host,"80",&hints,&host_addrinfo))){ return NULL; } return host_addrinfo; } int recv_timeout(int sockfd, int timeout, char *response){ int size_recv, total_size = 0; struct timeval begin, now; char chunk[CHUNK_SIZE]; double timediff; //make socket non bloking fcntl(sockfd, F_SETFL, O_NONBLOCK); // fcntl(clientfd, F_SETFL, O_NONBLOCK); gettimeofday(&begin, NULL); memset(response,'\0',BUFFSIZE); while(1){ gettimeofday(&now, NULL); timediff = (now.tv_sec - begin.tv_sec) + 1e-6 * (now.tv_usec - begin.tv_usec); if(total_size > 0 && timediff > timeout) break; else if(timediff > timeout*2) break; memset(chunk, '\0', CHUNK_SIZE); if((size_recv = recv(sockfd, chunk, CHUNK_SIZE,0)) <= 0) usleep(100000); else{ memcpy(response + total_size, chunk, size_recv); total_size += size_recv; gettimeofday(&begin, NULL); } } return total_size; } void logMessage(char const *client,char const *host,char const *path, char const *method, int cod){ FILE *fp; fp = fopen("resources/log.txt","a"); switch(cod){ case 0: printf("\033[44mr[%s]\t%s\t-\t%s\t%s%s\033[0m\n", time_system(),client,method,host,path); fprintf(fp, "r[%s]\t%s\t-\t%s\t%s%s\n", time_system(),client,method,host,path); break; case 1: printf("\033[41;30mb[%s]\t%s\t-\t%s%s\t-\t%s\033[0m\n", time_system(),client,host,path,method); fprintf(fp, "b[%s]\t%s\t-\t%s%s\t-\t%s\n", time_system(),client,host,path,method); break; case 2: printf("\033[42mc[%s]\t%s\t-\t%s%s\t-\t%s\033[0m\n", time_system(),client,host,path,method); fprintf(fp, "c[%s]\t%s\t-\t%s%s\t-\t%s\n", time_system(),client,host,path,method); break; default: printf("\033[43mh[%s]\t%s%s\t%d\t-\t%s\033[0m\n",time_system(),host,path,cod,client); fprintf(fp, "h[%s]\t%s%s\t%d\t-\t%s\n",time_system(),host,path,cod,client); } fclose(fp); } char* time2string(const struct tm *timeptr){ static const char wday_name[][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; static const char mon_name[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; static char result[26]; sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d", wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, 1900 + timeptr->tm_year); return result; } char* time_system(){ time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); return time2string(timeinfo); } void intHandler(int dummy) { printf("EXIT!!!"); keepRunning = 0; }
23.724928
100
0.658092
[ "3d" ]
4ae4a426b86b65b2ec39806a6d7a1cb725ea9f5f
2,006
h
C
src/common/public/aeon/common/listener_subject.h
aeon-engine/libaeon
e42b39e621dcd0a0fba05e1c166fc688288fb69b
[ "BSD-2-Clause" ]
7
2017-02-19T16:22:16.000Z
2021-03-02T05:47:39.000Z
src/common/public/aeon/common/listener_subject.h
aeon-engine/libaeon
e42b39e621dcd0a0fba05e1c166fc688288fb69b
[ "BSD-2-Clause" ]
61
2017-05-29T06:11:17.000Z
2021-03-28T21:51:44.000Z
src/common/public/aeon/common/listener_subject.h
aeon-engine/libaeon
e42b39e621dcd0a0fba05e1c166fc688288fb69b
[ "BSD-2-Clause" ]
2
2017-05-28T17:17:40.000Z
2017-07-14T21:45:16.000Z
// Distributed under the BSD 2-Clause License - Copyright 2012-2021 Robin Degen #pragma once #include <algorithm> #include <vector> namespace aeon::common { /*! * Subject of a observer pattern (listener class). */ template <typename T> class listener_subject final { public: listener_subject() = default; ~listener_subject() = default; listener_subject(listener_subject<T> &&) = default; auto operator=(listener_subject<T> &&) -> listener_subject<T> & = default; listener_subject(const listener_subject<T> &) = default; auto operator=(const listener_subject<T> &) -> listener_subject<T> & = default; /*! * Attach a listener/observer to this subject. * * This does not take ownership of this pointer, so it's up to * the caller to keep this pointer alive, and delete it appropriately. */ void attach(T &listener) { listeners_.push_back(&listener); } /*! * Remove a listener/observer from this subject. If this pointer was not previously attached, nothing happens. * * This will not delete the object, but merely detach it. */ void detach(T &listener) { listeners_.erase(std::remove(std::begin(listeners_), std::end(listeners_), &listener), std::end(listeners_)); } /*! * Detach all attached listeners. * * This will not delete the objects, but merely detach them. */ void detach_all() { listeners_.clear(); } /*! * Invoke a method in every attached listener */ template <typename func_t, class... args_t> void invoke_each(func_t &&func, args_t &&...args) { for (const auto &listener : listeners_) std::invoke(func, listener, std::forward<args_t>(args)...); } /*! * Access all attached listeners */ [[nodiscard]] const auto &listeners() const noexcept { return listeners_; } private: std::vector<T *> listeners_; }; } // namespace aeon::common
24.765432
117
0.633101
[ "object", "vector" ]
4ae9aa4fe870df646d945ad6a9957fa532567a2b
3,469
c
C
priority_queue.c
tacrazymage/Data-Structures-and-Algorithms
174f676d92bfcdf80230fc8d9698eb3d41c53ef8
[ "MIT" ]
21
2019-08-04T04:56:26.000Z
2021-08-13T12:33:31.000Z
priority_queue.c
tacrazymage/Data-Structures-and-Algorithms
174f676d92bfcdf80230fc8d9698eb3d41c53ef8
[ "MIT" ]
12
2019-10-08T16:29:41.000Z
2019-12-03T09:23:18.000Z
priority_queue.c
tacrazymage/Data-Structures-and-Algorithms
174f676d92bfcdf80230fc8d9698eb3d41c53ef8
[ "MIT" ]
14
2019-08-04T12:02:32.000Z
2021-08-24T06:15:26.000Z
#include <stdio.h> #include <stdlib.h> #include <limits.h> #define MAX 3 typedef struct queue Queue; struct queue { int front; int rear; int q[MAX+1][2]; }; // Deletes a element from the front of the Queue. int* dequeue(Queue* q) { /* * Arguments: `q` (Queue*) -> A referance to a Queue object * Deletes and returns the first element present in the Queue `q`. * Returns : `ele` (int) -> First element in the Queue `q` */ // If the `front` and `rear` attributes of // Queue `q` are overlapping // and are not equal to -1 means there is // only one element present in the Queue // which we will delete and reset the attributes // again to -1. if(q->front == q->rear && q->front != -1) { int *ele = q->q[q->front]; // get element in front of the queue q->q[q->front][0] = 0; // reinitialize the element q->q[q->front][1] = 0; // reinitialize priority q->front = q->rear = -1; // reset the attributes return ele; // return element. } // If the front or the rear attributes // are -1 means there are no elements // present in the queue and further // deletion doesn't make sense. So, // print error. else if(q->front == -1) { printf("Queue Underflow!\nTerminating Program...\n"); exit(1); // terminate program } // Else delete element and increament // `front` attribute of Queue `q`. else { // extract the element int *ele = q->q[q->front]; q->q[q->front][0] = 0; // reinitialize the element q->q[q->front][1] = 0; // reinitialize priority q->front++; // increment front return ele; // return element } } void enqueue(Queue* q, int key, int priority) { /* * Arguments: `q` (Queue*) -> A referance to a queue `q`. * `key` (int) -> A value to be inserted in the queue `q`. * Inserts `key` at the top of the queue `q`. */ // If the rear of the queue has reached its // maximum `MAX` print error Overflow. if(q->rear == MAX){ printf("Queue Overflow\nTerminating Program...\n"); exit(1); } // Else insert key at the end of // the queue `q`. else { if(q->rear!=-1){ int insertInd = q->rear; q->rear++; // increment attribute `rear` while(priority < q->q[insertInd][1]) { q->q[insertInd+1][0] = q->q[insertInd][0]; q->q[insertInd+1][1] = q->q[insertInd][1]; insertInd--; } q->q[insertInd+1][0] = key; // insert key q->q[insertInd+1][1] = priority; // insert priority } else { q->rear++; q->q[q->rear][0] = key; // insert key q->q[q->rear][1] = priority; // insert priority q->front++; } } } void disp_queue(Queue* q) { if(q->front == -1) printf("No elements present in the queue!"); else for(int i=q->front;i<=q->rear;i++) printf("[%d]%d ", q->q[i][1], q->q[i][0]); printf("\n"); } void init_queue(Queue* q) { q->front = -1; q->rear = -1; for(int i=0;i<MAX;i++) { q->q[i][0] = q->q[i][1] = 0; } } int main() { Queue que; init_queue(&que); enqueue(&que, 10, 1); enqueue(&que, 20, 2); enqueue(&que, 30, 3); enqueue(&que, 40, 1); disp_queue(&que); }
26.280303
86
0.518882
[ "object" ]
2b755cb29c90e0361918cf0e6ffb84d6c355f429
65,875
h
C
source/games/sw/src/game.h
Quake-Backup/Raze
16c81f0b1f409436ebf576d2c23f2459a29b34b4
[ "RSA-MD" ]
1
2022-03-30T15:53:09.000Z
2022-03-30T15:53:09.000Z
source/games/sw/src/game.h
Quake-Backup/Raze
16c81f0b1f409436ebf576d2c23f2459a29b34b4
[ "RSA-MD" ]
null
null
null
source/games/sw/src/game.h
Quake-Backup/Raze
16c81f0b1f409436ebf576d2c23f2459a29b34b4
[ "RSA-MD" ]
null
null
null
//------------------------------------------------------------------------- /* Copyright (C) 1997, 2005 - 3D Realms Entertainment This file is part of Shadow Warrior version 1.2 Shadow Warrior is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Original Source: 1997 - Frank Maddin and Jim Norwood Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- #ifndef GAME_H #define GAME_H #ifdef _MSC_VER #pragma warning(disable:4101) // there's too many of these... :( #endif #include "build.h" #include "d_net.h" #include "gamefuncs.h" #include "coreactor.h" #include "sounds.h" #include "gamecvars.h" #include "raze_sound.h" #include "c_cvars.h" #include "mapinfo.h" #include "gamecontrol.h" #include "gamestruct.h" #include "packet.h" #include "gameinput.h" #include "serialize_obj.h" EXTERN_CVAR(Bool, sw_ninjahack) EXTERN_CVAR(Bool, sw_darts) EXTERN_CVAR(Bool, sw_bunnyrockets) BEGIN_SW_NS class DSWActor; using HitInfo = THitInfo<DSWActor>; using Collision = TCollision<DSWActor>; constexpr int BIT(int shift) { return 1 << shift; } struct GAME_SET { // Net Options from Menus uint8_t NetGameType; // 0=DeathMatch [spawn], 1=Cooperative 2=DeathMatch [no spawn] uint8_t NetMonsters; // Cycle skill levels bool NetHurtTeammate; // Allow friendly kills bool NetSpawnMarkers; // Respawn markers on/off bool NetTeamPlay; // Team play uint8_t NetKillLimit; // Number of frags at which game ends uint8_t NetTimeLimit; // Limit time of game uint8_t NetColor; // Chosen color for player bool NetNuke; }; extern const GAME_SET gs_defaults; extern GAME_SET gs; enum { DREALMSPAL = 1, MAXMIRRORS = 8, // This is just some, high, blank tile number not used // by real graphics to put the MAXMIRRORS mirrors in MIRRORLABEL = 6000, }; //#define SW_SHAREWARE 1 // This determines whether game is shareware compile or not! #define SW_SHAREWARE (!!(g_gameType & GAMEFLAG_SHAREWARE)) // Turn warning off for unreferenced variables. // I really should fix them at some point //#pragma off(unreferenced) #define PRODUCTION_ASSERT(f) \ assert(f);\ do { \ if (!(f)) \ I_FatalError("Assertion failed: %s %s, line %u", #f, __FILE__, __LINE__); \ } while (0) #define ASSERT assert int RandomRange(int); inline int RANDOM(void) { randomseed = ((randomseed * 21 + 1) & 65535); return randomseed; } int RANDOM_P2(int pwr_of_2) { return (RANDOM() & (pwr_of_2 - 1)); } // // Map directions/degrees // #if 0 y-- ^ 1536 | | | | | | 2047 <----------------------------> 1024 | 0 x-- | x++ | | | | V 512 y++ #endif ////////////////////////////////////////////////////// // // KEYBOARD // ////////////////////////////////////////////////////// extern bool MenuInputMode; // // Defines // enum { CIRCLE_CAMERA_DIST_MIN = 12000, // dist at which actors will not move (unless shot?? to do) MAX_ACTIVE_RANGE = 42000, // dist at which actors roam about on their own MIN_ACTIVE_RANGE = 20000, }; inline int32_t FIXED(int32_t msw, int32_t lsw) { return IntToFixed(msw) | lsw; } // Ouch... #ifndef WORDS_BIGENDIAN # define MSB_VAR(fixed) (*(((uint8_t*)&(fixed)) + 1)) # define LSB_VAR(fixed) (*((uint8_t*)&(fixed))) #else # define LSB_VAR(fixed) (*(((uint8_t*)&(fixed)) + 1)) # define MSB_VAR(fixed) (*((uint8_t*)&(fixed))) #endif #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) constexpr int NORM_ANGLE(int ang) { return ((ang) & 2047); } inline int RANDOM_NEG(int x, int y) { return ((RANDOM_P2(((x) << (y)) << 1) - (x)) << (y)); } int StdRandomRange(int range); inline int MOVEx(int vel, int ang) { return (MulScale(vel, bcos(ang), 14)); } inline int MOVEy(int vel, int ang) { return (MulScale(vel, bsin(ang), 14)); } inline int SQ(int val) { return val * val; } inline int DIST(int x1, int y1, int x2, int y2) { return ksqrt(SQ((x1)-(x2)) + SQ((y1)-(y2))); } // Distance macro - tx, ty, tmin are holding vars that must be declared in the routine // that uses this macro inline void DISTANCE(int x1, int y1, int x2, int y2, int& dist, int& tx, int& ty, int& tmin) { tx = abs(x2 - x1); ty = abs(y2 - y1); tmin = min(tx, ty); dist = tx + ty - (tmin >> 1); } inline int GetSpriteSizeY(const spritetypebase* sp) { return MulScale(tileHeight(sp->picnum), sp->yrepeat, 6); } inline int GetSpriteSizeZ(const spritetypebase* sp) { return (tileHeight(sp->picnum) * sp->yrepeat) << 2; } // Z size of top (TOS) and bottom (BOS) part of sprite inline int GetSpriteSizeToTop(const spritetypebase* sp) { return ((GetSpriteSizeZ(sp) >> 1) + (tileTopOffset(sp->picnum) << 8)); } inline int GetSpriteSizeToBottom(const spritetypebase* sp) { return ((GetSpriteSizeZ(sp) >> 1) - (tileTopOffset(sp->picnum) << 8)); } // actual Z for TOS and BOS - handles both WYSIWYG and old style inline int GetSpriteZOfTop(const spritetypebase* sp) { return (sp->cstat & CSTAT_SPRITE_YCENTER) ? sp->pos.Z - GetSpriteSizeToTop(sp) : sp->pos.Z - GetSpriteSizeZ(sp); } inline int GetSpriteZOfBottom(const spritetypebase* sp) { return (sp->cstat & CSTAT_SPRITE_YCENTER) ? sp->pos.Z + GetSpriteSizeToBottom(sp) : sp->pos.Z; } // mid and upper/lower sprite calculations constexpr int Z(int value) { return value << 8; } constexpr int PIXZ(int value) { return value >> 8; } // two vectors // can determin direction constexpr int DOT_PRODUCT_2D(int x1, int y1, int x2, int y2) { return (MulScale((x1), (x2), 16) + MulScale((y1), (y2), 16)); } constexpr int SEC(int value) { return ((value) * 120); } enum { CEILING_DIST = (Z(4)), FLOOR_DIST = (Z(4)) }; // Clip Sprite adjustment constexpr int CS(int sprite_bit) { return (sprite_bit) << 16; } enum EClip { // for players to clip against walls CLIPMASK_PLAYER = CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK, // for actors to clip against walls CLIPMASK_ACTOR = CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK | CSTAT_WALL_BLOCK_ACTOR, // for missiles to clip against actors CLIPMASK_MISSILE = CS(CSTAT_SPRITE_BLOCK_HITSCAN | CSTAT_SPRITE_BLOCK_MISSILE) | CSTAT_WALL_BLOCK_HITSCAN, CLIPMASK_WARP_HITSCAN = CS(CSTAT_SPRITE_BLOCK_HITSCAN) | CSTAT_WALL_BLOCK_HITSCAN | CSTAT_WALL_WARP_HITSCAN, }; #define SIZ countof // // Directions // enum { DEGREE_45 = 256, DEGREE_90 = 512 }; //// // // Directional enumerations // //// enum DirOrd { ORD_NORTH, ORD_NE, ORD_EAST, ORD_SE, ORD_SOUTH, ORD_SW, ORD_WEST, ORD_NW }; enum Dir8 { NORTH = ORD_NORTH * DEGREE_45, NE = ORD_NE * DEGREE_45, EAST = ORD_EAST * DEGREE_45, SE = ORD_SE * DEGREE_45, SOUTH = ORD_SOUTH * DEGREE_45, SW = ORD_SW * DEGREE_45, WEST = ORD_WEST * DEGREE_45, NW = ORD_NW * DEGREE_45, }; // Auto building enumerations #define DIGI_ENUM enum digi { #include "digi.h" DIGI_MAX }; #undef DIGI_ENUM #define DAMAGE_ENUM enum dam { #include "damage.h" }; #undef DAMAGE_ENUM //// // // State declarations // //// // Forward declarations struct STATE; struct PANEL_STATE; struct PLAYER; struct PERSONALITY; struct ATTRIBUTE; struct SECTOR_OBJECT; struct PANEL_SPRITE; struct ANIM; class DSWActor; typedef int ANIMATOR (DSWActor* actor); typedef void pANIMATOR (PANEL_SPRITE*); typedef void (*soANIMATORp) (SECTOR_OBJECT*); struct STATE { short Pic; int Tics; ANIMATOR* Animator; STATE* NextState; }; // // State Flags // enum { SF_TICS_MASK = 0xFFFF, SF_QUICK_CALL = BIT(16), SF_PLAYER_FUNC = BIT(17), // only for players to execute SF_TIC_ADJUST = BIT(18), // use tic adjustment for these frames SF_WALL_STATE = BIT(19), // use for walls instead of sprite }; /////////////////////////////////////////////////////////////////////////////// // Jim's MISC declarations from other files /////////////////////////////////////////////////////////////////////////////// enum FOOT_TYPE {WATER_FOOT, BLOOD_FOOT}; extern FOOT_TYPE FootMode; ANIMATOR QueueFloorBlood; // Weapon.c int QueueFootPrint(DSWActor*); // Weapon.c void QueueLoWangs(DSWActor*); // Weapon.c int SpawnShell(DSWActor* actor, int ShellNum); // JWeapon.c void UnlockKeyLock(short key_num, DSWActor* actor); // JSector.c enum { MAX_PAIN = 5, MAX_TAUNTAI = 33, MAX_GETSOUNDS = 5, MAX_YELLSOUNDS = 3, }; extern int PlayerPainVocs[MAX_PAIN]; extern int PlayerLowHealthPainVocs[MAX_PAIN]; extern int TauntAIVocs[MAX_TAUNTAI]; extern int PlayerGetItemVocs[MAX_GETSOUNDS]; extern int PlayerYellVocs[MAX_YELLSOUNDS]; void BossHealthMeter(void); // Global variables used for modifying variouse things from the Console /////////////////////////////////////////////////////////////////////////////////////////// // // JPlayer // /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// // // Weapon // /////////////////////////////////////////////////////////////////////////////////////////// enum { MAX_WEAPONS_KEYS = 10, MAX_WEAPONS_EXTRA = 4, // extra weapons like the two extra head attacks MAX_WEAPONS = (MAX_WEAPONS_KEYS + MAX_WEAPONS_EXTRA), // weapons that not missile type sprites WPN_NM_LAVA = (-8), WPN_NM_SECTOR_SQUISH = (-9), }; //#define WEAP_ENTRY(id, init_func, damage_lo, damage_hi, radius) struct DAMAGE_DATA { void (*Init)(PLAYER*); int16_t damage_lo; int16_t damage_hi; unsigned int radius; int16_t max_ammo; int16_t min_ammo; int16_t with_weapon; int16_t weapon_pickup; int16_t ammo_pickup; }; extern DAMAGE_DATA DamageData[]; // bit arrays that determine if a) Weapon has no ammo b) Weapon is the ammo (no weapon exists) extern int WeaponHasNoAmmo, WeaponIsAmmo; void InitWeaponFist(PLAYER*); void InitWeaponStar(PLAYER*); void InitWeaponShotgun(PLAYER*); void InitWeaponRocket(PLAYER*); void InitWeaponRail(PLAYER*); void InitWeaponMicro(PLAYER*); void InitWeaponUzi(PLAYER*); void InitWeaponSword(PLAYER*); void InitWeaponHothead(PLAYER*); void InitWeaponElectro(PLAYER*); void InitWeaponHeart(PLAYER*); void InitWeaponGrenade(PLAYER*); void InitWeaponMine(PLAYER*); void InitWeaponNapalm(PLAYER*); void InitWeaponRing(PLAYER*); extern void (*InitWeapon[MAX_WEAPONS]) (PLAYER*); /////////////////////////////////////////////////////////////////////////////////////////// // // Player // /////////////////////////////////////////////////////////////////////////////////////////// enum { MAX_SW_PLAYERS_SW = (4), MAX_SW_PLAYERS_REG = (8) }; #define MAX_SW_PLAYERS (SW_SHAREWARE ? MAX_SW_PLAYERS_SW : MAX_SW_PLAYERS_REG) extern int ThemeTrack[6]; // w extern FString ThemeSongs[6]; // enum { MAX_KEYS = 8, MAX_FORTUNES = 16, MAX_INVENTORY_Q = 11,//InvDecl_TOTAL QUOTE_KEYMSG = 1, QUOTE_DOORMSG = QUOTE_KEYMSG + MAX_KEYS, // 23+24 are reserved. QUOTE_COOKIE = 25, QUOTE_INVENTORY = QUOTE_COOKIE + MAX_FORTUNES, QUOTE_WPNFIST = QUOTE_INVENTORY + MAX_INVENTORY_Q, QUOTE_WPNSWORD, QUOTE_WPNSHURIKEN, QUOTE_WPNSTICKY, QUOTE_WPNUZI, QUOTE_WPNLAUNCH, QUOTE_WPNNUKE, QUOTE_WPNGRENADE, QUOTE_WPNRAILGUN, QUOTE_WPNRIOT, QUOTE_WPNHEAD, QUOTE_WPNRIPPER, // Here a gap of two needs to be inserted because the weapon array contains two bogus entries the parser can access. // Not all ammo types here are used, but the entries must be reserved for the parser. QUOTE_AMMOFIST = QUOTE_WPNRIPPER + 2, QUOTE_AMMOSWORD, QUOTE_AMMOSHURIKEN, QUOTE_AMMOSTICKY, QUOTE_AMMOUZI, QUOTE_AMMOLAUNCH, QUOTE_AMMONUKE, QUOTE_AMMOGRENADE, QUOTE_AMMORAILGUN, QUOTE_AMMORIOT, QUOTE_AMMOHEAD, QUOTE_AMMORIPPER, // Again, here a gap of two needs to be inserted because the weapon array contains two bogus entries the parser can access. }; extern bool CameraTestMode; enum PlayerDeathTypes { PLAYER_DEATH_FLIP, PLAYER_DEATH_CRUMBLE, PLAYER_DEATH_EXPLODE, PLAYER_DEATH_RIPPER, PLAYER_DEATH_SQUISH, PLAYER_DEATH_DROWN, MAX_PLAYER_DEATHS }; typedef void (*PLAYER_ACTION_FUNCp)(PLAYER*); #include "inv.h" struct REMOTE_CONTROL { sectortype* cursectp, * lastcursectp; int pang; vec2_t vect, ovect, slide_vect; vec3_t pos; SECTOR_OBJECT* sop_control; }; struct PLAYER { // variable that fit in the sprite or user structure vec3_t pos, opos, oldpos; DSWActor* actor; // this may not be a TObjPtr! TObjPtr<DSWActor*> lowActor, highActor; TObjPtr<DSWActor*> remoteActor; TObjPtr<DSWActor*> PlayerUnderActor; TObjPtr<DSWActor*> KillerActor; //who killed me TObjPtr<DSWActor*> HitBy; // Sprite num of whatever player was last hit by TObjPtr<DSWActor*> last_camera_act; // holds last valid move position vec3_t lv; REMOTE_CONTROL remote; SECTOR_OBJECT* sop_remote; SECTOR_OBJECT* sop; // will either be sop_remote or sop_control int jump_count, jump_speed; // jumping int16_t down_speed, up_speed; // diving int z_speed,oz_speed; // used for diving and flying instead of down_speed, up_speed int climb_ndx; int hiz,loz; int ceiling_dist,floor_dist; sectortype* hi_sectp, *lo_sectp; int circle_camera_dist; vec3_t si; // save player interp position for PlayerSprite int16_t siang; vec2_t vect, ovect, slide_vect; int friction; int16_t slide_ang; int slide_dec; float drive_avel; int16_t view_outside_dang; // outside view delta ang int16_t circle_camera_ang; int16_t camera_check_time_delay; sectortype * cursector, * lastcursector, * lv_sector; void setcursector(sectortype* s) { cursector = s; } bool insector() const { return cursector != nullptr; } // variables that do not fit into sprite structure int hvel,tilt,tilt_dest; PlayerHorizon horizon; PlayerAngle angle; int16_t recoil_amt; int16_t recoil_speed; int16_t recoil_ndx; fixed_t recoil_ohorizoff, recoil_horizoff; vec3_t Revolve; int16_t RevolveDeltaAng; binangle RevolveAng; int16_t pnum; // carry along the player number sectortype* LadderSector; vec3_t LadderPosition; // ladder x and y int16_t JumpDuration; int16_t WadeDepth; int16_t bob_amt; int16_t bob_ndx; int16_t bcnt; // bob count int bob_z, obob_z; //Multiplayer variables InputPacket input; InputPacket lastinput; // must start out as 0 int playerreadyflag; PLAYER_ACTION_FUNCp DoPlayerAction; int Flags, Flags2; ESyncBits KeyPressBits; SECTOR_OBJECT* sop_control; // sector object pointer SECTOR_OBJECT* sop_riding; // sector object pointer struct { PANEL_SPRITE* Next, *Prev; } PanelSpriteList; // hack stuff to get a working pointer to this list element without running into type punning warnings with GCC. // The list uses itself as sentinel element despite the type mismatch. PANEL_SPRITE* GetPanelSpriteList() { void* p = &PanelSpriteList; return reinterpret_cast<PANEL_SPRITE*>(p); } // Key stuff uint8_t HasKey[8]; // Weapon stuff int16_t SwordAng; int WpnGotOnceFlags; // for no respawn mode where weapons are allowed grabbed only once int WpnFlags; int16_t WpnAmmo[MAX_WEAPONS]; int16_t WpnNum; PANEL_SPRITE* CurWpn; PANEL_SPRITE* Wpn[MAX_WEAPONS]; PANEL_SPRITE* Chops; uint8_t WpnRocketType; // rocket type uint8_t WpnRocketHeat; // 5 to 0 range uint8_t WpnRocketNuke; // 1, you have it, or you don't uint8_t WpnFlameType; // Guardian weapons fire uint8_t WpnFirstType; // First weapon type - Sword/Shuriken uint8_t WeaponType; // for weapons with secondary functions int16_t FirePause; // for sector objects - limits rapid firing // // Inventory Vars // int16_t InventoryNum; int16_t InventoryBarTics; int16_t InventoryTics[MAX_INVENTORY]; int16_t InventoryPercent[MAX_INVENTORY]; int8_t InventoryAmount[MAX_INVENTORY]; bool InventoryActive[MAX_INVENTORY]; int16_t DiveTics; int16_t DiveDamageTics; // Death stuff uint16_t DeathType; int16_t Kills; int16_t KilledPlayer[MAX_SW_PLAYERS_REG]; int16_t SecretsFound; // Health int16_t Armor; int16_t MaxHealth; char PlayerName[32]; uint8_t UziShellLeftAlt; uint8_t UziShellRightAlt; uint8_t TeamColor; // used in team play and also used in regular mulit-play for show // palette fading up and down for player hit and get items int16_t FadeTics; // Tics between each fade cycle int16_t FadeAmt; // Current intensity of fade bool NightVision; // Is player's night vision active? uint8_t StartColor; // Darkest color in color range being used //short electro[64]; bool IsAI; // Is this and AI character? int16_t fta,ftq; // First time active and first time quote, for talking in multiplayer games int16_t NumFootPrints; // Number of foot prints left to lay down uint8_t WpnUziType; // Toggle between single or double uzi's if you own 2. uint8_t WpnShotgunType; // Shotgun has normal or fully automatic fire uint8_t WpnShotgunAuto; // 50-0 automatic shotgun rounds uint8_t WpnShotgunLastShell; // Number of last shell fired uint8_t WpnRailType; // Normal Rail Gun or EMP Burst Mode bool Bloody; // Is player gooey from the slaughter? bool InitingNuke; bool TestNukeInit; bool NukeInitialized; // Nuke already has counted down int16_t FistAng; // KungFu attack angle uint8_t WpnKungFuMove; // KungFu special moves int16_t Reverb; // Player's current reverb setting int16_t Heads; // Number of Accursed Heads orbiting player int PlayerVersion; char cookieQuote[256]; // Should be an FString but must be POD for now so that PLAYER remains POD. int cookieTime; uint8_t WpnReloadState; }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; // // Player Flags // enum { PF_DEAD = (BIT(1)), PF_JUMPING = (BIT(2)), PF_FALLING = (BIT(3)), PF_LOCK_CRAWL = (BIT(4)), PF_PLAYER_MOVED = (BIT(7)), PF_PLAYER_RIDING = (BIT(8)), PF_RECOIL = (BIT(10)), PF_FLYING = (BIT(11)), PF_WEAPON_RETRACT = (BIT(12)), PF_PICKED_UP_AN_UZI = (BIT(13)), PF_CRAWLING = (BIT(14)), PF_CLIMBING = (BIT(15)), PF_SWIMMING = (BIT(16)), PF_DIVING = (BIT(17)), PF_DIVING_IN_LAVA = (BIT(18)), PF_TWO_UZI = (BIT(19)), PF_DEAD_HEAD = (BIT(22)), // are your a dead head PF_HEAD_CONTROL = (BIT(23)), // have control of turning when a head? PF_CLIP_CHEAT = (BIT(24)), // cheat for wall clipping PF_SLIDING = (BIT(25)), // cheat for wall clipping PF_VIEW_FROM_OUTSIDE = (BIT(26)), PF_VIEW_OUTSIDE_WEAPON = (BIT(27)), PF_VIEW_FROM_CAMERA = (BIT(28)), PF_TANK = (BIT(29)), // Doin the tank thang PF_WEAPON_DOWN = (BIT(31)), PF2_TELEPORTED = (BIT(0)), PF2_INPUT_CAN_AIM = (BIT(1)), // Allow calling DoPlayerHorizon() from processMovement() PF2_INPUT_CAN_TURN_GENERAL = (BIT(2)), // Allow calling DoPlayerTurn() from processMovement() PF2_INPUT_CAN_TURN_VEHICLE = (BIT(3)), // Allow calling DoPlayerTurnVehicle() from processMovement() PF2_INPUT_CAN_TURN_TURRET = (BIT(4)), // Allow calling DoPlayerTurnTurret() from processMovement() }; /////////////////////////////////////////////////////////////////////////////////////////// // // Actor // /////////////////////////////////////////////////////////////////////////////////////////// // // Hit Points // enum { HEALTH_RIPPER = 70 , HEALTH_RIPPER2 = 200 , HEALTH_MOMMA_RIPPER = 500 , HEALTH_NINJA = 40 , HEALTH_RED_NINJA = 160 , HEALTH_COOLIE = 120 , HEALTH_COOLIE_GHOST = 65 , HEALTH_SKEL_PRIEST = 90 , HEALTH_GORO = 200 , HEALTH_HORNET = 4 , HEALTH_SKULL = 4 , HEALTH_EEL = 100 , HEALTH_SERP_GOD = 3800, }; // // Action Set Structure // enum { MAX_ACTOR_CLOSE_ATTACK = 2, MAX_ACTOR_ATTACK = 6, }; struct ACTOR_ACTION_SET { STATE* *Stand; STATE* *Run; STATE* *Jump; STATE* *Fall; STATE* *Crawl; STATE* *Swim; STATE* *Fly; STATE* *Rise; STATE* *Sit; STATE* *Look; STATE* *Climb; STATE* *Pain; STATE* *Death1; STATE* *Death2; STATE* *Dead; STATE* *DeathJump; STATE* *DeathFall; STATE* *CloseAttack[MAX_ACTOR_CLOSE_ATTACK]; int16_t CloseAttackPercent[MAX_ACTOR_CLOSE_ATTACK]; STATE* *Attack[MAX_ACTOR_ATTACK]; int16_t AttackPercent[MAX_ACTOR_ATTACK]; STATE* *Special[2]; STATE* *Duck; STATE* *Dive; }; struct ROTATOR { int pos; // current position - always moves toward tgt int open_dest; // destination of open position int tgt; // current target int speed; // speed of movement int orig_speed; // original speed - vel jacks with speed int vel; // velocity adjuments TArray<int> origX; TArray<int> origY; void SetNumWalls(int num) { origX.Resize(num); origY.Resize(num); memset(origX.Data(), 0, num * sizeof(int)); memset(origY.Data(), 0, num * sizeof(int)); } void ClearWalls() { origX.Reset(); origY.Reset(); } }; // // User Extension record // struct USER { void Clear() { rotator.Clear(); WallShade.Clear(); memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } // // Variables that can be used by actors and Player // TPointer<ROTATOR> rotator; // wall vars for lighting TArray<int8_t> WallShade; walltype* WallP; // operate on wall instead of sprite STATE* State; STATE* *Rot; STATE* StateStart; STATE* StateEnd; STATE* *StateFallOverride; // a bit kludgy - override std fall state ANIMATOR* ActorActionFunc; ACTOR_ACTION_SET* ActorActionSet; PERSONALITY* Personality; ATTRIBUTE* Attrib; SECTOR_OBJECT* sop_parent; // denotes that this sprite is a part of the // sector object - contains info for the SO // referenced actors TObjPtr<DSWActor*> lowActor, highActor; TObjPtr<DSWActor*> targetActor; // target player for the enemy - can only handle one player at at time TObjPtr<DSWActor*> flameActor; TObjPtr<DSWActor*> attachActor; // attach to sprite if needed - electro snake TObjPtr<DSWActor*> flagOwnerActor; TObjPtr<DSWActor*> WpnGoalActor; int Flags; int Flags2; int Tics; int oz; // serialized copy of sprite.oz int16_t RotNum; int16_t ID; // Health/Pain related int16_t Health; int16_t MaxHealth; int16_t LastDamage; // last damage amount taken int16_t PainThreshold; // amount of damage that can be taken before // going into pain frames. // jump & fall int16_t jump_speed; int16_t jump_grav; // clipmove int16_t ceiling_dist; int16_t floor_dist; int16_t lo_step; int hiz,loz; int zclip; // z height to move up for clipmove int active_range; sectortype* hi_sectp, *lo_sectp; // if a player's sprite points to player structure PLAYER* PlayerP; int16_t Sibling; // // Possibly used by both. // // precalculated vectors vec3_t change; int z_tgt; // velocity int vel_tgt; int16_t vel_rate; uint8_t speed; // Ordinal Speed Range 0-3 from slow to fast int16_t Counter; int16_t Counter2; int16_t Counter3; int16_t DamageTics; int16_t BladeDamageTics; unsigned int Radius; // for distance checking int OverlapZ; // for z overlap variable // // Only have a place for actors // // scaling int16_t scale_speed; unsigned short scale_value; int16_t scale_tgt; // zig zagging int16_t DistCheck; int16_t Dist; int16_t TargetDist; int16_t WaitTics; // track int16_t track; int16_t point; int16_t track_dir; int track_vel; // sliding variables - slide backwards etc int16_t slide_ang; int slide_vel; int16_t slide_dec; int16_t motion_blur_dist; int16_t motion_blur_num; int16_t wait_active_check; // for enemy checking of player int16_t inactive_time; // length of time actor has been unaware of his tgt vec3_t pos; int16_t sang; uint8_t spal; // save off default palette number Collision coll; // same thing broken up into useful components. // Need to get rid of these flags int Flag1; int8_t LastWeaponNum; int8_t WeaponNum; int16_t bounce; // count bounces off wall for killing shrap stuff // !JIM! my extensions int ShellNum; // This is shell no. 0 to whatever // Shell gets deleted when ShellNum < (ShellCount - MAXSHELLS) int16_t FlagOwner; // Not the spritenum of the original flag (abused to hell by other things) int16_t Vis; // Shading upgrade, for shooting, etc... bool DidAlert; // Has actor done his alert noise before? int16_t oangdiff; // Used for interpolating sprite angles uint8_t filler; }; enum { // sprite->extra flags // BUILD AND GAME - DO NOT MOVE THESE SPRX_SKILL = (BIT(0) | BIT(1) | BIT(2)), // BIT(4) ST1 BUILD AND GAME SPRX_STAY_PUT_VATOR = (BIT(5)), // BUILD AND GAME - will not move with vators etc // DO NOT MOVE THIS SPRX_STAG = (BIT(6)), // BUILD AND GAME - NON-ST1 sprite with ST1 type tagging // DO NOT MOVE SPRX_QUEUE_SPRITE = (BIT(7)), // Queue sprite -check queue when deleting SPRX_MULTI_ITEM = (BIT(9)), // BUILD AND GAME - multi player item // have users - could be moved SPRX_PLAYER_OR_ENEMY = (BIT(11)), // for checking quickly if sprite is a // player or actor // do not need Users SPRX_FOUND = (BIT(12)), // BUILD ONLY INTERNAL - used for finding sprites SPRX_BLADE = (BIT(12)), // blade sprite SPRX_BREAKABLE = (BIT(13)), // breakable items SPRX_BURNABLE = (BIT(14)), // used for burnable sprites in the game // temp use SPRX_BLOCK = (BIT(15)), // BUILD AND GAME }; // BUILD - tell which actors should not spawn // GAME - used for internal game code // ALT-M debug mode // !LIGHT // all three bits set - should never happen with skill // #define SPRX_USER_NON_STANDARD (BIT(0)|BIT(1)|BIT(2)) // used for lighting // boolean flags carried over from build enum { SPRX_BOOL11 = (BIT(5)), SPRX_BOOL1 = (BIT(6)), SPRX_BOOL2 = (BIT(7)), SPRX_BOOL3 = (BIT(8)), SPRX_BOOL4 = (BIT(9)), SPRX_BOOL5 = (BIT(10)), SPRX_BOOL6 = (BIT(11)), SPRX_BOOL7 = (BIT(4)), // bit 12 was used build SPRX_BOOL8 = (BIT(13)), SPRX_BOOL9 = (BIT(14)), SPRX_BOOL10 = (BIT(15)), }; // User->Flags flags enum { SPR_MOVED = BIT(0), // Did actor move SPR_ATTACKED = BIT(1), // Is sprite being attacked? SPR_TARGETED = BIT(2), // Is sprite a target of a weapon? SPR_ACTIVE = BIT(3), // Is sprite aware of the player? SPR_ELECTRO_TOLERANT = BIT(4), // Electro spell does not slow actor SPR_JUMPING = BIT(5), // Actor is jumping SPR_FALLING = BIT(6), // Actor is falling SPR_CLIMBING = BIT(7), // Actor is falling SPR_DEAD = BIT(8), // Actor is dying SPR_ZDIFF_MODE = BIT(10), // For following tracks at different z heights SPR_SPEED_UP = BIT(11), // For following tracks at different speeds SPR_SLOW_DOWN = BIT(12), // For following tracks at different speeds SPR_DONT_UPDATE_ANG = BIT(13), // For tracks - don't update the angle for a while SPR_SO_ATTACHED = BIT(14), // sprite is part of a sector object SPR_SUICIDE = BIT(15), // sprite is set to kill itself SPR_RUN_AWAY = BIT(16), // sprite is in "Run Away" track mode. SPR_FIND_PLAYER = BIT(17), // sprite is in "Find Player" track mode. SPR_SWIMMING = BIT(18), // Actor is swimming SPR_WAIT_FOR_PLAYER = BIT(19), // Track Mode - Actor is waiting for player to come close SPR_WAIT_FOR_TRIGGER = BIT(20), // Track Mode - Actor is waiting for player to trigger SPR_SLIDING = BIT(21), // Actor is sliding SPR_ON_SO_SECTOR = BIT(22), // sprite is on a sector object sector SPR_SHADE_DIR = BIT(23), // sprite is on a sector object sector SPR_XFLIP_TOGGLE = BIT(24), // sprite rotation xflip bit SPR_NO_SCAREDZ = BIT(25), // not afraid of falling SPR_SET_POS_DONT_KILL = BIT(26), // Don't kill sprites in MissileSetPos SPR_SKIP2 = BIT(27), // 20 moves ps SPR_SKIP4 = BIT(28), // 10 moves ps SPR_BOUNCE = BIT(29), // For shrapnel types that can bounce once SPR_UNDERWATER = BIT(30), // For missiles etc SPR_SHADOW = BIT(31), // Sprites that have shadows // User->Flags2 flags SPR2_BLUR_TAPER = BIT(13)|BIT(14), // taper type SPR2_BLUR_TAPER_FAST = BIT(13), // taper fast SPR2_BLUR_TAPER_SLOW = BIT(14), // taper slow SPR2_SPRITE_FAKE_BLOCK = BIT(15), // fake blocking bit for damage SPR2_NEVER_RESPAWN = BIT(16), // for item respawning SPR2_ATTACH_WALL = BIT(17), SPR2_ATTACH_FLOOR = BIT(18), SPR2_ATTACH_CEILING = BIT(19), SPR2_CHILDREN = BIT(20), // sprite OWNS children SPR2_SO_MISSILE = BIT(21), // this is a missile from a SO SPR2_DYING = BIT(22), // Sprite is currently dying SPR2_VIS_SHADING = BIT(23), // Sprite shading to go along with vis adjustments SPR2_DONT_TARGET_OWNER = BIT(24), SPR2_FLAMEDIE = BIT(25), // was previously 'flame == -2' }; /////////////////////////////////////////////////////////////////////////////////////////// // // Sector Stuff - Sector Objects and Tracks // /////////////////////////////////////////////////////////////////////////////////////////// // flags in EXTRA variable enum { SECTFX_SINK = BIT(0), SECTFX_OPERATIONAL = BIT(1), SECTFX_WARP_SECTOR = BIT(2), SECTFX_CURRENT = BIT(3), SECTFX_Z_ADJUST = BIT(4), // adjust ceiling/floor SECTFX_NO_RIDE = BIT(5), // moving sector - don't ride it SECTFX_DYNAMIC_AREA = BIT(6), SECTFX_DIVE_AREA = BIT(7), // Diving area SECTFX_UNDERWATER = BIT(8), // Underwater area SECTFX_UNDERWATER2 = BIT(9), // Underwater area SECTFX_LIQUID_MASK = (BIT(10)|BIT(11)), // only valid for sectors with depth SECTFX_LIQUID_NONE = (0), SECTFX_LIQUID_LAVA = BIT(10), SECTFX_LIQUID_WATER = BIT(11), SECTFX_SECTOR_OBJECT = BIT(12), // for collision detection SECTFX_VATOR = BIT(13), // denotes that this is a vertical moving sector vator type SECTFX_TRIGGER = BIT(14), // trigger type to replace tags.h trigger types }; // flags in sector USER structure enum { SECTFU_SO_DONT_BOB = BIT(0), SECTFU_SO_SINK_DEST = BIT(1), SECTFU_SO_DONT_SINK = BIT(2), SECTFU_DONT_COPY_PALETTE = BIT(3), SECTFU_SO_SLOPE_FLOOR_TO_POINT = BIT(4), SECTFU_SO_SLOPE_CEILING_TO_POINT = BIT(5), SECTFU_DAMAGE_ABOVE_SECTOR = BIT(6), SECTFU_VATOR_BOTH = BIT(7), // vators set up for both ceiling and floor SECTFU_CANT_SURFACE = BIT(8), // for diving SECTFU_SLIDE_SECTOR = BIT(9), // for diving }; #define MAKE_STAG_ENUM enum STAG_ID { #include "stag.h" }; #undef MAKE_STAG_ENUM enum { WALLFX_LOOP_DONT_SPIN = BIT(0), WALLFX_LOOP_REVERSE_SPIN = BIT(1), WALLFX_LOOP_SPIN_2X = BIT(2), WALLFX_LOOP_SPIN_4X = BIT(3), WALLFX_LOOP_OUTER = BIT(4), // for sector object WALLFX_DONT_MOVE = BIT(5), // for sector object WALLFX_SECTOR_OBJECT = BIT(6), // for collision detection WALLFX_DONT_STICK = BIT(7), // for bullet holes and stars WALLFX_DONT_SCALE = BIT(8), // for sector object WALLFX_LOOP_OUTER_SECONDARY = BIT(9), // for sector object }; enum ShrapType { SHRAP_NONE = 0, SHRAP_GLASS = 1, // SHRAP_TREE_BARK = 2, // (NEED) outside tree bark SHRAP_SO_SMOKE = 3, // only used for damaged SO's SHRAP_PAPER = 4, // SHRAP_BLOOD = 5, // std blood from gibs SHRAP_EXPLOSION = 6, // small explosion SHRAP_LARGE_EXPLOSION = 7, // large explosion SHRAP_METAL = 8, // SHRAP_STONE = 9, // what we have might be ok SHRAP_PLANT = 10, // (NEED) SHRAP_GIBS = 11, // std blood and guts SHRAP_WOOD = 12, // SHRAP_GENERIC = 13, // what we have might be ok - sort of gray brown rock look SHRAP_TREE_PULP = 14, // (NEED) inside tree wood SHRAP_COIN = 15, SHRAP_METALMIX = 16, SHRAP_WOODMIX = 17, SHRAP_MARBELS = 18, SHRAP_PAPERMIX = 19, SHRAP_USER_DEFINED = 99 }; # define CallocMem(size, num) M_Calloc(size, num) # define FreeMem(ptr) M_Free(ptr) struct TARGET_SORT { DSWActor* actor; int16_t dang; int dist; int weight; }; enum { MAX_TARGET_SORT = 16 }; extern TARGET_SORT TargetSort[MAX_TARGET_SORT]; extern unsigned TargetSortCount; enum DOOR_TYPE { OPERATE_TYPE, DOOR_HORIZ_TYPE, DOOR_SLIDE_TYPE, DOOR_SWING_TYPE, DOOR_ROTATE_TYPE }; struct DOOR_AUTO_CLOSE { DOOR_TYPE Type; int Sector; int16_t Speed; int16_t TimeOut; }; struct SWING { int origx[17], origy[17]; int sector; int16_t angopen, angclosed, angopendir, sang, anginc; }; struct SINE_WAVE_FLOOR { sectortype* sectp; int floor_origz, ceiling_origz, range; int16_t sintable_ndx, speed_shift; uint8_t flags; }; enum { MAX_SINE_WAVE = 12, MAX_SINE_WALL = 10, MAX_SINE_WALL_POINTS = 64, }; extern SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21]; struct SINE_WALL { walltype* wallp; int orig_xy, range; int16_t sintable_ndx, speed_shift, type; }; extern SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS]; struct SPRING_BOARD { sectortype* sectp; int TimeOut; }; extern SPRING_BOARD SpringBoard[20]; extern SWING Rotate[17]; enum { MAX_DOOR_AUTO_CLOSE = 16, MAXANIM = 256 }; extern DOOR_AUTO_CLOSE DoorAutoClose[MAX_DOOR_AUTO_CLOSE]; typedef void (*ANIM_CALLBACKp) (ANIM*, void *); enum { ANIM_Floorz, ANIM_SopZ, ANIM_Spritez, ANIM_Userz, ANIM_SUdepth, }; struct TRACK_POINT { int x, y, z; int16_t ang, tag_low, tag_high, filler; }; struct TRACK { TRACK_POINT* TrackPoint; int ttflags; int flags; int NumPoints; void FreeTrackPoints() { if (TrackPoint) { M_Free(TrackPoint); // !JIM! I added null assigner TrackPoint = nullptr; } } TRACK_POINT* SetTrackSize(unsigned newsize) { FreeTrackPoints(); TrackPoint = (TRACK_POINT*)M_Calloc((newsize * sizeof(TRACK_POINT)), 1); return TrackPoint; } }; // Most track type flags are in tags.h // Regular track flags struct COLOR_MAP { uint8_t FromRange,ToRange,FromColor,ToColor; }; enum { TF_TRACK_OCCUPIED = BIT(0), MAX_TRACKS = 100, MAX_SO_SECTOR = 50, MAX_SO_POINTS = (MAX_SO_SECTOR*15), MAX_SO_SPRITE = 60, MAX_CLIPBOX = 32 }; extern TRACK Track[MAX_TRACKS]; struct SECTOR_OBJECT { soANIMATORp PreMoveAnimator; soANIMATORp PostMoveAnimator; soANIMATORp Animator; TObjPtr<DSWActor*> controller; TObjPtr<DSWActor*> sp_child; // child sprite that holds info for the sector object vec3_t pmid; // midpoints of the sector object TObjPtr<DSWActor*> so_actors[MAX_SO_SPRITE]; // hold the actors of the object TObjPtr<DSWActor*> match_event_actor; // spritenum of the match event sprite sectortype *sectp[MAX_SO_SECTOR], *scratch, // Just a filler to account for shitty loop tests. *op_main_sector, // main sector operational SO moves in - for speed purposes *mid_sector; // middle sector walltype * morph_wall_point; // actual wall point to drag int vel, // velocity vel_tgt, // target velocity player_xoff, // player x offset from the xmid player_yoff, // player y offset from the ymid zorig_floor[MAX_SO_SECTOR], // original z values for all sectors zorig_ceiling[MAX_SO_SECTOR], // original z values for all sectors zdelta, // z delta from original z_tgt, // target z delta z_rate, // rate at which z aproaches target update, // Distance from player at which you continue updating // only works for single player. bob_diff, // bobbing difference for the frame target_dist, // distance to next point floor_loz, // floor low z floor_hiz, // floor hi z morph_z, // morphing point z morph_z_min, // morphing point z min morph_z_max, bob_amt, // bob amount max in z coord // variables set by mappers for drivables drive_angspeed, drive_angslide, drive_speed, drive_slide, crush_z, flags; int16_t xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be yorig[MAX_SO_POINTS], // refreshed max_damage, // max damage ram_damage, // damage taken by ramming wait_tics, // num_sectors, // number of sectors num_walls, // number of sectors track, // the track # 0 to 20 point, // the point on the track that the sector object is headed toward vel_rate, // rate at which velocity aproaches target dir, // direction traveling on the track ang, // angle facing ang_moving, // angle the SO is facing clipdist, // cliping distance for operational sector objects clipbox_dist[MAX_CLIPBOX], // mult-clip box variables clipbox_xoff[MAX_CLIPBOX], // mult-clip box variables clipbox_yoff[MAX_CLIPBOX], // mult-clip box variables clipbox_ang[MAX_CLIPBOX], // mult-clip box variables clipbox_vdist[MAX_CLIPBOX], // mult-clip box variables clipbox_num, ang_tgt, // target angle ang_orig, // original angle last_ang, // last angle before started spinning old_ang, // holding variable for the old angle spin_speed, // spin_speed spin_ang, // spin angle turn_speed, // shift value determines how fast SO turns to match new angle bob_sine_ndx, // index into sine table bob_speed, // shift value for speed save_vel, // save velocity save_spin_speed, // save spin speed match_event, // match number // SO Scaling Vector Info scale_type, // type of scaling - enum controled scale_active_type, // activated by a switch or trigger // values for whole SO scale_dist, // distance from center scale_speed, // speed of scaling scale_dist_min, // absolute min scale_dist_max, // absolute max scale_rand_freq, // freqency of direction change - based on rand(1024) // values for single point scaling scale_point_dist[MAX_SO_POINTS], // distance from center scale_point_speed[MAX_SO_POINTS], // speed of scaling scale_point_base_speed, // base speed of scaling scale_point_dist_min, // absolute min scale_point_dist_max, // absolute max scale_point_rand_freq, // freqency of direction change - based on rand(1024) scale_x_mult, // x multiplyer for scaling scale_y_mult, // y multiplyer for scaling // Used for center point movement morph_ang, // angle moving from CENTER morph_speed, // speed of movement morph_dist_max, // radius boundry morph_rand_freq, // freq of dir change morph_dist, // dist from CENTER morph_z_speed, // z speed for morph point morph_xoff, // save xoff from center morph_yoff, // save yoff from center //scale_rand_reverse, // random at random interval // limit rotation angle limit_ang_center, // for limiting the angle of turning - turrets etc limit_ang_delta; // }; enum { SOBJ_SPEED_UP = BIT(0) , SOBJ_SLOW_DOWN = BIT(1) , SOBJ_ZUP = BIT(2) , SOBJ_ZDOWN = BIT(3) , SOBJ_ZDIFF_MODE = BIT(4) , SOBJ_MOVE_VERTICAL = BIT(5) ,// for sprite objects - move straight up/down SOBJ_ABSOLUTE_ANGLE = BIT(7) , SOBJ_SPRITE_OBJ = BIT(8) , SOBJ_DONT_ROTATE = BIT(9) , SOBJ_WAIT_FOR_EVENT = BIT(10), SOBJ_HAS_WEAPON = BIT(11), SOBJ_SYNC1 = BIT(12), // for syncing up several SO's perfectly SOBJ_SYNC2 = BIT(13), // for syncing up several SO's perfectly SOBJ_DYNAMIC = BIT(14), // denotes scaling or morphing object SOBJ_ZMID_FLOOR = BIT(15), // can't remember which sector objects need this think its the bobbing and sinking ones SOBJ_SLIDE = BIT(16), SOBJ_OPERATIONAL = BIT(17), SOBJ_KILLABLE = BIT(18), SOBJ_DIE_HARD = BIT(19), SOBJ_UPDATE_ONCE = BIT(20), SOBJ_UPDATE = BIT(21), SOBJ_NO_QUAKE = BIT(22), SOBJ_REMOTE_ONLY = BIT(23), SOBJ_RECT_CLIP = BIT(24), SOBJ_BROKEN = BIT(25), }; // track set to these to tell them apart enum { MAX_SECTOR_OBJECTS = 20, SO_OPERATE_TRACK_START = 90, SO_TURRET_MGUN = 96, // machine gun SO_TURRET = 97, SO_VEHICLE = 98, // #define SO_SPEED_BOAT 99 MAXSO = INT32_MAX / 2 }; inline bool SO_EMPTY(SECTOR_OBJECT* sop) { return (sop->pmid.X == MAXSO); } extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS]; /////////////////////////////////////////////////////////////////////////////////////////// // // Prototypes // /////////////////////////////////////////////////////////////////////////////////////////// ANIMATOR NullAnimator; int Distance(int x1, int y1, int x2, int y2); int NewStateGroup(DSWActor* actor, STATE* SpriteGroup[]); void SectorMidPoint(sectortype* sect, int *xmid, int *ymid, int *zmid); void SpawnUser(DSWActor* actor, short id, STATE* state); short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *track_point_num, int *track_dir); // Some sounds were checked by storing handles in static local variables. // Problems with this design: // 1. The variables were unmaintained and could refer to handles that had been reused already. // 2. No proper sound ownership tracking. // 3. In some cases items that were supposed to use the same check referred to different handle variables. // In short: It was very broken. This is a list of all sound items used this way, now each one gets a dedicated channel // so that proper checks can be performed and sound ownership be tracked. enum { CHAN_ToiletFart = 1000, CHAN_AnimeMad = 1001, CHAN_AnimeSing = 1002, CHAN_CoyHandle = 1003, CHAN_RipHeart = 1004, }; short SoundDist(int x, int y, int z, int basedist); short SoundAngle(int x, int y); //void PlaySound(int num, short angle, short vol); int _PlaySound(int num, DSWActor* sprite, PLAYER* player, vec3_t *pos, int flags, int channel, EChanFlags sndflags); void InitAmbient(int num, DSWActor* actor); inline void PlaySound(int num, PLAYER* player, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) { _PlaySound(num, nullptr, player, nullptr, flags, channel, sndflags); } inline void PlaySound(int num, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) { _PlaySound(num, nullptr, nullptr, nullptr, flags, channel, sndflags); } inline void PlaySound(int num, vec3_t *pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) { _PlaySound(num, nullptr, nullptr, pos, flags, channel, sndflags); } int _PlayerSound(int num, PLAYER* pp); inline int PlayerSound(int num, int flags, PLAYER* pp) { return _PlayerSound(num, pp); } void StopPlayerSound(PLAYER* pp, int which = -1); bool SoundValidAndActive(DSWActor* spr, int channel); ANIMATOR DoActorBeginJump,DoActorJump,DoActorBeginFall,DoActorFall,DoActorDeathMove; struct BREAK_INFO; int SpawnShrap(DSWActor*, DSWActor*, int = -1, BREAK_INFO* breakinfo = nullptr); void PlayerUpdateHealth(PLAYER* pp, short value); void PlayerUpdateAmmo(PLAYER* pp, short WeaponNum, short value); void PlayerUpdateWeapon(PLAYER* pp, short WeaponNum); void PlayerUpdateKills(PLAYER* pp, short value); void RefreshInfoLine(PLAYER* pp); void DoAnim(int numtics); void AnimDelete(int animtype, int animindex, DSWActor*); short AnimGetGoal(int animtype, int animindex, DSWActor*); int AnimSet(int animtype, int animindex, DSWActor* animactor, int thegoal, int thevel); int AnimSet(int animtype, sectortype* animindex, int thegoal, int thevel) { return AnimSet(animtype, sectnum(animindex), nullptr, thegoal, thevel); } short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECT* data); short AnimSetVelAdj(short anim_ndx, short vel_adj); void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITY* person); void getzrangepoint(int x, int y, int z, sectortype* sect, int32_t* ceilz, Collision* ceilhit, int32_t* florz, Collision* florhit); Collision move_sprite(DSWActor* , int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); Collision move_missile(DSWActor*, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); DSWActor* DoPickTarget(DSWActor*, uint32_t max_delta_ang, int skip_targets); void change_actor_stat(DSWActor* actor, int stat, bool quick = false); void SetOwner(DSWActor*, DSWActor*, bool flag = true); void SetOwner(int a, int b); // we still need this... void ClearOwner(DSWActor* ownr); DSWActor* GetOwner(DSWActor* child); void SetAttach(DSWActor*, DSWActor*); void analyzesprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang); void CollectPortals(); int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, int hit_y, int hit_z); enum { FAF_PLACE_MIRROR_PIC = 341, FAF_MIRROR_PIC = 2356 }; inline bool FAF_ConnectCeiling(sectortype* sect) { return (sect && sect->ceilingpicnum == FAF_MIRROR_PIC); } inline bool FAF_ConnectFloor(sectortype* sect) { return (sect && sect->floorpicnum == FAF_MIRROR_PIC); } inline bool FAF_ConnectArea(sectortype* sect) { return sect && (FAF_ConnectCeiling(sect) || FAF_ConnectFloor(sect)); } bool PlayerCeilingHit(PLAYER* pp, int zlimit); bool PlayerFloorHit(PLAYER* pp, int zlimit); void FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect, int32_t xvect, int32_t yvect, int32_t zvect, HitInfo& hit, int32_t clipmask); bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, int32_t xe, int32_t ye, int32_t ze, sectortype* secte); void FAFgetzrange(vec3_t pos, sectortype* sect, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask); void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, sectortype* sect, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit); enum SoundType { SOUND_OBJECT_TYPE, SOUND_EVERYTHING_TYPE }; void DoSoundSpotMatch(short match, short sound_num, short sound_type); /////////////////////////////////////////////////////////////////////////////////////////// // // Externs // /////////////////////////////////////////////////////////////////////////////////////////// extern bool NewGame; extern uint8_t CommPlayers; extern bool CommEnabled; extern int LastFrameTics; extern char ds[]; extern short Skill; extern int GodMode; extern bool ReloadPrompt; extern int lockspeed; // Various scattered constants enum { synctics = 3, ACTORMOVETICS = (synctics << 1), TICSPERMOVEMENT = synctics, ACTOR_GRAVITY = 8, // subtract value from clipdist on getzrange calls GETZRANGE_CLIP_ADJ = 8, STAT_DAMAGE_LIST_SIZE = 20, COLOR_PAIN = 128, // Light red range NTAG_SEARCH_LO = 1, NTAG_SEARCH_HI = 2, NTAG_SEARCH_LO_HI = 3, ANIM_SERP = 1, ANIM_SUMO =2, ANIM_ZILLA =3 }; extern int *lastpacket2clock; /////////////////////////// // // RECENT network additions // /////////////////////////// extern double smoothratio; extern int MoveSkip4, MoveSkip2, MoveSkip8; extern int MinEnemySkill; extern short screenpeek; extern int16_t StatDamageList[STAT_DAMAGE_LIST_SIZE]; /////////////////////////////////////////////////////////////// // // Stuff for player palette flashes when hurt or getting items // /////////////////////////////////////////////////////////////// extern void SetFadeAmt(PLAYER* pp, short damage, uint8_t startcolor); extern void DoPaletteFlash(PLAYER* pp); extern bool NightVision; /////////////////////////////////////////////////////////////// // // Stuff added by JonoF. These should get put into their own // headers and included by that which needs them. // /////////////////////////////////////////////////////////////// int PickJumpMaxSpeed(DSWActor*, short max_speed); // ripper.c int DoRipperRipHeart(DSWActor*); // ripper.c int DoRipper2RipHeart(DSWActor*); // ripper2.c DSWActor* BunnyHatch2(DSWActor*); // bunny.c void TerminateLevel(void); // game.c void DrawMenuLevelScreen(void); // game.c void DebugWriteString(char *string); // game.c void getsyncstat(void); // sync.c void SyncStatMessage(void); // sync.c int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c void ScreenCaptureKeys(void); // draw.c void computergetinput(int snum,InputPacket *syn); // jplayer.c void SetupMirrorTiles(void); // rooms.c bool FAF_Sector(sectortype* sect); // rooms.c int GetZadjustment(sectortype* sect,short hitag); // rooms.c void InitSetup(void); // setup.c void LoadKVXFromScript(const char *filename); // scrip2.c void LoadCustomInfoFromScript(const char *filename); // scrip2.c int PlayerInitChemBomb(PLAYER* pp); // jweapon.c int PlayerInitFlashBomb(PLAYER* pp); // jweapon.c int PlayerInitCaltrops(PLAYER* pp); // jweapon.c int InitPhosphorus(DSWActor*); // jweapon.c void SpawnFloorSplash(DSWActor*); // jweapon.c int SaveGame(short save_num); // save.c int LoadGame(short save_num); // save.c int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill); // save,c void LoadGameDescr(short save_num, char *descr); // save.c void SetRotatorActive(DSWActor* actor); // rotator.c bool VatorSwitch(short match, short setting); // vator.c void MoveSpritesWithSector(sectortype* sect,int z_amt,bool type); // vator.c void SetVatorActive(DSWActor*); // vator.c void DoSpikeMatch(short match); // spike.c void SpikeAlign(DSWActor*); // spike.c short DoSectorObjectSetScale(short match); // morph.c short DoSOevent(short match,short state); // morph.c void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop,int x,int y,int z); // morph.c void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop,int x,int y,int z); // morph.c void ScaleSectorObject(SECTOR_OBJECT* sop); // morph.c void MorphTornado(SECTOR_OBJECT* sop); // morph.c void MorphFloor(SECTOR_OBJECT* sop); // morph.c void ScaleRandomPoint(SECTOR_OBJECT* sop,short k,short ang,int x,int y,int *dx,int *dy); // morph.c void CopySectorMatch(int match); // copysect.c int DoWallMoveMatch(short match); // wallmove.c int DoWallMove(DSWActor* sp); // wallmove.c bool CanSeeWallMove(DSWActor* wp,int match); // wallmove.c void DoSpikeOperate(sectortype* sect); // spike.c void SetSpikeActive(DSWActor*); // spike.c DSWActor* insertActor(sectortype* sect, int statnum); void AudioUpdate(void); // stupid extern short LastSaveNum; void LoadSaveMsg(const char *msg); void UpdateStatusBar(); int32_t registerosdcommands(void); extern short LevelSecrets; extern int TotalKillable; extern int OrigCommPlayers; extern uint8_t PlayerGravity; extern short wait_active_check_offset; //extern short Zombies; extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust; extern bool left_foot; extern bool bosswasseen[3]; extern DSWActor* BossSpriteNum[3]; extern int ChopTics; extern int Bunny_Count; struct GameInterface : public ::GameInterface { const char* Name() override { return "ShadowWarrior"; } void app_init() override; void LoadGameTextures(); void loadPalette(); void clearlocalinputstate() override; void FreeLevelData() override; bool GenerateSavePic() override; void MenuSound(EMenuSounds snd) override; bool CanSave() override; bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; void SerializeGameState(FSerializer& arc); void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; void UpdateSounds() override; void ErrorCleanup() override; void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* input = nullptr) override; void DrawBackground(void) override; void Ticker(void) override; void Render() override; //void DrawWeapons() override; void Startup() override; const char *CheckCheatMode() override; const char* GenericCheat(int player, int cheat) override; void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill, bool) override; bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a, double const smoothratio) override; int playerKeyMove() override { return 35; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; void SwitchCoopView() override; int chaseCamX(binangle ang) override { return -ang.bcos(-3); } int chaseCamY(binangle ang) override { return -ang.bsin(-3); } int chaseCamZ(fixedhoriz horiz) override { return horiz.asq16() >> 8; } void processSprites(tspritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override; int Voxelize(int sprnum); void ExitFromMenu() override; int GetCurrentSkill() override; GameStats getStats() override; }; END_SW_NS #include "swactor.h" BEGIN_SW_NS // OVER and UNDER water macros inline bool SectorIsDiveArea(sectortype* sect) { return (sect->extra & SECTFX_DIVE_AREA) ? true : false; } inline bool SectorIsUnderwaterArea(sectortype* sect) { if (!sect) return false; return (sect->extra & (SECTFX_UNDERWATER | SECTFX_UNDERWATER2)) ? true : false; } inline int PlayerFacingRange(PLAYER* pp, DSWActor* a, int range) { return (abs(getincangle(getangle(a->spr.pos.X - (pp)->pos.X, a->spr.pos.Y - (pp)->pos.Y), (pp)->angle.ang.asbuild())) < (range)); } inline int FacingRange(DSWActor* a1, DSWActor* a2, int range) { return (abs(getincangle(getangle(a1->spr.pos.X - a2->spr.pos.X, a1->spr.pos.Y - a2->spr.pos.Y), a2->spr.ang)) < (range)); } inline void SET_BOOL1(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL1; } inline void SET_BOOL2(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL2; } inline void SET_BOOL3(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL3; } inline void SET_BOOL4(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL4; } inline void SET_BOOL5(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL5; } inline void SET_BOOL6(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL6; } inline void SET_BOOL7(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL7; } inline void SET_BOOL8(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL8; } inline void SET_BOOL9(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL9; } inline void SET_BOOL10(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL10; } inline void SET_BOOL11(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL11; } inline void RESET_BOOL1(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL1; } inline void RESET_BOOL2(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL2; } inline void RESET_BOOL3(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL3; } inline void RESET_BOOL4(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL4; } inline void RESET_BOOL5(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL5; } inline void RESET_BOOL6(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL6; } inline void RESET_BOOL7(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL7; } inline void RESET_BOOL8(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL8; } inline void RESET_BOOL9(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL9; } inline void RESET_BOOL10(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL10; } inline void RESET_BOOL11(DSWActor* sp) { sp->spr.extra &= ~SPRX_BOOL11; } inline int TEST_BOOL1(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL1; } inline int TEST_BOOL2(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL2; } inline int TEST_BOOL3(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL3; } inline int TEST_BOOL4(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL4; } inline int TEST_BOOL5(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL5; } inline int TEST_BOOL6(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL6; } inline int TEST_BOOL7(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL7; } inline int TEST_BOOL8(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL8; } inline int TEST_BOOL9(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL9; } inline int TEST_BOOL10(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL10; } inline int TEST_BOOL11(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL11; } // Defines for reading in ST1 sprite tagging inline int16_t SP_TAG1(DSWActor* actor) { return actor->spr.hitag; } inline int16_t& SP_TAG2(DSWActor* actor) { return actor->spr.lotag; } inline uint8_t& SP_TAG3(DSWActor* actor) { return actor->spr.clipdist; } inline int16_t& SP_TAG4(DSWActor* actor) { return actor->spr.ang; } inline int16_t& SP_TAG5(DSWActor* actor) { return actor->spr.xvel; } inline int16_t& SP_TAG6(DSWActor* actor) { return actor->spr.yvel; } inline uint8_t& SP_TAG7(DSWActor* actor) { return MSB_VAR(actor->spr.zvel); } inline uint8_t& SP_TAG8(DSWActor* actor) { return LSB_VAR(actor->spr.zvel); } inline uint8_t& SP_TAG9(DSWActor* actor) { return MSB_VAR(actor->spr.owner); } inline uint8_t& SP_TAG10(DSWActor* actor) { return LSB_VAR(actor->spr.owner); } inline int8_t& SP_TAG11(DSWActor* actor) { return actor->spr.shade; } inline uint8_t& SP_TAG12(DSWActor* actor) { return actor->spr.pal; } inline int16_t SP_TAG13(DSWActor* actor) { return int16_t(uint8_t(actor->spr.xoffset) + (actor->spr.yoffset << 8)); } inline void SET_SP_TAG13(DSWActor* actor, int val) { actor->spr.xoffset = uint8_t(val); actor->spr.yoffset = uint8_t(val >> 8); } // actual Z for TOS and BOS - handles both WYSIWYG and old style inline int ActorZOfTop(DSWActor* actor) { return GetSpriteZOfTop(&actor->spr); } inline int ActorZOfBottom(DSWActor* actor) { return GetSpriteZOfBottom(&actor->spr); } inline int ActorZOfMiddle(DSWActor* actor) { return (ActorZOfTop(actor) + ActorZOfBottom(actor)) >> 1; } inline int ActorSizeZ(DSWActor* actor) { return (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) << 2; } inline int ActorUpperZ(DSWActor* actor) { return (ActorZOfTop(actor) + (ActorSizeZ(actor) >> 2)); } inline int ActorLowerZ(DSWActor* actor) { return (ActorZOfBottom(actor) - (ActorSizeZ(actor) >> 2)); } // Z size of top (TOS) and bottom (BOS) part of sprite inline int ActorSizeToTop(DSWActor* a) { return ((ActorSizeZ(a)) + (tileTopOffset(a->spr.picnum) << 8)) >> 1; } inline int ActorSizeToBottom(DSWActor* a) { return ((ActorSizeZ(a)) - (tileTopOffset(a->spr.picnum) << 8)) >> 1; } inline int ActorSizeX(DSWActor* sp) { return MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6); } inline int ActorSizeY(DSWActor* sp) { return MulScale(tileHeight(sp->spr.picnum), sp->spr.yrepeat, 6); } inline int Facing(DSWActor* actor1, DSWActor* actor2) { return (abs(getincangle(getangle(actor1->spr.pos.X - actor2->spr.pos.X, actor1->spr.pos.Y - actor2->spr.pos.Y), actor2->spr.ang)) < 512); } // Given a z height and sprite return the correct y repeat value inline int GetRepeatFromHeight(DSWActor* sp, int zh) { return zh / (4 * tileHeight(sp->spr.picnum)); } inline bool SpriteInDiveArea(DSWActor* a) { return (a->sector()->extra & SECTFX_DIVE_AREA) ? true : false; } inline bool SpriteInUnderwaterArea(DSWActor* a) { return (a->sector()->extra & (SECTFX_UNDERWATER | SECTFX_UNDERWATER2)) ? true : false; } // just determine if the player is moving inline bool PLAYER_MOVING(PLAYER* pp) { return (pp->vect.X | pp->vect.Y); } inline void PlaySound(int num, DSWActor* actor, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) { _PlaySound(num, actor, nullptr, nullptr, flags, channel, sndflags); } struct ANIM { int animtype, animindex; int goal; int vel; short vel_adj; TObjPtr<DSWActor*> animactor; ANIM_CALLBACKp callback; SECTOR_OBJECT* callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. int& Addr(bool write) { static int scratch; switch (animtype) { case ANIM_Floorz: return *sector[animindex].floorzptr(!write); case ANIM_SopZ: return SectorObject[animindex].pmid.Z; case ANIM_Spritez: if (animactor == nullptr) return scratch; return animactor->spr.pos.Z; case ANIM_Userz: if (animactor == nullptr) return scratch; return animactor->user.pos.Z; case ANIM_SUdepth: return sector[animindex].depth_fixed; default: return animindex; } } }; extern ANIM Anim[MAXANIM]; extern short AnimCnt; struct USERSAVE { int16_t Health; int8_t WeaponNum; int8_t LastWeaponNum; void CopyFromUser(DSWActor* u) { Health = u->user.Health; WeaponNum = u->user.WeaponNum; LastWeaponNum = u->user.LastWeaponNum; } void CopyToUser(DSWActor* u) { u->user.Health = Health; u->user.WeaponNum = WeaponNum; u->user.LastWeaponNum = LastWeaponNum; } }; // save player info when moving to a new level (shortened to only cover the fields that actually are copied back.) extern USERSAVE puser[MAX_SW_PLAYERS_REG]; END_SW_NS #endif
30.385148
146
0.636539
[ "render", "object", "vector", "3d" ]
2b7a2ce1e5cf259f95ecad966505119dafb86512
841
h
C
shill/upstart/upstart_proxy_interface.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
5
2019-01-19T15:38:48.000Z
2021-10-06T03:59:46.000Z
shill/upstart/upstart_proxy_interface.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
1
2021-04-02T17:35:07.000Z
2021-04-02T17:35:07.000Z
shill/upstart/upstart_proxy_interface.h
strassek/chromiumos-platform2
12c953f41f48b8a6b0bd1c181d09bdb1de38325c
[ "BSD-3-Clause" ]
1
2020-11-04T22:31:45.000Z
2020-11-04T22:31:45.000Z
// Copyright 2018 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SHILL_UPSTART_UPSTART_PROXY_INTERFACE_H_ #define SHILL_UPSTART_UPSTART_PROXY_INTERFACE_H_ #include <string> #include <vector> namespace shill { // This class provides access for sending events to upstart. // Call ProxyFactory::CreateUpstartProxy() to create an instance of this // proxy. class UpstartProxyInterface { public: virtual ~UpstartProxyInterface() = default; // Sends a request to upstart to propagate an event. virtual void EmitEvent(const std::string& name, const std::vector<std::string>& env, bool wait) = 0; }; } // namespace shill #endif // SHILL_UPSTART_UPSTART_PROXY_INTERFACE_H_
29
73
0.724138
[ "vector" ]
2b7a55fa326c65c249d3c0e6733fd2d705af0d3b
5,282
h
C
ObitSystem/Obit/include/ObitSwPower.h
sarrvesh/Obit
e4ce6029e9beb2a8c0316ee81ea710b66b2b7986
[ "Linux-OpenIB" ]
5
2019-08-26T06:53:08.000Z
2020-10-20T01:08:59.000Z
ObitSystem/Obit/include/ObitSwPower.h
sarrvesh/Obit
e4ce6029e9beb2a8c0316ee81ea710b66b2b7986
[ "Linux-OpenIB" ]
null
null
null
ObitSystem/Obit/include/ObitSwPower.h
sarrvesh/Obit
e4ce6029e9beb2a8c0316ee81ea710b66b2b7986
[ "Linux-OpenIB" ]
8
2017-08-29T15:12:32.000Z
2022-03-31T12:16:08.000Z
/* $Id$ */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 2010 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*;Correspondence about this software should be addressed as follows: */ /*; Internet email: bcotton@nrao.edu. */ /*; Postal address: William Cotton */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ #ifndef OBITSWPOWER_H #define OBITSWPOWER_H #include "Obit.h" #include "ObitErr.h" #include "ObitUV.h" #include "ObitSwPower.h" #include "ObitTableSY.h" /*-------- Obit: Merx mollis mortibus nuper ------------------*/ /** * \file ObitSwPower.h * * ObitSwPower EVLA Switched Power interpolator class * * The ObitSwPower class provides an interface to a EVLA Switched power (SY) * table allowing interpolation for a given time and antenna. * * \section ObitSwPoweraccess Creators and Destructors * An ObitSwPower will usually be created using ObitSwPowerCreate which allows * specifying a name for the object as well as other information. * * A copy of a pointer to an ObitSwPower should always be made using the * #ObitSwPowerRef function which updates the reference count in the object. * Then whenever freeing an ObitSwPower or changing a pointer, the function * #ObitSwPowerUnref will decrement the reference count and destroy the object * when the reference count hits 0. * There is no explicit destructor. */ /*--------------Class definitions-------------------------------------*/ /** ObitSwPower Class structure. */ typedef struct { #include "ObitSwPowerDef.h" /* this class definition */ } ObitSwPower; /*----------------- Macroes ---------------------------*/ /** * Macro to unreference (and possibly destroy) an ObitSwPower * returns a ObitSwPower*. * in = object to unreference */ #define ObitSwPowerUnref(in) ObitUnref (in) /** * Macro to reference (update reference count) an ObitSwPower. * returns a ObitSwPower*. * in = object to reference */ #define ObitSwPowerRef(in) ObitRef (in) /** * Macro to determine if an object is the member of this or a * derived class. * Returns TRUE if a member, else FALSE * in = object to reference */ #define ObitSwPowerIsA(in) ObitIsA (in, ObitSwPowerGetClass()) /*---------------Public functions---------------------------*/ /** Public: Class initializer. */ void ObitSwPowerClassInit (void); /** Public: Default Constructor. */ ObitSwPower* newObitSwPower (gchar* name); /** Public: Create/initialize ObitSwPower structures */ ObitSwPower* ObitSwPowerCreate (gchar* name, ObitTableSY *SYTable, ObitUV *UVData, ObitErr *err); /** Typedef for definition of class pointer structure */ typedef ObitSwPower* (*ObitSwPowerCreateFP) (gchar* name, ObitTableSY *SYTable, ObitUV *UVData, ObitErr *err); /** Public: ClassInfo pointer */ gconstpointer ObitSwPowerGetClass (void); /** Public: Copy (deep) constructor. */ ObitSwPower* ObitSwPowerCopy (ObitSwPower *in, ObitSwPower *out, ObitErr *err); /** Public: Copy structure. */ void ObitSwPowerClone (ObitSwPower *in, ObitSwPower *out, ObitErr *err); /** Public: Interpolate SwPower values. */ void ObitSwPowerReport (ObitSwPower *in, ofloat time, olong ant, olong suba, ofloat *PwrDif1, ofloat *PwrSum1, ofloat *Gain1, ofloat *PwrDif2, ofloat *PwrSum2, ofloat *Gain2, ObitErr *err); /** Public: Smooth SY table. */ void ObitSwPowerSYSmo (ObitTableSY *SYTab, olong isuba, ObitErr* err) ; /*----------- ClassInfo Structure -----------------------------------*/ /** * ClassInfo Structure. * Contains class name, a pointer to any parent class * (NULL if none) and function pointers. */ typedef struct { #include "ObitSwPowerClassDef.h" } ObitSwPowerClassInfo; #endif /* OBITWPOWER_H */
40.630769
80
0.585006
[ "object" ]
2b82160ef3cb6c11c1839d4810483e7ba8c42d30
6,452
h
C
projects/dpg/dpg_element_vector_provider.h
Fytch/lehrfempp
c804b3e350aa893180f1a02ce57a93b3d7686e91
[ "MIT" ]
16
2018-08-30T19:55:43.000Z
2022-02-16T16:38:06.000Z
projects/dpg/dpg_element_vector_provider.h
Fytch/lehrfempp
c804b3e350aa893180f1a02ce57a93b3d7686e91
[ "MIT" ]
151
2018-05-27T13:01:50.000Z
2021-08-04T14:50:50.000Z
projects/dpg/dpg_element_vector_provider.h
Fytch/lehrfempp
c804b3e350aa893180f1a02ce57a93b3d7686e91
[ "MIT" ]
20
2018-11-13T13:46:38.000Z
2022-02-18T17:33:52.000Z
#ifndef PROJECTS_DPG_DPG_ELEMENT_VECTOR_PROVIDER #define PROJECTS_DPG_DPG_ELEMENT_VECTOR_PROVIDER /** * @file * @brief Class providing element vectors of DPG methods * @author Philippe Peter * @date June 2019 * @copyright MIT License */ #include <lf/mesh/mesh.h> #include "dpg.h" #include "product_element_matrix_provider.h" #include "product_element_vector_provider.h" namespace projects::dpg { /** * @brief Class to evaluate element vectors of DPG methods. * @tparam SCALAR type for the entries of the element matrix. Usually 'double'. * @note This interface class complies with the requirements for the template *parameter `ELEM_VEC_COMP` of the function lf::assemble::AssembleVectorLocally(). * * * This class evaluates the DPG element vector associated to a practical * DPG method * In an abstract setting to evaluate the DPG element vector the following ingredients * are needed * * - A diescrete Test space \f$ U_h \subset U \f$ with * - An enriched discrete test space \f$ V^r \subset V \f$ * - A bilinear form \f$ b : U \times V \rightarrow \mathbb{R} \f$ * - A localizable inner product \f$ (\cdot , \cdot )_V : V \times V \rightarrow \mathbb{R} \f$ * - A linear form \f$ \ell: V \rightarrow \mathbb{R} \f$ * * The practical DPG method can be implemented by computing a DPG element vector. * If \f$ \{ b^1_u \dots b^{Q_U}_u \} \f$ denote the local shape functions of \f$ U_h \f$ and * \f$ \{ b^2_v \dots b^{Q_V}_v \} \f$ denote the local shape functiosn of \f$ V^R \f$ on an elment \f$ K \f$, the * computation of the DPG element vector boils down to * * - Evaluate the extended element stiffness Matrix \f$ B_{i,j} = b(b^j_u,b^i_v) \f$ * - Evaluate the local Gramian matrix \f$ G_{i,j} = (b^i_v,b^j_v)_V \f$ * - Evaluate the extended element load vector \f$ l_{i} = \ell(b^i_v) \f$ * - Evaluate the DPG element vector \f$ \phi^K = B^T G^{-1} l \f$ */ template <typename SCALAR> class DpgElementVectorProvider { public: /** @brief internal type for element vectors */ using elem_vec_t = typename ProductElementVectorProvider<SCALAR>::elem_vec_t; /** @brief Return type of the @ref Eval() method */ using ElemVec = typename ProductElementVectorProvider<SCALAR>::ElemVec; /** @brief return type of the Eval() method of the * ProductElementMatrixProvider class */ using ElemMat = typename ProductElementMatrixProvider<SCALAR>::ElemMat; /** @brief standard constructors */ DpgElementVectorProvider(const DpgElementVectorProvider&) = delete; DpgElementVectorProvider(DpgElementVectorProvider&&) noexcept = default; DpgElementVectorProvider& operator=(const DpgElementVectorProvider&) = delete; DpgElementVectorProvider& operator=(DpgElementVectorProvider&&) = delete; /** * @brief main constructor * @param extendedLoadVectorProvider * evaluates the extended element load vector \f$ l \f$ * @param extendedStiffnessMatrixProvider * evaluates the extended element stiffness matrix \f$B \f$ * @param gramianProvider evaluates the * local Gramian \f$ G \f$ */ DpgElementVectorProvider( std::shared_ptr<ProductElementVectorProvider<SCALAR>> extendedLoadVectorProvider, std::shared_ptr<ProductElementMatrixProvider<SCALAR>> extendedStiffnessMatrixProvider, std::shared_ptr<ProductElementMatrixProvider<SCALAR>> gramianProvider) : extendedLoadVectorProvider_(std::move(extendedLoadVectorProvider)), extendedStiffnessMatrixProvider_( std::move(extendedStiffnessMatrixProvider)), gramianProvider_(std::move(gramianProvider)) {} /** * @brief All cells are considered active in the default implementation * * This method is meant to be overloaded if assembly should be restricted to a * subset of cells. */ virtual bool isActive(const lf::mesh::Entity& /*cell*/) { return true; } /** * @brief main routine for the computation of DPG element vectors * @param cell refernce to the cell for which the DPG element vector * should be computed * @return a small vector, containing the DPG element vector. */ ElemVec Eval(const lf::mesh::Entity& cell); virtual ~DpgElementVectorProvider() = default; private: /** A ProductElementVectorProvider, that evaluates the extended load vector l */ std::shared_ptr<ProductElementVectorProvider<SCALAR>> extendedLoadVectorProvider_; /** A ProductElementMatrixProvider, that evaluates the extended element * stiffness matrix B */ std::shared_ptr<ProductElementMatrixProvider<SCALAR>> extendedStiffnessMatrixProvider_; /** A ProductElementMatrixProvider, that evaluates the local Gramian G */ std::shared_ptr<ProductElementMatrixProvider<SCALAR>> gramianProvider_; }; // template deduction hint: template <class PTR1, class PTR2> DpgElementVectorProvider(PTR1 eLoadVectorProvider, PTR2 eStiffnessProvider, PTR2 gramianProvider) -> DpgElementVectorProvider<typename PTR1::element_type::SCALAR>; // evaluation method template <typename SCALAR> typename DpgElementVectorProvider<SCALAR>::ElemVec DpgElementVectorProvider<SCALAR>::Eval(const lf::mesh::Entity& cell) { // check for nullptrs LF_ASSERT_MSG(extendedLoadVectorProvider_ != nullptr && extendedStiffnessMatrixProvider_ != nullptr && gramianProvider_ != nullptr, "nullptr error for some provider"); LF_ASSERT_MSG(extendedLoadVectorProvider_->isActive(cell) && extendedStiffnessMatrixProvider_->isActive(cell) && gramianProvider_->isActive(cell), "Eval method called on inactive cell"); // evaluate extended element vector l, extended stiffness matrix B and local // Gramian G. ElemVec extendedLoadVector = extendedLoadVectorProvider_->Eval(cell); ElemMat extendedStiffnessMatrix = extendedStiffnessMatrixProvider_->Eval(cell); ElemMat gramian = gramianProvider_->Eval(cell); // perform some size checks. LF_ASSERT_MSG(gramian.rows() == gramian.cols(), "non quadratic gramian of size (" << gramian.rows() << ", " << gramian.cols() << ") on cell " << cell << "\n"); // evaluate element vector B^T G^-1 l return extendedStiffnessMatrix.transpose() * gramian.ldlt().solve(extendedLoadVector); } } // namespace projects::dpg #endif // PROJECTS_DPG_DPG_ELEMENt_VECTOR_PROVIDER
39.82716
80
0.712337
[ "mesh", "shape", "vector" ]
2b8c90e0ebf446f361933842cb5c7f930a199a4f
1,040
h
C
Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/Procedural/ProceduralPrefabUiHandler.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
11
2021-07-08T09:58:26.000Z
2022-03-17T17:59:26.000Z
Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/Procedural/ProceduralPrefabUiHandler.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
29
2021-07-06T19:33:52.000Z
2022-03-22T10:27:49.000Z
Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/Procedural/ProceduralPrefabUiHandler.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
4
2021-07-06T19:24:43.000Z
2022-03-31T12:42:27.000Z
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include <AzToolsFramework/UI/Prefab/PrefabUiHandler.h> #include <AzFramework/Entity/EntityContextBus.h> namespace AzToolsFramework { namespace Prefab { class PrefabFocusPublicInterface; class PrefabPublicInterface; }; //! Implements the Editor UI for Procedural Prefabs. class ProceduralPrefabUiHandler : public PrefabUiHandler { public: AZ_CLASS_ALLOCATOR(ProceduralPrefabUiHandler, AZ::SystemAllocator, 0); AZ_RTTI(AzToolsFramework::ProceduralPrefabUiHandler, "{3A3DF9FF-9C2E-4439-B7B4-72173B5A3502}", PrefabUiHandler); ProceduralPrefabUiHandler(); ~ProceduralPrefabUiHandler() override = default; QString GenerateItemTooltip(AZ::EntityId entityId) const override; }; } // namespace AzToolsFramework
28.108108
120
0.727885
[ "3d" ]
2b9e47c7d627fc957f508de40ca0db79d34370ca
3,154
h
C
include/Cloth.h
LamWS/ClothSimulation
008b24fa96005cbe7ccae27a765d19e5f68a3ef2
[ "MIT" ]
5
2021-11-10T08:39:34.000Z
2022-03-06T10:21:49.000Z
include/Cloth.h
LamWS/ClothSimulation
008b24fa96005cbe7ccae27a765d19e5f68a3ef2
[ "MIT" ]
null
null
null
include/Cloth.h
LamWS/ClothSimulation
008b24fa96005cbe7ccae27a765d19e5f68a3ef2
[ "MIT" ]
null
null
null
// // Created by lamws on 7/26/21. // #ifndef CLOTHSIMULATION_CLOTH_H #define CLOTHSIMULATION_CLOTH_H #include "Eigen/Dense" #include "Eigen/Sparse" #include "common/declarations.h" #include <vector> #include "map" #include <memory> #include "Mesh.h" #include "Energy.h" class Cloth { public: Cloth(const std::string &path, const std::vector<unsigned int> &fix_indices, double density = .01, double shearStiffness = 1, double stretchStiffness = 1, double dampingStiffness = 1, Vector2d anisotropic_a = Vector2d(1, 0), Vector2d anisotropic_b = Vector2d(0, 1), double dt = 1.0 / 60 ); void computeState(double dt); void solveImplicit(double dt); float *raw_vertices(); unsigned int *raw_indices(); int vertices_cnt(); int triangles_cnt(); double computeEnergy(); std::vector<Eigen::Vector3d> computeEnergyGradient(); Eigen::Matrix<double, 9, 9> computeTriangleHessian(int index); void computeHessian(int index); double get_masses(int index); Eigen::Vector3d get_vertex(int index); std::vector<Eigen::Vector3d> get_rest_vertices(); std::vector<Eigen::Vector3d> get_vertices(); std::vector<Eigen::Vector3i> get_triangles(); const std::vector<Eigen::Vector2i> &get_edges(); void set_vertex(int index, const Eigen::Vector3d &value); Eigen::Vector3d get_velocity(int index); void set_velocity(int index, const Eigen::Vector3d &value); Eigen::Vector3d get_maxConer(); Eigen::Vector3d get_minConer(); Eigen::Matrix3d get_constraint(int index); void compute_sewing_hessian(BHessian &BH); private: std::unique_ptr<Mesh> mesh; std::unique_ptr<Energy> stretch_energy, shear_energy; double t_now = 0; std::vector<Matrix<double, 6, 9>> triangle_dfdx; std::map<int, Matrix<double, 6, 9>> triangle_degenerated_isodfdx, triangle_degenerated_anisodfdx; std::vector<Vector3d> velocities; std::vector<Vector3d> accelerations; std::vector<Matrix<double, 9, 1>> forces; std::vector<Matrix<double, 9, 9>> forces_gradient; std::vector<bool> isFixedVertex, isDegenerated; const double density, stretchStiffness, shearStiffness, dampingStiffness; std::vector<double> vertexMasses; std::vector<Matrix3x2d> triangle_F; std::map<int, Matrix3x2d> triangle_degenerated_isoF, triangle_degenerated_anisoF; std::vector<Matrix<double, 6, 6>> H_stretch, H_shear, H_degenerate; Vector2d anisotropic_a, anisotropic_b; std::vector<Matrix2d> triangle_dmInvs; std::vector<double> triangle_areas; SparseMatrix<double, RowMajor> M; SparseMatrix<double, RowMajor> pfpx; SparseMatrix<double, RowMajor> S; std::vector<int> prefix_sum_size; std::vector<Vector2d> triangle_uv_normals; double dt; void computeF(int index); void computeF(); void computeAccelerations(); void computeForces(); void computeForcesGradients(); void computeHessians(); void computeDmInv(); void computeTriangleArea(); void computedFdX(); }; #endif //CLOTHSIMULATION_CLOTH_H
25.031746
101
0.694673
[ "mesh", "vector" ]
2ba23e36fb80cbfb36e8cf94f87812cf785d04aa
821
c
C
lib/wizards/siki/channel/_chl_eth_les.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/siki/channel/_chl_eth_les.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/siki/channel/_chl_eth_les.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
/* Free reinc */ resolve(bonus, target, god,arg) { object ob,obje, r_ob; int effect, exp,i,i2,modifier, worth; string totals, tmp; if (!target) { write("Reincarnate whom?\n"); return; } ob = find_player(lower_case(target)); if (!ob) { write("No such a player.\n"); return 1; } if (!ob->query_dead() && !arg) { write(capitalize(target) + " is not dead.\n"); return 1; } if (ob->query_free_exp() != "0" && ob->query_free_exp() != 0) { write(capitalize(ob->query_real_name())+" has free experience, "+ "can't be reincarnated.\n"); return 1; } r_ob = clone_object("/guilds/spell_obj/reincobject"); r_ob->start(ob, this_player()->query_name()); write("Done casting. Now the target has been given a chance to choose your reincarnation if he wishes to do so.\n"); return 1; }
29.321429
118
0.63581
[ "object" ]
2ba94a2fbbc06b809e8ea86bf36b9dfe76479f9f
2,590
h
C
multiscale/amsiDataDistribution.h
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
multiscale/amsiDataDistribution.h
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
multiscale/amsiDataDistribution.h
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
#ifndef AMSI_DATADISTRIBUTION_H_ #define AMSI_DATADISTRIBUTION_H_ #include "amsiAssemblable.h" #include "amsiDistributed.h" #include "amsiScale.h" #include "amsiTask.h" #include <PCU.h> #include <valarray> #include <vector> #ifdef ZOLTAN struct Zoltan_Struct; #endif namespace amsi { // unused class DistributedData : public Distributed { private: Scale * scl; int lcl_cnt; std::valarray<int> wgts; public: DistributedData(Scale * s,int cnt = 0); virtual void synchronize(); int operator[](unsigned) const; int& operator[](unsigned); void setWeight(unsigned,double); double getWeight(unsigned); }; class DataDistribution : public Assemblable { public: # ifdef ZOLTAN /** * Construct a data distribution object. */ DataDistribution(int sz, int l, bool wgtd = false, Zoltan_Struct * zs = NULL); /** * Get the zoltan structure related to this * DataDistribution. Used primarily by * AMSI load balancing algorithms. */ Zoltan_Struct * GetZS() const { return zs; } # else /** * Construct a data distribution object. */ DataDistribution(int sz, int l, bool wgtd = false); # endif virtual ~DataDistribution() {}; /** * Assemble the DataDistribution, so that * each process has full information on * the current state of the parallel * distribution of the modeled data. */ virtual void Assemble(MPI_Comm); /** * Get the data quantity for the process with rank * idx in the MPI_Comm this DataDistribution is * related to. Strictly a RHS operator. */ int operator[](unsigned idx) const; /** * Set the data quantity for the local process. */ int operator=(int qnt); /** * Accumulate the data quantity for the local process. */ int operator+=(int qnt); /** * Determine if the units of data modeled by this * DataDistribution have a weighting metric associated * with them. */ bool isWeighted() { return wgtd;} /** * Get/Set the weight associated with the wgt-th * unit of data on the n-th process. */ double & getWeight(unsigned nth, unsigned wgt); protected: DataDistribution(); int sz; int lcl_rnk; bool valid; bool wgtd; std::vector<std::vector<double>> wgts; std::vector<int> dd; # ifdef ZOLTAN Zoltan_Struct * zs; # endif }; } // namespace amsi #endif
24.666667
59
0.612355
[ "object", "vector" ]
2bab41104bf77d0182f56d65be2bf7e87d49883e
23,824
c
C
source/physics/Shape.c
VUEngine/VUEngine-Core
4737e0efd2c8e6ba7f69e689bf9e79dcdd627050
[ "MIT" ]
9
2021-01-09T19:24:27.000Z
2022-03-27T11:57:20.000Z
source/physics/Shape.c
VUEngine/VUEngine-Core
4737e0efd2c8e6ba7f69e689bf9e79dcdd627050
[ "MIT" ]
null
null
null
source/physics/Shape.c
VUEngine/VUEngine-Core
4737e0efd2c8e6ba7f69e689bf9e79dcdd627050
[ "MIT" ]
null
null
null
/* VUEngine - Virtual Utopia Engine <https://www.vuengine.dev> * A universal game engine for the Nintendo Virtual Boy * * © Jorge Eremiev <jorgech3@gmail.com> and Christian Radke <c.radke@posteo.de>, 2007-2020 * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial * portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ //--------------------------------------------------------------------------------------------------------- // INCLUDES //--------------------------------------------------------------------------------------------------------- #include <Shape.h> #include <Game.h> #include <CollisionManager.h> #include <CollisionHelper.h> #include <debugConfig.h> //--------------------------------------------------------------------------------------------------------- // CLASS'S MACROS //--------------------------------------------------------------------------------------------------------- #define __STILL_COLLIDING_CHECK_SIZE_INCREMENT __PIXELS_TO_METERS(2) //--------------------------------------------------------------------------------------------------------- // CLASS'S DEFINITION //--------------------------------------------------------------------------------------------------------- friend class VirtualNode; friend class VirtualList; //--------------------------------------------------------------------------------------------------------- // CLASS'S METHODS //--------------------------------------------------------------------------------------------------------- /** * Class constructor * * @param owner */ void Shape::constructor(SpatialObject owner) { // construct base object Base::constructor(); // set the owner this->owner = owner; // not setup yet this->ready = false; this->enabled = true; this->wireframe = NULL; // set flag this->checkForCollisions = false; this->layers = 0; this->layersToIgnore = 0; this->collidingShapes = NULL; this->isVisible = true; this->moved = false; this->registerCollisions = true; this->rightBox.x1 = __I_TO_FIX7_9(1); this->rightBox.y1 = __I_TO_FIX7_9(1); this->rightBox.z1 = __I_TO_FIX7_9(1); this->rightBox.x0 = __I_TO_FIX7_9(-1); this->rightBox.y0 = __I_TO_FIX7_9(-1); this->rightBox.z0 = __I_TO_FIX7_9(-1); } /** * Class destructor */ void Shape::destructor() { // unset owner now this->owner = NULL; Shape::hide(this); if(this->events) { Shape::fireEvent(this, kEventShapeDeleted); NM_ASSERT(!isDeleted(this), "Shape::destructor: deleted this during kEventShapeDeleted"); } if(this->collidingShapes) { VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { CollidingShapeRegistry* collidingShapeRegistry = (CollidingShapeRegistry*)node->data; ASSERT(!isDeleted(collidingShapeRegistry), "Shape::destructor: dead collidingShapeRegistry"); if(!isDeleted(collidingShapeRegistry->shape)) { Shape::removeEventListener(collidingShapeRegistry->shape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeDestroyed, kEventShapeDeleted); Shape::removeEventListener(collidingShapeRegistry->shape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeChanged, kEventShapeChanged); } delete collidingShapeRegistry; } delete this->collidingShapes; this->collidingShapes = NULL; } // destroy the super object // must always be called at the end of the destructor Base::destructor(); } /** * Reset */ void Shape::reset() { if(this->collidingShapes) { VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { CollidingShapeRegistry* collidingShapeRegistry = (CollidingShapeRegistry*)node->data; ASSERT(!isDeleted(collidingShapeRegistry), "Shape::reset: dead collidingShapeRegistry"); if(!isDeleted(collidingShapeRegistry->shape)) { Shape::removeEventListener(collidingShapeRegistry->shape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeDestroyed, kEventShapeDeleted); Shape::removeEventListener(collidingShapeRegistry->shape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeChanged, kEventShapeChanged); } delete collidingShapeRegistry; } delete this->collidingShapes; this->collidingShapes = NULL; } } /** * Setup * * @param layers uint32 * @param layersToIgnore uint32 */ void Shape::setup(uint32 layers, uint32 layersToIgnore) { this->layers = layers; this->layersToIgnore = layersToIgnore; if(this->events) { Shape::fireEvent(this, kEventShapeChanged); NM_ASSERT(!isDeleted(this), "Shape::setup: deleted this during kEventShapeChanged"); } } RightBox Shape::getSurroundingRightBox() { return this->rightBox; } /** * Position * * @return Vector3D */ Vector3D Shape::getNormal() { return Vector3D::zero(); } /** * Position * * @param position Vector3d* * @param rotation Rotation* * @param scale Scale* * @param size Size* */ void Shape::position(const Vector3D* position __attribute__ ((unused)), const Rotation* rotation __attribute__ ((unused)), const Scale* scale __attribute__ ((unused)), const Size* size __attribute__ ((unused))) { if(this->enabled && this->events) { Shape::fireEvent(this, kEventShapeChanged); NM_ASSERT(!isDeleted(this), "Shape::position: deleted this during kEventShapeChanged"); } this->ready = true; this->moved = true; // TODO: must update the rightbox } /** * Set position * * @param position Vector3d* */ void Shape::setPosition(const Vector3D* position __attribute__((unused))) { this->moved = true; // TODO: must update the rightbox } /** * Process enter collision event * * @param collisionData Collision data */ void Shape::enterCollision(CollisionData* collisionData) { if( SpatialObject::enterCollision(this->owner, &collisionData->collisionInformation)) { CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, collisionData->collisionInformation.collidingShape); if(collidingShapeRegistry) { collidingShapeRegistry->frictionCoefficient = SpatialObject::getFrictionCoefficient(collisionData->collisionInformation.collidingShape->owner); } } } /** * Process update collision event * * @param collisionData Collision data */ void Shape::updateCollision(CollisionData* collisionData) { if(collisionData->isImpenetrableCollidingShape) { if(collisionData->collisionInformation.solutionVector.magnitude > __STILL_COLLIDING_CHECK_SIZE_INCREMENT + __PIXELS_TO_METERS(1)) { Shape::resolveCollision(this, &collisionData->collisionInformation, false); } } else { SpatialObject::updateCollision(this->owner, &collisionData->collisionInformation); } } /** * Process exit collision event * * @param collisionData Collision data */ void Shape::exitCollision(CollisionData* collisionData) { SpatialObject::exitCollision(this->owner, collisionData->collisionInformation.shape, collisionData->shapeNotCollidingAnymore, collisionData->isImpenetrableCollidingShape); Shape::unregisterCollidingShape(this, collisionData->shapeNotCollidingAnymore); } /** * Check if collides with other shape * * @param shape shape to check for overlapping * * @return CollisionData */ // check if two rectangles overlap CollisionData Shape::collides(Shape shape) { CollisionData collisionData = { // result kNoCollision, // collision information { // shape NULL, // colliding shape NULL, // solution vector { // direction {0, 0, 0}, // magnitude 0 } }, // out-of-collision shape NULL, // is impenetrable colliding shape false, }; if(isDeleted(this->owner)) { return collisionData; } CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, shape); // test if new collision if(!collidingShapeRegistry) { // check for new overlap collisionData.collisionInformation = CollisionHelper::checkIfOverlap(CollisionHelper::getInstance(), this, shape); if(collisionData.collisionInformation.shape && collisionData.collisionInformation.solutionVector.magnitude) { // new collision collisionData.result = kEnterCollision; if(this->registerCollisions) { collidingShapeRegistry = Shape::registerCollidingShape(this, shape, collisionData.collisionInformation.solutionVector, false); } } //return collisionData; } // impenetrable registered colliding shapes require a another test // to determine if I'm not colliding against them anymore else if(collidingShapeRegistry->isImpenetrable && collidingShapeRegistry->solutionVector.magnitude) { collisionData.collisionInformation = Shape::testForCollision(this, shape, Vector3D::zero(), __STILL_COLLIDING_CHECK_SIZE_INCREMENT); if(collisionData.collisionInformation.shape == this && collisionData.collisionInformation.solutionVector.magnitude >= __STILL_COLLIDING_CHECK_SIZE_INCREMENT) { collisionData.result = kUpdateCollision; collisionData.isImpenetrableCollidingShape = true; } else { collisionData.collisionInformation.shape = this; collisionData.result = kExitCollision; collisionData.isImpenetrableCollidingShape = true; collisionData.shapeNotCollidingAnymore = shape; } } else { // otherwise make a normal collision test collisionData.collisionInformation = CollisionHelper::checkIfOverlap(CollisionHelper::getInstance(), this, shape); if(collisionData.collisionInformation.shape == this && collisionData.collisionInformation.solutionVector.magnitude) { collisionData.result = kUpdateCollision; } else { collisionData.collisionInformation.shape = this; collisionData.result = kExitCollision; collisionData.isImpenetrableCollidingShape = collidingShapeRegistry->isImpenetrable; collisionData.shapeNotCollidingAnymore = shape; } } switch(collisionData.result) { case kEnterCollision: Shape::enterCollision(this, &collisionData); break; case kUpdateCollision: Shape::updateCollision(this, &collisionData); break; case kExitCollision: Shape::exitCollision(this, &collisionData); break; default: break; } return collisionData; } /** * Check if there is a collision in the magnitude * * @param displacement shape displacement */ bool Shape::canMoveTowards(Vector3D displacement, fix10_6 sizeIncrement __attribute__ ((unused))) { if(!this->collidingShapes) { return true; } bool canMove = true; Vector3D normalizedDisplacement = Vector3D::normalize(displacement); VirtualNode node = this->collidingShapes->head; for(; canMove && node; node = node->next) { CollidingShapeRegistry* collidingShapeRegistry = (CollidingShapeRegistry*)node->data; ASSERT(!isDeleted(collidingShapeRegistry), "Shape::canMoveTowards: dead collidingShapeRegistry"); if(collidingShapeRegistry->isImpenetrable) { // check if solution is valid if(collidingShapeRegistry->solutionVector.magnitude) { fix10_6 cosAngle = Vector3D::dotProduct(collidingShapeRegistry->solutionVector.direction, normalizedDisplacement); canMove &= -__F_TO_FIX10_6(1 - 0.01f) < cosAngle; } } } // not colliding anymore return canMove; } /* void Shape::checkPreviousCollisions(Shape collidingShape) { if(!this->collidingShapes) { return; } VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { CollidingShapeRegistry* collidingShapeRegistry = (CollidingShapeRegistry*)node->data; ASSERT(!isDeleted(collidingShapeRegistry), "Shape::invalidateSolutionVectors: dead collidingShapeRegistry"); if(collidingShapeRegistry->isImpenetrable && collidingShapeRegistry->shape != collidingShape) { CollisionInformation collisionInformation = Shape::testForCollision(this, collidingShapeRegistry->shape, Vector3D::zero(), __STILL_COLLIDING_CHECK_SIZE_INCREMENT); if(collisionInformation.shape == this && 0 < collisionInformation.solutionVector.magnitude) { if(collisionInformation.solutionVector.magnitude > __STILL_COLLIDING_CHECK_SIZE_INCREMENT) { if(Shape::canMoveTowards(this, Vector3D::scalarProduct(collidingShapeRegistry->solutionVector.direction, collisionInformation.solutionVector.magnitude), 0)) { Shape::displaceOwner(this, Vector3D::scalarProduct(collisionInformation.solutionVector.direction, collisionInformation.solutionVector.magnitude)); } } else if(collisionInformation.solutionVector.magnitude < collidingShapeRegistry->solutionVector.magnitude) { // since I'm not close to that shape anymore, we can discard it collidingShapeRegistry->solutionVector.magnitude = 0; } } else { // since I'm not close to that shape anymore, we can discard it collidingShapeRegistry->solutionVector.magnitude = 0; } } } } */ /** * Displace owner * * @param displacement Displacement to apply to owner */ void Shape::displaceOwner(Vector3D displacement) { // retrieve the colliding spatialObject's position and gap Vector3D ownerPosition = * SpatialObject::getPosition(this->owner); ownerPosition.x += displacement.x; ownerPosition.y += displacement.y; ownerPosition.z += displacement.z; SpatialObject::setPosition(this->owner, &ownerPosition); } /** * Solve the collision by moving owner */ void Shape::resolveCollision(const CollisionInformation* collisionInformation, bool registerCollidingShape) { ASSERT(collisionInformation->shape, "Shape::resolveCollision: null shape"); ASSERT(collisionInformation->collidingShape, "Shape::resolveCollision: null collidingEntities"); if(isDeleted(this->owner)) { return; } SolutionVector solutionVector = collisionInformation->solutionVector; if(collisionInformation->shape == this && solutionVector.magnitude) { Shape::displaceOwner(this, Vector3D::scalarProduct(solutionVector.direction, solutionVector.magnitude)); // need to invalidate solution vectors for other colliding shapes //Shape::checkPreviousCollisions(this, collisionInformation->collidingShape); if(registerCollidingShape) { CollidingShapeRegistry* collidingShapeRegistry = Shape::registerCollidingShape(this, collisionInformation->collidingShape, collisionInformation->solutionVector, true); ASSERT(!isDeleted(collidingShapeRegistry), "Shape::resolveCollision: dead collidingShapeRegistry"); collidingShapeRegistry->frictionCoefficient = SpatialObject::getFrictionCoefficient(collisionInformation->collidingShape->owner); } } } /** * Retrieve owner * * @return Owning SpatialObject */ SpatialObject Shape::getOwner() { return this->owner; } /** * Is enabled? * * @return Enabled status */ bool Shape::isEnabled() { return this->enabled; } /** * Make this shape to test collision against other shapes * * @param activate */ void Shape::activeCollisionChecks(bool activate) { Shape::setCheckForCollisions(this, activate); CollisionManager::activeCollisionCheckForShape(Game::getCollisionManager(Game::getInstance()), this, activate); } /** * Enable / disable * * @param enable */ void Shape::enable(bool enable) { if(this->enabled != enable) { if(!enable) { Shape::fireEvent(this, kEventShapeChanged); } } this->enabled = enable; if(!this->enabled) { CollisionManager::activeCollisionCheckForShape(Game::getCollisionManager(Game::getInstance()), this, false); } } /** * Has been configured? * * @return Configured status */ bool Shape::isReady() { return this->ready; } /** * Set configured flag * * @param ready */ void Shape::setReady(bool ready) { this->ready = ready; } /** * Set flag * * @param checkForCollisions */ void Shape::setCheckForCollisions(bool checkForCollisions) { this->checkForCollisions = checkForCollisions; } /** * Get flag * * @return Collision check status */ bool Shape::checkForCollisions() { return this->checkForCollisions; } /** * Register colliding shape from the lists * * @private * @param collidingShape Colliding shape to register */ CollidingShapeRegistry* Shape::registerCollidingShape(Shape collidingShape, SolutionVector solutionVector, bool isImpenetrable) { if(!this->collidingShapes) { this->collidingShapes = new VirtualList(); } bool newEntry = false; CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, Shape::safeCast(collidingShape)); if(!collidingShapeRegistry) { newEntry = true; collidingShapeRegistry = new CollidingShapeRegistry; } collidingShapeRegistry->shape = collidingShape; collidingShapeRegistry->solutionVector = solutionVector; collidingShapeRegistry->isImpenetrable = isImpenetrable; collidingShapeRegistry->frictionCoefficient = 0; if(newEntry) { VirtualList::pushBack(this->collidingShapes, collidingShapeRegistry); Shape::addEventListener(collidingShape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeDestroyed, kEventShapeDeleted); Shape::addEventListener(collidingShape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeChanged, kEventShapeChanged); } return collidingShapeRegistry; } /** * Remove colliding shape from the lists * * @private * @param collidingShape Colliding shape to remove */ bool Shape::unregisterCollidingShape(Shape collidingShape) { ASSERT(!isDeleted(collidingShape), "Shape::removeCollidingShape: dead collidingShape"); CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, Shape::safeCast(collidingShape)); if(!collidingShapeRegistry) { return false; } ASSERT(!isDeleted(collidingShapeRegistry), "Shape::removeCollidingShape: dead collidingShapeRegistry"); VirtualList::removeElement(this->collidingShapes, collidingShapeRegistry); delete collidingShapeRegistry; if(!isDeleted(collidingShape)) { Shape::removeEventListener(collidingShape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeDestroyed, kEventShapeDeleted); Shape::removeEventListener(collidingShape, Object::safeCast(this), (EventListener)Shape::onCollidingShapeChanged, kEventShapeChanged); } return true; } /** * Shape destroying listener * * @private * @param eventFirer Destroyed shape */ void Shape::onCollidingShapeDestroyed(Object eventFirer) { if(isDeleted(this->owner)) { return; } Shape shapeNotCollidingAnymore = Shape::safeCast(eventFirer); CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, shapeNotCollidingAnymore); ASSERT(collidingShapeRegistry, "Shape::onCollidingShapeDestroyed: onCollidingShapeDestroyed not found"); if(!collidingShapeRegistry) { return; } bool isImpenetrable = collidingShapeRegistry->isImpenetrable; if(Shape::unregisterCollidingShape(this, shapeNotCollidingAnymore)) { SpatialObject::collidingShapeOwnerDestroyed(this->owner, this, shapeNotCollidingAnymore, isImpenetrable); } } /** * Shape changed listener * * @private * @param eventFirer Changed shape */ void Shape::onCollidingShapeChanged(Object eventFirer) { if(isDeleted(this->owner)) { return; } Shape shapeNotCollidingAnymore = Shape::safeCast(eventFirer); Shape::registerCollidingShape(this, shapeNotCollidingAnymore, (SolutionVector){{0, 0, 0}, 0}, true); CollidingShapeRegistry* collidingShapeRegistry = Shape::findCollidingShapeRegistry(this, shapeNotCollidingAnymore); ASSERT(!isDeleted(collidingShapeRegistry), "Shape::removeCollidingShape: dead collidingShapeRegistry"); bool isImpenetrable = collidingShapeRegistry->isImpenetrable; if(Shape::unregisterCollidingShape(this, shapeNotCollidingAnymore)) { SpatialObject::exitCollision(this->owner, this, shapeNotCollidingAnymore, isImpenetrable); } } /** * Get CollidingShapeRegistry * * @private * @param shape Shape to find * @return CollidingShapeRegistry* */ CollidingShapeRegistry* Shape::findCollidingShapeRegistry(Shape shape) { ASSERT(shape, "Shape::findCollidingShapeRegistry: null shape"); if(!this->collidingShapes || !shape) { return NULL; } VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { ASSERT(!isDeleted(node->data), "Shape::findCollidingShapeRegistry: deleted registry"); if(shape == ((CollidingShapeRegistry*)node->data)->shape) { return (CollidingShapeRegistry*)node->data; } } return NULL; } /** * Get total friction of colliding shapes * * @return The sum of friction coefficients */ fix10_6 Shape::getCollidingFrictionCoefficient() { if(!this->collidingShapes) { return 0; } fix10_6 totalFrictionCoefficient = 0; VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { CollidingShapeRegistry* collidingShapeRegistry = (CollidingShapeRegistry*)node->data; ASSERT(!isDeleted(collidingShapeRegistry), "Shape::getCollidingFriction: dead collidingShapeRegistry"); ASSERT(collidingShapeRegistry->shape, "Shape::getCollidingFriction: null collidingShape"); if(!isDeleted(collidingShapeRegistry->shape->owner)) { totalFrictionCoefficient += collidingShapeRegistry->frictionCoefficient; } } return totalFrictionCoefficient; } int32 Shape::getNumberOfImpenetrableCollidingShapes() { if(!this->collidingShapes) { return 0; } int32 count = 0; VirtualNode node = this->collidingShapes->head; for(; node; node = node->next) { count += ((CollidingShapeRegistry*)node->data)->isImpenetrable ? 1 : 0; } return count; } uint32 Shape::getLayers() { return this->layers; } void Shape::setLayers(uint32 layers) { this->layers = layers; } uint32 Shape::getLayersToIgnore() { return this->layersToIgnore; } void Shape::setLayersToIgnore(uint32 layersToIgnore) { this->layersToIgnore = layersToIgnore; } void Shape::registerCollisions(bool value) { this->registerCollisions = value; } // show me void Shape::show() { if(this->moved) { Shape::hide(this); } Shape::configureWireframe(this); // show the wireframe Wireframe::show(this->wireframe); } // hide polyhedron void Shape::hide() { if(this->wireframe) { // delete the Polyhedron delete this->wireframe; this->wireframe = NULL; } } void Shape::print(int32 x, int32 y) { Printing::text(Printing::getInstance(), "SHAPE ", x, y++, NULL); Printing::text(Printing::getInstance(), "Owner: ", x, y, NULL); Printing::text(Printing::getInstance(), this->owner ? __GET_CLASS_NAME(this->owner) : "No owner", x + 7, y++, NULL); Printing::hex(Printing::getInstance(), (int32)this->owner, x + 7, y++, 8, NULL); Printing::text(Printing::getInstance(), "Colliding shapes: ", x, y, NULL); Printing::int32(Printing::getInstance(), this->collidingShapes ? VirtualList::getSize(this->collidingShapes) : 0, x + 21, y++, NULL); Printing::text(Printing::getInstance(), "Impenetrable shapes: ", x, y, NULL); Printing::int32(Printing::getInstance(), Shape::getNumberOfImpenetrableCollidingShapes(this), x + 21, y++, NULL); }
26.471111
210
0.719527
[ "object", "shape", "vector" ]
2be71a34b0bb83d36f8c21f120667fd569169354
3,488
h
C
chromeos/services/tts/tts_player.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chromeos/services/tts/tts_player.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
chromeos/services/tts/tts_player.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_SERVICES_TTS_TTS_PLAYER_H_ #define CHROMEOS_SERVICES_TTS_TTS_PLAYER_H_ #include "base/synchronization/lock.h" #include "base/thread_annotations.h" #include "chromeos/services/tts/public/mojom/tts_service.mojom.h" #include "media/base/audio_renderer_sink.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/audio/public/cpp/output_device.h" namespace chromeos { namespace tts { class TtsPlayer : public media::AudioRendererSink::RenderCallback { public: typedef std::pair<int, base::TimeDelta> Timepoint; // Helper group of state to pass from main thread to audio thread. struct AudioBuffer { AudioBuffer(); ~AudioBuffer(); AudioBuffer(const AudioBuffer& other) = delete; AudioBuffer(AudioBuffer&& other); std::vector<float> frames; int char_index = -1; int status = 0; bool is_first_buffer = false; }; TtsPlayer(mojo::PendingRemote<media::mojom::AudioStreamFactory> factory, const media::AudioParameters& params); ~TtsPlayer() override; // Audio operations. void Play( base::OnceCallback<void(mojo::PendingReceiver<mojom::TtsEventObserver>)> callback); void AddAudioBuffer(AudioBuffer buf); void AddExplicitTimepoint(int char_index, base::TimeDelta delay); void Stop(); void SetVolume(float volume); void Pause(); void Resume(); // media::AudioRendererSink::RenderCallback: int Render(base::TimeDelta delay, base::TimeTicks delay_timestamp, int prior_frames_skipped, media::AudioBus* dest) override; void OnRenderError() override; private: // Handles stopping tts. void StopLocked(bool clear_buffers = true) EXCLUSIVE_LOCKS_REQUIRED(state_lock_); // Do any processing (e.g. sending start/end events) on buffers that have just // been rendered on the audio thread. void ProcessRenderedBuffers(); // Protects access to state from main thread and audio thread. base::Lock state_lock_; // Connection to send tts events. mojo::Remote<mojom::TtsEventObserver> tts_event_observer_; // Outputs speech synthesis to audio. audio::OutputDevice output_device_; // The queue of audio buffers to be played by the audio thread. std::queue<AudioBuffer> buffers_ GUARDED_BY(state_lock_); std::queue<AudioBuffer> rendered_buffers_; // An explicit list of increasing time delta sorted timepoints to be fired // while rendering audio at the specified |delay| from start of audio // playback. An AudioBuffer may contain an implicit timepoint for callers who // specify a character index along with the audio buffer. std::queue<Timepoint> timepoints_ GUARDED_BY(state_lock_); // The time at which playback of the current utterance started. base::Time start_playback_time_; // Whether a task to process rendered audio buffers has been posted. bool process_rendered_buffers_posted_ GUARDED_BY(state_lock_) = false; // Handles tasks posted from the audio thread, processed in the main thread. scoped_refptr<base::SingleThreadTaskRunner> task_runner_; base::WeakPtrFactory<TtsPlayer> weak_factory_{this}; }; } // namespace tts } // namespace chromeos #endif // CHROMEOS_SERVICES_TTS_TTS_PLAYER_H_
33.864078
80
0.746846
[ "render", "vector" ]
2bf98ebe1159d5aff6744877dfb1d3257f268d23
13,975
c
C
orte/mca/db/daemon/db_daemon.c
bringhurst/ompi
7da12594dc72085162265188b505aca0d0cfe811
[ "BSD-3-Clause-Open-MPI" ]
1
2016-05-01T09:37:07.000Z
2016-05-01T09:37:07.000Z
orte/mca/db/daemon/db_daemon.c
bringhurst/ompi
7da12594dc72085162265188b505aca0d0cfe811
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
orte/mca/db/daemon/db_daemon.c
bringhurst/ompi
7da12594dc72085162265188b505aca0d0cfe811
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
/* * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2004-2011 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ * */ #include "orte_config.h" #include "orte/constants.h" #include <time.h> #include "opal/class/opal_pointer_array.h" #include "opal/dss/dss_types.h" #include "opal/util/output.h" #include "orte/util/show_help.h" #include "orte/util/name_fns.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/rmcast/rmcast.h" #include "orte/runtime/orte_globals.h" #include "orte/runtime/orte_wait.h" #include "orte/mca/db/base/base.h" #include "db_daemon.h" static int init(void); static int finalize(void); static int store(char *key, void *object, opal_data_type_t type); static int set_source(orte_process_name_t *name); static int fetch(char *key, void *object, opal_data_type_t type); static int update(char *key, void *object, opal_data_type_t type); static int remove_data(char *key); orte_db_base_module_t orte_db_daemon_module = { init, finalize, store, set_source, fetch, update, remove_data }; /* local types */ typedef struct { opal_object_t super; orte_process_name_t name; char *key; int32_t size; uint8_t *bytes; } orte_db_data_t; static void dtconstructor(orte_db_data_t *dt) { dt->key = NULL; dt->bytes = NULL; dt->size = 0; } static void dtdestructor(orte_db_data_t *dt) { if (NULL != dt->key) { free(dt->key); } if (NULL != dt->bytes) { free(dt->bytes); } } OBJ_CLASS_INSTANCE(orte_db_data_t, opal_object_t, dtconstructor, dtdestructor); /* local variables */ static orte_vpid_t num_recvd; static bool ack_reqd; static opal_pointer_array_t datastore; static orte_rmcast_channel_t my_group_channel; /* local functions */ static void callback_fn(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata); static void recv_cmd(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata); static void recv_ack(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata); #include MCA_timer_IMPLEMENTATION_HEADER static inline double gettime(void) __opal_attribute_always_inline__; static inline double gettime(void) { double wtime; #if OPAL_TIMER_USEC_NATIVE wtime = ((double) opal_timer_base_get_usec()) / 1000000.0; #else struct timeval tv; gettimeofday(&tv, NULL); wtime = tv.tv_sec; wtime += (double)tv.tv_usec / 1000000.0; #endif return wtime; } #define TIMER_START(x) (x) = gettime(); #define TIMER_STOP(y,x) (y) = (gettime() - (x)); static int init(void) { int rc; if (ORTE_PROC_IS_DAEMON || ORTE_PROC_IS_HNP) { /* daemons recv data server cmds */ if (ORTE_SUCCESS != (rc = orte_rmcast.recv_buffer_nb(ORTE_RMCAST_DATA_SERVER_CHANNEL, ORTE_RMCAST_TAG_DATA, ORTE_RMCAST_PERSISTENT, recv_cmd, NULL))) { ORTE_ERROR_LOG(rc); } OBJ_CONSTRUCT(&datastore, opal_pointer_array_t); opal_pointer_array_init(&datastore, 16, INT_MAX, 16); } else if (ORTE_PROC_IS_APP) { /* get my multicast output group */ orte_rmcast.query_channel(&my_group_channel, NULL); /* recv responses */ if (ORTE_SUCCESS != (rc = orte_rmcast.recv_buffer_nb(my_group_channel, ORTE_RMCAST_TAG_CMD_ACK, ORTE_RMCAST_PERSISTENT, recv_ack, NULL))) { ORTE_ERROR_LOG(rc); } } return ORTE_SUCCESS; } static int finalize(void) { int i; orte_db_data_t *dat; /* cancel the callbacks */ if (ORTE_PROC_IS_DAEMON || ORTE_PROC_IS_HNP) { orte_rmcast.cancel_recv(ORTE_RMCAST_DATA_SERVER_CHANNEL, ORTE_RMCAST_TAG_DATA); for (i=0; i < datastore.size; i++) { if (NULL != (dat = (orte_db_data_t*)opal_pointer_array_get_item(&datastore, i))) { OBJ_RELEASE(dat); } } OBJ_DESTRUCT(&datastore); } else if (ORTE_PROC_IS_APP) { orte_rmcast.cancel_recv(my_group_channel, ORTE_RMCAST_TAG_WILDCARD); } return ORTE_SUCCESS; } static int send_data(orte_db_cmd_t cmd, char *key, void *object, opal_data_type_t type) { opal_buffer_t *buf, dat; orte_job_t *jdata; orte_proc_t *proc; orte_job_state_t *job_state; orte_proc_state_t *proc_state; int rc; bool got_response; opal_byte_object_t bo; /* construct the buffer we will use for packing the data */ buf = OBJ_NEW(opal_buffer_t); opal_dss.pack(buf, &cmd, 1, ORTE_DB_CMD_T); /* add cmd */ opal_dss.pack(buf, &my_group_channel, 1, ORTE_RMCAST_CHANNEL_T); /* tell the server my channel */ opal_dss.pack(buf, &key, 1, OPAL_STRING); /* pack the key */ if (NULL != object) { OBJ_CONSTRUCT(&dat, opal_buffer_t); /* pack the data */ switch (type) { case ORTE_JOB: jdata = (orte_job_t*)object; opal_dss.pack(&dat, &jdata, 1, ORTE_JOB); break; case ORTE_JOB_STATE: job_state = (orte_job_state_t*)object; opal_dss.pack(&dat, job_state, 1, ORTE_JOB_STATE); break; case ORTE_PROC: proc = (orte_proc_t*)object; opal_dss.pack(&dat, &proc, 1, ORTE_PROC); break; case ORTE_PROC_STATE: proc_state = (orte_proc_state_t*)object; opal_dss.pack(&dat, proc_state, 1, ORTE_PROC_STATE); break; default: orte_show_help("help-db-base.txt", "unrecognized-type", true, type); rc = ORTE_ERR_BAD_PARAM; goto cleanup; break; } opal_dss.unload(&dat, (void**)&bo.bytes, &bo.size); opal_dss.pack(buf, &bo.size, 1, OPAL_INT32); opal_dss.pack(buf, &bo.bytes, bo.size, OPAL_UINT8); OBJ_DESTRUCT(&dat); free(bo.bytes); } got_response = false; num_recvd = 0; ack_reqd = true; /* send the data to all the daemons */ if (ORTE_SUCCESS != (rc = orte_rmcast.send_buffer_nb(ORTE_RMCAST_DATA_SERVER_CHANNEL, ORTE_RMCAST_TAG_DATA, buf, callback_fn, NULL))) { ORTE_ERROR_LOG(rc); } /* wait for all daemons to ack the request */ ORTE_PROGRESSED_WAIT(got_response, num_recvd, orte_process_info.num_daemons); ack_reqd = false; cleanup: return rc; } static int store(char *key, void *object, opal_data_type_t type) { int rc; double start; double cpu_time_used; TIMER_START(start); if (ORTE_SUCCESS != (rc = send_data(ORTE_DB_STORE_CMD, key, object, type))) { ORTE_ERROR_LOG(rc); } TIMER_STOP(cpu_time_used, start); opal_output(0, "%s TOOK %g usecs TO STORE", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), cpu_time_used * 1000000.0); return rc; } static int set_source(orte_process_name_t *name) { return ORTE_SUCCESS; } static int fetch(char *key, void *object, opal_data_type_t type) { int rc; double cpu_time_used, start; TIMER_START(start); if (ORTE_SUCCESS != (rc = send_data(ORTE_DB_FETCH_CMD, key, NULL, OPAL_INT32))) { ORTE_ERROR_LOG(rc); } TIMER_STOP(cpu_time_used, start); opal_output(0, "%s TOOK %g usecs TO FETCH", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), cpu_time_used * 1000000.0); return ORTE_SUCCESS; } static int update(char *key, void *object, opal_data_type_t type) { int rc; double start; double cpu_time_used; TIMER_START(start); if (ORTE_SUCCESS != (rc = send_data(ORTE_DB_UPDATE_CMD, key, object, type))) { ORTE_ERROR_LOG(rc); } TIMER_STOP(cpu_time_used, start); opal_output(0, "%s TOOK %g usecs TO UPDATE", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), cpu_time_used * 1000000.0); return rc; } static int remove_data(char *key) { int rc; double start; double cpu_time_used; TIMER_START(start); if (ORTE_SUCCESS != (rc = send_data(ORTE_DB_REMOVE_CMD, key, NULL, OPAL_INT32))) { ORTE_ERROR_LOG(rc); } TIMER_STOP(cpu_time_used, start); opal_output(0, "%s TOOK %g usecs TO REMOVE", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), cpu_time_used * 1000000.0); return rc; } static void callback_fn(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata) { OBJ_RELEASE(buf); } static void recv_ack(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata) { if (ack_reqd) { num_recvd++; } } static void recv_cmd(int status, orte_rmcast_channel_t channel, orte_rmcast_seq_t seq_num, orte_rmcast_tag_t tag, orte_process_name_t *sender, opal_buffer_t *buf, void* cbdata) { orte_db_cmd_t cmd; opal_buffer_t *ans; int count, i; int32_t rc; char *key; orte_db_data_t *dat; orte_rmcast_channel_t ch; char *ch_name; OPAL_OUTPUT_VERBOSE((2, orte_db_base_output, "%s db:daemon: cmd recvd from %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ORTE_NAME_PRINT(sender))); count=1; opal_dss.unpack(buf, &cmd, &count, ORTE_DB_CMD_T); count=1; opal_dss.unpack(buf, &ch, &count, ORTE_RMCAST_CHANNEL_T); count=1; opal_dss.unpack(buf, &ch_name, &count, OPAL_STRING); count=1; opal_dss.unpack(buf, &key, &count, OPAL_STRING); ans = OBJ_NEW(opal_buffer_t); opal_dss.pack(ans, &cmd, 1, ORTE_DB_CMD_T); switch (cmd) { case ORTE_DB_STORE_CMD: dat = OBJ_NEW(orte_db_data_t); dat->name.jobid = sender->jobid; dat->name.vpid = sender->vpid; ORTE_EPOCH_SET(dat->name.epoch,sender->epoch); dat->key = key; count=1; opal_dss.unpack(buf, &dat->size, &count, OPAL_INT32); dat->bytes = (uint8_t*)malloc(dat->size); opal_dss.unpack(buf, dat->bytes, &dat->size, OPAL_UINT8); opal_pointer_array_add(&datastore, dat); OPAL_OUTPUT_VERBOSE((2, orte_db_base_output, "%s db:daemon: data from %s stored: key %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ORTE_NAME_PRINT(sender), key)); rc = ORTE_SUCCESS; opal_dss.pack(ans, &rc, 1, OPAL_INT32); break; case ORTE_DB_FETCH_CMD: /* find the key */ for (i=0; i < datastore.size; i++) { if (NULL == (dat = (orte_db_data_t*)opal_pointer_array_get_item(&datastore, i))) { continue; } if (0 != strcmp(key, dat->key)) { continue; } /* found the data - return it */ rc = ORTE_SUCCESS; opal_dss.pack(ans, &rc, 1, OPAL_INT32); opal_dss.pack(ans, &dat->size, 1, OPAL_INT32); opal_dss.pack(ans, dat->bytes, dat->size, OPAL_UINT8); OPAL_OUTPUT_VERBOSE((2, orte_db_base_output, "%s db:daemon: data fetched for %s: key %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ORTE_NAME_PRINT(sender), key)); break; } rc = ORTE_ERR_NOT_FOUND; opal_dss.pack(ans, &rc, 1, OPAL_INT32); OPAL_OUTPUT_VERBOSE((2, orte_db_base_output, "%s db:daemon: data fetch request from %s not found: key %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ORTE_NAME_PRINT(sender), key)); break; default: rc = ORTE_ERR_NOT_FOUND; break; } /* ensure the return channel is open */ orte_rmcast.open_channel(ch, ch_name, NULL, -1, NULL, ORTE_RMCAST_XMIT); orte_rmcast.send_buffer_nb(ch, ORTE_RMCAST_TAG_CMD_ACK, ans, callback_fn, NULL); }
31.689342
102
0.564794
[ "object" ]
2bfbce27f8408c81bf47e47fcc91050bbb239c71
41,687
c
C
lib-dynload/_recordclass/lib/recordclass/mutabletuple.c
tabulon-ext/dedupsqlfs
9dfbed17450e7f2a499a7381e0368d08ae3c700d
[ "MIT" ]
22
2015-04-09T09:00:00.000Z
2022-03-23T00:16:04.000Z
lib-dynload/_recordclass/lib/recordclass/mutabletuple.c
tabulon-ext/dedupsqlfs
9dfbed17450e7f2a499a7381e0368d08ae3c700d
[ "MIT" ]
119
2015-02-11T21:39:27.000Z
2021-07-27T23:04:49.000Z
lib-dynload/_recordclass/lib/recordclass/mutabletuple.c
tabulon-ext/dedupsqlfs
9dfbed17450e7f2a499a7381e0368d08ae3c700d
[ "MIT" ]
7
2016-03-16T11:53:45.000Z
2022-02-24T13:47:31.000Z
// The MIT License (MIT) // Copyright (c) «2015-2020» «Shibzukhov Zaur, szport at gmail dot com» // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software - recordclass library - and associated documentation files // (the "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, distribute, // sublicense, and/or sell copies of the Software, and to permit persons to whom // the Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #ifdef Py_LIMITED_API #undef Py_LIMITED_API #endif /*#include "pyconfig.h"*/ #include "Python.h" #include <string.h> #ifndef Py_RETURN_NOTIMPLEMENTED /* Macro for returning Py_NotImplemented from a function */ #define Py_RETURN_NOTIMPLEMENTED \ return Py_INCREF(Py_NotImplemented), Py_NotImplemented #endif #define PyMutableTuple_GET_ITEM(op, i) (((PyMutableTupleObject *)(op))->ob_item[i]) #define PyMutableTuple_SET_ITEM(op, i, v) (((PyMutableTupleObject *)(op))->ob_item[i] = v) #define PyMutableTuple_Check(op) (Py_TYPE(op) == &PyMutableTuple_Type || PyObject_IsInstance(op, (PyObject*)&PyMutableTuple_Type)) #define PyMutableTuple_CheckExact(op) (Py_TYPE(op) == &PyMutableTuple_Type) #define IGS_GET_INDEX(op) ((struct mutabletuple_itemgetset_object*)op)->i #if PY_MAJOR_VERSION == 2 static PyObject * _PyObject_GetBuiltin(const char *name) { PyObject *mod_name, *mod, *attr; mod_name = PyUnicode_FromString("__builtin__"); /* borrowed */ if (mod_name == NULL) return NULL; mod = PyImport_Import(mod_name); if (mod == NULL) return NULL; attr = PyObject_GetAttrString(mod, name); Py_DECREF(mod); return attr; } #endif #define DEFERRED_ADDRESS(addr) 0 static PyTypeObject PyMutableTuple_Type; typedef PyTupleObject PyMutableTupleObject; typedef PyTupleObject PyMutableTupleReadonlyObject; static PyObject * PyMutableTuple_New(PyTypeObject *tp, Py_ssize_t size) { PyMutableTupleObject *op; int is_gc; if (size < 0) { PyErr_BadInternalCall(); return NULL; } is_gc = PyType_IS_GC(tp); if (is_gc) op = (PyMutableTupleObject*)_PyObject_GC_NewVar(tp, size); else op = (PyMutableTupleObject*)_PyObject_NewVar(tp, size); if (op == NULL) return NULL; memset(op->ob_item, 0, Py_SIZE(op)*sizeof(void*)); if (is_gc) PyObject_GC_Track(op); return (PyObject*)op; } static PyObject * mutabletuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyTupleObject *tmp; PyMutableTupleObject *newobj; Py_ssize_t i, n; PyObject *item; if (args == NULL) return PyMutableTuple_New(type, 0); if (PyTuple_CheckExact(args)) { tmp = (PyTupleObject*)args; Py_INCREF(args); } else { tmp = (PyTupleObject*)PySequence_Tuple(args); if (tmp == NULL) return NULL; } n = PyTuple_GET_SIZE(tmp); if (type == &PyMutableTuple_Type) { newobj = (PyMutableTupleObject*)PyMutableTuple_New(type, n); } else { //assert(PyType_IsSubtype(type, &PyMutableTuple_Type)); newobj = (PyMutableTupleObject*)(type->tp_alloc(type, n)); if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) Py_INCREF(type); } if (newobj == NULL) { Py_DECREF(tmp); return NULL; } for (i = n; --i >= 0; ) { item = PyTuple_GET_ITEM(tmp, i); newobj->ob_item[i] = item; Py_INCREF(item); } Py_DECREF(tmp); return (PyObject*)newobj; } static PyObject * mutabletuple_getnewargs(PyMutableTupleObject *ob) { PyObject *v; PyTupleObject *res; Py_ssize_t i, n = Py_SIZE(ob); res = (PyTupleObject*)PyTuple_New(n); if (res == NULL) return NULL; for (i = n; --i >= 0; ) { v = PyTuple_GET_ITEM(ob, i); PyTuple_SET_ITEM(res, i, v); Py_INCREF(v); } return (PyObject*)res; } static int mutabletuple_clear(PyMutableTupleObject *op) { Py_ssize_t i; for (i = Py_SIZE(op); --i >= 0; ) { Py_CLEAR(op->ob_item[i]); } return 0; } static void mutabletuple_dealloc(PyMutableTupleObject *op) { Py_ssize_t i; if (PyType_IS_GC(Py_TYPE(op))) PyObject_GC_UnTrack(op); else for (i = Py_SIZE(op); --i >= 0; ) { Py_CLEAR(op->ob_item[i]); } Py_TYPE(op)->tp_free((PyObject *)op); } static void mutabletuple_free(void *o) { #if PY_VERSION_HEX >= 0x03080000 PyTypeObject *type = Py_TYPE(o); #endif if (PyType_IS_GC(Py_TYPE((PyObject*)o))) PyObject_GC_Del((PyObject*)o); else PyObject_Del((PyObject*)o); #if PY_VERSION_HEX >= 0x03080000 // This was not needed before Python 3.8 (Python issue 35810) Py_DECREF(type); #endif } static int mutabletuple_traverse(PyMutableTupleObject *o, visitproc visit, void *arg) { Py_ssize_t i; for (i = Py_SIZE(o); --i >= 0; ) { Py_VISIT(o->ob_item[i]); } return 0; } static PyObject * mutabletuple_repr(PyObject *dd) { PyObject *baserepr; PyObject *v, *result; Py_ssize_t n; n = PyTuple_GET_SIZE(dd); if (n == 0) { #if PY_MAJOR_VERSION >= 3 result = PyUnicode_FromString("mutabletuple()\0"); #else result = PyString_FromString("mutabletuple()\0"); #endif return result; } if (n == 1) { v = PyTuple_GET_ITEM(dd, 0); baserepr = PyObject_Repr(v); #if PY_MAJOR_VERSION >= 3 result = PyUnicode_FromFormat("mutabletuple(%U)", baserepr); #else result = PyString_FromFormat("mutabletuple(%s)", PyString_AS_STRING(baserepr)); #endif return result; } baserepr = PyTuple_Type.tp_repr(dd); if (baserepr == NULL) return NULL; #if PY_MAJOR_VERSION >= 3 result = PyUnicode_FromFormat("mutabletuple%U", baserepr); #else result = PyString_FromFormat("mutabletuple%s", PyString_AS_STRING(baserepr)); #endif Py_DECREF(baserepr); return result; } PyDoc_STRVAR(mutabletuple_doc, "mutabletuple([...]) --> mutabletuple\n\n\ "); static PyObject * mutabletuple_concat(PyMutableTupleObject *a, PyObject *bb) { Py_ssize_t size; Py_ssize_t i, n; PyObject **src, **dest; PyMutableTupleObject *np; if (!PyTuple_Check(bb) && !PyMutableTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only concatenate tuple (not \"%.200s\") to tuple", Py_TYPE(bb)->tp_name); return NULL; } #define b ((PyMutableTupleObject *)bb) size = Py_SIZE(a) + Py_SIZE(b); if (size < 0) return PyErr_NoMemory(); np = (PyMutableTupleObject *) PyMutableTuple_New(Py_TYPE(a), size); if (np == NULL) { return NULL; } src = a->ob_item; dest = np->ob_item; n = Py_SIZE(a); if (n > 0) { for (i = 0; i < n; i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } } src = b->ob_item; dest = np->ob_item + Py_SIZE(a); n = Py_SIZE(b); for (i = 0; i < n; i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } #undef b return (PyObject *)np; } static PyObject * mutabletuple_slice(PyMutableTupleObject *a, Py_ssize_t ilow, Py_ssize_t ihigh) { #define aa ((PyMutableTupleObject*)a) PyMutableTupleObject *np; PyObject **src, **dest; Py_ssize_t i; Py_ssize_t len; if (ilow < 0) ilow = 0; if (ihigh > Py_SIZE(a)) ihigh = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; if (ilow == 0 && ihigh == Py_SIZE(a) && Py_TYPE(a) == &PyMutableTuple_Type) { Py_INCREF(a); return (PyObject*)a; } len = ihigh - ilow; if (Py_TYPE(a) == &PyMutableTuple_Type) np = (PyMutableTupleObject*)PyMutableTuple_New(&PyMutableTuple_Type, len); else np = (PyMutableTupleObject*)(Py_TYPE(a)->tp_alloc(Py_TYPE(a), len)); if (np == NULL) return NULL; src = aa->ob_item + ilow; dest = np->ob_item; if (len > 0) { for (i = 0; i < len; i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } } return (PyObject *)np; #undef aa } static int mutabletuple_ass_slice(PyMutableTupleObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) { PyObject **item; PyObject **vitem = NULL; PyObject *v_as_SF = NULL; /* PySequence_Fast(v) */ Py_ssize_t n; Py_ssize_t k; int result = -1; if (v == NULL) return result; else { if ((PyObject*)a == v) { v = mutabletuple_slice((PyMutableTupleObject*)v, 0, Py_SIZE(v)); if (v == NULL) return result; result = mutabletuple_ass_slice(a, ilow, ihigh, v); Py_DECREF(v); return result; } v_as_SF = PySequence_Fast(v, "can only assign an iterable"); if(v_as_SF == NULL) { return result; } n = PySequence_Fast_GET_SIZE(v_as_SF); vitem = PySequence_Fast_ITEMS(v_as_SF); } if (ilow < 0) ilow = 0; else if (ilow > Py_SIZE(a)) ilow = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; else if (ihigh > Py_SIZE(a)) ihigh = Py_SIZE(a); if (n != ihigh - ilow) { Py_XDECREF(v_as_SF); return -1; } item = ((PyMutableTupleObject*)a)->ob_item; if (n > 0) { for (k = 0; k < n; k++, ilow++) { PyObject *w = vitem[k]; PyObject *u = item[ilow]; Py_XDECREF(u); item[ilow] = w; Py_XINCREF(w); } } Py_XDECREF(v_as_SF); return 0; } static int mutabletuple_ass_item(PyMutableTupleObject *a, Py_ssize_t i, PyObject *v) { PyObject *old_value; if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "assignment index out of range"); return -1; } if (v == NULL) return -1; old_value = PyMutableTuple_GET_ITEM(a, i); Py_XDECREF(old_value); PyMutableTuple_SET_ITEM(a, i, v); Py_INCREF(v); return 0; } static PyObject * mutabletuple_item(PyMutableTupleObject *a, Py_ssize_t i) { PyObject* v; if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; } v = a->ob_item[i]; Py_INCREF(v); return (PyObject*)v; } static PyObject* mutabletuple_subscript(PyMutableTupleObject* self, PyObject* item) { if (PyIndex_Check(item)) { PyObject *v; Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i < 0) { if (i == -1 && PyErr_Occurred()) return NULL; i += Py_SIZE(self); } if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; } v = self->ob_item[i]; Py_INCREF(v); return (PyObject*)v; } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; #if PY_MAJOR_VERSION >= 3 if (PySlice_GetIndicesEx(item, (PyTuple_GET_SIZE(self)), &start, &stop, &step, &slicelength) < 0) { return NULL; } #else if (PySlice_GetIndicesEx(((PySliceObject*)item), (PyTuple_GET_SIZE(self)), &start, &stop, &step, &slicelength) < 0) { return NULL; } #endif return mutabletuple_slice(self, start, stop); } else { #if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) #else if (PyString_Check(item)) #endif { PyObject *ob = PyObject_GetAttr((PyObject*)self, item); if (ob == NULL) { PyErr_Format(PyExc_KeyError, "Invalid key"); return NULL; } //Py_INCREF(ob); return ob; } else { PyErr_Format(PyExc_TypeError, "subscript must be integer, slice or string, but not %.200s", Py_TYPE(item)->tp_name); return NULL; } } } static int mutabletuple_ass_subscript(PyMutableTupleObject* self, PyObject* item, PyObject* value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) i += PyList_GET_SIZE(self); return mutabletuple_ass_item(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; #if PY_MAJOR_VERSION >= 3 if (PySlice_GetIndicesEx(item, (Py_SIZE(self)), &start, &stop, &step, &slicelength) < 0) { return -1; } #else if (PySlice_GetIndicesEx(((PySliceObject*)item), (Py_SIZE(self)), &start, &stop, &step, &slicelength) < 0) { return -1; } #endif return mutabletuple_ass_slice(self, start, stop, value); } else { #if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) #else if (PyString_Check(item)) #endif { int res = PyObject_SetAttr((PyObject*)self, item, value); if (res == -1) { PyErr_Format(PyExc_KeyError, "Invalid key"); return res; } return 0; } else { PyErr_Format(PyExc_TypeError, "indices must be integers, not %.200s", Py_TYPE(item)->tp_name); return -1; } } } static PyObject * mutabletuple_repeat(PyMutableTupleObject *a, Py_ssize_t n) { Py_ssize_t i, j; Py_ssize_t size; PyTupleObject *np; PyObject **p, **items; if (n < 0) n = 0; if (Py_SIZE(a) == 0) { return PyMutableTuple_New(Py_TYPE(a), 0); } if (n > PY_SSIZE_T_MAX / Py_SIZE(a)) return PyErr_NoMemory(); size = Py_SIZE(a); np = (PyMutableTupleObject *) PyMutableTuple_New(Py_TYPE(a), Py_SIZE(a) * n); if (np == NULL) return NULL; if (size == 0) return (PyObject *)np; p = np->ob_item; items = a->ob_item; for (i = 0; i < n; i++) { for (j = 0; j < size; j++) { *p = items[j]; Py_INCREF(*p); p++; } } return (PyObject *) np; } PyDoc_STRVAR(mutabletuple_len_doc, "T.__len__() -- len of T"); static Py_ssize_t mutabletuple_len(PyMutableTupleObject *op) { return Py_SIZE(op); } PyDoc_STRVAR(mutabletuple_sizeof_doc, "T.__sizeof__() -- size of T in memory, in bytes"); static PyObject * mutabletuple_sizeof(PyMutableTupleObject *self) { Py_ssize_t res; res = PyMutableTuple_Type.tp_basicsize + Py_SIZE(self) * sizeof(PyObject*); return PyLong_FromSsize_t(res); } static PyObject * mutabletuple_richcompare(PyObject *v, PyObject *w, int op) { PyMutableTupleObject *vt, *wt; Py_ssize_t i; Py_ssize_t vlen, wlen; if (!PyType_IsSubtype(Py_TYPE(v), &PyMutableTuple_Type) || (!PyType_IsSubtype(Py_TYPE(w), &PyMutableTuple_Type) && !PyTuple_Check(w))) Py_RETURN_NOTIMPLEMENTED; vt = (PyMutableTupleObject *)v; wt = (PyMutableTupleObject *)w; vlen = Py_SIZE(vt); wlen = Py_SIZE(wt); if ((vlen != wlen) && (op == Py_EQ || op == Py_NE)) { PyObject *res; if (op == Py_EQ) res = Py_False; else res = Py_True; Py_INCREF(res); return res; } for (i = 0; i < vlen && i < wlen; i++) { int k = PyObject_RichCompareBool(vt->ob_item[i], wt->ob_item[i], Py_EQ); if (k < 0) return NULL; if (!k) break; } if (i >= vlen || i >= wlen) { /* No more items to compare -- compare sizes */ int cmp; PyObject *res; switch (op) { case Py_LT: cmp = vlen < wlen; break; case Py_LE: cmp = vlen <= wlen; break; case Py_EQ: cmp = vlen == wlen; break; case Py_NE: cmp = vlen != wlen; break; case Py_GT: cmp = vlen > wlen; break; case Py_GE: cmp = vlen >= wlen; break; default: return NULL; /* cannot happen */ } if (cmp) res = Py_True; else res = Py_False; Py_INCREF(res); return res; } /* We have an item that differs -- shortcuts for EQ/NE */ if (op == Py_EQ) { Py_INCREF(Py_False); return Py_False; } if (op == Py_NE) { Py_INCREF(Py_True); return Py_True; } /* Compare the final item again using the proper operator */ return PyObject_RichCompare(vt->ob_item[i], wt->ob_item[i], op); } static PySequenceMethods mutabletuple_as_sequence = { (lenfunc)mutabletuple_len, /* sq_length */ (binaryfunc)mutabletuple_concat, /* sq_concat */ (ssizeargfunc)mutabletuple_repeat, /* sq_repeat */ (ssizeargfunc)mutabletuple_item, /* sq_item */ 0, /* sq_slice */ (ssizeobjargproc)mutabletuple_ass_item, /* sq_ass_item */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ 0, /* sq_contains */ }; static PyMappingMethods mutabletuple_as_mapping = { (lenfunc)mutabletuple_len, (binaryfunc)mutabletuple_subscript, (objobjargproc)mutabletuple_ass_subscript }; static PySequenceMethods mutabletuplereadonly_as_sequence = { (lenfunc)mutabletuple_len, /* sq_length */ (binaryfunc)mutabletuple_concat, /* sq_concat */ (ssizeargfunc)mutabletuple_repeat, /* sq_repeat */ (ssizeargfunc)mutabletuple_item, /* sq_item */ 0, /* sq_slice */ 0, /* sq_ass_item */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ 0, /* sq_contains */ }; static PyMappingMethods mutabletuplereadonly_as_mapping = { (lenfunc)mutabletuple_len, (binaryfunc)mutabletuple_subscript, 0 }; PyDoc_STRVAR(mutabletuple_copy_doc, "D.copy() -> a shallow copy of D."); static PyObject * mutabletuple_copy(PyMutableTupleObject *ob) { return mutabletuple_slice(ob, 0, PyTuple_GET_SIZE(ob)); } PyDoc_STRVAR(mutabletuple_reduce_doc, "D.__reduce__()"); static PyObject * mutabletuple_reduce(PyObject *ob) { PyObject *args; PyObject *result; PyObject *tmp; tmp = PySequence_Tuple(ob); args = PyTuple_Pack(1, tmp); Py_DECREF(tmp); if (args == NULL) return NULL; result = PyTuple_Pack(2, &PyMutableTuple_Type, args); Py_DECREF(args); return result; } static long mutabletuple_hash(PyObject *v) { register long x, y; register Py_ssize_t len = Py_SIZE(v); register PyObject **p; long mult = 1000003L; x = 0x345678L; p = ((PyTupleObject*)v)->ob_item; while (--len >= 0) { y = PyObject_Hash(*p++); if (y == -1) return -1; x = (x ^ y) * mult; /* the cast might truncate len; that doesn't change hash stability */ mult += (long)(82520L + len + len); } x += 97531L; if (x == -1) x = -2; return x; } static PyMethodDef mutabletuple_methods[] = { {"__getnewargs__", (PyCFunction)mutabletuple_getnewargs, METH_NOARGS}, /*{"copy", (PyCFunction)mutabletuple_copy, METH_NOARGS, mutabletuple_copy_doc},*/ {"__copy__", (PyCFunction)mutabletuple_copy, METH_NOARGS, mutabletuple_copy_doc}, {"__len__", (PyCFunction)mutabletuple_len, METH_NOARGS, mutabletuple_len_doc}, {"__sizeof__", (PyCFunction)mutabletuple_sizeof, METH_NOARGS, mutabletuple_sizeof_doc}, {"__reduce__", (PyCFunction)mutabletuple_reduce, METH_NOARGS, mutabletuple_reduce_doc}, {NULL} }; static PyObject* mutabletuple_iter(PyObject *seq); static PyTypeObject PyMutableTuple_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "recordclass.mutabletuple.mutabletuple", /* tp_name */ sizeof(PyMutableTupleObject) - sizeof(PyObject*), /* tp_basicsize */ sizeof(PyObject*), /* tp_itemsize */ /* methods */ (destructor)mutabletuple_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ (reprfunc)mutabletuple_repr, /* tp_repr */ 0, /* tp_as_number */ &mutabletuple_as_sequence, /* tp_as_sequence */ &mutabletuple_as_mapping, /* tp_as_mapping */ PyObject_HashNotImplemented, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ mutabletuple_doc, /* tp_doc */ (traverseproc)mutabletuple_traverse, /* tp_traverse */ (inquiry)mutabletuple_clear, /* tp_clear */ mutabletuple_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset*/ mutabletuple_iter, /* tp_iter */ 0, /* tp_iternext */ mutabletuple_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_mutabletuple */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_mutabletupleoffset */ 0, /* tp_init */ 0, /* tp_alloc */ mutabletuple_new, /* tp_new */ mutabletuple_free, /* tp_free */ 0 /* tp_is_gc */ }; static PyTypeObject PyImmutableTuple_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "recordclass.mutabletuple.immutabletuple", /* tp_name */ sizeof(PyMutableTupleObject) - sizeof(PyObject*), /* tp_basicsize */ sizeof(PyObject*), /* tp_itemsize */ /* methods */ (destructor)mutabletuple_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ (reprfunc)mutabletuple_repr, /* tp_repr */ 0, /* tp_as_number */ &mutabletuplereadonly_as_sequence, /* tp_as_sequence */ &mutabletuplereadonly_as_mapping, /* tp_as_mapping */ mutabletuple_hash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ mutabletuple_doc, /* tp_doc */ (traverseproc)mutabletuple_traverse, /* tp_traverse */ (inquiry)mutabletuple_clear, /* tp_clear */ mutabletuple_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset*/ mutabletuple_iter, /* tp_iter */ 0, /* tp_iternext */ mutabletuple_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_mutabletuple */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_mutabletupleoffset */ 0, /* tp_init */ 0, /* tp_alloc */ mutabletuple_new, /* tp_new */ mutabletuple_free, /* tp_free */ 0 /* tp_is_gc */ }; /*********************** MutableTuple Iterator **************************/ typedef struct { PyObject_HEAD Py_ssize_t it_index; PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */ } mutabletupleiterobject; static void mutabletupleiter_dealloc(mutabletupleiterobject *it) { PyObject_GC_UnTrack(it); Py_CLEAR(it->it_seq); PyObject_GC_Del(it); } static int mutabletupleiter_traverse(mutabletupleiterobject *it, visitproc visit, void *arg) { Py_VISIT(it->it_seq); return 0; } static int mutabletupleiter_clear(mutabletupleiterobject *it) { Py_CLEAR(it->it_seq); return 0; } static PyObject * mutabletupleiter_next(mutabletupleiterobject *it) { PyTupleObject *seq; PyObject *item; // assert(it != NULL); seq = it->it_seq; if (seq == NULL) return NULL; // assert(PyTuple_Check(seq)); if (it->it_index < PyTuple_GET_SIZE(seq)) { item = PyTuple_GET_ITEM(seq, it->it_index); Py_INCREF(item); ++it->it_index; return item; } Py_DECREF(seq); it->it_seq = NULL; return NULL; } static PyObject * mutabletupleiter_len(mutabletupleiterobject *it) { Py_ssize_t len = 0; if (it->it_seq) len = PyTuple_GET_SIZE(it->it_seq) - it->it_index; return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); static PyObject * mutabletupleiter_reduce(mutabletupleiterobject *it) //, PyObject *Py_UNUSED(ignore)) { #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 _Py_IDENTIFIER(iter); if (it->it_seq) return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter), it->it_seq, it->it_index); else return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); #else if (it->it_seq) return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"), it->it_seq, it->it_index); else return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); #endif } PyDoc_STRVAR(mutabletupleiter_reduce_doc, "D.__reduce__()"); static PyObject * mutabletupleiter_setstate(mutabletupleiterobject *it, PyObject *state) { Py_ssize_t index; #if PY_MAJOR_VERSION >= 3 index = PyLong_AsSsize_t(state); #else index = PyNumber_AsSsize_t(state, NULL); #endif if (index == -1 && PyErr_Occurred()) return NULL; if (it->it_seq != NULL) { if (index < 0) index = 0; else if (index > PyTuple_GET_SIZE(it->it_seq)) index = PyTuple_GET_SIZE(it->it_seq); /* exhausted iterator */ it->it_index = index; } Py_RETURN_NONE; } PyDoc_STRVAR(setstate_doc, "Set state information for unpickling."); static PyMethodDef mutabletupleiter_methods[] = { {"__length_hint__", (PyCFunction)mutabletupleiter_len, METH_NOARGS, length_hint_doc}, {"__reduce__", (PyCFunction)mutabletupleiter_reduce, METH_NOARGS, mutabletupleiter_reduce_doc}, {"__setstate__", (PyCFunction)mutabletupleiter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ }; PyTypeObject PyMutableTupleIter_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "recordclass.mutabletuple.mutabletuple_iterator", /* tp_name */ sizeof(mutabletupleiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)mutabletupleiter_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)mutabletupleiter_traverse, /* tp_traverse */ (inquiry)mutabletupleiter_clear, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ (iternextfunc)mutabletupleiter_next, /* tp_iternext */ mutabletupleiter_methods, /* tp_methods */ 0, }; static PyObject * mutabletuple_iter(PyObject *seq) { mutabletupleiterobject *it; it = PyObject_GC_New(mutabletupleiterobject, &PyMutableTupleIter_Type); if (it == NULL) return NULL; it->it_index = 0; it->it_seq = (PyTupleObject *)seq; Py_INCREF(seq); PyObject_GC_Track(it); return (PyObject *)it; } struct mutabletuple_itemgetset_object { PyObject_HEAD Py_ssize_t i; }; /*static PyTypeObject mutabletuple_itemgetset_Type;*/ static PyMethodDef mutabletuple_itemgetset_methods[] = { {0, 0, 0, 0} }; static PyObject* mutabletuple_itemgetset_new(PyTypeObject *t, PyObject *args, PyObject *k) { PyObject *ob; PyObject *item; Py_ssize_t i; ob = (PyObject*) PyBaseObject_Type.tp_new(t, PyTuple_New(0), 0); if (ob == NULL) return NULL; item = PyTuple_GET_ITEM(args, 0); i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) { Py_DECREF(ob); return NULL; } ((struct mutabletuple_itemgetset_object*)ob)->i = i; return ob; } static void mutabletuple_itemgetset_dealloc(PyObject *o) { PyObject_Del(o); } static PyObject* mutabletuple_itemgetset_get(PyObject *self, PyObject *obj, PyObject *type) { //Py_ssize_t i; PyObject *v; if (obj == NULL || obj == Py_None) { Py_INCREF(self); return self; } v = PyTuple_GET_ITEM(obj, IGS_GET_INDEX(self)); Py_INCREF(v); return v; } static int mutabletuple_itemgetset_set(PyObject *self, PyObject *obj, PyObject *value) { Py_ssize_t i; PyObject *v; if (value == NULL) { PyErr_SetString(PyExc_NotImplementedError, "__delete__"); return -1; } if (obj == NULL || obj == Py_None) return 0; i = IGS_GET_INDEX(self); v = PyTuple_GET_ITEM(obj, i); Py_XDECREF(v); PyTuple_SET_ITEM(obj, i, value); Py_INCREF(value); return 0; } static PyTypeObject mutabletuple_itemgetset_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "recordclass.mutabletuple.mutabletuple_itemgetset", /*tp_name*/ sizeof(struct mutabletuple_itemgetset_object), /*tp_basicsize*/ 0, /*tp_itemsize*/ mutabletuple_itemgetset_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ mutabletuple_itemgetset_methods, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ mutabletuple_itemgetset_get, /*tp_descr_get*/ mutabletuple_itemgetset_set, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ mutabletuple_itemgetset_new, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ }; static PyTypeObject ItemGet_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "recordclass.mutabletuple.mutabletuple_itemget", /*tp_name*/ sizeof(struct mutabletuple_itemgetset_object), /*tp_basicsize*/ 0, /*tp_itemsize*/ mutabletuple_itemgetset_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ mutabletuple_itemgetset_methods, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ mutabletuple_itemgetset_get, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ mutabletuple_itemgetset_new, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ }; // static PyObject* get_item(PyObject *mod, PyObject *args) { // PyObject *res; // PyObject *obj = PyTuple_GET_ITEM(args, 0); // PyObject *ind = PyTuple_GET_ITEM(args, 1); // PyObject **ob_items = (PyObject**)((char*)obj + sizeof(PyObject)); // Py_ssize_t i = PyNumber_AsSsize_t(ind, PyExc_IndexError); // if (i == -1 && PyErr_Occurred()) { // return NULL; // } // res = ob_items[i]; // Py_INCREF(res); // return res; // } /* List of functions defined in the module */ PyDoc_STRVAR(mutabletuplemodule_doc, "MutableTuple module provide mutable tuple-like type `mutabletuple` and descriptor type `mutabletuple_itemgetset`."); // static PyObject * // mutabletuple_freeze(PyObject *module, PyObject *args) // { // if (Py_SIZE(args) > 2) // return NULL; // PyObject *ob = PyTuple_GET_ITEM(args, 0); // PyObject *is_copy = PyTuple_GET_ITEM(args, 1); // if (PyObject_IsInstance(&PyMutableTupleTypeRO_Type) { // Py_INCREF(ob); // return ob; // } // if (PyObject_Bool(is_copy)) // ob = mutabletuple_slice(ob, 0, Py_SIZE(ob)); // if (PyObject_IsInstance(&PyMutableTupleType_Type) { // Py_DECREF((PyObject*)Py_TYPE(ob)); // Py_TYPE(ob) = &PyMutableTupleType_Type; // Py_INCREF((PyObject*)&PyMutableTupleType_Type); // } // return mutabletuple_slice(ob, 0, PyTuple_GET_SIZE(ob)); // } #if PY_MAJOR_VERSION >= 3 static PyMethodDef mutabletuplemodule_methods[] = { // {"getitem", get_item, METH_VARARGS, "__getitem__"}, // {"freeze", mutabletuple_freeze, METH_VARARGS, "freeze mutabletuple object (make it readonly and hashable)"}, {0, 0, 0, 0} }; static struct PyModuleDef mutabletuplemodule = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "recordclass.mutabletuple", mutabletuplemodule_doc, -1, mutabletuplemodule_methods, NULL, NULL, NULL, NULL }; #endif #if PY_MAJOR_VERSION >= 3 PyMODINIT_FUNC PyInit_mutabletuple(void) { PyObject *m; m = PyState_FindModule(&mutabletuplemodule); if (m) { Py_INCREF(m); return m; } m = PyModule_Create(&mutabletuplemodule); if (m == NULL) return NULL; if (PyType_Ready(&PyMutableTuple_Type) < 0) Py_FatalError("Can't initialize mutabletuple type"); if (PyType_Ready(&PyImmutableTuple_Type) < 0) Py_FatalError("Can't initialize mutabletuplereadonly type"); if (PyType_Ready(&mutabletuple_itemgetset_Type) < 0) Py_FatalError("Can't initialize mutabletuple_itemgetset type"); if (PyType_Ready(&ItemGet_Type) < 0) Py_FatalError("Can't initialize mutabletuple_itemget type"); if (PyType_Ready(&PyMutableTupleIter_Type) < 0) Py_FatalError("Can't initialize mutabletuple iter type"); #if PY_VERSION_HEX >= 0x03080000 if (PyMutableTuple_Type.tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) PyMutableTuple_Type.tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; if (PyImmutableTuple_Type.tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) PyImmutableTuple_Type.tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; if (mutabletuple_itemgetset_Type.tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) mutabletuple_itemgetset_Type.tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; if (PyMutableTupleIter_Type.tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) PyMutableTupleIter_Type.tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; if (ItemGet_Type.tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) ItemGet_Type.tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; #endif Py_INCREF(&PyMutableTuple_Type); PyModule_AddObject(m, "mutabletuple", (PyObject *)&PyMutableTuple_Type); Py_INCREF(&PyImmutableTuple_Type); PyModule_AddObject(m, "immutabletuple", (PyObject *)&PyImmutableTuple_Type); Py_INCREF(&mutabletuple_itemgetset_Type); PyModule_AddObject(m, "mutabletuple_itemgetset", (PyObject *)&mutabletuple_itemgetset_Type); Py_INCREF(&ItemGet_Type); PyModule_AddObject(m, "mutabletuple_itemget", (PyObject *)&ItemGet_Type); Py_INCREF(&PyMutableTupleIter_Type); PyModule_AddObject(m, "mutabletupleiter", (PyObject *)&PyMutableTupleIter_Type); return m; } #else PyMODINIT_FUNC initmutabletuple(void) { PyObject *m; m = Py_InitModule3("recordclass.mutabletuple", NULL, mutabletuplemodule_doc); if (m == NULL) return; Py_XINCREF(m); if (PyType_Ready(&PyMutableTuple_Type) < 0) Py_FatalError("Can't initialize mutabletuple type"); if (PyType_Ready(&PyImmutableTuple_Type) < 0) Py_FatalError("Can't initialize mutabletuplereadonly type"); if (PyType_Ready(&mutabletuple_itemgetset_Type) < 0) Py_FatalError("Can't initialize mutabletuple_itemgetset type"); if (PyType_Ready(&ItemGet_Type) < 0) Py_FatalError("Can't initialize mutabletuple_itemget type"); if (PyType_Ready(&PyMutableTupleIter_Type) < 0) Py_FatalError("Can't initialize mutabletuple iter type"); Py_INCREF(&PyMutableTuple_Type); PyModule_AddObject(m, "mutabletuple", (PyObject *)&PyMutableTuple_Type); Py_INCREF(&PyImmutableTuple_Type); PyModule_AddObject(m, "immutabletuple", (PyObject *)&PyImmutableTuple_Type); Py_INCREF(&mutabletuple_itemgetset_Type); PyModule_AddObject(m, "mutabletuple_itemgetset", (PyObject *)&mutabletuple_itemgetset_Type); Py_INCREF(&ItemGet_Type); PyModule_AddObject(m, "mutabletuple_itemget", (PyObject *)&ItemGet_Type); Py_INCREF(&PyMutableTupleIter_Type); PyModule_AddObject(m, "mutabletupleiter", (PyObject *)&PyMutableTupleIter_Type); return; } #endif
30.361981
130
0.568547
[ "object" ]
9208447e220165532f6d96cc674e7a827edfceee
1,689
h
C
projects/generation/sculptor/source/sculptor/operations/extrude.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
projects/generation/sculptor/source/sculptor/operations/extrude.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
projects/generation/sculptor/source/sculptor/operations/extrude.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
#pragma once #include "sculptor/geometry.h" #include "operations.h" #include <vectoring/utility.h> using namespace sculptor_old::geometry; namespace sculptor_old { namespace operations { // template<typename Iterator> // void extrude(Iterator &edges, mat4 &offset, bool fill = false); template<typename Iterator> void extrude(const Iterator &edges, const mat4 &offset, bool fill = false) { Basic_Mesh *mesh = vector_first(edges)->get_mesh(); auto count = edges.size(); vector<Edge *> original_edges; for (auto &edge: edges) { original_edges.push_back(edge); } vector<Polygon *> polygons; if (fill) { Edge::get_polygons(edges, polygons); } Selection original_vertices; Edge::get_vertices(edges, original_vertices); Selection new_vertices; for (auto &original_vertex: original_vertices) { auto temp = offset * vec4(original_vertex->get_position(), 1); auto new_vector = vec3(temp); auto new_vertex = mesh->add_vertex(new_vector); new_vertices.push_back(new_vertex); } operations:: fill_gap(original_vertices, new_vertices); if (fill) { for (auto &polygon: polygons) { mesh->add_polygon( new_vertices[vector_index(original_vertices, polygon->vertices[3])], new_vertices[vector_index(original_vertices, polygon->vertices[2])], new_vertices[vector_index(original_vertices, polygon->vertices[1])], new_vertices[vector_index(original_vertices, polygon->vertices[0])] ); } } } } }
30.160714
81
0.628182
[ "mesh", "geometry", "vector" ]
6003b690f945ee493ec81ae50103daa226cadfc2
7,393
h
C
oneflow/core/eager/eager_blob_object.h
Panlichen/oneflow
ad93c69c9932e5515aa31fb7f157073708810a3d
[ "Apache-2.0" ]
null
null
null
oneflow/core/eager/eager_blob_object.h
Panlichen/oneflow
ad93c69c9932e5515aa31fb7f157073708810a3d
[ "Apache-2.0" ]
null
null
null
oneflow/core/eager/eager_blob_object.h
Panlichen/oneflow
ad93c69c9932e5515aa31fb7f157073708810a3d
[ "Apache-2.0" ]
1
2021-12-15T02:14:49.000Z
2021-12-15T02:14:49.000Z
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef ONEFLOW_CORE_EAGER_EAGER_BLOB_OBJECT_H_ #define ONEFLOW_CORE_EAGER_EAGER_BLOB_OBJECT_H_ #include "oneflow/core/common/maybe.h" #include "oneflow/core/common/optional.h" #include "oneflow/core/eager/local_dep_object.h" #include "oneflow/core/device/device_context.h" #include "oneflow/core/memory/memory_allocator.h" #include "oneflow/core/framework/device.h" #include "oneflow/core/framework/stream.h" #include "oneflow/core/framework/tensor_methods.h" #include "oneflow/core/register/blob.h" namespace oneflow { namespace vm { class TensorStorage { public: TensorStorage() : non_pod_allocator_(std::make_unique<MemoryAllocator>()), producer_stream_(NullOpt), last_used_stream_(NullOpt) {} ~TensorStorage() { for (const auto& hook : storage_delete_hooks_) { hook(); } } size_t blob_bytes() const { return blob_bytes_; } char* blob_dptr() { return blob_dptr_.get(); } MemoryAllocator* non_pod_allocator() { return non_pod_allocator_.get(); } void set_blob_dptr(std::unique_ptr<char, std::function<void(char*)>>&& blob_dptr, size_t bytes) { blob_dptr_ = std::move(blob_dptr); blob_bytes_ = bytes; } const Optional<Symbol<Stream>>& producer_stream() const { return producer_stream_; } Maybe<void> init_producer_stream(Symbol<Stream> producer_stream) { CHECK_OR_RETURN(!producer_stream_.has_value()); producer_stream_ = producer_stream; return Maybe<void>::Ok(); } const Optional<Symbol<Stream>>& last_used_stream() const { return last_used_stream_; } void set_last_used_stream(Symbol<Stream> last_used_stream) { last_used_stream_ = last_used_stream; } void Release() { non_pod_allocator_.reset(); blob_dptr_.reset(); } void RegisterStorageDeleteHook(const std::function<void()>& hook) { storage_delete_hooks_.emplace_back(hook); } private: size_t blob_bytes_; std::unique_ptr<char, std::function<void(char*)>> blob_dptr_; std::unique_ptr<MemoryAllocator> non_pod_allocator_; Optional<Symbol<Stream>> producer_stream_; Optional<Symbol<Stream>> last_used_stream_; std::vector<std::function<void()>> storage_delete_hooks_; }; class EagerBlobObject final { public: EagerBlobObject(const EagerBlobObject&) = delete; EagerBlobObject(EagerBlobObject&&) = delete; EagerBlobObject(const std::shared_ptr<MemoryCase>& mem_case, const std::shared_ptr<Shape>& shape, const std::shared_ptr<Stride>& stride, DataType data_type, const std::shared_ptr<TensorStorage>& tensor_storage) : EagerBlobObject(mem_case, shape, stride, data_type, tensor_storage, intrusive::shared_ptr<LocalDepObject>()) {} EagerBlobObject(const std::shared_ptr<MemoryCase>& mem_case, const std::shared_ptr<Shape>& shape, const std::shared_ptr<Stride>& stride, DataType data_type, const std::shared_ptr<TensorStorage>& tensor_storage, const intrusive::shared_ptr<LocalDepObject>& dep_object); ~EagerBlobObject() { tensor_storage_.reset(); } void set_storage_offset(const int64_t offset); [[deprecated("\"Blob\" will be removed in eager. Please avoid to use this method whenever " "possible. Almost all methods of `Blob` are also in `EagerBlobObject`.")]] Blob* blob(); Maybe<void> TryAllocateBlobBodyMemory(DeviceCtx* device_ctx); Maybe<void> DeallocateBlobDataPtr() { tensor_storage_->Release(); tensor_storage_.reset(new TensorStorage); return Maybe<void>::Ok(); } void RegisterStorageDeleteHook(const std::function<void()>& hook) { tensor_storage_->RegisterStorageDeleteHook(hook); } Maybe<LocalDepObject*> compute_local_dep_object() const { CHECK_NOTNULL_OR_RETURN(compute_local_dep_object_.get()); return compute_local_dep_object_.get(); } std::shared_ptr<TensorStorage>& tensor_storage() { return tensor_storage_; } bool is_shape_synced() const { return is_shape_synced_; } void set_is_shape_synced(bool val) { is_shape_synced_ = val; } const Optional<Symbol<Stream>>& producer_stream() const { return tensor_storage_->producer_stream(); } Maybe<void> init_producer_stream(Symbol<Stream> producer_stream) { return tensor_storage_->init_producer_stream(producer_stream); } const Optional<Symbol<Stream>>& last_used_stream() const { return tensor_storage_->last_used_stream(); } void set_last_used_stream(Symbol<Stream> last_used_stream) { tensor_storage_->set_last_used_stream(last_used_stream); } void set_pin_memory(const bool pin_memory) { pin_memory_ = pin_memory; } bool pin_memory() const { return pin_memory_; } std::shared_ptr<const Shape> shape_ptr() const { return shape_; } const Shape& shape() const { return *shape_; } Shape& mut_shape() { return *shape_; } std::shared_ptr<const Stride> stride_ptr() const { return stride_; } const Stride& stride() const { return *stride_; } Stride& mut_stride() { return *stride_; } size_t ByteSizeOfBlobBody() const { return shape_->elem_cnt() * GetSizeOfDataType(data_type_); } size_t AlignedByteSizeOfBlobBody() const { return RoundUp(ByteSizeOfBlobBody(), kBlobBodyAlignSize); } size_t ByteSizeOfBlobHeader() const { return shape().NumAxes() * sizeof(int64_t); } size_t AlignedByteSizeOfBlobHeader() const { return RoundUp(ByteSizeOfBlobHeader(), kBlobHeaderAlignSize); } template<typename T = void> const T* dptr() const { return reinterpret_cast<T*>(tensor_storage_->blob_dptr() + storage_offset_ * GetSizeOfDataType(data_type_)); } template<typename T = void> T* mut_dptr() { return const_cast<T*>(dptr<T>()); } const char* header_ptr() const { return reinterpret_cast<const char*>(shape_->dim_vec().data()); } char* mut_header_ptr() { return reinterpret_cast<char*>(shape_->dim_vec().data()); } DataType data_type() const { return data_type_; } DataType* mut_data_type() { return &data_type_; } const MemoryCase& mem_case() const { return *mem_case_; } bool is_dynamic() const { return is_dynamic_; } void set_is_dynamic(bool is_dynamic) { is_dynamic_ = is_dynamic; } bool* mut_is_dynamic() { return &is_dynamic_; } private: bool is_dynamic_; std::shared_ptr<MemoryCase> mem_case_; DataType data_type_; std::shared_ptr<Shape> shape_; std::shared_ptr<Stride> stride_; int64_t storage_offset_; std::shared_ptr<TensorStorage> tensor_storage_; std::atomic<bool> is_shape_synced_; bool pin_memory_; intrusive::shared_ptr<LocalDepObject> compute_local_dep_object_; // NOTE: Will be removed soon. Avoid to use it whenever possible. BlobDesc blob_desc_; std::unique_ptr<Blob> blob_; }; } // namespace vm } // namespace oneflow #endif // ONEFLOW_CORE_EAGER_EAGER_BLOB_OBJECT_H_
36.063415
100
0.73272
[ "shape", "vector" ]
600595338b1041aebe694dd732687487aa535270
848
h
C
JSON/include/JsonDocument.h
josexy/QtScreenShot
0a10e32c5f69949aa7ba7992f9d96729f90eee25
[ "Apache-2.0" ]
11
2020-09-26T14:45:56.000Z
2021-12-10T10:22:22.000Z
json/include/JsonDocument.h
josexy/jsontest
f9a0a59b49f5fbd8ae0104f3696bd5aa39aab477
[ "MIT" ]
null
null
null
json/include/JsonDocument.h
josexy/jsontest
f9a0a59b49f5fbd8ae0104f3696bd5aa39aab477
[ "MIT" ]
1
2021-06-14T14:36:27.000Z
2021-06-14T14:36:27.000Z
#ifndef JSONTEST_JSONDOCUMENT_H #define JSONTEST_JSONDOCUMENT_H #include "JsonConvert.h" #include "JsonException.h" #include "JsonWriter.h" namespace Json { class JsonDocument { public: explicit JsonDocument(const std::string &, bool format = false, int indent = 4, bool escape = false); explicit JsonDocument(FILE *, bool format = false, int indent = 4, bool escape = false); explicit JsonDocument(std::ifstream &, bool format = false, int indent = 4, bool escape = false); ~JsonDocument() {} bool isObject(); JsonObject *object(); bool isArray(); JsonArray *array(); std::string toJson(); static std::shared_ptr<JsonDocument> fromJson(const std::string &); private: std::shared_ptr<JsonValue> jsonValuePtr = nullptr; }; } #endif
22.918919
109
0.645047
[ "object" ]
600aac6b354ae4cdd77c5207703ccb2abf4d16bb
12,552
h
C
Toolkit/CommuterWidget.h
SlyVTT/Widget-for-TI-NSpire
5bf4b66731156c69abf9e3cc28b76d9922eddfa2
[ "MIT" ]
9
2021-03-07T10:59:29.000Z
2022-03-16T13:15:34.000Z
Toolkit/CommuterWidget.h
SlyVTT/Widget-for-TI-NSpire
5bf4b66731156c69abf9e3cc28b76d9922eddfa2
[ "MIT" ]
null
null
null
Toolkit/CommuterWidget.h
SlyVTT/Widget-for-TI-NSpire
5bf4b66731156c69abf9e3cc28b76d9922eddfa2
[ "MIT" ]
null
null
null
#ifndef COMMUTERWIDGET_H #define COMMUTERWIDGET_H #include "ButtonWidget.h" /// Example of program using CommuterWidget controls /// /// The following simple example demonstrates how to use the CommuterWidget controls. /// \image html CommuterWidgetExample1.jpg /// \image html CommuterWidgetExample2.jpg /// /// ### Examples of usage: /// ~~~~~~~~~~~~~~~~~~~~~~.cpp /// #include "Toolkit/GUIToolkit.h" /// /// int main ( int argc, char** argv ) /// { /// bool done = false; /// /// WidgetApplication *MyApp = new WidgetApplication(); /// MyApp->setuniformbackgroundcolor(0, 0, 0); /// /// DesktopWidget *desktop1 = new DesktopWidget( (char*) "First Desktop", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, nullptr ); /// /// WindowWidget *window = new WindowWidget( (char*) "Examples of CommuterWidgets", 5, 5, 310, 230, desktop1 ); /// ContainerVWidget *containervert = new ContainerVWidget( (char*) "container", 1, 1, 1, 1, window ); /// /// LabelWidget *labelB = new LabelWidget( (char*) "Examples of CommuterWidget", 1, 1, 1, 1, containervert ); /// /// ContainerHWidget *contH1 = new ContainerHWidget( (char*) "container", 1, 1, 1, 1, containervert ); /// CommuterWidget *com11 = new CommuterWidget( (char*) "St.1 Normal", 1, 1, 1, 1, contH1 ); /// com11->settype( CommuterWidget::style1 ); /// com11->setnormal(); /// CommuterWidget *com12 = new CommuterWidget( (char*) "St.1 Reverse", 1, 1, 1, 1, contH1 ); /// com12->settype( CommuterWidget::style1 ); /// com12->setreversed(); /// /// ContainerHWidget *contH2 = new ContainerHWidget( (char*) "container", 1, 1, 1, 1, containervert ); /// CommuterWidget *com21 = new CommuterWidget( (char*) "St.2 Normal", 1, 1, 1, 1, contH2 ); /// com21->settype( CommuterWidget::style2 ); /// com21->setnormal(); /// CommuterWidget *com22 = new CommuterWidget( (char*) "St.2 Reverse", 1, 1, 1, 1, contH2 ); /// com22->settype( CommuterWidget::style2 ); /// com22->setreversed(); /// /// ContainerHWidget *contH3 = new ContainerHWidget( (char*) "container", 1, 1, 1, 1, containervert ); /// CommuterWidget *com31 = new CommuterWidget( (char*) "St.3 Normal", 1, 1, 1, 1, contH3 ); /// com31->settype( CommuterWidget::style3 ); /// com31->setnormal(); /// CommuterWidget *com32 = new CommuterWidget( (char*) "St.3 Reverse", 1, 1, 1, 1, contH3 ); /// com32->settype( CommuterWidget::style3 ); /// com32->setreversed(); /// /// ContainerHWidget *contH4 = new ContainerHWidget( (char*) "container", 1, 1, 1, 1, containervert ); /// CommuterWidget *com41 = new CommuterWidget( (char*) "St.4 Normal", 1, 1, 1, 1, contH4 ); /// com41->settype( CommuterWidget::style4 ); /// com41->setnormal(); /// CommuterWidget *com42 = new CommuterWidget( (char*) "St.4 Reverse", 1, 1, 1, 1, contH4 ); /// com42->settype( CommuterWidget::style4 ); /// com42->setreversed(); /// /// // the button to be clicked to quit /// ButtonWidget *buttonQuit = new ButtonWidget( (char*) "Quit [CTRL]+[ESC]", 1, 1, 1, 1, contH ); /// /// // We ask for an automatic positioning of the widgets in the grid /// // Note : this will fully override the dimensions given to the Widgets manually /// window->adjust(); /// /// MyApp->addchild( desktop1 ); /// /// KeyboardTask *keyboard = MyApp->getkeyboardhandler(); /// /// // We render the app for the first time so what we can see what's happening on the screen /// MyApp->render(); /// /// while (!done) /// { /// /// MyApp->logic(); /// /// if ((keyboard->kbCTRL && keyboard->kbESC) || buttonQuit->ispressed()) done = true; /// /// } /// /// return 0; /// } /// ~~~~~~~~~~~~~~~~~~~~~~ /// CommuterWidget class. /// /// The class to be used for using a CommuterWidget control widget. /// CommuterWidget inherits from ButtonWidget class. /// @see ButtonWidget /// /// ### Examples of usage: /// ~~~~~~~~~~~~~~~~~~~~~~.cpp /// CommuterWidget* myCommuter = new CommuterWidget(); // Simple constructor, will need specific properties assignement later /// ~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~.cpp /// CommuterWidget* myCommuter = new CommuterWidget( "I am a CommuterWidget", 10, 50, 100, 15, parent ); // Full constructor /// ~~~~~~~~~~~~~~~~~~~~~~ class CommuterWidget : public ButtonWidget { public: /// Simple constructor. /// /// Widget properties are set to default, nothing more. /// Simple constructor, will need specific properties assignement later. /// @param None /// @returns Nothing /// @see ButtonWidget() or Widget() CommuterWidget(); /// Advanced constructor. /// /// Widget properties are set with parameters values given at call. /// @param l : text string (char*) that will be used as the widget textual content /// @param x : position x in pixels relatively to the parent widget usable drawspace /// @param y : position y in pixels relatively to the parent widget usable drawspace /// @param w : width in pixel of the widget /// @param h : height in pixel of the widget /// @param p : pointer type to a Widget* to create a link with the parent widget (if any). /// @note *p* should be set to *nullptr* if no parent exists /// @note *p* can be omitted (i.e. set to *nullptr*) and parent-children link can be created with a call to the Widget::addchild() method of the parent Widget. /// @returns Nothing /// @see ButtonWidget( char*, int, int, int, int, Widget* ) or Widget( char*, int, int, int, int, Widget* ) CommuterWidget( std::string l, unsigned int x, unsigned int y, unsigned int w, unsigned int h, Widget *p ); /// Object destructor /// /// Object destructor, remove all trace of the object and free allocated memory /// @param None /// @returns Nothing /// @see ~Widget() virtual ~CommuterWidget(); /// Enumerator for CommuterWidget style. /// /// Gives the style of CommuterWidget (of the colors of both backgroud and commuter button). /// *style1* the commuter background is blank and the button also /// *style2* the commuter background is blank and the button is colorized /// *style3* the commuter background is blank and the button is colorized in color depending on switch position /// *style4* the commuter background and the button are colorized in color depending on switch position enum commutertype { style1 = 0, style2 = 1, style3 = 2, style4 = 3 }; /// Invert the CommuterWidget status /// /// Invert the CommuterWidget status, if unticked --> ticked and if ticked --> unticked /// @param None /// @returns None /// @note It changes the internal property *is_ticked* of the CommuterWidget virtual void invert(); /// Is the CommuterWidget ticked ? /// /// Gives the status of the CommuterWidget (switched or not). /// @param None /// @returns Boolean value : *true* if the CommuterWidget is switched, *false* otherwise virtual bool isticked( void ); /// The CommuterWidget logic mechanism /// /// Method to be launched to drive the the mechanics behind the widget behavior. /// @param mouse : pointer to a CursorTask handler object serving at passing the mouse (Touchpad) state and position /// @param keyboard : pointer to a KeyboardTask handler object serving at passing the keyboard state /// @returns Nothing, but will launch the logic() method of all the Widgets belonging to chidren (vector<Widget*>) /// @note This method overrides Widget::logic( CursorTask*, KeyboardTask*) /// @note This method is not intended to be used by a direct call from the user, it is normally called through cascaded calls to children->logic() from the WidgetApplication class /// @note Direct call can be used when the Widget is used out of the WidgetApplication 'ecosystem', for example in an application that just use few individual widgets (not recommended cause it may need intensive work from the developper to create adequate working conditions). /// @warning Before calling the logic method, a mouse handler and a keyboard handler must be instancied and properly updated through their respective logic() methods. This is normally done by using the WidgetApplication class. virtual void logic( CursorTask *mouse, KeyboardTask *keyboard ) override; /// The CommuterWidget render method. /// /// Method to be launched to draw the CommuterWidget. /// @param screen : pointer to a SDL_Surface object where we would like to draw the wigdet /// @param colors : pointer to a ColorEngine object giving all the color options to be used (theme) for drawing the widget /// @param fonts : pointer to a FontEngine object giving all the fonts options to be used (theme) for drawing the widget /// @returns Nothing, but will launch the render() method of all the Widgets belonging to chidren (vector<Widget*>) /// @note This method overrides Widget::render( SDL_Surface*, ColorEngine*, FontEngine*) /// @note This method is not intended to be used by a direct call from the user, it is normally called through cascaded calls to children->render() from the WidgetApplication class. /// @note Direct call can be used when the Widget is used out of the WidgetApplication 'ecosystem', for example in an application that just use few individual widgets (not recommended cause it may need intensive work from the developper to create adequate working conditions). /// @warning Before calling the render method, a SDL_Surface (i.e. a rendering context) as well as a ColorEngine and FontEngine objects must be properly instancied. This is normally done by using the WidgetApplication class. virtual void render( SDL_Surface *screen, ColorEngine *colors, FontEngine *fonts ) override; /// CommuterWidget style setter. /// /// Gives the style of CommuterWidget /// @param type refers to one of the styles given by the *tick* enumerator /// @returns Nothing /// @see commutertype virtual void settype( commutertype type ); /// CommuterWidget style getter. /// /// Gives the style of CommuterWidget /// @param None /// @returns The corresponding type of CommuterWidget style /// @see commutertype virtual commutertype gettype(); /// CommuterWidget normal style setter. /// /// Set the normal order of the CommuterWidget (false = switch on the left / true = switch on the right) /// @param None /// @returns Nothing virtual void setnormal(); /// CommuterWidget reversed style setter. /// /// Set the normal order of the CommuterWidget (false = switch on the right / true = switch on the left) /// @param None /// @returns Nothing virtual void setreversed(); /// CommuterWidget normal/reveresed style getter. /// /// Ask if the CommuterWidget is normal or reversed /// @param None /// @returns Nothing /// @see setnormal() or setreversed() virtual bool isreversed(); protected: private: /// Is the CommuterWidget switched ? /// /// Widget properties giving the status of the CommuterWidget. /// @note This boolean should not be adressed directly by the user. Status should be obtained by the CommuterWidget::isticked() method. /// @see CommuterWidget::isticked() bool is_ticked = false; /// Is the CommuterWidget reversed ? /// /// Widget properties giving the status of the CommuterWidget. /// @note This boolean should not be adressed directly by the user. Status should be obtained by the CommuterWidget::isreversed() method. /// @see CommuterWidget::isreversed() bool is_reversed = false; /// Is the mouse clickbutton hold down ? /// /// Private property, not accessible by the user directly /// @note This boolean should not be adressed directly by the user. It says if the click button is hold down to avoid the CommuterWidget to switch on/off at each call to logic(); /// @note This is only aiming at serving good behavior of the widget. bool mouse_hold_down = false; /// The style of the CommuterWidget /// /// Private property, not accessible by the user directly /// @note This boolean should not be adressed directly by the user. Status should be obtained by the CommuterWidget::gettype() method. /// @see CommuterWidget::gettype() commutertype typetick = style1; }; #endif // COMMUTERWIDGET_H
43.888112
280
0.66595
[ "render", "object", "vector" ]
6035148aa15450ce53575364aadb90db6822ae75
473
h
C
WYAKit/Classes/WYAUtils/WYACategories/Foundation/NSNotificationCenter/NSNotificationCenter+WYANotificationCenter.h
wya-team/WYAKit
395dbe71422ce20a0eec0f2c16d1093214dd8399
[ "MIT" ]
2
2019-02-28T01:04:44.000Z
2019-03-11T10:06:54.000Z
WYAKit/Classes/WYAUtils/WYACategories/Foundation/NSNotificationCenter/NSNotificationCenter+WYANotificationCenter.h
wya-team/WYAKit
395dbe71422ce20a0eec0f2c16d1093214dd8399
[ "MIT" ]
null
null
null
WYAKit/Classes/WYAUtils/WYACategories/Foundation/NSNotificationCenter/NSNotificationCenter+WYANotificationCenter.h
wya-team/WYAKit
395dbe71422ce20a0eec0f2c16d1093214dd8399
[ "MIT" ]
1
2019-10-28T08:03:57.000Z
2019-10-28T08:03:57.000Z
// // NSNotificationCenter+WYANotificationCenter.h // WYAKit_Example // // Created by 李世航 on 2019/1/3. // Copyright © 2019 WYATeam. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface NSNotificationCenter (WYANotificationCenter) - (void)wya_addObserverWithName:(NSString *)name object:(_Nullable id)object selector:(void (^)(NSNotification *))sel; @end NS_ASSUME_NONNULL_END
22.52381
64
0.693446
[ "object" ]
605dc26b682e06bf8c8b367cbc22c4647b67dee5
1,616
h
C
chrome/browser/ui/views/tabs/tab_renderer_data.h
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
chrome/browser/ui/views/tabs/tab_renderer_data.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
chrome/browser/ui/views/tabs/tab_renderer_data.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ #include "base/strings/string16.h" #include "chrome/browser/ui/tabs/tab_network_state.h" #include "chrome/browser/ui/tabs/tab_utils.h" #include "chrome/browser/ui/views/chrome_views_export.h" #include "ui/gfx/image/image_skia.h" #include "url/gurl.h" // Wraps the state needed by the renderers. struct CHROME_VIEWS_EXPORT TabRendererData { TabRendererData(); TabRendererData(const TabRendererData& other); TabRendererData(TabRendererData&& other); ~TabRendererData(); TabRendererData& operator=(const TabRendererData& other); TabRendererData& operator=(TabRendererData&& other); bool operator==(const TabRendererData& other) const; // This interprets the crashed status to decide whether or not this // render data represents a tab that is "crashed" (i.e. the render // process died unexpectedly). bool IsCrashed() const; gfx::ImageSkia favicon; TabNetworkState network_state = TabNetworkState::kNone; base::string16 title; GURL url; base::TerminationStatus crashed_status = base::TERMINATION_STATUS_STILL_RUNNING; bool incognito = false; bool show_icon = true; bool pinned = false; bool blocked = false; bool app = false; TabAlertState alert_state = TabAlertState::NONE; bool should_hide_throbber = false; }; #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_
33.666667
73
0.774134
[ "render" ]
006eb3c96ed3518ed7e3592eb737f7f6bcbb3dd8
1,189
h
C
inc/Node.h
rjmrohit94/WSN-PrecisionAgriculture-Simulator
f42a0a912ff13f98f442646db7ccd5bbdbdc923e
[ "Zlib" ]
null
null
null
inc/Node.h
rjmrohit94/WSN-PrecisionAgriculture-Simulator
f42a0a912ff13f98f442646db7ccd5bbdbdc923e
[ "Zlib" ]
null
null
null
inc/Node.h
rjmrohit94/WSN-PrecisionAgriculture-Simulator
f42a0a912ff13f98f442646db7ccd5bbdbdc923e
[ "Zlib" ]
null
null
null
/****************************************************************************************** * File Name: * Author(s): * Desciption: * Created Date: * License: * *********************************************************************************************/ #ifndef NODE_H #define NODE_H #include <list> #include <vector> #include <string> #include <mqueue.h> #include <iostream> #include <bits/stdc++.h> #include <utility> #include "wsn_common.h" using namespace std; class Node { private: list<int> neighbours; int id; int energy; string messageQueueRcv; char message[60]; char packet[PACKET_SIZE]; public: void setId(int id, int energy){ this->id= id; this->energy=energy; messageQueueRcv = "/nodeclient-"; messageQueueRcv += to_string(id); } int init(); void startListening(); bool last_node(char *packet); bool node_in_packet(char *packet, int *locat); void packet_arrange_sync(char *packet); char* find_neighbor(char *packet); char* ack_neighbor(char *packet); char* data_pack(char *packet); void packet_arrange_data(char *packet); bool last_nodedata(char *packet); bool node_in_packetdata(char *packet, int *locat); }; #endif
20.5
94
0.590412
[ "vector" ]
007c30e715667cdf1bb849670d42182f73d0f0f5
2,089
h
C
table.h
linus-young/my_toy_cx_compiler
e6d87658883cf007b8d94f252139efdb34267ea9
[ "MIT" ]
1
2018-01-18T05:39:55.000Z
2018-01-18T05:39:55.000Z
table.h
linus-young/my_toy_cx_compiler
e6d87658883cf007b8d94f252139efdb34267ea9
[ "MIT" ]
null
null
null
table.h
linus-young/my_toy_cx_compiler
e6d87658883cf007b8d94f252139efdb34267ea9
[ "MIT" ]
null
null
null
#include "stdio.h" #include "string.h" #include "limits.h" #include "stdlib.h" #define IDENT_TABLE_MAX 100 /* 标识符表长度 */ #define IDENT_LEN 20 /* 每个标识符最大长度 */ #define LEV_MAX 10 #define CONST_MAX 2147483647 /* 常量最大值 */ #define STACK_SIZE 500 int level = 0; int table_index = 0; int data_allocation_index = 0; int number; char ident[IDENT_LEN]; enum object{constant, variable, func}; enum object kind; /* object 别名 kind */ void error(int error_no); struct ident_table { char name[IDENT_LEN]; enum object kind; int val; int level; /* 层 */ int adr; /* 过程地址或变量地址 */ int size; /* 过程申请的空间大小 */ }; struct ident_table table[IDENT_TABLE_MAX + 1]; struct LEVEL_REGISTRATION { int init_dx; int init_tx; /* initial table index 保留本过程名在名字表中的位置 */ int init_cx; /* initial code index 保留本过程目标代码的起始位置 */ } level_registration[4]; int get_ident_position_in_table(char ident[IDENT_LEN]) { int i; strcpy(table[0].name, ident); /* tx 表示的是当前标识符总个数,来了一个标识符后,先 tx+1, 再登入 table 表, 相当于 table[0] 为空 */ i = table_index; while(strcmp(table[i].name, ident)!=0) i--; return i; } void enter_object_to_table(enum object obj) { int pos; pos = get_ident_position_in_table(ident); // DEPRECARED: // 由于 function 里面允许定义局部变量,所以不能通过此方法判断变量名是否重复 // if(pos == 0) { /* new ident */ table_index++; strcpy(table[table_index].name, ident); /* 将标识符填入 table 表 */ table[table_index].kind = obj; switch(obj) { case constant: if(number > CONST_MAX) { error(31); number = 0; } table[table_index].val = number; break; case variable: table[table_index].level = level; /* 变量则设置它的层号及地址 */ table[table_index].adr = data_allocation_index; data_allocation_index++; break; case func: /* 过程名则设置它的层号 */ table[table_index].level = level; break; } // } // else { ident redeclared // error(5); // } }
24.011494
101
0.597894
[ "object" ]
007cb713bd9250dbe912f2fe9dbabbe1a34a1b20
2,451
c
C
slinky/write.c
Museum-of-Art-and-Digital-Entertainment/macross
992179723541e5405c15bb8f7b3dd257e00328eb
[ "MIT" ]
158
2016-01-22T02:14:14.000Z
2022-02-23T00:08:44.000Z
slinky/write.c
ksherlock/macross
992179723541e5405c15bb8f7b3dd257e00328eb
[ "MIT" ]
6
2016-01-23T09:35:22.000Z
2016-08-18T16:04:38.000Z
slinky/write.c
ksherlock/macross
992179723541e5405c15bb8f7b3dd257e00328eb
[ "MIT" ]
23
2016-01-23T08:21:26.000Z
2020-10-12T19:57:39.000Z
/* * Copyright (c) 1987 Fujitsu * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* write.c -- Routines to write out the eventual object module for the Slinky linker Chip Morningstar -- Lucasfilm Ltd. 19-March-1985 */ #include "slinkyTypes.h" #include "slinkyGlobals.h" #include "write.h" #define writeWord(aWord) putc(aWord & 0xFF, loadFileOutput);\ putc((aWord >> 8) & 0xFF, loadFileOutput) #define writeByte(aByte) putc(aByte & 0xFF, loadFileOutput) void writeEntryPoint(void) { writeWord(entryPointAddress); writeWord(entryPointAddress); writeByte(0); } void writeCodeSegment(codeSegmentHeaderType *codeSegment) { int length; int i; writeWord(codeSegment->segmentStartAddress); writeWord(codeSegment->segmentEndAddress); length = codeSegment->segmentEndAddress - codeSegment-> segmentStartAddress + 1; for (i=0; i<length; i++) writeByte(codeSegment->segmentCodeBuffer[i]); } void writem(void) { int regionNumber; codeSegmentHeaderType *lastSegment; segmentListType *segment; writeWord(0xFFFF); if (haveEntryPoint) writeEntryPoint(); lastSegment = NULL; for (regionNumber = 0; regionNumber < CODE_REGIONS_IN_ADDRESS_SPACE; regionNumber++) { for (segment = generatedLoadImage[regionNumber]; segment != NULL; segment = segment->nextSegment) { if (segment->thisSegment != lastSegment) writeCodeSegment(lastSegment = segment-> thisSegment); } } }
29.890244
80
0.74745
[ "object" ]
007f14033dd7e7a7d2b2cb9b82d0ee69f7f16504
4,599
h
C
GUI/src/KParam.h
kooBH/Audio-Recorder
078b87bebc9b2efb98c5ad736deefd19ec47d6f1
[ "MIT" ]
null
null
null
GUI/src/KParam.h
kooBH/Audio-Recorder
078b87bebc9b2efb98c5ad736deefd19ec47d6f1
[ "MIT" ]
2
2021-02-05T12:12:54.000Z
2021-06-03T05:40:58.000Z
GUI/src/KParam.h
kooBH/Audio-Recorder
078b87bebc9b2efb98c5ad736deefd19ec47d6f1
[ "MIT" ]
null
null
null
#ifndef _H_KPARAM_ #define _H_KPARAM_ #include <QGridLayout> #include <QWidget> #include <QLabel> #include "ParamComboBox.h" #include "ParamLineEdit.h" #include "jsonConfig.h" class KParam : public QWidget{ private: QGridLayout layout; //ConfigParam param_s; vector<tuple<QLabel *, ParamComboBox *>> cb; vector<tuple<QLabel*, ParamLineEdit*>> param_algo; vector<QLabel*> title; int r,c; int max_row; QString style_label; public : inline KParam(); inline ~KParam(); // inline void AddAlgo(jsonConfig config); // inline void AddIntParam(jsonConfig config); }; inline KParam::KParam(){ r=0; c=0; max_row =14; layout.setAlignment(Qt::AlignLeft|Qt::AlignTop); /*** JSON Reading ***/ std::ifstream ifs(_CONFIG_JSON); if(!ifs.is_open()){ QMessageBox::critical( this, tr("KParam"), tr("Can't Open Config.json File!") ); exit(-1); } json j = json::parse(ifs); json param = j["param"]; /* Dynamic combobox for PARAM */ r=0; QLabel *temp_title = new QLabel(QString::fromStdString("Base")); layout.addWidget(temp_title,r,c,1,1); title.push_back(temp_title); r++; for (json::iterator it = param.begin(); it != param.end(); ++it) { QLabel *t1 = new QLabel(QString::fromStdString(it.key())); t1->setFixedHeight(40); t1->setStyleSheet(style_label); t1->setAlignment(Qt::AlignCenter); ParamComboBox*t2 = new ParamComboBox(_CONFIG_JSON, it.key() ); /* Iterate on "OPTIONS "*/ json options = it.value().at("options"); for (auto it2 = options.begin(); it2 != options.end(); ++it2) { t2->addItem(QString::fromStdString(std::to_string((int)it2.value()) )); } /* Set Default iten as in json */ const int index = t2->findText(QString::fromStdString( std::to_string((int)it.value().at("value")))); if(index >= 0) t2->setCurrentIndex(index); cb.push_back(std::make_tuple(t1, t2)); /**/ layout.addWidget(t1, r, c, 1, 1); layout.addWidget(t2, r+1, c, 1, 1); r=r+2; } c++; /* ConfigVAD vad; AddAlgo(vad); ConfigWPE wpe; AddAlgo(wpe); ConfigStereo_AEC stereo_aec; AddAlgo(stereo_aec); ConfigMLDR mldr; AddAlgo(mldr); ConfigCam Cam; AddIntParam(Cam); */ ifs.close(); // setFixedSize(600,400); setLayout(&layout); } /* inline void KParam::AddAlgo(JsonConfig config){ r=0; QLabel *temp_title = new QLabel(QString::fromStdString(config.GetName())); layout.addWidget(temp_title,r,c,1,1); title.push_back(temp_title); r++; for(auto it : config.GetData()) { QLabel *t1; ParamLineEdit *t2; t1 = new QLabel(QString::fromStdString(it.first)); t1->setFixedHeight(40); t1->setStyleSheet(style_label); t1->setAlignment(Qt::AlignCenter); t2 = new ParamLineEdit(_CONFIG_JSON,config.GetName(),it.first); // Is Integer Parameter ? if(t2->IsInteger()) t1->setText("[int]" + t1->text()); param_algo.push_back(std::make_tuple(t1, t2)); layout.addWidget(t1,r,c,1,1); layout.addWidget(t2,r+1,c,1,1); r=r+2; } c++; } */ /* inline void KParam::AddIntParam(JsonConfig config){ r=0; QLabel *temp_title = new QLabel(QString::fromStdString(config.GetName())); layout.addWidget(temp_title,r,c,1,1); title.push_back(temp_title); r++; for(auto it : config.GetData()) { QLabel *t1; ParamLineEdit *t2; t1 = new QLabel(QString::fromStdString(it.first)); t1->setFixedHeight(40); t1->setStyleSheet(style_label); t1->setAlignment(Qt::AlignCenter); t2 = new ParamLineEdit(_CONFIG_JSON,config.GetName(),it.first); // Is Integer Parameter ? if(t2->IsInteger()) t1->setText("[int]" + t1->text()); param_algo.push_back(std::make_tuple(t1, t2)); layout.addWidget(t1,r,c,1,1); layout.addWidget(t2,r+1,c,1,1); r=r+2; } c++; } */ KParam::~KParam(){ for (auto &t : cb) { delete std::get<0>(t); delete std::get<1>(t); } for (auto &t : param_algo) { delete std::get<0>(t); delete std::get<1>(t); } for(auto &t : title) delete t; } #endif
24.593583
81
0.560557
[ "vector" ]
008a7d234928c5f467e6ee9d6f6ffe4093a45bd3
4,687
h
C
Engine/Source/FileIO/Data/IesFile.h
jasonoscar88/Photon-v2
90649196c436261d28cc2300511b78ac88236448
[ "MIT" ]
88
2017-01-21T18:20:16.000Z
2021-12-21T02:32:04.000Z
Engine/Source/FileIO/Data/IesFile.h
jasonoscar88/Photon-v2
90649196c436261d28cc2300511b78ac88236448
[ "MIT" ]
72
2017-07-28T10:00:35.000Z
2021-11-09T18:36:23.000Z
Engine/Source/FileIO/Data/IesFile.h
jasonoscar88/Photon-v2
90649196c436261d28cc2300511b78ac88236448
[ "MIT" ]
8
2017-03-19T12:19:10.000Z
2020-05-19T15:15:05.000Z
#pragma once #include "FileIO/FileSystem/Path.h" #include "Common/Logger.h" #include "Common/primitive_type.h" #include <vector> #include <string> namespace ph { /* A low-level class that parses an IES photometric data file and provides convenient methods for file content accessing. Reference: http://lumen.iee.put.poznan.pl/kw/iesna.txt */ class IesFile final { public: enum class EIesFileType { LM_63_1986, LM_63_1991, LM_63_1995, UNKNOWN }; enum class EPhotometricWebType { /* Type A photometry is normally used for automotive headlights and signal lights. The polar axis of the luminaire coincides with the major axis (length) of the luminaire, and the 0-180 degree photometric plane coinicides with the luminaire's vertical axis. */ A, /* Type B photometry is normally used for adjustable outdoor area and sports lighting luminaires. The polar axis of the luminaire coincides with the minor axis (width) of the luminaire, and the 0-180 degree photometric plane coinicides with the luminaire's vertical axis. */ B, /* Type C photometry is normally used for architectural and roadway luminaires. The polar axis of the photometric web coincides with the vertical axis of the luminaire, and the 0-180 degree photometric plane coincides with the luminaire's major axis (length). */ C }; public: IesFile(const Path& iesFilePath); bool load(); std::string getFilename() const; // Retrieving file contents. // Gets the type of this IES file. // EIesFileType getIesFileType() const; // Gets the test report number and laboratory for the IES file. // std::string getTestInfo() const; std::string getLuminaireManufacturer() const; std::string getLuminaireCatalogNumber() const; std::string getLuminaireDescription() const; std::string getLampCatalogNumber() const; std::string getLampDescription() const; // Gets descriptions that are not categorized by the parser. // std::string getUncategorizedInfo() const; uint32 getNumLamps() const; real getLumensPerLamp() const; real getCandelaMultiplier() const; uint32 getNumVerticalAngles() const; uint32 getNumHorizontalAngles() const; EPhotometricWebType getPhotometricWebType() const; std::vector<real> getVerticalAngles() const; std::vector<real> getHorizontalAngles() const; // Candela values stored as data[horizontal-index][vertical-index]. // std::vector<std::vector<real>> getCandelaValues() const; private: Path m_path; EIesFileType m_iesFileType; // file descriptions (labels/keywords in the file) // std::string m_testInfo; std::string m_luminaireManufacturer; std::string m_luminaireCatalogNumber; std::string m_luminaireDescription; std::string m_lampCatalogNumber; std::string m_lampDescription; std::string m_uncategorizedInfo; // type of tilt information // std::string m_tilt; // first line of metadata for the IES file (metadata 1) // uint32 m_numLamps; real m_lumensPerLamp; real m_candelaMultiplier; uint32 m_numVerticalAngles; uint32 m_numHorizontalAngles; EPhotometricWebType m_webType; real m_luminaireOpeningArea; // second line of metadata for the IES file (metadata 2) // real m_ballastFactor; real m_ballastLampPhotometricFactor; real m_inputWatts; // lighting data // std::vector<real> m_verticalAngles; std::vector<real> m_horizontalAngles; std::vector<std::vector<real>> m_candelaValues; bool parse(const std::vector<char>& data); std::size_t parseFileType(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseLabelsAndKeywords(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseTiltLine(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseTiltData(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseMetadata1(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseMetadata2(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseAngles(const std::vector<std::string>& lines, std::size_t currentLine); std::size_t parseCandelaValues(const std::vector<std::string>& lines, std::size_t currentLine); private: static const Logger logger; static std::vector<std::string> retrieveLines(const std::vector<char>& data); }; }// end namespace ph
30.23871
100
0.703222
[ "vector" ]
008c61932f5322ffe26ecf763e94c9dc73c3367b
1,194
h
C
Source/Assets.h
ponspack9/GameEngine
f2f932daf7588db11707db16649d52864198a150
[ "MIT" ]
1
2019-11-11T10:08:34.000Z
2019-11-11T10:08:34.000Z
Source/Assets.h
ponspack9/GameEngine
f2f932daf7588db11707db16649d52864198a150
[ "MIT" ]
null
null
null
Source/Assets.h
ponspack9/GameEngine
f2f932daf7588db11707db16649d52864198a150
[ "MIT" ]
1
2021-02-13T00:53:19.000Z
2021-02-13T00:53:19.000Z
#ifndef __ASSETS_H__ #define __ASSETS_H__ #include "Panel.h" #include "PathNode.h" #include "Timer.h" #include "Imgui/imgui.h" #include <vector> #define REFRESH_RATE 3 class Assets : public Panel { public: static const uint default_width = 1280; static const uint default_height = 323; static const uint default_pos_x = 0; static const uint default_pos_y = 701; public: Assets(); virtual ~Assets(); void Draw(); void ImportAsset(const PathNode& node); Resource* GetSelectedResource(); private: void UpdateAssets(); void UpdateFilters(PathNode& node); void DrawHierarchy(const PathNode& node); void DrawIcons(const PathNode& node); uint GetIcon(const PathNode& node); void FilterFolders(PathNode& node, PathNode& parent); public: uint folder_icon; uint file_icon; uint model_icon; uint material_icon; uint scene_icon; private: std::vector<uint> selected_assets; PathNode assets; PathNode models; PathNode materials; PathNode scenes; PathNode current_node; PathNode next_node; PathNode selected_node; Timer timer; ImVec4 border_color; bool filter_scenes = false; bool filter_models = false; bool filter_materials = false; }; #endif// __ASSETS_H__
17.820896
54
0.757119
[ "vector" ]
0094746f030252e9978f25a49df6e51416f17227
5,013
c
C
main/keyboard.c
annieZ/EllieSmelly
a61523bad12ab479f989fd1945a97007cb48ed24
[ "MIT" ]
null
null
null
main/keyboard.c
annieZ/EllieSmelly
a61523bad12ab479f989fd1945a97007cb48ed24
[ "MIT" ]
null
null
null
main/keyboard.c
annieZ/EllieSmelly
a61523bad12ab479f989fd1945a97007cb48ed24
[ "MIT" ]
null
null
null
/* * AWS IoT EduKit - Core2 for AWS IoT EduKit * EllieMeter v2.1.0 * keyoard.c * * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "esp_log.h" #include "core2forAWS.h" #include "global.h" #include "keyboard.h" #include "received.h" #include "core_http_config.h" lv_obj_t* tabview; lv_obj_t* keyboard_tab; static lv_obj_t * kb; static lv_obj_t * ta; static const char* TAG = KEYBOARD_TAB_NAME; void display_keyboard_tab(lv_obj_t* tv, lv_obj_t* core2forAWS_screen_obj){ xSemaphoreTake(xGuiSemaphore, portMAX_DELAY); tabview = tv; keyboard_tab = lv_tabview_add_tab(tv, KEYBOARD_TAB_NAME); // Create a tab /* Create the main body object and set background within the tab*/ static lv_style_t bg_style; lv_obj_t* keyb_bg = lv_obj_create(keyboard_tab, NULL); lv_obj_align(keyb_bg, NULL, LV_ALIGN_IN_TOP_LEFT, 16, 36); lv_obj_set_size(keyb_bg, 290, 190); lv_obj_set_click(keyb_bg, false); lv_style_init(&bg_style); lv_style_set_bg_color(&bg_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_add_style(keyb_bg, LV_OBJ_PART_MAIN, &bg_style); /* Create the title within the main body object */ static lv_style_t title_style; lv_style_init(&title_style); lv_style_set_text_font(&title_style, LV_STATE_DEFAULT, LV_THEME_DEFAULT_FONT_TITLE); lv_style_set_text_color(&title_style, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_t* tab_title_label = lv_label_create(keyb_bg, NULL); lv_obj_add_style(tab_title_label, LV_OBJ_PART_MAIN, &title_style); lv_label_set_static_text(tab_title_label, ""); lv_obj_align(tab_title_label, keyb_bg, LV_ALIGN_IN_TOP_MID, 0, 10); /* Add Keyoard */ /*Create a keyboard to use it with an of the text areas*/ /*Create a text area. The keyboard will write here*/ ta = lv_textarea_create(keyboard_tab, NULL); lv_textarea_set_one_line(ta, true); lv_textarea_set_max_length(ta, 20); lv_obj_align(ta, tab_title_label, LV_ALIGN_CENTER, 0 , 10); lv_obj_set_event_cb(ta, ta_event_cb); lv_textarea_set_text(ta, ""); kb_create(); xSemaphoreGive(xGuiSemaphore); // xTaskCreatePinnedToCore(keyboard_task, "keyboardTask", configMINIMAL_STACK_SIZE * 2, (void*) core2forAWS_screen_obj, 0, &keyboard_handle, 1); } static void kb_event_cb(lv_obj_t * keyboard, lv_event_t e) { lv_keyboard_def_event_cb(kb, e); if(e == LV_EVENT_CANCEL) { lv_textarea_set_text(ta, ""); // start over lv_tabview_set_tab_act(tabview, 0, LV_ANIM_OFF); } if(e == LV_EVENT_APPLY) { // Call back end server and then display received userInputStr = lv_textarea_get_text(ta); lv_textarea_set_text(ta, ""); if(userInputStr != NULL){ ESP_LOGI(TAG, "\n\n Read %s: ", userInputStr); lv_tabview_set_tab_act(tabview, 4, LV_ANIM_OFF); /// TODO verify http client /* const char* path = "/submitSample/"; strcat(path,userInputStr ); strcat(path, "/"); if (tvoc != NULL) strcat(path, tvoc); if (eCO2 != NULL){ strcat(path, "/"); strcat(path, eCO2); } ESP_LOGI(TAG, "\n\n Sending sample to %s: ", path); sendReceiveEllieSample("POST",path); */ } } } static void kb_create(void) { userInputStr=NULL; kb = lv_keyboard_create(keyboard_tab, NULL); lv_keyboard_set_cursor_manage(kb, true); lv_obj_set_event_cb(kb, kb_event_cb); lv_keyboard_set_textarea(kb, ta); } static void ta_event_cb(lv_obj_t * ta_local, lv_event_t e) { if(e == LV_EVENT_CLICKED && kb == NULL) { kb_create(); } }
35.055944
147
0.687014
[ "object" ]
009e4446bd4168e1168cde7bd0184bf9442d5f70
60
h
C
Simplified/NYPLNull.h
datalogics-tsmith/Simplified-iOS
2822295486f3f4901ce65731bcd30dd77b9ed003
[ "Apache-2.0" ]
26
2016-09-24T05:27:15.000Z
2022-03-24T09:12:31.000Z
Simplified/NYPLNull.h
datalogics-tsmith/Simplified-iOS
2822295486f3f4901ce65731bcd30dd77b9ed003
[ "Apache-2.0" ]
570
2016-08-11T18:46:07.000Z
2022-03-21T16:32:07.000Z
Simplified/NYPLNull.h
datalogics-tsmith/Simplified-iOS
2822295486f3f4901ce65731bcd30dd77b9ed003
[ "Apache-2.0" ]
35
2016-08-15T19:49:52.000Z
2021-11-15T04:10:12.000Z
id NYPLNullFromNil(id object); id NYPLNullToNil(id object);
20
30
0.8
[ "object" ]
00a4ed5d28ea0d263e80c99b1ecc89c2b30b597e
708
h
C
src/fpga_stages/MnmpAlignFPGAUtils/host_interface/mmsw_orig.h
falcon-computing/minimap2
fa7cd64b3e49a15d83b6bd05cc2b419025e0b6fd
[ "Apache-2.0" ]
null
null
null
src/fpga_stages/MnmpAlignFPGAUtils/host_interface/mmsw_orig.h
falcon-computing/minimap2
fa7cd64b3e49a15d83b6bd05cc2b419025e0b6fd
[ "Apache-2.0" ]
null
null
null
src/fpga_stages/MnmpAlignFPGAUtils/host_interface/mmsw_orig.h
falcon-computing/minimap2
fa7cd64b3e49a15d83b6bd05cc2b419025e0b6fd
[ "Apache-2.0" ]
null
null
null
/* * ===================================================================================== * * Filename: mmsw_orig.h * * Description: * * Version: 1.0 * Created: 11/09/2018 10:50:40 AM * Revision: none * Compiler: gcc * * Author: Jiayi Sheng (jys), jysheng@falcon-computing.com * Organization: * * ===================================================================================== */ #ifndef MMSW_ORIG_H #define MMSW_ORIG_H #include "minimap.h" #include "host_types.h" #include <vector> void mmsw_orig_compute(const mm_mapopt_t* opt, const mm_idx_t* mi, std::vector<align_input>& inputs, std::vector<align_output>& outputs); #endif
26.222222
137
0.471751
[ "vector" ]
00aa41afa9dc413f3bcebbb2af53cbc1ad4214f4
3,257
c
C
src/luasql.c
LuaDist-testing/luafanmicro
c30a6341d14e8b57e0949f90e60292f2fe4173a3
[ "MIT" ]
3
2017-07-15T22:19:51.000Z
2022-02-09T07:24:56.000Z
src/luasql.c
LuaDist-testing/luafanmicro
c30a6341d14e8b57e0949f90e60292f2fe4173a3
[ "MIT" ]
2
2017-05-21T09:20:15.000Z
2019-10-17T06:03:42.000Z
src/luasql.c
LuaDist-testing/luafanmicro
c30a6341d14e8b57e0949f90e60292f2fe4173a3
[ "MIT" ]
null
null
null
/* ** $Id: luasql.c,v 1.28 2009/02/11 12:08:50 tomas Exp $ ** See Copyright Notice in license.html */ #include <string.h> #include "lauxlib.h" #include "lua.h" #include "luasql.h" #if !defined(lua_pushliteral) #define lua_pushliteral(L, s) \ lua_pushstring(L, "" s, (sizeof(s) / sizeof(char)) - 1) #endif /* ** Typical database error situation */ LUASQL_API int luasql_faildirect(lua_State *L, const char *err) { lua_pushnil(L); lua_pushliteral(L, LUASQL_PREFIX); lua_pushstring(L, err); lua_concat(L, 2); return 2; } /* ** Database error with LuaSQL message ** @param err LuaSQL error message. ** @param m Driver error message. */ LUASQL_API int luasql_failmsg(lua_State *L, const char *err, const char *m) { lua_pushnil(L); lua_pushliteral(L, LUASQL_PREFIX); lua_pushstring(L, err); lua_pushstring(L, m); lua_concat(L, 3); return 2; } typedef struct { short closed; } pseudo_data; /* ** Return the name of the object's metatable. ** This function is used by `tostring'. */ static int luasql_tostring(lua_State *L) { char buff[100]; pseudo_data *obj = (pseudo_data *)lua_touserdata(L, 1); if (obj->closed) strcpy(buff, "closed"); else sprintf(buff, "%p", (void *)obj); lua_pushfstring(L, "%s (%s)", lua_tostring(L, lua_upvalueindex(1)), buff); return 1; } #if !defined LUA_VERSION_NUM || LUA_VERSION_NUM == 501 /* ** Adapted from Lua 5.2.0 */ void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { luaL_checkstack(L, nup, "too many upvalues"); for (; l->name != NULL; l++) { /* fill the table with given functions */ int i; for (i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup); lua_pushstring(L, l->name); lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ lua_settable(L, -(nup + 3)); } lua_pop(L, nup); /* remove upvalues */ } #endif /* ** Create a metatable and leave it on top of the stack. */ LUASQL_API int luasql_createmeta(lua_State *L, const char *name, const luaL_Reg *methods) { if (!luaL_newmetatable(L, name)) return 0; /* define methods */ luaL_setfuncs(L, methods, 0); /* define metamethods */ lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); lua_settable(L, -3); lua_pushliteral(L, "__tostring"); lua_pushstring(L, name); lua_pushcclosure(L, luasql_tostring, 1); lua_settable(L, -3); lua_pushliteral(L, "__metatable"); lua_pushliteral(L, LUASQL_PREFIX "you're not allowed to get this metatable"); lua_settable(L, -3); return 1; } /* ** Define the metatable for the object on top of the stack */ LUASQL_API void luasql_setmeta(lua_State *L, const char *name) { luaL_getmetatable(L, name); lua_setmetatable(L, -2); } /* ** Assumes the table is on top of the stack. */ LUASQL_API void luasql_set_info(lua_State *L) { lua_pushliteral(L, "_COPYRIGHT"); lua_pushliteral(L, "Copyright (C) 2003-2012 Kepler Project"); lua_settable(L, -3); lua_pushliteral(L, "_DESCRIPTION"); lua_pushliteral(L, "LuaSQL is a simple interface from Lua to a DBMS"); lua_settable(L, -3); lua_pushliteral(L, "_VERSION"); lua_pushliteral(L, "LuaSQL 2.3.0"); lua_settable(L, -3); }
25.445313
80
0.658274
[ "object" ]
00ab9a90522e68a3e76a6c1dc91d1e20fb91655c
17,131
c
C
Fault.c
Mastergatto/cen64-vr4300
cc1964c9ed3c4ef5e9510f7d429664149fbd546b
[ "BSD-3-Clause" ]
null
null
null
Fault.c
Mastergatto/cen64-vr4300
cc1964c9ed3c4ef5e9510f7d429664149fbd546b
[ "BSD-3-Clause" ]
null
null
null
Fault.c
Mastergatto/cen64-vr4300
cc1964c9ed3c4ef5e9510f7d429664149fbd546b
[ "BSD-3-Clause" ]
null
null
null
/* ============================================================================ * Fault.c: Fault and exception handler. * * VR4300SIM: NEC VR43xx Processor SIMulator. * Copyright (C) 2013, Tyler J. Stachecki. * All rights reserved. * * This file is subject to the terms and conditions defined in * file 'LICENSE', which is part of this source code package. * ========================================================================= */ #include "Common.h" #include "CP0.h" #include "CPU.h" #include "Fault.h" #include "ICache.h" #include "Pipeline.h" #ifdef __cplusplus #include <cassert> #include <cstring> #else #include <assert.h> #include <string.h> #endif static void CommonExceptionHandler(struct VR4300CP0 *, uint64_t *, uint64_t, unsigned, uint32_t); /* ============================================================================ * VR4300/MIPS exception vectors. * ========================================================================= */ #define VR4300_GENERAL_BEV_VECTOR 0xFFFFFFFFBFC00200ULL #define VR4300_GENERAL_VECTOR 0xFFFFFFFF80000180ULL #define VR4300_RESET_VECTOR 0xFFFFFFFFBFC00000ULL /* ============================================================================ * Mnemonic and callback tables. * ========================================================================= */ #ifndef NDEBUG const char *VR4300FaultMnemonics[NUM_VR4300_FAULTS] = { #define X(fault) #fault, #include "Fault.md" #undef X }; #endif /* ============================================================================ * Common exception handler for all but Cold/Soft/NMI and TLB/XTLB. * ========================================================================= */ static void CommonExceptionHandler(struct VR4300CP0 *cp0, uint64_t *pc, uint64_t faultingPC, unsigned exeCode, uint32_t opcodeFlags) { cp0->regs.cause.excCode = exeCode; /* Setup the cause register. */ if (cp0->regs.status.exl == 0) { uint64_t epc; if (opcodeFlags & OPCODE_INFO_BRANCH) { epc = faultingPC - 4; cp0->regs.cause.bd = 1; } else { epc = faultingPC; cp0->regs.cause.bd = 0; } cp0->regs.epc = epc; } /* Disable interrupts. */ /* Switch to kernel mode. */ cp0->interruptRaiseMask = 0; cp0->regs.status.exl = 1; /* Jump to the exception vector. */ *pc = (cp0->regs.status.ds.bev) ? VR4300_GENERAL_BEV_VECTOR - 4 : VR4300_GENERAL_VECTOR - 4; } /* =========================================================================== * InitFaultManager: Initializes the fault manager. * ========================================================================= */ void InitFaultManager(struct VR4300FaultManager *manager) { manager->excpIndex = VR4300_PCU_NORMAL; manager->ilIndex = VR4300_PCU_NORMAL; manager->faulting = 0; PerformHardReset(manager); } /* =========================================================================== * PerformHardReset: Queues up a hard reset exception. * ========================================================================= */ void PerformHardReset(struct VR4300FaultManager *manager) { QueueException(manager, VR4300_FAULT_RST, 0, 0, 0, VR4300_PCU_START_RF); } /* =========================================================================== * PerformSoftReset: Queues up a soft reset exception. * ========================================================================= */ void PerformSoftReset(struct VR4300FaultManager *manager) { QueueException(manager, VR4300_FAULT_RST, 0, 0, 1, VR4300_PCU_START_RF); } /* =========================================================================== * QueueException: Queues up a pipeline exception in a prioritized fashion. * ========================================================================= */ void QueueException(struct VR4300FaultManager *manager, enum VR4300PipelineFault fault,uint64_t faultingPC, uint32_t nextOpcodeFlags, uint32_t excpCauseData, enum VR4300PCUIndex excpIndex) { assert(excpIndex != VR4300_PCU_NORMAL); /* Higher priority fault ready? On an exception, the faulting instruction * * and all instructions that follow it are aborted. So, we only raise an * * exception iff the faulting stage comes after the instruction that may * * have already caused a fault. */ if (excpIndex <= manager->excpIndex #ifdef DO_FASTFORWARD && manager->excpIndex != VR4300_PCU_FASTFORWARD #endif ) return; debugarg("Queued up a fault: %s.", VR4300FaultMnemonics[fault]); manager->faultingPC = faultingPC; manager->nextOpcodeFlags = nextOpcodeFlags; manager->excpCauseData = excpCauseData; manager->excpIndex = excpIndex; manager->excp = fault; manager->faulting = 1; } /* ============================================================================ * QueueInterlock: Queues up an interlock condition in a prioritized fashion. * ========================================================================= */ void QueueInterlock(struct VR4300Pipeline *pipeline, enum VR4300PipelineFault fault, uint32_t ilData, enum VR4300PCUIndex ilIndex) { struct VR4300FaultManager *manager = &pipeline->faultManager; assert(ilIndex != VR4300_PCU_NORMAL); /* Higher priority fault ready? We'll ignore the current one if so, because * * it will inevitably be raised again after the current fault is resolved. */ if (ilIndex <= manager->ilIndex) return; manager->ilData = ilData; manager->ilIndex = ilIndex; manager->il = fault; manager->faulting = 1; /* TODO: Load this value from a table. */ /* Right now, we just assume this is ICB. */ pipeline->stalls = 54; } /* ============================================================================ * VR4300FaultBRPT: Breakpoint Exception. * ========================================================================= */ void VR4300FaultBRPT(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: BRPT."); } /* ============================================================================ * VR4300FaultCOP: CACHE Op Interlock. * ========================================================================= */ void VR4300FaultCOP(struct VR4300 *vr4300) { /* TODO: Selectively handle ICache/DCache */ uint32_t address = vr4300->pipeline.faultManager.ilData; /* TODO: vaddr */ VR4300ICacheFill(&vr4300->icache, vr4300->bus, address, address); /* Restore latch contents that may have been lost. */ memcpy(&vr4300->pipeline.icrfLatch, &vr4300->pipeline.faultManager. savedIcrfLatch, sizeof(vr4300->pipeline.icrfLatch)); } /* ============================================================================ * VR4300FaultCP0I: CP0 Bypass Interlock. * ========================================================================= */ void VR4300FaultCP0I(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: CP0I."); } /* ============================================================================ * VR4300FaultCPU: Coprocessor Unusable Exception. * ========================================================================= */ void VR4300FaultCPU(struct VR4300 *vr4300) { const struct VR4300FaultManager *manager = &vr4300->pipeline.faultManager; struct VR4300Pipeline *pipeline = &vr4300->pipeline; struct VR4300CP0 *cp0 = &vr4300->cp0; debug("Handing fault: CPU."); cp0->regs.cause.ce = manager->excpCauseData; CommonExceptionHandler(cp0, &pipeline->icrfLatch.pc, manager->faultingPC, 11, manager->nextOpcodeFlags); } /* ============================================================================ * VR4300FaultDADE: Data Address Error Exception. * ========================================================================= */ void VR4300FaultDADE(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: DADE."); } /* ============================================================================ * VR4300FaultDBE: Data Bus Error Exception. * ========================================================================= */ void VR4300FaultDBE(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: DBE."); } /* ============================================================================ * VR4300FaultDCB: Data Cache Busy Interlock. * ========================================================================= */ void VR4300FaultDCB(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: DCB."); } /* ============================================================================ * VR4300FaultDCM: Data Cache Miss Interlock. * ========================================================================= */ void VR4300FaultDCM(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: DCM."); } /* ============================================================================ * VR4300FaultDTLB: Data TLB Exception (Miss/Invalid/Modification). * ========================================================================= */ void VR4300FaultDTLB(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: DTLB."); } /* ============================================================================ * VR4300FaultFPE: Floating Point Exception. * ========================================================================= */ void VR4300FaultFPE(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: FPE."); } /* ============================================================================ * VR4300FaultIADE: Instruction Address Error Exception. * ========================================================================= */ void VR4300FaultIADE(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: IADE."); } /* ============================================================================ * VR4300FaultIBE: Instruction Bus Error Exception. * ========================================================================= */ void VR4300FaultIBE(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: IBE."); } /* ============================================================================ * VR4300FaultICB: Instruction Cache Busy Interlock. * ========================================================================= */ void VR4300FaultICB(struct VR4300 *vr4300) { uint64_t vaddr = vr4300->pipeline.faultManager.savedIcrfLatch.address; uint32_t paddr = vr4300->pipeline.faultManager.ilData; VR4300ICacheFill(&vr4300->icache, vr4300->bus, vaddr, paddr); /* Restore latch contents that may have been lost. */ memcpy(&vr4300->pipeline.icrfLatch, &vr4300->pipeline.faultManager. savedIcrfLatch, sizeof(vr4300->pipeline.icrfLatch)); } /* ============================================================================ * VR4300FaultINTR: Interrupt Exception. * ========================================================================= */ void VR4300FaultINTR(struct VR4300 *vr4300) { const struct VR4300FaultManager *manager = &vr4300->pipeline.faultManager; struct VR4300Pipeline *pipeline = &vr4300->pipeline; struct VR4300CP0 *cp0 = &vr4300->cp0; debug("Handing fault: INTR."); vr4300->cp0.interruptRaiseMask = 0; cp0->regs.cause.ce = manager->excpCauseData; CommonExceptionHandler(cp0, &pipeline->icrfLatch.pc, manager->faultingPC, 0, manager->nextOpcodeFlags); } /* ============================================================================ * VR4300FaultINV: Invalid fault. * ========================================================================= */ void VR4300FaultINV(struct VR4300 *unused(vr4300)) { assert(0 && "Caught the 'INV' fault?"); } /* ============================================================================ * VR4300FaultITM: Instruction TLB Exception (Miss E./Invalid/Miss I.). * ========================================================================= */ void VR4300FaultITM(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: ITM."); } /* ============================================================================ * VR4300FaultLDI: Load Interlock. * ========================================================================= */ void VR4300FaultLDI(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: LDI."); } /* ============================================================================ * VR4300FaultMCI: Multicycle Instruction Interlock. * ========================================================================= */ void VR4300FaultMCI(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: MCI."); } /* ============================================================================ * VR4300FaultNMI: Non-Maskable Interrupt Exception. * ========================================================================= */ void VR4300FaultNMI(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: NMI."); } /* ============================================================================ * VR4300FaultOVFL: Integer Overflow Exception. * ========================================================================= */ void VR4300FaultOVFL(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: OVFL."); } /* ============================================================================ * VR4300FaultRST: Reset Exception. * ========================================================================= */ void VR4300FaultRST(struct VR4300 *vr4300) { struct VR4300Pipeline *pipeline = &vr4300->pipeline; struct VR4300CP0 *cp0 = &vr4300->cp0; debug("Handling fault: RST"); /* RST/SOFT */ if (vr4300->pipeline.faultManager.excpCauseData) { debug("Unimplemented fault: RST/Soft."); } /* RST/HARD */ else { cp0->regs.status.ds.ts = 0; cp0->regs.status.ds.sr = 0; cp0->regs.status.rp = 0; cp0->regs.config.ep = 0; cp0->regs.status.erl = 1; cp0->regs.status.ds.bev = 1; cp0->regs.config.be = 1; /* Set to upper limit. */ cp0->regs.random = 31; /* Set to DivMode pins. */ cp0->regs.config.ec = 0; } /* Change the PC to the reset exception vector. */ pipeline->icrfLatch.pc = VR4300_RESET_VECTOR - 4; } /* ============================================================================ * VR4300FaultRSVD: Reserved Instruction Exception. * ========================================================================= */ void VR4300FaultRSVD(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: RSVD."); } /* ============================================================================ * VR4300FaultSYSC: System Call Exception. * ========================================================================= */ void VR4300FaultSYSC(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: SYSC."); } /* ============================================================================ * VR4300FaultTRAP: Trap Exception. * ========================================================================= */ void VR4300FaultTRAP(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: TRAP."); } /* ============================================================================ * VR4300FaultWAT: Watch Exception. * ========================================================================= */ void VR4300FaultWAT(struct VR4300 *unused(vr4300)) { debug("Unimplemented fault: WAT."); } /* ============================================================================ * HandleFaults: Resolves pipeline fault conditions. * * Interlocks: Resolve by stalling the pipeline until hardware corrects. * Exceptions: Resolve by aborting both the faulty and subsequent insns. * ========================================================================= */ typedef void (*const FaultHandler)(struct VR4300 *); static const FaultHandler FaultHandlerTable[NUM_VR4300_FAULTS] = { #define X(fault) &VR4300Fault##fault, #include "Fault.md" #undef X }; void HandleExceptions(struct VR4300 *vr4300) { struct VR4300FaultManager *manager = &vr4300->pipeline.faultManager; struct VR4300ICRFLatch *icrfLatch = &vr4300->pipeline.icrfLatch; struct VR4300RFEXLatch *rfexLatch = &vr4300->pipeline.rfexLatch; struct VR4300EXDCLatch *exdcLatch = &vr4300->pipeline.exdcLatch; struct VR4300DCWBLatch *dcwbLatch = &vr4300->pipeline.dcwbLatch; /* Trash all outputs of proceeding instructions. */ memset(&dcwbLatch->result, 0, sizeof(dcwbLatch->result)); memset(&exdcLatch->result, 0, sizeof(exdcLatch->result)); VR4300InvalidateOpcode(&rfexLatch->opcode); icrfLatch->iwMask = 0; /* Resolve the exception appropriately. */ FaultHandlerTable[manager->excp](vr4300); /* Reset the pipeline (to effectively flush it). */ manager->excpIndex = VR4300_PCU_NORMAL; manager->ilIndex = VR4300_PCU_NORMAL; manager->excp = VR4300_FAULT_INV; manager->il = VR4300_FAULT_INV; manager->faulting = 0; } void HandleInterlocks(struct VR4300 *vr4300) { struct VR4300FaultManager *manager = &vr4300->pipeline.faultManager; /* Resolve the fault appropriately. */ FaultHandlerTable[manager->il](vr4300); /* Reset the pipeline (to effectively flush it). */ manager->faulting = (manager->excpIndex != VR4300_PCU_NORMAL); manager->ilIndex = VR4300_PCU_NORMAL; manager->il = VR4300_FAULT_INV; }
35.914046
79
0.492324
[ "vector" ]
00ad33f4ec51cce68f691b34e234f7bd46724661
417
h
C
src/solver/enumerate_term_solver.h
jiry17/PolyGen
b384e478ec91299d6a14f4681ff3e0850911822b
[ "MIT" ]
1
2021-09-13T04:05:20.000Z
2021-09-13T04:05:20.000Z
src/solver/enumerate_term_solver.h
jiry17/PolyGen
b384e478ec91299d6a14f4681ff3e0850911822b
[ "MIT" ]
null
null
null
src/solver/enumerate_term_solver.h
jiry17/PolyGen
b384e478ec91299d6a14f4681ff3e0850911822b
[ "MIT" ]
1
2021-12-01T08:18:21.000Z
2021-12-01T08:18:21.000Z
#ifndef CPP_ENUMERATE_TERM_SOLVER_H #define CPP_ENUMERATE_TERM_SOLVER_H #include "term_solver.h" #include "gurobi_c++.h" #include "glog/logging.h" // Term solver used in Eusolver, which is used only in ablation_T class EnumerateTermSolver: public TermSolver { public: int prog_num; virtual std::vector<Program*> getTerms(const std::vector<PointExample*>& example_list); }; #endif //CPP_ILP_TERM_SOLVER_H
23.166667
91
0.77458
[ "vector" ]
00b0e89e9dd8186bf1409ee72b8c337886486c37
2,692
h
C
ios/OPPWAMobile.xcframework/ios-i386_x86_64-simulator/OPPWAMobile.framework/Headers/OPPYooKassaPaymentParams.h
hadysata/hyperpay
590f50ff8a8379e407c15c2ee8b3af93041ab422
[ "BSD-2-Clause" ]
7
2021-08-21T06:35:15.000Z
2022-01-31T18:12:08.000Z
ios/OPPWAMobile.xcframework/ios-i386_x86_64-simulator/OPPWAMobile.framework/Headers/OPPYooKassaPaymentParams.h
hadysata/hyperpay
590f50ff8a8379e407c15c2ee8b3af93041ab422
[ "BSD-2-Clause" ]
10
2021-09-12T13:39:46.000Z
2022-03-12T14:00:33.000Z
ios/OPPWAMobile.xcframework/ios-i386_x86_64-simulator/OPPWAMobile.framework/Headers/OPPYooKassaPaymentParams.h
hadysata/hyperpay
590f50ff8a8379e407c15c2ee8b3af93041ab422
[ "BSD-2-Clause" ]
13
2021-09-07T13:39:51.000Z
2022-03-23T10:50:10.000Z
// // Copyright (c) $$year$$ by ACI Worldwide, Inc. // All rights reserved. // // This software is the confidential and proprietary information // of ACI Worldwide Inc ("Confidential Information"). You shall // not disclose such Confidential Information and shall use it // only in accordance with the terms of the license agreement // you entered with ACI Worldwide Inc. // #import "OPPPaymentParams.h" /** Class to encapsulate all necessary parameters for performing transaction with YooKassa. */ NS_ASSUME_NONNULL_BEGIN @interface OPPYooKassaPaymentParams : OPPPaymentParams /// @name Initialization /// :nodoc: - (instancetype)initWithCheckoutID:(NSString *)checkoutID paymentBrand:(NSString *)paymentBrand error:(NSError * _Nullable __autoreleasing *)error NS_UNAVAILABLE; /** Creates an object representing YooKassa transaction. @param checkoutID The checkout ID of the transaction. Must be not nil or empty. @param paymentToken The payment token received from YooKassa. @param error The error that occurred while validating payment parameters. See code attribute (`OPPErrorCode`) and `NSLocalizedDescription` to identify the reason of failure. @return Returns an object representing YooKassa transaction, and nil if parameters are invalid. */ + (nullable instancetype)yooKassaPaymentParamsWithCheckoutID:(NSString *)checkoutID paymentToken:(NSString *)paymentToken error:(NSError **)error; /** Creates an object representing YooKassa transaction. @param checkoutID The checkout ID of the transaction. Must be not nil or empty. @param paymentToken The payment token received from YooKassa. @param error The error that occurred while validating payment parameters. See code attribute (`OPPErrorCode`) and `NSLocalizedDescription` to identify the reason of failure. @return Returns an object representing YooKassa transaction, and nil if parameters are invalid. */ - (nullable instancetype)initWithCheckoutID:(NSString *)checkoutID paymentToken:(NSString *)paymentToken error:(NSError **)error NS_DESIGNATED_INITIALIZER; /// @name Properties /** One-time token for payment. */ @property (nonatomic, copy, readonly) NSString *paymentToken; /// @name Validation methods /** Checks if the payment token is valid to perform a transaction. @param paymentToken The payment token received from YooKassa. @return `YES` if the payment token is not empty. */ + (BOOL)isPaymentTokenValid:(NSString *)paymentToken; @end NS_ASSUME_NONNULL_END
37.388889
174
0.720654
[ "object" ]
00b0fbe97f5eef81f91a2c0d1854811a92eca7fa
2,646
c
C
nitan/cmds/std/cuifa.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/cmds/std/cuifa.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/cmds/std/cuifa.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// cuifa.c inherit F_SSERVER; #include <ansi.h> void sanshi(object me, object target); int main(object me, string arg) { object target; if( me->is_fighting() ) return notify_fail("戰鬥中催發?找死嗎?\n"); if( query("family/master_id", me) != "renwoxing" ) return notify_fail("你不是任教主的弟子,無法催發丹藥!\n"); if(me->is_busy()) return notify_fail("你正忙着呢!\n"); if((int)me->query_skill("xixing-dafa", 1) < 100) return notify_fail("你的吸星大法修為還不夠。\n"); if((int)me->query_skill("kuihua-xinfa", 1) < 100) return notify_fail("你的葵花心法修為太低。\n"); if( query("qi", me)<300 ) return notify_fail("你的氣不夠。\n"); if( query("neili", me)<400 ) return notify_fail("你的真氣不夠。\n"); if( query("eff_qi", me)<query("max_qi", me)/2 ) return notify_fail("你受傷過重,只怕一運真氣便有生命危險!\n"); if ( !arg ) return notify_fail("你要催發誰身上的丹藥?\n"); if ( present(arg, environment(me)) ) return notify_fail("你要催發的人就在你身邊,不怕被砍?\n"); target = find_player(arg); if (!target) target = find_living(arg); if (!target || !me->visible(target)) return notify_fail("你要催發的人現在沒在吧?\n"); write( HIW "你盤膝坐下來開始催發三尸腦神丹。\n" NOR); message("vision", HIW + me->name() + "運起吸星大法,盤膝坐下,開始催發三尸腦神丹。\n" NOR, environment(me), me); addn("neili", -300, me); me->start_busy(5); me->start_call_out( (: call_other,__FILE__,"sanshi",me,target :),5); return 1; } void sanshi(object me, object target) { message_vision("$N盤膝而坐,嘴裏不知道唸叨着什麼。\n",me); if( !query("sanshi", target) ) { tell_object(me,"你忽然覺得不對頭,"+query("name", target)+"體內沒有被種屍蟲!\n"); return; } if( query("sanshi", target) != query("id", me) ) { tell_object(me,"你忽然覺得不對頭,"+query("name", target)+"體內種的不是你的屍蟲!\n"); return; } tell_object(target, "你忽然覺得頭不知什麼原因疼了起來,漸漸痛不可抑。猛然想起是屍蟲發作,只覺得頭腦一轟,就什麼也不知道了!\n"); // target->die(); delete("sanshi", target); target->receive_wound("qi", 10000,"三尸腦神丹突發而亡。真是可惜。"); target->receive_damage("qi", 10000,"三尸腦神丹突發而亡。真是可惜。"); target->receive_wound("jing", 10000,"三尸腦神丹突發而亡。真是可惜。"); target->receive_damage("jing", 10000,"三尸腦神丹突發而亡。真是可惜。"); //message("channel:rumor", MAG"【謠言】某人:"+target->query("name")+"三尸腦神丹突發而亡。真是可惜!\n"NOR, users()); return; } int help(object me) { write(@HELP 指令格式 : cuifa <人物> 這個指令讓你催發一個人物身上的三尸腦神丹。當然,只有吃了 你的三尸腦神丹的人才會被你催發。 HELP ); return 1; }
35.28
98
0.562358
[ "object" ]
00b1ebb556ba20306c39160e4cd216d22af1f98d
37,902
h
C
server/3rd/include/frame/asm/IAsynIpcChannel.h
netsecsp/aftpx
eb1d696aa3b2c0c12e60a987bd5f97408ae49fbd
[ "Apache-2.0" ]
null
null
null
server/3rd/include/frame/asm/IAsynIpcChannel.h
netsecsp/aftpx
eb1d696aa3b2c0c12e60a987bd5f97408ae49fbd
[ "Apache-2.0" ]
null
null
null
server/3rd/include/frame/asm/IAsynIpcChannel.h
netsecsp/aftpx
eb1d696aa3b2c0c12e60a987bd5f97408ae49fbd
[ "Apache-2.0" ]
null
null
null
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.00.0603 */ /* at Tue Apr 26 17:24:39 2022 */ /* Compiler settings for IAsynIpcChannel.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __IAsynIpcChannel_h__ #define __IAsynIpcChannel_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __IAsynIpcIoOperation_FWD_DEFINED__ #define __IAsynIpcIoOperation_FWD_DEFINED__ typedef interface IAsynIpcIoOperation IAsynIpcIoOperation; #endif /* __IAsynIpcIoOperation_FWD_DEFINED__ */ #ifndef __IAsynNamedPipe_FWD_DEFINED__ #define __IAsynNamedPipe_FWD_DEFINED__ typedef interface IAsynNamedPipe IAsynNamedPipe; #endif /* __IAsynNamedPipe_FWD_DEFINED__ */ #ifndef __IAsynIpcDevice_FWD_DEFINED__ #define __IAsynIpcDevice_FWD_DEFINED__ typedef interface IAsynIpcDevice IAsynIpcDevice; #endif /* __IAsynIpcDevice_FWD_DEFINED__ */ #ifndef __IAsynIpcDeviceListener_FWD_DEFINED__ #define __IAsynIpcDeviceListener_FWD_DEFINED__ typedef interface IAsynIpcDeviceListener IAsynIpcDeviceListener; #endif /* __IAsynIpcDeviceListener_FWD_DEFINED__ */ #ifndef __IAsynIpcChannel_FWD_DEFINED__ #define __IAsynIpcChannel_FWD_DEFINED__ typedef interface IAsynIpcChannel IAsynIpcChannel; #endif /* __IAsynIpcChannel_FWD_DEFINED__ */ /* header files for imported files */ #include "IAsynFileSystem.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_IAsynIpcChannel_0000_0000 */ /* [local] */ #pragma pack(push, 1) extern RPC_IF_HANDLE __MIDL_itf_IAsynIpcChannel_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_IAsynIpcChannel_0000_0000_v0_0_s_ifspec; #ifndef __IAsynIpcIoOperation_INTERFACE_DEFINED__ #define __IAsynIpcIoOperation_INTERFACE_DEFINED__ /* interface IAsynIpcIoOperation */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IAsynIpcIoOperation; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("63A88D82-1EB4-45a1-847D-0F2AE3D54D06") IAsynIpcIoOperation : public IAsynIoOperation { public: virtual HRESULT STDMETHODCALLTYPE GetPeerAddress( /* [in] */ IStringSetter *Name, /* [out] */ uint32_t *pid) = 0; virtual HRESULT STDMETHODCALLTYPE SetPeerAddress( /* [in] */ STRING Name, /* [in] */ uint32_t pid) = 0; }; #else /* C style interface */ typedef struct IAsynIpcIoOperationVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IAsynIpcIoOperation * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IAsynIpcIoOperation * This); ULONG ( STDMETHODCALLTYPE *Release )( IAsynIpcIoOperation * This); HRESULT ( STDMETHODCALLTYPE *Get )( IAsynIpcIoOperation * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Set )( IAsynIpcIoOperation * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ IUnknown *pObject); HRESULT ( STDMETHODCALLTYPE *GetAsynFrameThread )( IAsynIpcIoOperation * This, /* [out] */ IAsynFrameThread **ppAsynFrameThread); HRESULT ( STDMETHODCALLTYPE *QueryStatus )( IAsynIpcIoOperation * This); HRESULT ( STDMETHODCALLTYPE *NewIoBuffer )( IAsynIpcIoOperation * This, /* [in] */ uint32_t index, /* [in] */ BYTE *pFillBuffer, /* [in] */ uint32_t lFillOffset, /* [in] */ uint32_t lFillSize, /* [in] */ uint32_t lNewBufferSize, /* [out] */ BYTE **ppBuffer); HRESULT ( STDMETHODCALLTYPE *GetIoBuffer )( IAsynIpcIoOperation * This, /* [in] */ uint32_t index, /* [out] */ IBuffer **ppObject, /* [out] */ BYTE **ppBuffer); HRESULT ( STDMETHODCALLTYPE *SetIoBuffer )( IAsynIpcIoOperation * This, /* [in] */ uint32_t index, /* [in] */ IBuffer *pObject); HRESULT ( STDMETHODCALLTYPE *GetOsBuffer )( IAsynIpcIoOperation * This, /* [in] */ uint32_t index, /* [out] */ handle *ppBuffer); HRESULT ( STDMETHODCALLTYPE *GetOpParams )( IAsynIpcIoOperation * This, /* [out] */ uint32_t *message, /* [out] */ uint64_t *pParam1, /* [out] */ uint64_t *pParam2); HRESULT ( STDMETHODCALLTYPE *SetOpParams )( IAsynIpcIoOperation * This, /* [in] */ uint32_t message, /* [in] */ uint64_t *pParam1, /* [in] */ uint64_t lparam2); HRESULT ( STDMETHODCALLTYPE *SetOpParam1 )( IAsynIpcIoOperation * This, /* [in] */ uint64_t lparam1); HRESULT ( STDMETHODCALLTYPE *GetIoParams )( IAsynIpcIoOperation * This, /* [out] */ uint32_t *pSumBytes, /* [out] */ uint32_t *pMinBytes); HRESULT ( STDMETHODCALLTYPE *SetIoParam1 )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lSumBytes); HRESULT ( STDMETHODCALLTYPE *SetIoParams )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lTransferedBytes, /* [in] */ uint32_t lSumBytes, /* [in] */ uint32_t lMinBytes); HRESULT ( STDMETHODCALLTYPE *NewBufferIovectors )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lCount, /* [out] */ handle *ppBuffer); HRESULT ( STDMETHODCALLTYPE *SetBufferIovectors )( IAsynIpcIoOperation * This, /* [in] */ STRING *pIovector, /* [in] */ uint32_t lCount, /* [in] */ uint32_t lMinBytes); HRESULT ( STDMETHODCALLTYPE *AddBufferIovectors )( IAsynIpcIoOperation * This, /* [in] */ STRING *pIovector, /* [in] */ uint32_t lCount, /* [in] */ uint32_t lAddBytes); HRESULT ( STDMETHODCALLTYPE *ReadBuffers )( IAsynIpcIoOperation * This, /* [out][in] */ STRING *pSrcIovector, /* [out][in] */ uint32_t *count, /* [out] */ uint32_t *pCopyBytes, /* [out] */ uint32_t *pMinBytes); HRESULT ( STDMETHODCALLTYPE *Copy )( IAsynIpcIoOperation * This, /* [in] */ BOOL bIsDGRAM, /* [in] */ IAsynIoOperation *pDstAsynIoOperation, /* [out] */ uint32_t *pCopyBytes, /* [out] */ uint32_t *pMinBytes, /* [out] */ uint32_t *pStayBytes); HRESULT ( STDMETHODCALLTYPE *GetCompletedResult )( IAsynIpcIoOperation * This, /* [out] */ uint32_t *pErrorCode, /* [out] */ uint32_t *pTransferedBytes, /* [out] */ uint32_t *pReservedBytes); HRESULT ( STDMETHODCALLTYPE *SetCompletedResult )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lErrorCode); HRESULT ( STDMETHODCALLTYPE *SetTransferedBytes )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lTransferedBytes); HRESULT ( STDMETHODCALLTYPE *AddTransferedBytes )( IAsynIpcIoOperation * This, /* [in] */ uint32_t lTransferedBytes); HRESULT ( STDMETHODCALLTYPE *GetCompletedObject )( IAsynIpcIoOperation * This, /* [in] */ BOOL bTaked, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *SetCompletedObject )( IAsynIpcIoOperation * This, /* [in] */ IUnknown *pObject); HRESULT ( STDMETHODCALLTYPE *GetPeerAddress )( IAsynIpcIoOperation * This, /* [in] */ IStringSetter *Name, /* [out] */ uint32_t *pid); HRESULT ( STDMETHODCALLTYPE *SetPeerAddress )( IAsynIpcIoOperation * This, /* [in] */ STRING Name, /* [in] */ uint32_t pid); END_INTERFACE } IAsynIpcIoOperationVtbl; interface IAsynIpcIoOperation { CONST_VTBL struct IAsynIpcIoOperationVtbl *lpVtbl; }; #ifdef COBJMACROS #define IAsynIpcIoOperation_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IAsynIpcIoOperation_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IAsynIpcIoOperation_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IAsynIpcIoOperation_Get(This,method,lparam,riid,ppObject) \ ( (This)->lpVtbl -> Get(This,method,lparam,riid,ppObject) ) #define IAsynIpcIoOperation_Set(This,method,lparam,pObject) \ ( (This)->lpVtbl -> Set(This,method,lparam,pObject) ) #define IAsynIpcIoOperation_GetAsynFrameThread(This,ppAsynFrameThread) \ ( (This)->lpVtbl -> GetAsynFrameThread(This,ppAsynFrameThread) ) #define IAsynIpcIoOperation_QueryStatus(This) \ ( (This)->lpVtbl -> QueryStatus(This) ) #define IAsynIpcIoOperation_NewIoBuffer(This,index,pFillBuffer,lFillOffset,lFillSize,lNewBufferSize,ppBuffer) \ ( (This)->lpVtbl -> NewIoBuffer(This,index,pFillBuffer,lFillOffset,lFillSize,lNewBufferSize,ppBuffer) ) #define IAsynIpcIoOperation_GetIoBuffer(This,index,ppObject,ppBuffer) \ ( (This)->lpVtbl -> GetIoBuffer(This,index,ppObject,ppBuffer) ) #define IAsynIpcIoOperation_SetIoBuffer(This,index,pObject) \ ( (This)->lpVtbl -> SetIoBuffer(This,index,pObject) ) #define IAsynIpcIoOperation_GetOsBuffer(This,index,ppBuffer) \ ( (This)->lpVtbl -> GetOsBuffer(This,index,ppBuffer) ) #define IAsynIpcIoOperation_GetOpParams(This,message,pParam1,pParam2) \ ( (This)->lpVtbl -> GetOpParams(This,message,pParam1,pParam2) ) #define IAsynIpcIoOperation_SetOpParams(This,message,pParam1,lparam2) \ ( (This)->lpVtbl -> SetOpParams(This,message,pParam1,lparam2) ) #define IAsynIpcIoOperation_SetOpParam1(This,lparam1) \ ( (This)->lpVtbl -> SetOpParam1(This,lparam1) ) #define IAsynIpcIoOperation_GetIoParams(This,pSumBytes,pMinBytes) \ ( (This)->lpVtbl -> GetIoParams(This,pSumBytes,pMinBytes) ) #define IAsynIpcIoOperation_SetIoParam1(This,lSumBytes) \ ( (This)->lpVtbl -> SetIoParam1(This,lSumBytes) ) #define IAsynIpcIoOperation_SetIoParams(This,lTransferedBytes,lSumBytes,lMinBytes) \ ( (This)->lpVtbl -> SetIoParams(This,lTransferedBytes,lSumBytes,lMinBytes) ) #define IAsynIpcIoOperation_NewBufferIovectors(This,lCount,ppBuffer) \ ( (This)->lpVtbl -> NewBufferIovectors(This,lCount,ppBuffer) ) #define IAsynIpcIoOperation_SetBufferIovectors(This,pIovector,lCount,lMinBytes) \ ( (This)->lpVtbl -> SetBufferIovectors(This,pIovector,lCount,lMinBytes) ) #define IAsynIpcIoOperation_AddBufferIovectors(This,pIovector,lCount,lAddBytes) \ ( (This)->lpVtbl -> AddBufferIovectors(This,pIovector,lCount,lAddBytes) ) #define IAsynIpcIoOperation_ReadBuffers(This,pSrcIovector,count,pCopyBytes,pMinBytes) \ ( (This)->lpVtbl -> ReadBuffers(This,pSrcIovector,count,pCopyBytes,pMinBytes) ) #define IAsynIpcIoOperation_Copy(This,bIsDGRAM,pDstAsynIoOperation,pCopyBytes,pMinBytes,pStayBytes) \ ( (This)->lpVtbl -> Copy(This,bIsDGRAM,pDstAsynIoOperation,pCopyBytes,pMinBytes,pStayBytes) ) #define IAsynIpcIoOperation_GetCompletedResult(This,pErrorCode,pTransferedBytes,pReservedBytes) \ ( (This)->lpVtbl -> GetCompletedResult(This,pErrorCode,pTransferedBytes,pReservedBytes) ) #define IAsynIpcIoOperation_SetCompletedResult(This,lErrorCode) \ ( (This)->lpVtbl -> SetCompletedResult(This,lErrorCode) ) #define IAsynIpcIoOperation_SetTransferedBytes(This,lTransferedBytes) \ ( (This)->lpVtbl -> SetTransferedBytes(This,lTransferedBytes) ) #define IAsynIpcIoOperation_AddTransferedBytes(This,lTransferedBytes) \ ( (This)->lpVtbl -> AddTransferedBytes(This,lTransferedBytes) ) #define IAsynIpcIoOperation_GetCompletedObject(This,bTaked,riid,ppObject) \ ( (This)->lpVtbl -> GetCompletedObject(This,bTaked,riid,ppObject) ) #define IAsynIpcIoOperation_SetCompletedObject(This,pObject) \ ( (This)->lpVtbl -> SetCompletedObject(This,pObject) ) #define IAsynIpcIoOperation_GetPeerAddress(This,Name,pid) \ ( (This)->lpVtbl -> GetPeerAddress(This,Name,pid) ) #define IAsynIpcIoOperation_SetPeerAddress(This,Name,pid) \ ( (This)->lpVtbl -> SetPeerAddress(This,Name,pid) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IAsynIpcIoOperation_INTERFACE_DEFINED__ */ #ifndef __IAsynNamedPipe_INTERFACE_DEFINED__ #define __IAsynNamedPipe_INTERFACE_DEFINED__ /* interface IAsynNamedPipe */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IAsynNamedPipe; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("852F8BD3-2CC0-40c4-8156-6AF0735FFCBD") IAsynNamedPipe : public IAsynIoDevice { public: virtual HRESULT STDMETHODCALLTYPE Open( /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING PipeName, /* [in] */ uint32_t lOpenMode, /* [in] */ BOOL bIsStream, /* [in] */ uint32_t lMaxInstances, /* [in] */ uint32_t lOutBufferSize, /* [in] */ uint32_t lInBufferSize, /* [in] */ uint32_t lDefaultTimeOut, /* [in] */ handle pSecurityAttributes) = 0; virtual HRESULT STDMETHODCALLTYPE Accept( /* [in] */ IAsynIoOperation *pAsynIoOperation) = 0; }; #else /* C style interface */ typedef struct IAsynNamedPipeVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IAsynNamedPipe * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IAsynNamedPipe * This); ULONG ( STDMETHODCALLTYPE *Release )( IAsynNamedPipe * This); HRESULT ( STDMETHODCALLTYPE *Get )( IAsynNamedPipe * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Set )( IAsynNamedPipe * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ IUnknown *pObject); HRESULT ( STDMETHODCALLTYPE *IsOpened )( IAsynNamedPipe * This, /* [in] */ IStringSetter *pDeviceName); HRESULT ( STDMETHODCALLTYPE *IsStream )( IAsynNamedPipe * This, /* [out] */ uint32_t *pBlockSize); HRESULT ( STDMETHODCALLTYPE *GetDeviceHandle )( IAsynNamedPipe * This, /* [in] */ uint32_t lType, /* [out] */ handle *ppDeviceHandle); HRESULT ( STDMETHODCALLTYPE *Read )( IAsynNamedPipe * This, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Write )( IAsynNamedPipe * This, /* [in] */ IAsynIoOperation *pAsynIoOperation, /* [in] */ uint64_t reserved); HRESULT ( STDMETHODCALLTYPE *Close )( IAsynNamedPipe * This, /* [in] */ uint32_t reserved); HRESULT ( STDMETHODCALLTYPE *Attach )( IAsynNamedPipe * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ uint32_t lAttachType, /* [in] */ BOOL bCopyHandle, /* [in] */ handle pRecvDeviceHandle, /* [in] */ handle pSendDeviceHandle, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Detach )( IAsynNamedPipe * This, /* [in] */ uint32_t level); HRESULT ( STDMETHODCALLTYPE *Clone )( IAsynNamedPipe * This, /* [in] */ IUnknown *pReserved, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Open )( IAsynNamedPipe * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING PipeName, /* [in] */ uint32_t lOpenMode, /* [in] */ BOOL bIsStream, /* [in] */ uint32_t lMaxInstances, /* [in] */ uint32_t lOutBufferSize, /* [in] */ uint32_t lInBufferSize, /* [in] */ uint32_t lDefaultTimeOut, /* [in] */ handle pSecurityAttributes); HRESULT ( STDMETHODCALLTYPE *Accept )( IAsynNamedPipe * This, /* [in] */ IAsynIoOperation *pAsynIoOperation); END_INTERFACE } IAsynNamedPipeVtbl; interface IAsynNamedPipe { CONST_VTBL struct IAsynNamedPipeVtbl *lpVtbl; }; #ifdef COBJMACROS #define IAsynNamedPipe_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IAsynNamedPipe_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IAsynNamedPipe_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IAsynNamedPipe_Get(This,method,lparam,riid,ppObject) \ ( (This)->lpVtbl -> Get(This,method,lparam,riid,ppObject) ) #define IAsynNamedPipe_Set(This,method,lparam,pObject) \ ( (This)->lpVtbl -> Set(This,method,lparam,pObject) ) #define IAsynNamedPipe_IsOpened(This,pDeviceName) \ ( (This)->lpVtbl -> IsOpened(This,pDeviceName) ) #define IAsynNamedPipe_IsStream(This,pBlockSize) \ ( (This)->lpVtbl -> IsStream(This,pBlockSize) ) #define IAsynNamedPipe_GetDeviceHandle(This,lType,ppDeviceHandle) \ ( (This)->lpVtbl -> GetDeviceHandle(This,lType,ppDeviceHandle) ) #define IAsynNamedPipe_Read(This,pAsynIoOperation) \ ( (This)->lpVtbl -> Read(This,pAsynIoOperation) ) #define IAsynNamedPipe_Write(This,pAsynIoOperation,reserved) \ ( (This)->lpVtbl -> Write(This,pAsynIoOperation,reserved) ) #define IAsynNamedPipe_Close(This,reserved) \ ( (This)->lpVtbl -> Close(This,reserved) ) #define IAsynNamedPipe_Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) \ ( (This)->lpVtbl -> Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) ) #define IAsynNamedPipe_Detach(This,level) \ ( (This)->lpVtbl -> Detach(This,level) ) #define IAsynNamedPipe_Clone(This,pReserved,riid,ppObject) \ ( (This)->lpVtbl -> Clone(This,pReserved,riid,ppObject) ) #define IAsynNamedPipe_Open(This,pAsynFrameThread,PipeName,lOpenMode,bIsStream,lMaxInstances,lOutBufferSize,lInBufferSize,lDefaultTimeOut,pSecurityAttributes) \ ( (This)->lpVtbl -> Open(This,pAsynFrameThread,PipeName,lOpenMode,bIsStream,lMaxInstances,lOutBufferSize,lInBufferSize,lDefaultTimeOut,pSecurityAttributes) ) #define IAsynNamedPipe_Accept(This,pAsynIoOperation) \ ( (This)->lpVtbl -> Accept(This,pAsynIoOperation) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IAsynNamedPipe_INTERFACE_DEFINED__ */ #ifndef __IAsynIpcDevice_INTERFACE_DEFINED__ #define __IAsynIpcDevice_INTERFACE_DEFINED__ /* interface IAsynIpcDevice */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IAsynIpcDevice; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("EB387F4A-854B-41f2-B92A-0C80E2E44515") IAsynIpcDevice : public IAsynIoDevice { public: virtual HRESULT STDMETHODCALLTYPE Connect( /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING IpcName, /* [in] */ uint32_t lDstProcessId, /* [in] */ IAsynIoOperation *pAsynIoOperation, /* [in] */ uint32_t lTimeoutMillisec) = 0; }; #else /* C style interface */ typedef struct IAsynIpcDeviceVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IAsynIpcDevice * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IAsynIpcDevice * This); ULONG ( STDMETHODCALLTYPE *Release )( IAsynIpcDevice * This); HRESULT ( STDMETHODCALLTYPE *Get )( IAsynIpcDevice * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Set )( IAsynIpcDevice * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ IUnknown *pObject); HRESULT ( STDMETHODCALLTYPE *IsOpened )( IAsynIpcDevice * This, /* [in] */ IStringSetter *pDeviceName); HRESULT ( STDMETHODCALLTYPE *IsStream )( IAsynIpcDevice * This, /* [out] */ uint32_t *pBlockSize); HRESULT ( STDMETHODCALLTYPE *GetDeviceHandle )( IAsynIpcDevice * This, /* [in] */ uint32_t lType, /* [out] */ handle *ppDeviceHandle); HRESULT ( STDMETHODCALLTYPE *Read )( IAsynIpcDevice * This, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Write )( IAsynIpcDevice * This, /* [in] */ IAsynIoOperation *pAsynIoOperation, /* [in] */ uint64_t reserved); HRESULT ( STDMETHODCALLTYPE *Close )( IAsynIpcDevice * This, /* [in] */ uint32_t reserved); HRESULT ( STDMETHODCALLTYPE *Attach )( IAsynIpcDevice * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ uint32_t lAttachType, /* [in] */ BOOL bCopyHandle, /* [in] */ handle pRecvDeviceHandle, /* [in] */ handle pSendDeviceHandle, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Detach )( IAsynIpcDevice * This, /* [in] */ uint32_t level); HRESULT ( STDMETHODCALLTYPE *Clone )( IAsynIpcDevice * This, /* [in] */ IUnknown *pReserved, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Connect )( IAsynIpcDevice * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING IpcName, /* [in] */ uint32_t lDstProcessId, /* [in] */ IAsynIoOperation *pAsynIoOperation, /* [in] */ uint32_t lTimeoutMillisec); END_INTERFACE } IAsynIpcDeviceVtbl; interface IAsynIpcDevice { CONST_VTBL struct IAsynIpcDeviceVtbl *lpVtbl; }; #ifdef COBJMACROS #define IAsynIpcDevice_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IAsynIpcDevice_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IAsynIpcDevice_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IAsynIpcDevice_Get(This,method,lparam,riid,ppObject) \ ( (This)->lpVtbl -> Get(This,method,lparam,riid,ppObject) ) #define IAsynIpcDevice_Set(This,method,lparam,pObject) \ ( (This)->lpVtbl -> Set(This,method,lparam,pObject) ) #define IAsynIpcDevice_IsOpened(This,pDeviceName) \ ( (This)->lpVtbl -> IsOpened(This,pDeviceName) ) #define IAsynIpcDevice_IsStream(This,pBlockSize) \ ( (This)->lpVtbl -> IsStream(This,pBlockSize) ) #define IAsynIpcDevice_GetDeviceHandle(This,lType,ppDeviceHandle) \ ( (This)->lpVtbl -> GetDeviceHandle(This,lType,ppDeviceHandle) ) #define IAsynIpcDevice_Read(This,pAsynIoOperation) \ ( (This)->lpVtbl -> Read(This,pAsynIoOperation) ) #define IAsynIpcDevice_Write(This,pAsynIoOperation,reserved) \ ( (This)->lpVtbl -> Write(This,pAsynIoOperation,reserved) ) #define IAsynIpcDevice_Close(This,reserved) \ ( (This)->lpVtbl -> Close(This,reserved) ) #define IAsynIpcDevice_Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) \ ( (This)->lpVtbl -> Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) ) #define IAsynIpcDevice_Detach(This,level) \ ( (This)->lpVtbl -> Detach(This,level) ) #define IAsynIpcDevice_Clone(This,pReserved,riid,ppObject) \ ( (This)->lpVtbl -> Clone(This,pReserved,riid,ppObject) ) #define IAsynIpcDevice_Connect(This,pAsynFrameThread,IpcName,lDstProcessId,pAsynIoOperation,lTimeoutMillisec) \ ( (This)->lpVtbl -> Connect(This,pAsynFrameThread,IpcName,lDstProcessId,pAsynIoOperation,lTimeoutMillisec) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IAsynIpcDevice_INTERFACE_DEFINED__ */ #ifndef __IAsynIpcDeviceListener_INTERFACE_DEFINED__ #define __IAsynIpcDeviceListener_INTERFACE_DEFINED__ /* interface IAsynIpcDeviceListener */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IAsynIpcDeviceListener; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("9ED3FDED-C662-4d3c-A951-29E7FDEDADAF") IAsynIpcDeviceListener : public IAsynIoDevice { public: virtual HRESULT STDMETHODCALLTYPE Open( /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING IpcName) = 0; virtual HRESULT STDMETHODCALLTYPE Accept( /* [in] */ IAsynIoOperation *pAsynIoOperation) = 0; }; #else /* C style interface */ typedef struct IAsynIpcDeviceListenerVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IAsynIpcDeviceListener * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IAsynIpcDeviceListener * This); ULONG ( STDMETHODCALLTYPE *Release )( IAsynIpcDeviceListener * This); HRESULT ( STDMETHODCALLTYPE *Get )( IAsynIpcDeviceListener * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Set )( IAsynIpcDeviceListener * This, /* [in] */ uint32_t method, /* [in] */ uint32_t lparam, /* [in] */ IUnknown *pObject); HRESULT ( STDMETHODCALLTYPE *IsOpened )( IAsynIpcDeviceListener * This, /* [in] */ IStringSetter *pDeviceName); HRESULT ( STDMETHODCALLTYPE *IsStream )( IAsynIpcDeviceListener * This, /* [out] */ uint32_t *pBlockSize); HRESULT ( STDMETHODCALLTYPE *GetDeviceHandle )( IAsynIpcDeviceListener * This, /* [in] */ uint32_t lType, /* [out] */ handle *ppDeviceHandle); HRESULT ( STDMETHODCALLTYPE *Read )( IAsynIpcDeviceListener * This, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Write )( IAsynIpcDeviceListener * This, /* [in] */ IAsynIoOperation *pAsynIoOperation, /* [in] */ uint64_t reserved); HRESULT ( STDMETHODCALLTYPE *Close )( IAsynIpcDeviceListener * This, /* [in] */ uint32_t reserved); HRESULT ( STDMETHODCALLTYPE *Attach )( IAsynIpcDeviceListener * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ uint32_t lAttachType, /* [in] */ BOOL bCopyHandle, /* [in] */ handle pRecvDeviceHandle, /* [in] */ handle pSendDeviceHandle, /* [in] */ IAsynIoOperation *pAsynIoOperation); HRESULT ( STDMETHODCALLTYPE *Detach )( IAsynIpcDeviceListener * This, /* [in] */ uint32_t level); HRESULT ( STDMETHODCALLTYPE *Clone )( IAsynIpcDeviceListener * This, /* [in] */ IUnknown *pReserved, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *Open )( IAsynIpcDeviceListener * This, /* [in] */ IAsynFrameThread *pAsynFrameThread, /* [in] */ STRING IpcName); HRESULT ( STDMETHODCALLTYPE *Accept )( IAsynIpcDeviceListener * This, /* [in] */ IAsynIoOperation *pAsynIoOperation); END_INTERFACE } IAsynIpcDeviceListenerVtbl; interface IAsynIpcDeviceListener { CONST_VTBL struct IAsynIpcDeviceListenerVtbl *lpVtbl; }; #ifdef COBJMACROS #define IAsynIpcDeviceListener_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IAsynIpcDeviceListener_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IAsynIpcDeviceListener_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IAsynIpcDeviceListener_Get(This,method,lparam,riid,ppObject) \ ( (This)->lpVtbl -> Get(This,method,lparam,riid,ppObject) ) #define IAsynIpcDeviceListener_Set(This,method,lparam,pObject) \ ( (This)->lpVtbl -> Set(This,method,lparam,pObject) ) #define IAsynIpcDeviceListener_IsOpened(This,pDeviceName) \ ( (This)->lpVtbl -> IsOpened(This,pDeviceName) ) #define IAsynIpcDeviceListener_IsStream(This,pBlockSize) \ ( (This)->lpVtbl -> IsStream(This,pBlockSize) ) #define IAsynIpcDeviceListener_GetDeviceHandle(This,lType,ppDeviceHandle) \ ( (This)->lpVtbl -> GetDeviceHandle(This,lType,ppDeviceHandle) ) #define IAsynIpcDeviceListener_Read(This,pAsynIoOperation) \ ( (This)->lpVtbl -> Read(This,pAsynIoOperation) ) #define IAsynIpcDeviceListener_Write(This,pAsynIoOperation,reserved) \ ( (This)->lpVtbl -> Write(This,pAsynIoOperation,reserved) ) #define IAsynIpcDeviceListener_Close(This,reserved) \ ( (This)->lpVtbl -> Close(This,reserved) ) #define IAsynIpcDeviceListener_Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) \ ( (This)->lpVtbl -> Attach(This,pAsynFrameThread,lAttachType,bCopyHandle,pRecvDeviceHandle,pSendDeviceHandle,pAsynIoOperation) ) #define IAsynIpcDeviceListener_Detach(This,level) \ ( (This)->lpVtbl -> Detach(This,level) ) #define IAsynIpcDeviceListener_Clone(This,pReserved,riid,ppObject) \ ( (This)->lpVtbl -> Clone(This,pReserved,riid,ppObject) ) #define IAsynIpcDeviceListener_Open(This,pAsynFrameThread,IpcName) \ ( (This)->lpVtbl -> Open(This,pAsynFrameThread,IpcName) ) #define IAsynIpcDeviceListener_Accept(This,pAsynIoOperation) \ ( (This)->lpVtbl -> Accept(This,pAsynIoOperation) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IAsynIpcDeviceListener_INTERFACE_DEFINED__ */ #ifndef __IAsynIpcChannel_INTERFACE_DEFINED__ #define __IAsynIpcChannel_INTERFACE_DEFINED__ /* interface IAsynIpcChannel */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IAsynIpcChannel; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("D453C04E-A8E6-4d8d-B024-442365E86B85") IAsynIpcChannel : public IAsynIoOperationFactory { public: virtual HRESULT STDMETHODCALLTYPE CreateAsynNamedPipe( /* [out] */ IAsynNamedPipe **ppAsynNamedPipe) = 0; virtual HRESULT STDMETHODCALLTYPE CreateAsynIpcDevice( /* [out] */ IAsynIpcDevice **ppAsynIpcDevice) = 0; virtual HRESULT STDMETHODCALLTYPE CreateAsynIpcDeviceListener( /* [in] */ STRING argv, /* [out] */ IAsynIpcDeviceListener **ppAsynIpcDeviceListener) = 0; }; #else /* C style interface */ typedef struct IAsynIpcChannelVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IAsynIpcChannel * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IAsynIpcChannel * This); ULONG ( STDMETHODCALLTYPE *Release )( IAsynIpcChannel * This); HRESULT ( STDMETHODCALLTYPE *CreateAsynIoOperation )( IAsynIpcChannel * This, /* [in] */ IAsynFrame *pAsynFrame, /* [in] */ uint32_t param1, /* [in] */ uint32_t param2, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppObject); HRESULT ( STDMETHODCALLTYPE *CreateAsynNamedPipe )( IAsynIpcChannel * This, /* [out] */ IAsynNamedPipe **ppAsynNamedPipe); HRESULT ( STDMETHODCALLTYPE *CreateAsynIpcDevice )( IAsynIpcChannel * This, /* [out] */ IAsynIpcDevice **ppAsynIpcDevice); HRESULT ( STDMETHODCALLTYPE *CreateAsynIpcDeviceListener )( IAsynIpcChannel * This, /* [in] */ STRING argv, /* [out] */ IAsynIpcDeviceListener **ppAsynIpcDeviceListener); END_INTERFACE } IAsynIpcChannelVtbl; interface IAsynIpcChannel { CONST_VTBL struct IAsynIpcChannelVtbl *lpVtbl; }; #ifdef COBJMACROS #define IAsynIpcChannel_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IAsynIpcChannel_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IAsynIpcChannel_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IAsynIpcChannel_CreateAsynIoOperation(This,pAsynFrame,param1,param2,riid,ppObject) \ ( (This)->lpVtbl -> CreateAsynIoOperation(This,pAsynFrame,param1,param2,riid,ppObject) ) #define IAsynIpcChannel_CreateAsynNamedPipe(This,ppAsynNamedPipe) \ ( (This)->lpVtbl -> CreateAsynNamedPipe(This,ppAsynNamedPipe) ) #define IAsynIpcChannel_CreateAsynIpcDevice(This,ppAsynIpcDevice) \ ( (This)->lpVtbl -> CreateAsynIpcDevice(This,ppAsynIpcDevice) ) #define IAsynIpcChannel_CreateAsynIpcDeviceListener(This,argv,ppAsynIpcDeviceListener) \ ( (This)->lpVtbl -> CreateAsynIpcDeviceListener(This,argv,ppAsynIpcDeviceListener) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IAsynIpcChannel_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_IAsynIpcChannel_0000_0005 */ /* [local] */ #pragma pack(pop) extern RPC_IF_HANDLE __MIDL_itf_IAsynIpcChannel_0000_0005_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_IAsynIpcChannel_0000_0005_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
34.176736
163
0.608517
[ "object" ]
00b2e4f8a020d8e19b4acfcd7402fe9ba4b73d41
906
h
C
include/Point.h
kbrauss/FMM3D
e55ff2f6e80a8503ea0594535167099367ec84f3
[ "MIT" ]
6
2018-07-27T14:09:05.000Z
2020-12-26T02:19:31.000Z
include/Point.h
kbrauss/FMM3D
e55ff2f6e80a8503ea0594535167099367ec84f3
[ "MIT" ]
null
null
null
include/Point.h
kbrauss/FMM3D
e55ff2f6e80a8503ea0594535167099367ec84f3
[ "MIT" ]
2
2019-04-07T13:08:42.000Z
2020-11-21T01:20:38.000Z
/* * Point.h * * Created on: Jul 8, 2016 * Author: dbpc */ #ifndef POINT_H_ #define POINT_H_ class Point { public: std::vector<double> coord; // coordinates for point in 3-dimensional space /** constructors */ Point(); Point(double x, double y, double z); Point(std::vector<double> coord); //Point(const Point &p); std::vector<double> getCoord() { return coord; }; void setCoord(std::vector<double> coord) { this->coord = coord; }; void setX(double x_coord) { this->coord[0]=x_coord; }; double getX() { return coord[0]; }; void setY(double y_coord) { this->coord[1]=y_coord; }; double getY() { return coord[1]; }; void setZ(double z_coord) { this->coord[2]=z_coord; }; double getZ() { return coord[2]; }; std::string coordToString(); bool equals(Point &p); int getBoxIndex(unsigned int level); }; #endif /* POINT_H_ */
22.65
75
0.618102
[ "vector" ]
00b49f51649d8adf0d4986a7ae42d7009b4826f8
4,151
h
C
elfitor/elfreader/ELFReader.h
uafio/elfitor
9633d903f2175f54efdca9f64d1724b1e4b82bdb
[ "MIT" ]
null
null
null
elfitor/elfreader/ELFReader.h
uafio/elfitor
9633d903f2175f54efdca9f64d1724b1e4b82bdb
[ "MIT" ]
null
null
null
elfitor/elfreader/ELFReader.h
uafio/elfitor
9633d903f2175f54efdca9f64d1724b1e4b82bdb
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include <fstream> #include <vector> #include "elf.h" #include "../imgui_memory_editor.h" typedef enum { unknown_t = 0, elf32_t, elf64_t, elf_t, } File_t; typedef struct { enum _hdr { ehdr = 0, phdr, shdr, hex } hdr; int idx; } ElfCTX; class State; class File; class Elf32; class Elf64; class FileFactory; class State { private: State( void ); static State* state; void remove( File* file ); protected: std::vector< File* > files; File* ctx_file; public: static State* instance( void ); void add( File* newfile ); File* get_ctx_file( void ); void close( void ); void draw( void ); }; class FileFactory { private: void* base; size_t size; char* fname; char* fpath; File_t type; bool is_supported( void ); File_t get_type( void ); public: FileFactory( const char* fname ); void* get_base( void ); size_t get_file_size( void ); char* filename( void ); char* filepath( void ); virtual File* build( void ); }; class File { protected: void* base; size_t size; char* fname; char* fpath; public: // Hex Editor MemoryEditor mViewer; // Construct the base object File( void ); // Free all buffers ~File( void ); // Pointer to base void* get_base( void ); // Size of file size_t get_file_size( void ); // Pointer to filename from filepath const char* filename( void ); // Full path to filename const char* filepath( void ); // Relative Virtual Address to Virtual Address void* rva2va( size_t rva ); // Virtual Address to Relative Virtual Address uint64_t va2rva( void* va ); // Saves File on disk virtual bool save( const char* fname ); // File type with architecture virtual File_t get_type( void ) = 0; // File type virtual File_t get_type_group( void ) = 0; // Navigational list view for supported main windows virtual void show_nav( void ) = 0; // Code to execute in the main window view virtual void show_main( void ) = 0; // Optional code of additional windows virtual void other_windows( void ) {}; // Show hex editor void show_hex_editor( void ); }; class Elf32 : public File { private: ElfCTX ctx; public: Elf32( FileFactory* factory ); virtual File_t get_type( void ); virtual File_t get_type_group( void ); virtual void show_nav( void ); virtual void show_main( void ); ElfCTX& get_ctx( void ); Elf32_Ehdr* get_elf_header( void ); Elf32_Phdr* get_prog_header( int index ); Elf32_Shdr* get_section_header( int index ); Elf32_Shdr* get_section_header( const char* sname ); char* get_section_name( int index ); char* get_section_name( Elf32_Shdr* section ); Elf32_Sym* get_symtab( void ); Elf32_Sym* get_dynsym( void ); Elf32_Dyn* get_dynamic( void ); Elf32_Rela* get_rela( Elf32_Shdr* shdr, int index = 0 ); Elf32_Rel* get_rel( Elf32_Shdr* shdr, int index = 0 ); Elf32_Shdr* va2section( size_t va ); char* get_sym_by_value( size_t value ); char* get_dynsym_by_index( size_t index ); }; class Elf64 : public File { private: ElfCTX ctx; public: Elf64( FileFactory* factory ); virtual File_t get_type( void ); virtual File_t get_type_group( void ); virtual void show_nav( void ); virtual void show_main( void ); ElfCTX& get_ctx( void ); Elf64_Ehdr* get_elf_header( void ); Elf64_Phdr* get_prog_header( int index ); Elf64_Shdr* get_section_header( int index ); Elf64_Shdr* get_section_header( const char* sname ); char* get_section_name( int index ); char* get_section_name( Elf64_Shdr* section ); Elf64_Sym* get_symtab( void ); Elf64_Sym* get_dynsym( void ); Elf64_Dyn* get_dynamic( void ); Elf64_Rela* get_rela( Elf64_Shdr* shdr, int index = 0 ); Elf64_Rel* get_rel( Elf64_Shdr* shdr, int index = 0 ); Elf64_Shdr* va2section( size_t va ); char* get_sym_by_value( size_t value ); char* get_dynsym_by_index( size_t index ); };
22.559783
60
0.647073
[ "object", "vector" ]
00b7a57f35cfe641f4178ba4debee1f6741996ea
1,836
h
C
VolumeRender/Content/LightProbe.h
StarsX/VolumeRender
f9766963f63199fe93fc0f3aedc792dbe46e1729
[ "MIT" ]
12
2021-11-20T09:21:14.000Z
2022-03-30T13:14:21.000Z
VolumeRender/Content/LightProbe.h
StarsX/VolumeRender
f9766963f63199fe93fc0f3aedc792dbe46e1729
[ "MIT" ]
null
null
null
VolumeRender/Content/LightProbe.h
StarsX/VolumeRender
f9766963f63199fe93fc0f3aedc792dbe46e1729
[ "MIT" ]
1
2021-11-20T09:21:22.000Z
2021-11-20T09:21:22.000Z
//-------------------------------------------------------------------------------------- // Copyright (c) XU, Tianchen. All rights reserved. //-------------------------------------------------------------------------------------- #pragma once #include "Core/XUSG.h" #include "Advanced/XUSGSphericalHarmonics.h" class LightProbe { public: LightProbe(); virtual ~LightProbe(); bool Init(XUSG::CommandList* pCommandList, const XUSG::DescriptorTableCache::sptr& descriptorTableCache, std::vector<XUSG::Resource::uptr>& uploaders, const wchar_t* fileName, XUSG::Format rtFormat, XUSG::Format dsFormat); bool CreateDescriptorTables(XUSG::Device* pDevice); void UpdateFrame(uint8_t frameIndex, DirectX::CXMMATRIX viewProj, const DirectX::XMFLOAT3& eyePt); void TransformSH(XUSG::CommandList* pCommandList); void RenderEnvironment(const XUSG::CommandList* pCommandList, uint8_t frameIndex); XUSG::ShaderResource* GetRadiance() const; XUSG::StructuredBuffer::sptr GetSH() const; static const uint8_t FrameCount = 3; static const uint8_t CubeMapFaceCount = 6; protected: enum PipelineIndex : uint8_t { ENVIRONMENT, NUM_PIPELINE }; bool createPipelineLayouts(); bool createPipelines(XUSG::Format rtFormat, XUSG::Format dsFormat); bool createDescriptorTables(); XUSG::ShaderPool::sptr m_shaderPool; XUSG::Graphics::PipelineCache::uptr m_graphicsPipelineCache; XUSG::Compute::PipelineCache::sptr m_computePipelineCache; XUSG::PipelineLayoutCache::sptr m_pipelineLayoutCache; XUSG::DescriptorTableCache::sptr m_descriptorTableCache; XUSG::PipelineLayout m_pipelineLayouts[NUM_PIPELINE]; XUSG::Pipeline m_pipelines[NUM_PIPELINE]; XUSG::SphericalHarmonics::uptr m_sphericalHarmonics; XUSG::DescriptorTable m_srvTable; XUSG::Texture::sptr m_radiance; XUSG::ConstantBuffer::uptr m_cbPerFrame; };
30.6
105
0.709695
[ "vector" ]
00d21d100af966f73432755f05ce157e0c956a79
5,379
h
C
src/RTL/Component/Include/IFXSkeleton.h
alemuntoni/u3d
7907b907464a2db53dac03fdc137dcb46d447513
[ "Apache-2.0" ]
44
2016-05-06T00:47:11.000Z
2022-02-11T06:51:37.000Z
src/RTL/Component/Include/IFXSkeleton.h
alemuntoni/u3d
7907b907464a2db53dac03fdc137dcb46d447513
[ "Apache-2.0" ]
3
2016-06-27T12:37:31.000Z
2021-03-24T12:39:48.000Z
src/RTL/Component/Include/IFXSkeleton.h
alemuntoni/u3d
7907b907464a2db53dac03fdc137dcb46d447513
[ "Apache-2.0" ]
15
2016-02-28T11:08:30.000Z
2021-06-01T03:32:01.000Z
//*************************************************************************** // // Copyright (c) 2000 - 2006 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //*************************************************************************** /** @file IFXSkeleton.h Declaration of IFXSkeleton interface. The IFXSkeleton interface is used to get and set bone information. The bone information is used for bones based character animation. */ #ifndef IFXSKELETON_H__ #define IFXSKELETON_H__ #include "IFXUnknown.h" #include "IFXBones.h" // {1FC935D0-47CB-4077-80BA-9AE89070B796} IFXDEFINE_GUID(IID_IFXSkeleton, 0x1fc935d0, 0x47cb, 0x4077, 0x80, 0xba, 0x9a, 0xe8, 0x90, 0x70, 0xb7, 0x96); /** These members directly reflect attributes used by IFXBonesManager. */ struct IFXBoneInfo { IFXBoneInfo(void) { //* defaults stringBoneName=L"<unnamed>"; stringParentName=L"<unnamed>"; iParentBoneID= -1; fBoneLength= 1.0f; v3BoneDisplacement.Reset(); v4BoneRotation.Set(1.0f,0.0f,0.0f,0.0f); uBoneAttributes= 0x0; fRotationConstraintXMax= 0.0f; fRotationConstraintXMin= 0.0f; fRotationConstraintYMax= 0.0f; fRotationConstraintYMin= 0.0f; fRotationConstraintZMax= 0.0f; fRotationConstraintZMin= 0.0f; uNumLinks= 0; fLinkLength= 1.0f; v2StartJointCenter.Reset(); v2StartJointScale.Reset(); v2EndJointCenter.Reset(); v2EndJointScale.Reset(); iLinkBoneID= 0; }; IFXString stringBoneName; IFXString stringParentName; I32 iParentBoneID; F32 fBoneLength; IFXVector3 v3BoneDisplacement; IFXVector4 v4BoneRotation; U32 uBoneAttributes; F32 fRotationConstraintXMax; F32 fRotationConstraintXMin; F32 fRotationConstraintYMax; F32 fRotationConstraintYMin; F32 fRotationConstraintZMax; F32 fRotationConstraintZMin; U32 uNumLinks; F32 fLinkLength; IFXVector2 v2StartJointCenter; IFXVector2 v2StartJointScale; IFXVector2 v2EndJointCenter; IFXVector2 v2EndJointScale; I32 iLinkBoneID; }; /** The IFXSkeleton interface is used to get and set bone information used for bones based character animation. A skeleton holds the bone data and vertex weights for a particular model. @note Underlying weight data is designed for sequential, not random, access. Restrictions are on a per-mesh independent basis. Vertex weight writes must be done in ascending order or data will be corrupted. Vertex weight reads/replaces should be done in ascending order or heavy performance penalties may result (Read & Replace use the same iterator). Write pass may be done only once (per mesh). Read/Replace location should never exceed write location. Replacements must use the exact number of weights as previously set. */ class IFXSkeleton : virtual public IFXUnknown { public: /// Sets all the data for a particular indexed bone from an IFXBoneInfo. virtual IFXRESULT IFXAPI SetBoneInfo(U32 uBoneID, IFXBoneInfo *pBoneInfo) =0; /// Gets all the data for a particular indexed bone to an IFXBoneInfo. virtual IFXRESULT IFXAPI GetBoneInfo(U32 uBoneID, IFXBoneInfo *pBoneInfo) =0; /// Gets the number of bones contained int he skeleton. virtual IFXRESULT IFXAPI GetNumBones(U32& uNumBones) =0; /** Sets the blocktype from which this object was derived. There can be several blocktypes which can correspond on a one to one basis with a given object. This is generally the case with backwards file format compatibility issues. The purpose for setting this parameter is so that an encoder knows whether or not a cached copy of the blocks for this object is held by the generator to which this modifier belongs. */ virtual IFXRESULT IFXAPI SetBlockTypeBase(U32 BlockType) =0; /** Gets the blocktype from which this object was derived. There can be several blocktypes which can correspond on a one to one basis with a given object. This is generally the case with backwards file format compatibiliy issues. The purpose for determining this blocktype is so that an encoder knows whether or not a cached copy of the blocks for this object is held by the generator to which this modifier belongs. */ virtual IFXRESULT IFXAPI GetBlockTypeBase(U32* pBlockType) =0; /// Accesses the core Bonesmanager for this resource. virtual IFXBonesManager* IFXAPI GetBonesManagerNR(void) =0; }; #define IFXSKELETON_LINKPRESENT (1 << 0) #define IFXSKELETON_JOINTPRESENT (1 << 1) #define IFXSKELETON_ROTATIONCONSTRAINTACTIVE_X (1 << 2) #define IFXSKELETON_ROTATIONCONSTRAINTLIMITED_X (1 << 3) #define IFXSKELETON_ROTATIONCONSTRAINTACTIVE_Y (1 << 4) #define IFXSKELETON_ROTATIONCONSTRAINTLIMITED_Y (1 << 5) #define IFXSKELETON_ROTATIONCONSTRAINTACTIVE_Z (1 << 6) #define IFXSKELETON_ROTATIONCONSTRAINTLIMITED_Z (1 << 7) #endif
36.100671
80
0.730433
[ "mesh", "object", "model" ]
00d732656fd0c6691548b6e3cfd7b0a186c246cc
4,232
h
C
include/stdtype.h
RothschildYuan/CDBQuery
32f748cdd538b9b3cdca7aa87abe1e851a65cee0
[ "MIT" ]
2
2019-11-05T03:12:44.000Z
2020-07-20T16:20:38.000Z
include/stdtype.h
RothschildYuan/CDBQuery
32f748cdd538b9b3cdca7aa87abe1e851a65cee0
[ "MIT" ]
null
null
null
include/stdtype.h
RothschildYuan/CDBQuery
32f748cdd538b9b3cdca7aa87abe1e851a65cee0
[ "MIT" ]
1
2020-09-07T12:16:46.000Z
2020-09-07T12:16:46.000Z
#ifndef STDTYPE_H #define STDTYPE_H typedef char Int1; typedef short Int2; typedef int Int4; typedef long long int Int8; typedef Int1* PInt1; typedef Int2* PInt2; typedef Int4* PInt4; typedef Int8* PInt8; typedef unsigned char UInt1; typedef unsigned short UInt2; typedef unsigned int UInt4; typedef unsigned long long int UInt8; typedef unsigned char Byte; typedef unsigned long DWORD; typedef UInt1* PUInt1; typedef UInt2* PUInt2; typedef UInt4* PUInt3; typedef UInt8* PUInt4; typedef Byte* PByte; typedef DWORD* PDWORD; typedef float Float4; typedef double Float8; typedef long double Float16; typedef Float4* PFloat4; typedef Float8* PFloat8; typedef Float16* PFloat16; typedef char Char; typedef Char* PChar; typedef void* Pointer; #define SFree(p) if(p != nullptr) { free(p); p = nullptr;} #ifdef __cplusplus #include <iostream> #include <fstream> #include <sstream> #include <strstream> #include <string> #include <vector> #include <deque> #include <list> #include <map> #include <set> #include <memory> #include <stdexcept> #include <typeinfo> #include <functional> #include <algorithm> #include <iomanip> #define SDelete(p) if(p != nullptr) { delete p; p = nullptr;} #define SDeletes(p) if(p != nullptr) { delete[] p; p = nullptr;} typedef bool* PBool; using std::ostream; using std::istream; using std::fstream; using std::ifstream; using std::ofstream; using std::stringstream; using std::cout; using std::endl; using std::cerr; using std::flush; using std::function; using std::forward; using std::make_pair; using std::string; using std::wstring; using std::vector; using std::deque; using std::list; using std::map; using std::set; using std::ios; using std::ios_base; using std::exception; typedef string* PString; typedef wstring* PWstring; #define PVector vector* #define PDeque deque* #define PList list* #define PMap map* #define PSet set* #if __cplusplus >= 201103L #include <unordered_map> #include <unordered_set> #include <functional> #include <mutex> #include <thread> #include <atomic> #include <condition_variable> using std::unordered_map; using std::unordered_set; using std::shared_ptr; using std::weak_ptr; using std::atomic_bool; using std::atomic_int; using std::mutex; using std::thread; using std::condition_variable; typedef std::mutex ACTMutex; typedef std::thread ACTThread; typedef std::condition_variable ACTCond; #else #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include <boost/unordered_map.hpp> #include <boost/unordered_set.hpp> #include <boost/function.hpp> #include <CMutex.h> #include <CThread.h> #include <CCond.h> using boost::unordered::unordered_map; using boost::unordered::unordered_set; using boost::shared_ptr; using boost::weak_ptr; typedef ACT::CMutex ACTMutex; typedef ACT::CThread ACTThread; typedef ACT::CCond ACTCond; using ACT::unique_lock; #define nullptr NULL #define override #define final #endif #else typedef char bool; typedef bool* PBool; #define true 1 #define false 0 #endif // #ifdef __MACH__ typedef unsigned long int PthreadSize; typedef int SOCKET; #define INVALID_SOCKET (SOCKET)(~0) #define SOCKET_ERROR (-1) #elif defined _WIN32 typedef unsigned int PthreadSize; #else typedef unsigned int PthreadSize; typedef int SOCKET; #define INVALID_SOCKET (SOCKET)(-1) #define SOCKET_ERROR (-1) #endif typedef enum { tpIdle, tpLowest, tpLower, tpNormal, tpHigher, tpHighest, tpTimeCritical }TThreadPriority; // 字节对齐规则 #pragma pack(push, 1) #pragma pack(pop) #endif
20.950495
65
0.625
[ "vector" ]
00da26a4ac7942fcaa0ee3bba6722f646b51ee3b
7,921
h
C
gmsh/Geo/Geo.h
Poofee/fastFEM
14eb626df973e2123604041451912c867ab7188c
[ "MIT" ]
4
2019-05-06T09:35:08.000Z
2021-05-14T16:26:45.000Z
gmsh/Geo/Geo.h
Poofee/fastFEM
14eb626df973e2123604041451912c867ab7188c
[ "MIT" ]
null
null
null
gmsh/Geo/Geo.h
Poofee/fastFEM
14eb626df973e2123604041451912c867ab7188c
[ "MIT" ]
1
2019-06-28T09:23:43.000Z
2019-06-28T09:23:43.000Z
// Gmsh - Copyright (C) 1997-2019 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // issues on https://gitlab.onelab.info/gmsh/gmsh/issues. #ifndef GEO_H #define GEO_H // Internal data structures and functions for the built-in CAD kernel. This is // legacy code and should never be used directly: use GEO_Internals instead, or // the public api. #include <cmath> #include <vector> #include <list> #include "GmshDefines.h" #include "GeoDefines.h" #include "gmshSurface.h" #include "ListUtils.h" #include "TreeUtils.h" #include "SPoint2.h" #include "ExtrudeParams.h" #include "findLinks.h" struct Coord { double X, Y, Z; }; class Vertex { public: int Num; int Typ; double lc, u, w; Coord Pos; // a model vertex is usually defined in the euclidian coordinates // (Pos). Yet, it can also be defined in the parametric coordinates // of a surface: pntOnGeometry stores the local coodinates of the // vertex in the gmshSurface it belongs to. gmshSurface *geometry; SPoint2 pntOnGeometry; int boundaryLayerIndex; Vertex(double X = 0., double Y = 0., double Z = 0., double l = 1., double W = 1.) : Num(0), lc(l), u(0.), w(W), geometry(0), boundaryLayerIndex(0) { Typ = MSH_POINT; Pos.X = X; Pos.Y = Y; Pos.Z = Z; } void norme() { double const d = std::sqrt(Pos.X * Pos.X + Pos.Y * Pos.Y + Pos.Z * Pos.Z); if(d == 0.0) return; Pos.X /= d; Pos.Y /= d; Pos.Z /= d; } Vertex operator%(Vertex &autre) // cross product { return Vertex(Pos.Y * autre.Pos.Z - Pos.Z * autre.Pos.Y, -(Pos.X * autre.Pos.Z - Pos.Z * autre.Pos.X), Pos.X * autre.Pos.Y - Pos.Y * autre.Pos.X, lc, w); } }; class CircParam { public: double t1, t2, f1, f2, incl; double invmat[3][3]; double n[3]; }; class Curve { public: int Num; int Typ; bool degenerated; int Method; int nbPointsTransfinite; int typeTransfinite; double coeffTransfinite; double l; double mat[4][4]; Vertex *beg, *end; double ubeg, uend; List_T *Control_Points; ExtrudeParams *Extrude; float *k; int degre; CircParam Circle; gmshSurface *geometry; int ReverseMesh; int master; std::list<double> affineTransformation; bool degenerate() const { if(beg == end && Typ == MSH_SEGM_LINE) return true; return false; } }; class EdgeLoop { public: int Num; List_T *Curves; }; class Surface { public: int Num; int Typ; int Method; int Recombine; int Recombine_Dir; // -1 is left, +1 is right, -2/2 is alternated left/right double RecombineAngle; int TransfiniteSmoothing; List_T *Generatrices; List_T *GeneratricesByTag; List_T *TrsfPoints; Vertex *InSphereCenter; ExtrudeParams *Extrude; // A surface is defined topologically by its Generatrices i.e. curves that are // the closure of it. The geometry of the surface is defined hereafter. Note // that this representation should be the only one in gmsh, so parameter // "Type" should disappear from the class Surface. gmshSurface *geometry; int ReverseMesh; bool degenerate() const; }; class SurfaceLoop { public: int Num; List_T *Surfaces; }; class Volume { public: int Num; int Typ; int Method; int Recombine3D; int QuadTri; ExtrudeParams *Extrude; List_T *TrsfPoints; List_T *Surfaces; List_T *SurfacesOrientations; List_T *SurfacesByTag; }; class PhysicalGroup { public: int Num; int Typ; List_T *Entities; }; int CompareVertex(const void *a, const void *b); int CompareSurfaceLoop(const void *a, const void *b); int CompareEdgeLoop(const void *a, const void *b); int CompareCurve(const void *a, const void *b); int CompareSurface(const void *a, const void *b); int CompareVolume(const void *a, const void *b); int ComparePhysicalGroup(const void *a, const void *b); void FreeVertex(void *a, void *b); void FreePhysicalGroup(void *a, void *b); void FreeEdgeLoop(void *a, void *b); void FreeSurfaceLoop(void *a, void *b); void FreeCurve(void *a, void *b); void FreeSurface(void *a, void *b); void FreeVolume(void *a, void *b); inline void Projette(Vertex *v, double mat[3][3]) { double X = v->Pos.X * mat[0][0] + v->Pos.Y * mat[0][1] + v->Pos.Z * mat[0][2]; double Y = v->Pos.X * mat[1][0] + v->Pos.Y * mat[1][1] + v->Pos.Z * mat[1][2]; double Z = v->Pos.X * mat[2][0] + v->Pos.Y * mat[2][1] + v->Pos.Z * mat[2][2]; v->Pos.X = X; v->Pos.Y = Y; v->Pos.Z = Z; } Vertex *CreateVertex(int Num, double X, double Y, double Z, double lc, double u); Vertex *CreateVertex(int Num, double u, double v, gmshSurface *s, double lc); Curve *CreateCurve(int Num, int Typ, int Order, List_T *Liste, List_T *Knots, int p1, int p2, double u1, double u2); Curve *CreateReversedCurve(Curve *c); Surface *CreateSurface(int Num, int Typ); Volume *CreateVolume(int Num, int Typ); EdgeLoop *CreateEdgeLoop(int Num, List_T *intlist); SurfaceLoop *CreateSurfaceLoop(int Num, List_T *intlist); PhysicalGroup *CreatePhysicalGroup(int Num, int typ, List_T *intlist); void EndCurve(Curve *c); void EndSurface(Surface *s); Vertex *FindPoint(int inum); Curve *FindCurve(int inum); EdgeLoop *FindEdgeLoop(int inum); Surface *FindSurface(int inum); SurfaceLoop *FindSurfaceLoop(int inum); Volume *FindVolume(int inum); PhysicalGroup *FindPhysicalGroup(int inum, int type); void TranslateShapes(double X, double Y, double Z, List_T *shapes); void DilatShapes(double X, double Y, double Z, double A, double B, double C, List_T *shapes); void RotateShapes(double Ax, double Ay, double Az, double Px, double Py, double Pz, double alpha, List_T *shapes); void SymmetryShapes(double A, double B, double C, double D, List_T *shapes); Vertex *DuplicateVertex(Vertex *v); Curve *DuplicateCurve(Curve *c); Surface *DuplicateSurface(Surface *s); Volume *DuplicateVolume(Volume *s); void DeletePoint(int Num, bool recursive = false); void DeleteCurve(int Num, bool recursive = false); void DeleteSurface(int Num, bool recursive = false); void DeleteVolume(int Num, bool recursive = false); void DeletePhysicalPoint(int Num); void DeletePhysicalLine(int Num); void DeletePhysicalSurface(int Num); void DeletePhysicalVolume(int Num); void ExtrudeShapes(int extrude_type, List_T *in, double T0, double T1, double T2, double A0, double A1, double A2, double X0, double X1, double X2, double alpha, ExtrudeParams *e, List_T *out); void ProtudeXYZ(double &x, double &y, double &z, ExtrudeParams *e); void ReplaceAllDuplicates(); void ReplaceAllDuplicatesNew(double tol = -1.); bool ProjectPointOnSurface(Surface *s, Vertex &p, double uv[2]); bool IntersectCurvesWithSurface(List_T *curve_ids, int surface_id, List_T *shapes); bool SplitCurve(int line_id, List_T *vertices_id, List_T *curves); int RecognizeLineLoop(List_T *liste, int *loop); int RecognizeSurfaceLoop(List_T *liste, int *loop); void SortEdgesInLoop(int num, List_T *edges, bool orient = false); void SetSurfaceGeneratrices(Surface *s, List_T *loops); void SetVolumeSurfaces(Volume *v, List_T *loops); void SetTranslationMatrix(double matrix[4][4], double T[3]); void SetSymmetryMatrix(double matrix[4][4], double A, double B, double C, double D); void SetDilatationMatrix(double matrix[4][4], double T[3], double A, double B, double C); void SetRotationMatrix(double matrix[4][4], double Axe[3], double alpha); int NEWPOINT(); int NEWLINE(); int NEWLINELOOP(); int NEWSURFACE(); int NEWSURFACELOOP(); int NEWVOLUME(); int NEWREG(); int NEWFIELD(); int NEWPHYSICAL(); #endif
29.55597
82
0.665068
[ "cad", "geometry", "vector", "model" ]
00dcd06f13b6308d9f537f9b2d588777610c039e
2,093
h
C
Alpha_shapes_3/doc/Alpha_shapes_3/Concepts/AlphaShapeCell_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
3,227
2015-03-05T00:19:18.000Z
2022-03-31T08:20:35.000Z
Alpha_shapes_3/doc/Alpha_shapes_3/Concepts/AlphaShapeCell_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
5,574
2015-03-05T00:01:56.000Z
2022-03-31T15:08:11.000Z
Alpha_shapes_3/doc/Alpha_shapes_3/Concepts/AlphaShapeCell_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
1,274
2015-03-05T00:01:12.000Z
2022-03-31T14:47:56.000Z
/*! \ingroup PkgAlphaShapes3Concepts \cgalConcept The concept `AlphaShapeCell_3` describes the requirements for the base cell of an alpha shape. \cgalRefines `DelaunayTriangulationCellBase_3`, if the underlying triangulation of the alpha shape is a Delaunay triangulation. \cgalRefines `RegularTriangulationCellBase_3`, if the underlying triangulation of the alpha shape is a regular triangulation. \cgalRefines `Periodic_3TriangulationDSCellBase_3`, if the underlying triangulation of the alpha shape is a periodic triangulation. \cgalHasModel `CGAL::Alpha_shape_cell_base_3` (templated with the appropriate triangulation cell base class). \sa `CGAL::Alpha_status` */ class AlphaShapeCell_3 { public: /// \name Types /// @{ /*! A number type. Must be the same as the number type used in the traits class of the triangulation underlying the alpha shape. */ typedef unspecified_type NT; /*! An iterator with value type `CGAL::Alpha_status<NT>`. */ typedef unspecified_type Alpha_status_iterator; /// @} /// \name Creation /// @{ /*! default constructor. */ AlphaShapeCell_3(); /*! constructor setting the incident vertices. */ AlphaShapeCell_3(const Vertex_handle& v0, const Vertex_handle& v1, const Vertex_handle& v2, const Vertex_handle& v3); /*! constructor setting the incident vertices and the neighboring cells. */ AlphaShapeCell_3(const Vertex_handle& v0, const Vertex_handle& v1, const Vertex_handle& v2, const Vertex_handle& v3, const Cell_handle& n0, const Cell_handle& n1, const Cell_handle& n2, const Cell_handle& n3); /// @} /// \name Access Functions /// @{ /*! Returns the alpha value of the cell. */ NT get_alpha(); /*! Returns an iterator on the `CGAL::Alpha_status<NT>` of the facet `i` of the cell. */ Alpha_status_iterator get_facet_status(int i); /// @} /// \name Modifiers /// @{ /*! Sets the critical value of the cell. */ void set_alpha(const NT & alpha); /*! Sets the iterator pointing to the `CGAL::Alpha_status<NT>` of the facet `i` of the cell. */ void set_facet_status(int i, Alpha_status_iterator as); /// @} }; /* end AlphaShapeCell_3 */
23
131
0.749642
[ "shape" ]
00df793e752d22c46962e8699cd271f53e958c42
650
c
C
mudlib/cmds/usr/finger.c
mudchina/es2-mudlib-utf8
87bba6bd2249beec8424b0d6623486a0dd1f7b30
[ "MIT" ]
30
2016-06-18T08:56:50.000Z
2021-11-17T17:08:31.000Z
mudlib/cmds/usr/finger.c
mudchina/es2-mudlib-utf8
87bba6bd2249beec8424b0d6623486a0dd1f7b30
[ "MIT" ]
4
2017-08-07T19:57:15.000Z
2020-04-13T03:07:06.000Z
mudlib/cmds/usr/finger.c
mudchina/es2-mudlib-utf8
87bba6bd2249beec8424b0d6623486a0dd1f7b30
[ "MIT" ]
29
2016-05-19T13:24:55.000Z
2022-02-03T02:50:50.000Z
// finger.c inherit F_CLEAN_UP; void create() { seteuid(getuid()); } int main(object me, string arg) { if( !arg ) { if( (int)me->query("sen") < 50 ) return notify_fail("你的精神无法集中。\n"); if( !wizardp(me) ) me->receive_damage("sen", 50); write( FINGER_D->finger_all() ); } else { if( (int)me->query("sen") < 15 ) return notify_fail("你的精神无法集中。\n"); if( !wizardp(me) ) me->receive_damage("sen", 15); write( FINGER_D->finger_user(arg) ); } return 1; } int help(object me) { write(@HELP 指令格式 : finger [使用者姓名] 这个指令, 如果没有指定使用者姓明, 会显示出所有正在线上玩家 的连线资料. 反之, 则可显示有关某个玩家的连线, 权限等资料. see also : who HELP ); return 1; }
15.47619
38
0.613846
[ "object" ]
00f2c54b9859043d2ec7042f6081315a1d4ff44e
9,520
h
C
include/scheduler.h
ipkn/goplus
00a746426624d3b2fa0ac258168a90eb60d67c38
[ "MIT" ]
14
2016-09-03T00:18:08.000Z
2022-03-17T05:54:36.000Z
include/scheduler.h
ipkn/goplus
00a746426624d3b2fa0ac258168a90eb60d67c38
[ "MIT" ]
null
null
null
include/scheduler.h
ipkn/goplus
00a746426624d3b2fa0ac258168a90eb60d67c38
[ "MIT" ]
null
null
null
#pragma once #include <deque> #include <thread> #include <mutex> #include <condition_variable> #include <iostream> #include <boost/asio.hpp> #include "goroutine.h" //#define GOPLUS_DEBUG namespace goplus { namespace detail { // TODO haha global queue? inline auto get_detail() { thread_local goroutine scheduler_context; thread_local goroutine* scheduler_current{}; //thread_local std::mutex* static std::mutex global_lock_; static std::deque<goroutine*> global_queue_; static bool done_{false}; static int global_count_ = 0; struct VariableSet{ std::mutex& global_lock{global_lock_}; std::deque<goroutine*>& global_queue{global_queue_}; bool& done{done_}; int& global_count{global_count_}; goroutine* scheduler_context; goroutine** scheduler_current; VariableSet(goroutine** scheduler_current, goroutine* scheduler_context) : scheduler_context(scheduler_context), scheduler_current(scheduler_current) { } } variable_set(&scheduler_current, &scheduler_context); return variable_set; } } class scheduler { private: std::vector<std::thread> threads_; std::vector<boost::asio::io_service> io_services_; scheduler() { int num_thread = GOPLUS_CONCURRENCY; if (num_thread < 1) num_thread = std::thread::hardware_concurrency(); std::atomic<int> initializing{num_thread}; for(int i = 0; i < num_thread; i ++) queues_.emplace_back(); std::condition_variable cv; std::mutex cv_mtx; for(int i = 0; i < num_thread; i ++) { threads_.emplace_back([&, i]{ { boost::context::execution_context<void> x( [&](boost::context::execution_context<void> sink)mutable{ detail::get_detail().scheduler_context->set(std::move(sink)); detail::get_detail().scheduler_context->set_scheduler(i); return detail::get_detail().scheduler_context->detach();}); x(); } std::mutex local_lock; auto& q = queues_[i]; q.lock = &local_lock; { initializing --; cv.notify_one(); } while(!detail::get_detail().done || !q.queue.empty() || !detail::get_detail().global_queue.empty()) { if (!q.queue.empty()) { q.lock->lock(); if (!q.queue.empty()) { *detail::get_detail().scheduler_current = q.queue.front(); q.queue.pop_front(); q.lock->unlock(); #ifdef GOPLUS_DEBUG std::cerr << "l run " << i << std::endl; #endif (*detail::get_detail().scheduler_current)->execute(); } else { q.lock->unlock(); } } if (!detail::get_detail().global_queue.empty()) { detail::get_detail().global_lock.lock(); if (!detail::get_detail().global_queue.empty()) { goroutine* r = detail::get_detail().global_queue.front(); r->set_scheduler(i); detail::get_detail().global_queue.pop_front(); detail::get_detail().global_lock.unlock(); *detail::get_detail().scheduler_current = r; #ifdef GOPLUS_DEBUG std::cerr << "g run " << i << std::endl; #endif (*detail::get_detail().scheduler_current)->execute(); } else { detail::get_detail().global_lock.unlock(); } } std::this_thread::yield(); } q.dead = true; q.lock = nullptr; }); } while(initializing > 0) { std::unique_lock<std::mutex> lock(cv_mtx); cv.wait(lock); } } ~scheduler() { for(auto& t:threads_) t.join(); } static scheduler& instance() { static scheduler s; return s; } public: template <typename F> static void spawn(F f) { scheduler::instance(); detail::get_detail().global_lock.lock(); detail::get_detail().global_count ++; detail::get_detail().global_queue.emplace_back(new goroutine( [f](boost::context::execution_context<void> sink)mutable{ detail::get_detail().scheduler_context->set(std::move(sink)); f(); { std::unique_lock<std::mutex> u(detail::get_detail().global_lock); detail::get_detail().global_count --; if (detail::get_detail().global_count == 0) detail::get_detail().done = true; } return detail::get_detail().scheduler_context->detach(); } )); detail::get_detail().global_lock.unlock(); } struct normal_thread_helper { std::mutex mtx; std::condition_variable cv; bool wakeup{false}; }; static void resume(goroutine& go) { if (reinterpret_cast<std::intptr_t>(&go) & 1 == 1) { #ifdef GOPLUS_DEBUG std::cerr << "normal notify" << std::endl; #endif // normal thread normal_thread_helper* h = reinterpret_cast<normal_thread_helper*>(reinterpret_cast<std::intptr_t>(&go)&~(std::intptr_t)1); std::unique_lock<std::mutex> _(h->mtx); h->wakeup = true; h->cv.notify_one(); } else if (go.get_scheduler() >= 0) { auto& q = instance().queues_[go.get_scheduler()]; q.lock->lock(); q.queue.push_back(&go); q.lock->unlock(); } else { detail::get_detail().global_lock.lock(); detail::get_detail().global_queue.push_back(&go); detail::get_detail().global_lock.unlock(); } } static goroutine* current() { if (*detail::get_detail().scheduler_current == nullptr) { #ifdef GOPLUS_DEBUG std::cerr << "null scheduler_current" << std::endl; #endif *detail::get_detail().scheduler_current = reinterpret_cast<goroutine*>( reinterpret_cast<std::intptr_t>(new normal_thread_helper) + 1 ); } return *detail::get_detail().scheduler_current; } static void park() { if (*detail::get_detail().scheduler_current == nullptr) { #ifdef GOPLUS_DEBUG std::cerr << "null scheduler_current" << std::endl; #endif *detail::get_detail().scheduler_current = reinterpret_cast<goroutine*>( reinterpret_cast<std::intptr_t>(new normal_thread_helper) + 1 ); } if (reinterpret_cast<std::intptr_t>(*detail::get_detail().scheduler_current) & 1 == 1) { normal_thread_helper* h = reinterpret_cast<normal_thread_helper*>(reinterpret_cast<std::intptr_t>( *detail::get_detail().scheduler_current )&~(std::intptr_t)1); std::unique_lock<std::mutex> lock{h->mtx}; #ifdef GOPLUS_DEBUG std::cerr << "normal wait" << std::endl; #endif while(!h->wakeup) h->cv.wait(lock); h->wakeup = false; #ifdef GOPLUS_DEBUG std::cerr << "normal wait done" << std::endl; #endif return; } auto save = (*detail::get_detail().scheduler_current); detail::get_detail().scheduler_context->execute(); *detail::get_detail().scheduler_current = (save); } private: struct local_queue_t { std::mutex* lock; std::deque<goroutine*> queue; double dummy; bool dead{false}; local_queue_t(){}; local_queue_t(local_queue_t&&) = default; local_queue_t& operator = (local_queue_t&&) = default; }; std::vector<local_queue_t> queues_; }; };
35.259259
138
0.464286
[ "vector" ]