code
stringlengths
4
1.01M
language
stringclasses
2 values
/* * This file is part of InTEL, the Interactive Toolkit for Engineering Learning. * http://intel.gatech.edu * * InTEL 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. * * InTEL 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 InTEL. If not, see <http://www.gnu.org/licenses/>. */ /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package keyboard; import com.jme.math.Vector3f; import com.jme.renderer.ColorRGBA; import com.jme.system.DisplaySystem; import edu.gatech.statics.application.StaticsApplication; import edu.gatech.statics.exercise.Diagram; import edu.gatech.statics.exercise.DiagramType; import edu.gatech.statics.exercise.Schematic; import edu.gatech.statics.math.Unit; import edu.gatech.statics.math.Vector3bd; import edu.gatech.statics.modes.description.Description; import edu.gatech.statics.modes.equation.EquationDiagram; import edu.gatech.statics.modes.equation.EquationMode; import edu.gatech.statics.modes.equation.EquationState; import edu.gatech.statics.modes.equation.worksheet.TermEquationMathState; import edu.gatech.statics.modes.frame.FrameExercise; import edu.gatech.statics.objects.Body; import edu.gatech.statics.objects.DistanceMeasurement; import edu.gatech.statics.objects.Force; import edu.gatech.statics.objects.Point; import edu.gatech.statics.objects.bodies.Bar; import edu.gatech.statics.objects.bodies.Beam; import edu.gatech.statics.objects.connectors.Connector2ForceMember2d; import edu.gatech.statics.objects.connectors.Pin2d; import edu.gatech.statics.objects.connectors.Roller2d; import edu.gatech.statics.objects.representations.ModelNode; import edu.gatech.statics.objects.representations.ModelRepresentation; import edu.gatech.statics.tasks.Solve2FMTask; import edu.gatech.statics.ui.AbstractInterfaceConfiguration; import edu.gatech.statics.ui.windows.navigation.Navigation3DWindow; import edu.gatech.statics.ui.windows.navigation.ViewConstraints; import java.math.BigDecimal; import java.util.Map; /** * * @author Calvin Ashmore */ public class KeyboardExercise extends FrameExercise { @Override public AbstractInterfaceConfiguration createInterfaceConfiguration() { AbstractInterfaceConfiguration ic = super.createInterfaceConfiguration(); ic.setNavigationWindow(new Navigation3DWindow()); ic.setCameraSpeed(.2f, 0.02f, .05f); ViewConstraints vc = new ViewConstraints(); vc.setPositionConstraints(-2, 2, -1, 4); vc.setZoomConstraints(0.5f, 1.5f); vc.setRotationConstraints(-5, 5, 0, 5); ic.setViewConstraints(vc); return ic; } @Override public Description getDescription() { Description description = new Description(); description.setTitle("Keyboard Stand"); description.setNarrative( "Kasiem Hill is in a music group comprised of Civil Engineering " + "students from Georgia Tech, in which he plays the keyboard. " + "For his birthday, he received a new keyboard, but it is much bigger " + "(both in size and weight) than his last one, so he needs to buy a " + "new keyboard stand. He finds one he really likes from a local " + "dealer and is unsure if the connections will be able to support " + "the weight of the new keyboard. He measures the dimensions of " + "the stand and he wants to calculate how much force he can expect " + "at each connection in the cross bar before he makes the investment."); description.setProblemStatement( "The stand can be modeled as a frame and is supported by two beams and a cross bar PQ. " + "The supports at B and E are rollers and the floor is frictionless."); description.setGoals( "Find the force in PQ and define whether it is in tension or compression."); description.addImage("keyboard/assets/keyboard 1.png"); description.addImage("keyboard/assets/keyboard 2.jpg"); description.addImage("keyboard/assets/keyboard 3.jpg"); return description; } @Override public void initExercise() { // setName("Keyboard Stand"); // // setDescription( // "This is a keyboard stand supported by two beams and a cross bar, PQ. " + // "Find the force in PQ and define whether it is in tension or compression. " + // "The supports at B and E are rollers, and the floor is frictionless."); Unit.setSuffix(Unit.distance, " m"); Unit.setSuffix(Unit.moment, " N*m"); Unit.setDisplayScale(Unit.distance, new BigDecimal("10")); getDisplayConstants().setMomentSize(0.5f); getDisplayConstants().setForceSize(0.5f); getDisplayConstants().setPointSize(0.5f); getDisplayConstants().setCylinderRadius(0.5f); //getDisplayConstants().setForceLabelDistance(1f); //getDisplayConstants().setMomentLabelDistance(0f); //getDisplayConstants().setMeasurementBarSize(0.1f); // 10/21/2010 HOTFIX: THIS CORRECTS AN ISSUE IN WHICH OBSERVATION DIRECTION IS SET TO NULL IN EQUATIONS for (Map<DiagramType, Diagram> diagramMap : getState().allDiagrams().values()) { EquationDiagram eqDiagram = (EquationDiagram) diagramMap.get(EquationMode.instance.getDiagramType()); if(eqDiagram == null) continue; EquationState.Builder builder = new EquationState.Builder(eqDiagram.getCurrentState()); TermEquationMathState.Builder xBuilder = new TermEquationMathState.Builder((TermEquationMathState) builder.getEquationStates().get("F[x]")); xBuilder.setObservationDirection(Vector3bd.UNIT_X); TermEquationMathState.Builder yBuilder = new TermEquationMathState.Builder((TermEquationMathState) builder.getEquationStates().get("F[y]")); yBuilder.setObservationDirection(Vector3bd.UNIT_Y); TermEquationMathState.Builder zBuilder = new TermEquationMathState.Builder((TermEquationMathState) builder.getEquationStates().get("M[p]")); zBuilder.setObservationDirection(Vector3bd.UNIT_Z); builder.putEquationState(xBuilder.build()); builder.putEquationState(yBuilder.build()); builder.putEquationState(zBuilder.build()); eqDiagram.pushState(builder.build()); eqDiagram.clearStateStack(); } } Point A, B, C, D, E, P, Q; Pin2d jointC; Connector2ForceMember2d jointP, jointQ; Roller2d jointB, jointE; Body leftLeg, rightLeg; Bar bar; @Override public void loadExercise() { Schematic schematic = getSchematic(); DisplaySystem.getDisplaySystem().getRenderer().setBackgroundColor(new ColorRGBA(.7f, .8f, .9f, 1.0f)); StaticsApplication.getApp().getCamera().setLocation(new Vector3f(0.0f, 0.0f, 65.0f)); A = new Point("A", "0", "6", "0"); D = new Point("D", "8", "6", "0"); B = new Point("B", "8", "0", "0"); E = new Point("E", "0", "0", "0"); C = new Point("C", "4", "3", "0"); P = new Point("P", "2.7", "4", "0"); Q = new Point("Q", "5.3", "4", "0"); leftLeg = new Beam("Left Leg", B, A); bar = new Bar("Bar", P, Q); rightLeg = new Beam("Right Leg", E, D); jointC = new Pin2d(C); jointP = new Connector2ForceMember2d(P, bar); //Pin2d(P); jointQ = new Connector2ForceMember2d(Q, bar); //new Pin2d(Q); jointB = new Roller2d(B); jointE = new Roller2d(E); jointB.setDirection(Vector3bd.UNIT_Y); jointE.setDirection(Vector3bd.UNIT_Y); DistanceMeasurement distance1 = new DistanceMeasurement(D, A); distance1.setName("Measure AD"); distance1.createDefaultSchematicRepresentation(0.5f); distance1.addPoint(E); distance1.addPoint(B); schematic.add(distance1); DistanceMeasurement distance2 = new DistanceMeasurement(C, D); distance2.setName("Measure CD"); distance2.createDefaultSchematicRepresentation(0.5f); distance2.forceVertical(); distance2.addPoint(A); schematic.add(distance2); DistanceMeasurement distance3 = new DistanceMeasurement(C, Q); distance3.setName("Measure CQ"); distance3.createDefaultSchematicRepresentation(1f); distance3.forceVertical(); distance3.addPoint(P); schematic.add(distance3); DistanceMeasurement distance4 = new DistanceMeasurement(B, D); distance4.setName("Measure BD"); distance4.createDefaultSchematicRepresentation(2.4f); distance4.addPoint(A); distance4.addPoint(E); schematic.add(distance4); Force keyboardLeft = new Force(A, Vector3bd.UNIT_Y.negate(), new BigDecimal(50)); keyboardLeft.setName("Keyboard Left"); leftLeg.addObject(keyboardLeft); Force keyboardRight = new Force(D, Vector3bd.UNIT_Y.negate(), new BigDecimal(50)); keyboardRight.setName("Keyboard Right"); rightLeg.addObject(keyboardRight); jointC.attach(leftLeg, rightLeg); jointC.setName("Joint C"); jointP.attach(leftLeg, bar); jointP.setName("Joint P"); jointQ.attach(bar, rightLeg); jointQ.setName("Joint Q"); jointE.attachToWorld(rightLeg); jointE.setName("Joint E"); jointB.attachToWorld(leftLeg); jointB.setName("Joint B"); A.createDefaultSchematicRepresentation(); B.createDefaultSchematicRepresentation(); C.createDefaultSchematicRepresentation(); D.createDefaultSchematicRepresentation(); E.createDefaultSchematicRepresentation(); P.createDefaultSchematicRepresentation(); Q.createDefaultSchematicRepresentation(); keyboardLeft.createDefaultSchematicRepresentation(); keyboardRight.createDefaultSchematicRepresentation(); //leftLeg.createDefaultSchematicRepresentation(); //bar.createDefaultSchematicRepresentation(); //rightLeg.createDefaultSchematicRepresentation(); schematic.add(leftLeg); schematic.add(bar); schematic.add(rightLeg); ModelNode modelNode = ModelNode.load("keyboard/assets/", "keyboard/assets/keyboard.dae"); float scale = .28f; ModelRepresentation rep = modelNode.extractElement(leftLeg, "VisualSceneNode/stand/leg1"); rep.setLocalScale(scale); rep.setModelOffset(new Vector3f(14f, 0, 0)); leftLeg.addRepresentation(rep); rep.setSynchronizeRotation(false); rep.setSynchronizeTranslation(false); rep.setHoverLightColor(ColorRGBA.yellow); rep.setSelectLightColor(ColorRGBA.yellow); rep = modelNode.extractElement(rightLeg, "VisualSceneNode/stand/leg2"); rep.setLocalScale(scale); rep.setModelOffset(new Vector3f(14f, 0, 0)); rightLeg.addRepresentation(rep); rep.setSynchronizeRotation(false); rep.setSynchronizeTranslation(false); rep.setHoverLightColor(ColorRGBA.yellow); rep.setSelectLightColor(ColorRGBA.yellow); rep = modelNode.extractElement(bar, "VisualSceneNode/stand/middle_support"); rep.setLocalScale(scale); rep.setModelOffset(new Vector3f(14f, 0, 0)); bar.addRepresentation(rep); rep.setSynchronizeRotation(false); rep.setSynchronizeTranslation(false); rep.setHoverLightColor(ColorRGBA.yellow); rep.setSelectLightColor(ColorRGBA.yellow); rep = modelNode.getRemainder(schematic.getBackground()); schematic.getBackground().addRepresentation(rep); rep.setLocalScale(scale); rep.setModelOffset(new Vector3f(14f, 0, 0)); rep.setSynchronizeRotation(false); rep.setSynchronizeTranslation(false); addTask(new Solve2FMTask("Solve PQ", bar, jointP)); } }
Java
<?php /** * Online Course Resources [Pre-Clerkship] * Module: Courses * Area: Admin * @author Unit: Medical Education Technology Unit * @author Director: Dr. Benjamin Chen <bhc@post.queensu.ca> * @author Developer: James Ellis <james.ellis@queensu.ca> * @version 0.8.3 * @copyright Copyright 2009 Queen's University, MEdTech Unit * * $Id: add.inc.php 505 2009-07-09 19:15:57Z jellis $ */ @set_include_path(implode(PATH_SEPARATOR, array( dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", dirname(__FILE__) . "/../core/library/vendor", get_include_path(), ))); /** * Include the Entrada init code. */ require_once("init.inc.php"); if((!isset($_SESSION["isAuthorized"])) || (!$_SESSION["isAuthorized"])) { header("Location: ".ENTRADA_URL); exit; } else { /** * Clears all open buffers so we can return a simple REST response. */ ob_clear_open_buffers(); $id = (int) $_GET["objective_id"]; $course_id = (int) (isset($_GET["course_id"]) ? $_GET["course_id"] : false); $event_id = (int) (isset($_GET["event_id"]) ? $_GET["event_id"] : false); $assessment_id = (int) (isset($_GET["assessment_id"]) ? $_GET["assessment_id"] : false); $org_id = (int) (isset($_GET["org_id"]) ? $_GET["org_id"] : (isset($ENTRADA_USER) && $ENTRADA_USER->getActiveOrganisation() ? $ENTRADA_USER->getActiveOrganisation() : false)); $objective_ids_string = ""; if (isset($_GET["objective_ids"]) && ($objective_ids = explode(",", $_GET["objective_ids"])) && @count($objective_ids)) { foreach ($objective_ids as $objective_id) { $objective_ids_string .= ($objective_ids_string ? ", " : "").$db->qstr($objective_id); } } $select = "a.*"; if ($course_id) { $select .= ", COALESCE(b.`cobjective_id`, 0) AS `mapped`"; } elseif ($event_id) { $select .= ", COALESCE(b.`eobjective_id`, 0) AS `mapped`"; } elseif ($assessment_id) { $select .= ", COALESCE(b.`aobjective_id`, 0) AS `mapped`"; } elseif ($objective_ids_string) { $select .= ", COALESCE(b.`objective_id`, 0) AS `mapped`"; } $qu_arr = array("SELECT ".$select." FROM `global_lu_objectives` a"); if ($course_id) { $qu_arr[1] = " LEFT JOIN `course_objectives` b ON a.`objective_id` = b.`objective_id` AND b.`course_id` = ".$db->qstr($course_id); } elseif ($event_id) { $qu_arr[1] = " LEFT JOIN `event_objectives` b ON a.`objective_id` = b.`objective_id` AND b.`event_id` = ".$db->qstr($event_id); } elseif ($assessment_id) { $qu_arr[1] = " LEFT JOIN `assessment_objectives` b ON a.`objective_id` = b.`objective_id` AND b.`assessment_id` = ".$db->qstr($assessment_id); } elseif ($objective_ids_string) { $qu_arr[1] = " LEFT JOIN `global_lu_objectives` AS b ON a.`objective_id` = b.`objective_id` AND b.`objective_id` IN (".$objective_ids_string.")"; } else { $qu_arr[1] = ""; } $qu_arr[1] .= " JOIN `objective_organisation` AS c ON a.`objective_id` = c.`objective_id` "; $qu_arr[2] = " WHERE a.`objective_parent` = ".$db->qstr($id)." AND a.`objective_active` = '1' AND c.`organisation_id` = ".$db->qstr($org_id); $qu_arr[4] = " ORDER BY a.`objective_order`"; $query = implode(" ",$qu_arr); $objectives = $db->GetAll($query); if ($objectives) { $obj_array = array(); foreach($objectives as $objective){ $fields = array( 'objective_id'=>$objective["objective_id"], 'objective_code'=>$objective["objective_code"], 'objective_name'=>$objective["objective_name"], 'objective_description'=>$objective["objective_description"] ); if ($course_id || $event_id || $assessment_id || $objective_ids_string){ $fields["mapped"] = $objective["mapped"]; if ($course_id) { $fields["child_mapped"] = course_objective_has_child_mapped($objective["objective_id"],$course_id,true); } else if ($event_id) { $fields["child_mapped"] = event_objective_parent_mapped_course($objective["objective_id"],$event_id,true); } else if ($assessment_id) { $fields["child_mapped"] = assessment_objective_parent_mapped_course($objective["objective_id"],$assessment_id,true); } } $query = " SELECT a.* FROM `global_lu_objectives` AS a JOIN `objective_organisation` AS b ON a.`objective_id` = b.`objective_id` WHERE a.`objective_parent` = ".$db->qstr($objective["objective_id"])." AND b.`organisation_id` = ".$db->qstr($org_id); $fields["has_child"] = $db->GetAll($query) ? true : false; $obj_array[] = $fields; } echo json_encode($obj_array); } else { echo json_encode(array('error'=>'No child objectives found for the selected objective.')); } exit; }
Java
/* * Transportr * * Copyright (c) 2013 - 2021 Torsten Grote * * 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 <http://www.gnu.org/licenses/>. */ package de.grobox.transportr.data.locations; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; import androidx.test.ext.junit.runners.AndroidJUnit4; import de.grobox.transportr.data.DbTest; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Product; import static de.schildbach.pte.NetworkId.BVG; import static de.schildbach.pte.NetworkId.DB; import static de.schildbach.pte.dto.LocationType.ADDRESS; import static de.schildbach.pte.dto.LocationType.ANY; import static de.schildbach.pte.dto.LocationType.POI; import static de.schildbach.pte.dto.LocationType.STATION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @RunWith(AndroidJUnit4.class) public class FavoriteLocationTest extends DbTest { private LocationDao dao; @Before @Override public void createDb() throws Exception { super.createDb(); dao = db.locationDao(); } @Test public void insertFavoriteLocation() throws Exception { // no locations should exist assertNotNull(getValue(dao.getFavoriteLocations(DB))); // create a complete station location Location loc1 = new Location(STATION, "stationId", Point.from1E6(23, 42), "place", "name", Product.ALL); long uid1 = dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); // assert that location has been inserted and retrieved properly List<FavoriteLocation> locations1 = getValue(dao.getFavoriteLocations(DB)); assertEquals(1, locations1.size()); FavoriteLocation f1 = locations1.get(0); assertEquals(uid1, f1.getUid()); assertEquals(DB, f1.getNetworkId()); assertEquals(loc1.type, f1.type); assertEquals(loc1.id, f1.id); assertEquals(loc1.getLatAs1E6(), f1.lat); assertEquals(loc1.getLonAs1E6(), f1.lon); assertEquals(loc1.place, f1.place); assertEquals(loc1.name, f1.name); assertEquals(loc1.products, f1.products); // insert a second location in a different network Location loc2 = new Location(ANY, null, Point.from1E6(1337, 0), null, null, Product.fromCodes("ISB".toCharArray())); long uid2 = dao.addFavoriteLocation(new FavoriteLocation(BVG, loc2)); // assert that location has been inserted and retrieved properly List<FavoriteLocation> locations2 = getValue(dao.getFavoriteLocations(BVG)); assertEquals(1, locations2.size()); FavoriteLocation f2 = locations2.get(0); assertEquals(uid2, f2.getUid()); assertEquals(BVG, f2.getNetworkId()); assertEquals(loc2.type, f2.type); assertEquals(loc2.id, f2.id); assertEquals(loc2.getLatAs1E6(), f2.lat); assertEquals(loc2.getLonAs1E6(), f2.lon); assertEquals(loc2.place, f2.place); assertEquals(loc2.name, f2.name); assertEquals(loc2.products, f2.products); } @Test public void replaceFavoriteLocation() throws Exception { // create a complete station location Location loc1 = new Location(STATION, "stationId", Point.from1E6(23, 42), "place", "name", Product.ALL); long uid1 = dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); // retrieve favorite location List<FavoriteLocation> locations1 = getValue(dao.getFavoriteLocations(DB)); assertEquals(1, locations1.size()); FavoriteLocation f1 = locations1.get(0); assertEquals(uid1, f1.getUid()); // change the favorite location and replace it in the DB f1.place = "new place"; f1.name = "new name"; f1.products = null; uid1 = dao.addFavoriteLocation(f1); assertEquals(uid1, f1.getUid()); // retrieve favorite location again List<FavoriteLocation> locations2 = getValue(dao.getFavoriteLocations(DB)); assertEquals(1, locations2.size()); FavoriteLocation f2 = locations2.get(0); // assert that same location was retrieved and data changed assertEquals(f1.getUid(), f2.getUid()); assertEquals(f1.place, f2.place); assertEquals(f1.name, f2.name); assertEquals(f1.products, f2.products); } @Test public void twoLocationsWithoutId() throws Exception { Location loc1 = new Location(ADDRESS, null, Point.from1E6(23, 42), null, "name1", null); Location loc2 = new Location(ADDRESS, null, Point.from1E6(0, 0), null, "name2", null); dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); dao.addFavoriteLocation(new FavoriteLocation(DB, loc2)); assertEquals(2, getValue(dao.getFavoriteLocations(DB)).size()); } @Test public void twoLocationsWithSameId() throws Exception { Location loc1 = new Location(ADDRESS, "test", Point.from1E6(23, 42), null, "name1", null); Location loc2 = new Location(ADDRESS, "test", Point.from1E6(0, 0), null, "name2", null); dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); dao.addFavoriteLocation(new FavoriteLocation(DB, loc2)); // second location should override first one and don't create a new one List<FavoriteLocation> locations = getValue(dao.getFavoriteLocations(DB)); assertEquals(1, locations.size()); FavoriteLocation f = locations.get(0); assertEquals(loc2.getLatAs1E6(), f.lat); assertEquals(loc2.getLonAs1E6(), f.lon); assertEquals(loc2.name, f.name); } @Test public void twoLocationsWithSameIdDifferentNetworks() throws Exception { Location loc1 = new Location(ADDRESS, "test", Point.from1E6(23, 42), null, "name1", null); Location loc2 = new Location(ADDRESS, "test", Point.from1E6(0, 0), null, "name2", null); dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); dao.addFavoriteLocation(new FavoriteLocation(BVG, loc2)); // second location should not override first one assertEquals(1, getValue(dao.getFavoriteLocations(DB)).size()); assertEquals(1, getValue(dao.getFavoriteLocations(BVG)).size()); } @Test public void getFavoriteLocationByUid() throws Exception { // insert a minimal location Location l1 = new Location(STATION, "id", Point.from1E6(1, 1), "place", "name", null); FavoriteLocation f1 = new FavoriteLocation(DB, l1); long uid = dao.addFavoriteLocation(f1); // retrieve by UID FavoriteLocation f2 = dao.getFavoriteLocation(uid); // assert that retrieval worked assertNotNull(f2); assertEquals(uid, f2.getUid()); assertEquals(DB, f2.getNetworkId()); assertEquals(l1.type, f2.type); assertEquals(l1.id, f2.id); assertEquals(l1.getLatAs1E6(), f2.lat); assertEquals(l1.getLonAs1E6(), f2.lon); assertEquals(l1.place, f2.place); assertEquals(l1.name, f2.name); assertEquals(l1.products, f2.products); } @Test public void getFavoriteLocationByValues() { // insert a minimal location Location loc1 = new Location(ANY, null, Point.from1E6(0, 0), null, null, null); dao.addFavoriteLocation(new FavoriteLocation(DB, loc1)); // assert the exists check works assertNotNull(dao.getFavoriteLocation(DB, loc1.type, loc1.id, loc1.getLatAs1E6(), loc1.getLonAs1E6(), loc1.place, loc1.name)); assertNull(dao.getFavoriteLocation(DB, ADDRESS, loc1.id, loc1.getLatAs1E6(), loc1.getLonAs1E6(), loc1.place, loc1.name)); assertNull(dao.getFavoriteLocation(DB, loc1.type, "id", loc1.getLatAs1E6(), loc1.getLonAs1E6(), loc1.place, loc1.name)); assertNull(dao.getFavoriteLocation(DB, loc1.type, loc1.id, 1, loc1.getLonAs1E6(), loc1.place, loc1.name)); assertNull(dao.getFavoriteLocation(DB, loc1.type, loc1.id, loc1.getLatAs1E6(), 1, loc1.place, loc1.name)); assertNull(dao.getFavoriteLocation(DB, loc1.type, loc1.id, loc1.getLatAs1E6(), loc1.getLonAs1E6(), "place", loc1.name)); assertNull(dao.getFavoriteLocation(DB, loc1.type, loc1.id, loc1.getLatAs1E6(), loc1.getLonAs1E6(), loc1.place, "name")); // insert a maximal location Location loc2 = new Location(STATION, "id", Point.from1E6(1, 1), "place", "name", null); dao.addFavoriteLocation(new FavoriteLocation(DB, loc2)); // assert the exists check works assertNotNull(dao.getFavoriteLocation(DB, loc2.type, loc2.id, loc2.getLatAs1E6(), loc2.getLonAs1E6(), loc2.place, loc2.name)); assertNull(dao.getFavoriteLocation(DB, POI, loc2.id, loc2.getLatAs1E6(), loc2.getLonAs1E6(), loc2.place, loc2.name)); assertNull(dao.getFavoriteLocation(DB, loc2.type, "oid", loc2.getLatAs1E6(), loc2.getLonAs1E6(), loc2.place, loc2.name)); assertNull(dao.getFavoriteLocation(DB, loc2.type, loc2.id, 42, loc2.getLonAs1E6(), loc2.place, loc2.name)); assertNull(dao.getFavoriteLocation(DB, loc2.type, loc2.id, loc2.getLatAs1E6(), 42, loc2.place, loc2.name)); assertNull(dao.getFavoriteLocation(DB, loc2.type, loc2.id, loc2.getLatAs1E6(), loc2.getLonAs1E6(), "oplace", loc2.name)); assertNull(dao.getFavoriteLocation(DB, loc2.type, loc2.id, loc2.getLatAs1E6(), loc2.getLonAs1E6(), loc2.place, "oname")); } }
Java
import time from datetime import datetime from pydoc import locate from unittest import SkipTest from countries_plus.models import Country from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.test import override_settings, tag from django.urls import reverse from django.utils import timezone from django.utils.timezone import make_aware from elasticsearch.client import IngestClient from elasticsearch.exceptions import ConnectionError from elasticsearch_dsl.connections import ( connections, get_connection as get_es_connection, ) from languages_plus.models import Language from rest_framework import status from rest_framework.test import APITestCase, APITransactionTestCase from ESSArch_Core.agents.models import ( Agent, AgentTagLink, AgentTagLinkRelationType, AgentType, MainAgentType, RefCode, ) from ESSArch_Core.auth.models import Group, GroupType from ESSArch_Core.configuration.models import Feature from ESSArch_Core.ip.models import InformationPackage from ESSArch_Core.maintenance.models import AppraisalJob from ESSArch_Core.search import alias_migration from ESSArch_Core.tags.documents import ( Archive, Component, File, StructureUnitDocument, ) from ESSArch_Core.tags.models import ( Structure, StructureType, StructureUnit, StructureUnitType, Tag, TagStructure, TagVersion, TagVersionType, ) User = get_user_model() def get_test_client(nowait=False): client = get_es_connection('default') # wait for yellow status for _ in range(1 if nowait else 5): try: client.cluster.health(wait_for_status="yellow") return client except ConnectionError: time.sleep(0.1) else: # timeout raise SkipTest("Elasticsearch failed to start") class ESSArchSearchBaseTestCaseMixin: @staticmethod def _get_client(): return get_test_client() @classmethod def setUpClass(cls): if cls._overridden_settings: cls._cls_overridden_context = override_settings(**cls._overridden_settings) cls._cls_overridden_context.enable() connections.configure(**settings.ELASTICSEARCH_CONNECTIONS) cls.es_client = cls._get_client() IngestClient(cls.es_client).put_pipeline(id='ingest_attachment', body={ 'description': "Extract attachment information", 'processors': [ { "attachment": { "field": "data", "indexed_chars": "-1" }, "remove": { "field": "data" } } ] }) super().setUpClass() def setUp(self): for _index_name, index_class in settings.ELASTICSEARCH_INDEXES['default'].items(): doctype = locate(index_class) alias_migration.setup_index(doctype) def tearDown(self): self.es_client.indices.delete(index="*", ignore=404) self.es_client.indices.delete_template(name="*", ignore=404) @override_settings(ELASTICSEARCH_CONNECTIONS=settings.ELASTICSEARCH_TEST_CONNECTIONS) @tag('requires-elasticsearch') class ESSArchSearchBaseTestCase(ESSArchSearchBaseTestCaseMixin, APITestCase): pass @override_settings(ELASTICSEARCH_CONNECTIONS=settings.ELASTICSEARCH_TEST_CONNECTIONS) @tag('requires-elasticsearch') class ESSArchSearchBaseTransactionTestCase(ESSArchSearchBaseTestCaseMixin, APITransactionTestCase): pass class ComponentSearchTestCase(ESSArchSearchBaseTestCase): fixtures = ['countries_data', 'languages_data'] @classmethod def setUpTestData(cls): cls.url = reverse('search-list') Feature.objects.create(name='archival descriptions', enabled=True) cls.user = User.objects.create() permission = Permission.objects.get(codename='search') cls.user.user_permissions.add(permission) org_group_type = GroupType.objects.create(codename='organization') cls.group1 = Group.objects.create(name='group1', group_type=org_group_type) cls.group1.add_member(cls.user.essauth_member) cls.group2 = Group.objects.create(name='group2', group_type=org_group_type) cls.group2.add_member(cls.user.essauth_member) cls.component_type = TagVersionType.objects.create(name='component', archive_type=False) cls.archive_type = TagVersionType.objects.create(name='archive', archive_type=True) def setUp(self): super().setUp() self.client.force_authenticate(user=self.user) @staticmethod def create_agent(): return Agent.objects.create( type=AgentType.objects.create(main_type=MainAgentType.objects.create()), ref_code=RefCode.objects.create( country=Country.objects.get(iso='SE'), repository_code='repo', ), level_of_detail=0, record_status=0, script=0, language=Language.objects.get(iso_639_1='sv'), create_date=timezone.now(), ) def test_search_component(self): component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", ) Component.from_obj(component_tag_version).save(refresh='true') with self.subTest('without archive'): res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) structure_type = StructureType.objects.create() structure_template = Structure.objects.create(type=structure_type, is_template=True) archive_tag = Tag.objects.create() archive_tag_version = TagVersion.objects.create( tag=archive_tag, type=self.archive_type, elastic_index="archive", ) self.group1.add_object(archive_tag_version) structure, archive_tag_structure = structure_template.create_template_instance(archive_tag) Archive.from_obj(archive_tag_version).save(refresh='true') TagStructure.objects.create(tag=component_tag, parent=archive_tag_structure, structure=structure) Component.index_documents(remove_stale=True) with self.subTest('with archive'): res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) with self.subTest('with archive, non-active organization'): self.user.user_profile.current_organization = self.group2 self.user.user_profile.save() res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) def test_filter_on_component_agent(self): agent = self.create_agent() component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", ) structure_type = StructureType.objects.create() structure_template = Structure.objects.create(type=structure_type, is_template=True) archive_tag = Tag.objects.create() archive_tag_version = TagVersion.objects.create( tag=archive_tag, type=self.archive_type, elastic_index="archive", ) structure, archive_tag_structure = structure_template.create_template_instance(archive_tag) Archive.from_obj(archive_tag_version).save(refresh='true') TagStructure.objects.create(tag=component_tag, parent=archive_tag_structure, structure=structure) AgentTagLink.objects.create( agent=agent, tag=component_tag_version, type=AgentTagLinkRelationType.objects.create(), ) Component.from_obj(component_tag_version).save(refresh='true') res = self.client.get(self.url, {'agents': str(agent.pk)}) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) def test_filter_on_archive_agent(self): agent = self.create_agent() component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", ) structure_type = StructureType.objects.create() structure_template = Structure.objects.create(type=structure_type, is_template=True) archive_tag = Tag.objects.create() archive_tag_version = TagVersion.objects.create( tag=archive_tag, type=self.archive_type, elastic_index="archive", ) structure, archive_tag_structure = structure_template.create_template_instance(archive_tag) Archive.from_obj(archive_tag_version).save(refresh='true') TagStructure.objects.create(tag=component_tag, parent=archive_tag_structure, structure=structure) AgentTagLink.objects.create( agent=agent, tag=archive_tag_version, type=AgentTagLinkRelationType.objects.create(), ) Component.from_obj(component_tag_version).save(refresh='true') res = self.client.get(self.url, {'agents': str(agent.pk)}) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) def test_filter_appraisal_date(self): component_tag = Tag.objects.create(appraisal_date=make_aware(datetime(year=2020, month=1, day=1))) component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", ) doc = Component.from_obj(component_tag_version) doc.save(refresh='true') with self.subTest('2020-01-01 is after or equal to 2020-01-01'): res = self.client.get(self.url, data={'appraisal_date_after': '2020-01-01'}) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) with self.subTest('2020-01-01 not after 2020-01-02'): res = self.client.get(self.url, data={'appraisal_date_after': '2020-01-02'}) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) with self.subTest('2020-01-01 not before 2019-12-31'): res = self.client.get(self.url, data={'appraisal_date_before': '2019-12-31'}) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) with self.subTest('2020-01-01 between 2019-01-01 and 2020-01-01'): res = self.client.get(self.url, data={ 'appraisal_date_after': '2019-01-01', 'appraisal_date_before': '2020-01-01', }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) with self.subTest('2020-01-01 between 2020-01-01 and 2020-12-31'): res = self.client.get(self.url, data={ 'appraisal_date_after': '2020-01-01', 'appraisal_date_before': '2020-12-31', }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) with self.subTest('2020-01-01 not between 2020-01-02 and 2020-12-31'): res = self.client.get(self.url, data={ 'appraisal_date_after': '2020-01-02', 'appraisal_date_before': '2020-12-31', }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) with self.subTest('2020-01-01 not between 2019-01-01 and 2019-12-31'): res = self.client.get(self.url, data={ 'appraisal_date_after': '2019-01-01', 'appraisal_date_before': '2019-12-31', }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) with self.subTest('invalid range 2020-12-31 - 2020-01-01'): res = self.client.get(self.url, data={ 'appraisal_date_after': '2020-12-31', 'appraisal_date_before': '2020-01-01', }) self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) def test_add_results_to_appraisal(self): component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( name='foo', tag=component_tag, type=self.component_type, elastic_index="component", ) Component.from_obj(component_tag_version).save(refresh='true') component_tag2 = Tag.objects.create() component_tag_version2 = TagVersion.objects.create( name='bar', tag=component_tag2, type=self.component_type, elastic_index="component", ) Component.from_obj(component_tag_version2).save(refresh='true') # test that we don't try to add structure units matched by query to job structure = Structure.objects.create(type=StructureType.objects.create(), is_template=False) structure_unit = StructureUnit.objects.create( name='foo', structure=structure, type=StructureUnitType.objects.create(structure_type=structure.type), ) StructureUnitDocument.from_obj(structure_unit).save(refresh='true') appraisal_job = AppraisalJob.objects.create() res = self.client.get(self.url, data={ 'q': 'foo', 'add_to_appraisal': appraisal_job.pk }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertCountEqual(appraisal_job.tags.all(), [component_tag]) res = self.client.get(self.url, data={ 'add_to_appraisal': appraisal_job.pk }) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertCountEqual(appraisal_job.tags.all(), [component_tag, component_tag2]) class DocumentSearchTestCase(ESSArchSearchBaseTestCase): fixtures = ['countries_data', 'languages_data'] @classmethod def setUpTestData(cls): cls.url = reverse('search-list') Feature.objects.create(name='archival descriptions', enabled=True) org_group_type = GroupType.objects.create(codename='organization') cls.group = Group.objects.create(group_type=org_group_type) cls.component_type = TagVersionType.objects.create(name='component', archive_type=False) cls.archive_type = TagVersionType.objects.create(name='archive', archive_type=True) def setUp(self): super().setUp() permission = Permission.objects.get(codename='search') self.user = User.objects.create() self.user.user_permissions.add(permission) self.group.add_member(self.user.essauth_member) self.client.force_authenticate(user=self.user) def test_search_document_in_ip_with_other_user_responsible_without_permission_to_see_it(self): other_user = User.objects.create(username='other') self.group.add_member(other_user.essauth_member) ip = InformationPackage.objects.create(responsible=other_user) self.group.add_object(ip) document_tag = Tag.objects.create(information_package=ip) document_tag_version = TagVersion.objects.create( tag=document_tag, type=self.component_type, elastic_index="document", ) File.from_obj(document_tag_version).save(refresh='true') res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) def test_search_document_in_ip_with_other_user_responsible_with_permission_to_see_it(self): self.user.user_permissions.add(Permission.objects.get(codename='see_other_user_ip_files')) other_user = User.objects.create(username='other') self.group.add_member(other_user.essauth_member) ip = InformationPackage.objects.create(responsible=other_user) self.group.add_object(ip) document_tag = Tag.objects.create(information_package=ip) document_tag_version = TagVersion.objects.create( tag=document_tag, type=self.component_type, elastic_index="document", ) File.from_obj(document_tag_version).save(refresh='true') res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(document_tag_version.pk)) class SecurityLevelTestCase(ESSArchSearchBaseTestCase): fixtures = ['countries_data', 'languages_data'] @classmethod def setUpTestData(cls): cls.url = reverse('search-list') Feature.objects.create(name='archival descriptions', enabled=True) cls.component_type = TagVersionType.objects.create(name='component', archive_type=False) cls.security_levels = [1, 2, 3, 4, 5] def setUp(self): super().setUp() self.user = User.objects.create() permission = Permission.objects.get(codename='search') self.user.user_permissions.add(permission) self.client.force_authenticate(user=self.user) def test_user_with_no_security_level(self): component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", security_level=None, ) Component.from_obj(component_tag_version).save(refresh='true') with self.subTest('no security level'): res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) for lvl in self.security_levels[1:]: with self.subTest(f'security level {lvl}'): component_tag_version.security_level = lvl component_tag_version.save() Component.from_obj(component_tag_version).save(refresh='true') res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) def test_user_with_security_level_3(self): self.user.user_permissions.add(Permission.objects.get(codename='security_level_3')) self.user = User.objects.get(pk=self.user.pk) component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", security_level=None, ) Component.from_obj(component_tag_version).save(refresh='true') with self.subTest('no security level'): res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) for lvl in self.security_levels: with self.subTest(f'security level {lvl}'): component_tag_version.security_level = lvl component_tag_version.save() Component.from_obj(component_tag_version).save(refresh='true') if lvl == 3: res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) else: res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0) def test_user_with_multiple_security_levels(self): self.user.user_permissions.add( Permission.objects.get(codename='security_level_1'), Permission.objects.get(codename='security_level_3'), ) self.user = User.objects.get(pk=self.user.pk) component_tag = Tag.objects.create() component_tag_version = TagVersion.objects.create( tag=component_tag, type=self.component_type, elastic_index="component", security_level=None, ) Component.from_obj(component_tag_version).save(refresh='true') with self.subTest('no security level'): res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) for lvl in self.security_levels: with self.subTest(f'security level {lvl}'): component_tag_version.security_level = lvl component_tag_version.save() Component.from_obj(component_tag_version).save(refresh='true') if lvl in [1, 3]: res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 1) self.assertEqual(res.data['hits'][0]['_id'], str(component_tag_version.pk)) else: res = self.client.get(self.url) self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertEqual(len(res.data['hits']), 0)
Java
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>ActionView::Helpers::NumberHelper::InvalidNumberError</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" /> <link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" /> <link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" /> <script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script> <script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script> <script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div class="banner"> <span>Ruby on Rails 4.2.0</span><br /> <h1> <span class="type">Class</span> ActionView::Helpers::NumberHelper::InvalidNumberError <span class="parent">&lt; StandardError </span> </h1> <ul class="files"> <li><a href="../../../../files/__/__/_rvm/gems/ruby-2_1_1/gems/actionview-4_2_0/lib/action_view/helpers/number_helper_rb.html">/home/rafael/.rvm/gems/ruby-2.1.1/gems/actionview-4.2.0/lib/action_view/helpers/number_helper.rb</a></li> </ul> </div> <div id="bodyContent"> <div id="content"> <div class="description"> <p>Raised when argument <code>number</code> param given to the helpers is invalid and the option :raise is set to <code>true</code>.</p> </div> <!-- Method ref --> <div class="sectiontitle">Methods</div> <dl class="methods"> <dt>N</dt> <dd> <ul> <li> <a href="#method-c-new">new</a> </li> </ul> </dd> </dl> <!-- Section attributes --> <div class="sectiontitle">Attributes</div> <table border='0' cellpadding='5'> <tr valign='top'> <td class='attr-rw'> [RW] </td> <td class='attr-name'>number</td> <td class='attr-desc'></td> </tr> </table> <!-- Methods --> <div class="sectiontitle">Class Public methods</div> <div class="method"> <div class="title method-title" id="method-c-new"> <b>new</b>(number) <a href="../../../../classes/ActionView/Helpers/NumberHelper/InvalidNumberError.html#method-c-new" name="method-c-new" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a> </p> <div id="method-c-new_source" class="dyn-source"> <pre><span class="ruby-comment"># File ../../.rvm/gems/ruby-2.1.1/gems/actionview-4.2.0/lib/action_view/helpers/number_helper.rb, line 22</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">number</span>) <span class="ruby-ivar">@number</span> = <span class="ruby-identifier">number</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> </div> </div> </body> </html>
Java
here is some text followed by \mycommand {here is some text \textbf {bold tex } after text } {and some \emph {emphacised } text } [and finally some \itshape {italicized } ] and some more text \textbf {bold text } and here is another command \cmh [optional ] {mandatory } after text \final {command text } and yet more text here is some text followed by \mycommand {here is some text \textbf {bold tex } after text } {and some \emph {emphacised } text } [and finally some \itshape {italicized } ] and some more text \textbf {bold text } and here is another command \cmh [optional ] {mandatory } after text \final {command text } and yet more text here is some text followed by \mycommand {here is some text \textbf {bold tex } after text } {and some \emph {emphacised } text } [and finally some \itshape {italicized } ] and some more text \textbf {bold text } and here is another command \cmh [optional ] {mandatory } after text \final {command text } and yet more text
Java
/** * Bukkit plugin which moves the mobs closer to the players. * Copyright (C) 2016 Jakub "Co0sh" Sapalski * * 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 <http://www.gnu.org/licenses/>. */ package pl.betoncraft.hordes; import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.CreatureSpawnEvent; /** * Blocks the mobs from spawning in unwanted places. * * @author Jakub Sapalski */ public class Blocker implements Listener { private Hordes plugin; private Random rand = new Random(); /** * Starts the blocker. * * @param plugin * instance of the plugin */ public Blocker(Hordes plugin) { this.plugin = plugin; Bukkit.getPluginManager().registerEvents(this, plugin); } @EventHandler public void onSpawn(CreatureSpawnEvent event) { LivingEntity e = event.getEntity(); WorldSettings set = plugin.getWorlds().get(event.getEntity().getWorld().getName()); if (set == null) { return; } if (!set.getEntities().contains(e.getType())) { return; } if (!set.shouldExist(e)) { event.setCancelled(true); } else if (rand.nextDouble() > set.getRatio(e.getType())) { event.setCancelled(true); } else { AttributeInstance maxHealth = e.getAttribute(Attribute.GENERIC_MAX_HEALTH); maxHealth.setBaseValue(maxHealth.getBaseValue() * set.getHealth(e.getType())); e.setHealth(e.getMaxHealth()); } } }
Java
<!DOCTYPE HTML> <html lang="zh-hans" > <!-- Start book Unity Source Book --> <head> <!-- head:start --> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>Transform | Unity Source Book</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta name="description" content=""> <meta name="generator" content="GitBook 2.6.7"> <meta name="author" content="李康"> <meta name="HandheldFriendly" content="true"/> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png"> <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="../gitbook/style.css"> <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css"> <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-maxiang/maxiang.css"> <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-comment/plugin.css"> <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css"> <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css"> <link rel="next" href="../UnityClass/translate.html" /> <link rel="prev" href="../UnityClass/resources.html" /> <!-- head:end --> </head> <body> <!-- body:start --> <div class="book" data-level="3.5" data-chapter-title="Transform" data-filepath="UnityClass/transform.md" data-basepath=".." data-revision="Tue Apr 19 2016 08:44:49 GMT+0800 (中国标准时间)" data-innerlanguage=""> <div class="book-summary"> <nav role="navigation"> <ul class="summary"> <li class="chapter " data-level="0" data-path="index.html"> <a href="../index.html"> <i class="fa fa-check"></i> 介绍 </a> </li> <li class="chapter " data-level="1" > <span><b>1.</b> Unity基础</span> <ul class="articles"> <li class="chapter " data-level="1.1" > <span><b>1.1.</b> Unity中的主要面板</span> </li> <li class="chapter " data-level="1.2" data-path="UnityBasic/prefab.html"> <a href="../UnityBasic/prefab.html"> <i class="fa fa-check"></i> <b>1.2.</b> 预制体 </a> </li> <li class="chapter " data-level="1.3" data-path="UnityBasic/scene.html"> <a href="../UnityBasic/scene.html"> <i class="fa fa-check"></i> <b>1.3.</b> 场景搭建 </a> </li> </ul> </li> <li class="chapter " data-level="2" > <span><b>2.</b> 3D数学基础</span> <ul class="articles"> <li class="chapter " data-level="2.1" data-path="3DMath/coordinate.html"> <a href="../3DMath/coordinate.html"> <i class="fa fa-check"></i> <b>2.1.</b> 坐标系 </a> </li> <li class="chapter " data-level="2.2" data-path="3DMath/vector.html"> <a href="../3DMath/vector.html"> <i class="fa fa-check"></i> <b>2.2.</b> 向量 </a> </li> <li class="chapter " data-level="2.3" data-path="3DMath/vector_compute.html"> <a href="../3DMath/vector_compute.html"> <i class="fa fa-check"></i> <b>2.3.</b> 向量的运算 </a> </li> <li class="chapter " data-level="2.4" > <span><b>2.4.</b> 奥特曼打小怪兽</span> </li> <li class="chapter " data-level="2.5" > <span><b>2.5.</b> 矩阵</span> </li> <li class="chapter " data-level="2.6" > <span><b>2.6.</b> 计算机图形学基础</span> </li> <li class="chapter " data-level="2.7" > <span><b>2.7.</b> 四元数与旋转</span> </li> </ul> </li> <li class="chapter " data-level="3" > <span><b>3.</b> Unity中的类</span> <ul class="articles"> <li class="chapter " data-level="3.1" data-path="UnityClass/component.html"> <a href="../UnityClass/component.html"> <i class="fa fa-check"></i> <b>3.1.</b> Component </a> </li> <li class="chapter " data-level="3.2" data-path="UnityClass/monobehaviour.html"> <a href="../UnityClass/monobehaviour.html"> <i class="fa fa-check"></i> <b>3.2.</b> MonoBehaviour </a> </li> <li class="chapter " data-level="3.3" data-path="UnityClass/gameobject.html"> <a href="../UnityClass/gameobject.html"> <i class="fa fa-check"></i> <b>3.3.</b> GameObject </a> </li> <li class="chapter " data-level="3.4" data-path="UnityClass/resources.html"> <a href="../UnityClass/resources.html"> <i class="fa fa-check"></i> <b>3.4.</b> Resources </a> </li> <li class="chapter active" data-level="3.5" data-path="UnityClass/transform.html"> <a href="../UnityClass/transform.html"> <i class="fa fa-check"></i> <b>3.5.</b> Transform </a> <ul class="articles"> <li class="chapter " data-level="3.5.1" data-path="UnityClass/translate.html"> <a href="../UnityClass/translate.html"> <i class="fa fa-check"></i> <b>3.5.1.</b> 移动 </a> </li> <li class="chapter " data-level="3.5.2" data-path="UnityClass/rotate.html"> <a href="../UnityClass/rotate.html"> <i class="fa fa-check"></i> <b>3.5.2.</b> 旋转 </a> </li> <li class="chapter " data-level="3.5.3" data-path="UnityClass/scale.html"> <a href="../UnityClass/scale.html"> <i class="fa fa-check"></i> <b>3.5.3.</b> 缩放 </a> </li> <li class="chapter " data-level="3.5.4" data-path="UnityClass/parent.html"> <a href="../UnityClass/parent.html"> <i class="fa fa-check"></i> <b>3.5.4.</b> 物体间的层次关系 </a> </li> </ul> </li> <li class="chapter " data-level="3.6" data-path="UnityClass/time.html"> <a href="../UnityClass/time.html"> <i class="fa fa-check"></i> <b>3.6.</b> Time </a> </li> <li class="chapter " data-level="3.7" data-path="UnityClass/input.html"> <a href="../UnityClass/input.html"> <i class="fa fa-check"></i> <b>3.7.</b> Input </a> </li> <li class="chapter " data-level="3.8" data-path="UnityClass/object.html"> <a href="../UnityClass/object.html"> <i class="fa fa-check"></i> <b>3.8.</b> Object </a> </li> </ul> </li> <li class="chapter " data-level="4" > <span><b>4.</b> 协同</span> <ul class="articles"> <li class="chapter " data-level="4.1" data-path="Coroutine/coroutine.html"> <a href="../Coroutine/coroutine.html"> <i class="fa fa-check"></i> <b>4.1.</b> 协同 Coroutine </a> </li> <li class="chapter " data-level="4.2" data-path="Coroutine/xiang_mu_shi_6218-_ta_fang.html"> <a href="../Coroutine/xiang_mu_shi_6218-_ta_fang.html"> <i class="fa fa-check"></i> <b>4.2.</b> 项目实战-塔防 </a> </li> </ul> </li> <li class="chapter " data-level="5" > <span><b>5.</b> 物理系统</span> <ul class="articles"> <li class="chapter " data-level="5.1" data-path="Physics/rigidbody.html"> <a href="../Physics/rigidbody.html"> <i class="fa fa-check"></i> <b>5.1.</b> 刚体 Rigidbody </a> </li> <li class="chapter " data-level="5.2" data-path="Physics/constant_force.html"> <a href="../Physics/constant_force.html"> <i class="fa fa-check"></i> <b>5.2.</b> 静态力场 Constant Force </a> </li> <li class="chapter " data-level="5.3" data-path="Physics/collider.html"> <a href="../Physics/collider.html"> <i class="fa fa-check"></i> <b>5.3.</b> 碰撞体 Collider </a> </li> <li class="chapter " data-level="5.4" data-path="Physics/ray.html"> <a href="../Physics/ray.html"> <i class="fa fa-check"></i> <b>5.4.</b> 射线 Ray </a> </li> <li class="chapter " data-level="5.5" data-path="Physics/cloth.html"> <a href="../Physics/cloth.html"> <i class="fa fa-check"></i> <b>5.5.</b> 布料 Cloth </a> </li> <li class="chapter " data-level="5.6" data-path="Physics/joint.html"> <a href="../Physics/joint.html"> <i class="fa fa-check"></i> <b>5.6.</b> 关节 Joint </a> </li> <li class="chapter " data-level="5.7" data-path="Physics/character_controller.html"> <a href="../Physics/character_controller.html"> <i class="fa fa-check"></i> <b>5.7.</b> 角色控制器 Character Controller </a> </li> <li class="chapter " data-level="5.8" data-path="Physics/project-3d-hit-plane.html"> <a href="../Physics/project-3d-hit-plane.html"> <i class="fa fa-check"></i> <b>5.8.</b> 项目实战-3D打飞机 </a> </li> </ul> </li> <li class="chapter " data-level="6" data-path="Animate/readme.html"> <a href="../Animate/readme.html"> <i class="fa fa-check"></i> <b>6.</b> 动作系统 </a> <ul class="articles"> <li class="chapter " data-level="6.1" data-path="Animate/2dgame.html"> <a href="../Animate/2dgame.html"> <i class="fa fa-check"></i> <b>6.1.</b> 2D游戏开发 </a> </li> <li class="chapter " data-level="6.2" data-path="Animate/animation.html"> <a href="../Animate/animation.html"> <i class="fa fa-check"></i> <b>6.2.</b> 帧动画 </a> </li> <li class="chapter " data-level="6.3" data-path="Animate/project-angry-bird.html"> <a href="../Animate/project-angry-bird.html"> <i class="fa fa-check"></i> <b>6.3.</b> 项目实战-愤怒的小鸟 </a> </li> <li class="chapter " data-level="6.4" data-path="Animate/animator_controller.html"> <a href="../Animate/animator_controller.html"> <i class="fa fa-check"></i> <b>6.4.</b> 动画状态机 </a> </li> <li class="chapter " data-level="6.5" > <span><b>6.5.</b> 3D动画</span> </li> <li class="chapter " data-level="6.6" > <span><b>6.6.</b> 层动画</span> </li> <li class="chapter " data-level="6.7" > <span><b>6.7.</b> Blend动画</span> </li> </ul> </li> <li class="chapter " data-level="7" > <span><b>7.</b> 组件</span> <ul class="articles"> <li class="chapter " data-level="7.1" data-path="Component/camera.html"> <a href="../Component/camera.html"> <i class="fa fa-check"></i> <b>7.1.</b> 摄像机 Camera </a> </li> <li class="chapter " data-level="7.2" data-path="Component/project_observe.html"> <a href="../Component/project_observe.html"> <i class="fa fa-check"></i> <b>7.2.</b> 项目实战-观察模型 </a> </li> <li class="chapter " data-level="7.3" data-path="renderer.html"> <span><b>7.3.</b> 显示组件 Renderer</span> </li> <li class="chapter " data-level="7.4" > <span><b>7.4.</b> 粒子系统</span> </li> </ul> </li> <li class="chapter " data-level="8" > <span><b>8.</b> UI</span> </li> <li class="chapter " data-level="9" > <span><b>9.</b> 数据持久化</span> <ul class="articles"> <li class="chapter " data-level="9.1" > <span><b>9.1.</b> IO流</span> </li> <li class="chapter " data-level="9.2" > <span><b>9.2.</b> 序列化与反序列化</span> </li> <li class="chapter " data-level="9.3" > <span><b>9.3.</b> XML</span> </li> <li class="chapter " data-level="9.4" > <span><b>9.4.</b> JSON</span> </li> </ul> </li> <li class="chapter " data-level="10" > <span><b>10.</b> 网络</span> </li> <li class="chapter " data-level="11" > <span><b>11.</b> AI</span> <ul class="articles"> <li class="chapter " data-level="11.1" data-path="AI/state_controller.html"> <a href="../AI/state_controller.html"> <i class="fa fa-check"></i> <b>11.1.</b> 状态机的实现 </a> </li> </ul> </li> <li class="chapter " data-level="12" > <span><b>12.</b> 游戏框架</span> <ul class="articles"> <li class="chapter " data-level="12.1" > <span><b>12.1.</b> 模块间通信</span> </li> <li class="chapter " data-level="12.2" > <span><b>12.2.</b> 全局数据</span> </li> <li class="chapter " data-level="12.3" > <span><b>12.3.</b> 单例模式</span> </li> </ul> </li> <li class="chapter " data-level="13" > <span><b>13.</b> 常用插件</span> </li> <li class="chapter " data-level="14" data-path="项目实战/readme.html"> <span><b>14.</b> 项目实战</span> <ul class="articles"> <li class="chapter " data-level="14.1" > <span><b>14.1.</b> Unity官方案例介绍</span> </li> </ul> </li> <li class="chapter " data-level="15" data-path="Summary/readme.html"> <a href="../Summary/readme.html"> <i class="fa fa-check"></i> <b>15.</b> 总结 </a> <ul class="articles"> <li class="chapter " data-level="15.1" data-path="Summary/awesome.html"> <a href="../Summary/awesome.html"> <i class="fa fa-check"></i> <b>15.1.</b> Awesome </a> </li> <li class="chapter " data-level="15.2" > <span><b>15.2.</b> Unity中的常用快捷键及使用技巧</span> </li> <li class="chapter " data-level="15.3" > <span><b>15.3.</b> MonoDevelop中的常用快捷键及使用技巧</span> </li> <li class="chapter " data-level="15.4" > <span><b>15.4.</b> VS中的常用快捷键及使用技巧</span> </li> <li class="chapter " data-level="15.5" data-path="Summary/dui_unity_de_zheng_ti_ren_shi.html"> <a href="../Summary/dui_unity_de_zheng_ti_ren_shi.html"> <i class="fa fa-check"></i> <b>15.5.</b> 对Unity的整体认识 </a> </li> <li class="chapter " data-level="15.6" > <span><b>15.6.</b> 实现等待</span> </li> <li class="chapter " data-level="15.7" > <span><b>15.7.</b> 控制物体移动的几种方式</span> </li> <li class="chapter " data-level="15.8" > <span><b>15.8.</b> 刚体与碰撞体间的联系</span> </li> <li class="chapter " data-level="15.9" data-path="Summary/vector3forwardtransformforwardyu_wu_ti_zuo_biao_xi.html"> <a href="../Summary/vector3forwardtransformforwardyu_wu_ti_zuo_biao_xi.html"> <i class="fa fa-check"></i> <b>15.9.</b> Vector3.forward、transform.forward与坐标系间的联系 </a> </li> <li class="chapter " data-level="15.10" data-path="Summary/gameobjectyu_component_de_guan_xi.html"> <a href="../Summary/gameobjectyu_component_de_guan_xi.html"> <i class="fa fa-check"></i> <b>15.10.</b> GameObject与Component的关系 </a> </li> <li class="chapter " data-level="15.11" > <span><b>15.11.</b> 顺序加载脚本</span> </li> <li class="chapter " data-level="15.12" > <span><b>15.12.</b> 2D射线</span> </li> <li class="chapter " data-level="15.13" > <span><b>15.13.</b> 动态创建地形</span> </li> <li class="chapter " data-level="15.14" data-path="Summary/Lerp.html"> <a href="../Summary/Lerp.html"> <i class="fa fa-check"></i> <b>15.14.</b> 插值与平滑 </a> </li> <li class="chapter " data-level="15.15" data-path="Summary/coordinate.html"> <a href="../Summary/coordinate.html"> <i class="fa fa-check"></i> <b>15.15.</b> 坐标系转化 </a> </li> </ul> </li> <li class="divider"></li> <li> <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> 本书使用 GitBook 发布 </a> </li> </ul> </nav> </div> <div class="book-body"> <div class="body-inner"> <div class="book-header" role="navigation"> <!-- Actions Left --> <!-- Title --> <h1> <i class="fa fa-circle-o-notch fa-spin"></i> <a href="../" >Unity Source Book</a> </h1> </div> <div class="page-wrapper" tabindex="-1" role="main"> <div class="page-inner"> <section class="normal" id="section-"> <h1 id="transform">Transform</h1> </section> </div> </div> </div> <a href="../UnityClass/resources.html" class="navigation navigation-prev " aria-label="Previous page: Resources"><i class="fa fa-angle-left"></i></a> <a href="../UnityClass/translate.html" class="navigation navigation-next " aria-label="Next page: 移动"><i class="fa fa-angle-right"></i></a> </div> </div> <script src="../gitbook/app.js"></script> <script src="../gitbook/plugins/gitbook-plugin-maxiang/maxiang.js"></script> <script src="../gitbook/plugins/gitbook-plugin-comment/plugin.js"></script> <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script> <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script> <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script> <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script> <script src="../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script> <script> require(["gitbook"], function(gitbook) { var config = {"comment":{"highlightCommented":true},"highlight":{},"include-codeblock":{},"maxiang":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}}; gitbook.start(config); }); </script> <!-- body:end --> </body> <!-- End of book Unity Source Book --> </html>
Java
<?php include(__DIR__ . '/http_move.php'); include(__DIR__ . '/security_arguments.php'); // this is it
Java
/* * RenderRasterize_Shader.h * Created by Clemens Unterkofler on 1/20/09. * for Aleph One * * http://www.gnu.org/licenses/gpl.html */ #ifndef _RENDERRASTERIZE_SHADER__H #define _RENDERRASTERIZE_SHADER__H #include "cseries.h" #include "map.h" #include "RenderRasterize.h" #include "OGL_FBO.h" #include "OGL_Textures.h" #include "Rasterizer_Shader.h" #include <memory> class Blur; class RenderRasterize_Shader : public RenderRasterizerClass { std::unique_ptr<Blur> blur; Rasterizer_Shader_Class *RasPtr; int objectCount; world_distance objectY; float weaponFlare; float selfLuminosity; long_vector2d leftmost_clip, rightmost_clip; protected: virtual void render_node(sorted_node_data *node, bool SeeThruLiquids, RenderStep renderStep); virtual void store_endpoint(endpoint_data *endpoint, long_vector2d& p); virtual void render_node_floor_or_ceiling( clipping_window_data *window, polygon_data *polygon, horizontal_surface_data *surface, bool void_present, bool ceil, RenderStep renderStep); virtual void render_node_side( clipping_window_data *window, vertical_surface_data *surface, bool void_present, RenderStep renderStep); virtual void render_node_object(render_object_data *object, bool other_side_of_media, RenderStep renderStep); virtual void clip_to_window(clipping_window_data *win); virtual void _render_node_object_helper(render_object_data *object, RenderStep renderStep); public: RenderRasterize_Shader(); ~RenderRasterize_Shader(); virtual void setupGL(Rasterizer_Shader_Class& Rasterizer); virtual void render_tree(void); TextureManager setupWallTexture(const shape_descriptor& Texture, short transferMode, float pulsate, float wobble, float intensity, float offset, RenderStep renderStep); TextureManager setupSpriteTexture(const rectangle_definition& rect, short type, float offset, RenderStep renderStep); }; #endif
Java
#include <QtGui> #include <QTcpSocket> #include "phonecall.h" #include "dcc.h" DCCDialog::DCCDialog(QWidget *parent) : QDialog(parent) { QStringList list; QVBoxLayout* mainLayout = new QVBoxLayout(this); table = new QTableWidget(this); table->setColumnCount(8); list << tr("Status") << tr("File") << tr("Size") << tr("Position") << "%" << "KB/s" << "ETA" << tr("Nick"); table->setHorizontalHeaderLabels(list); mainLayout->addWidget(table); closeButton = new QPushButton(tr("Save and Close")); connect(closeButton, SIGNAL(clicked()), this, SLOT(saveAndClose())); mainLayout->addWidget(closeButton); setLayout(mainLayout); setWindowTitle(tr("File Transfers")); call = 0; } DCCDialog::~DCCDialog() { } void DCCDialog::command(const QString &cmd) { //user:ip:DCC SEND <filename> <ip> <port> <filesize> //user:ip:DCC CHAT accept <ip> <audio port> <video port> //user:ip:DCC CHAT call <ip> <audio port> <video port> //qWarning()<<"cmd: "<<cmd; QStringList list = cmd.split(':'); QString user = list.at(0); QString ip = list.at(1); QStringList params = cmd.split(' '); //qWarning()<<"params "<<params; //qWarning()<<"list "<<list; if(params.size() < 6) return; if(params.at(1).contains("SEND")) { QMessageBox msgBox; QString text = QString("%1 wants to send you a file called %2").arg(user).arg(params.at(2)); msgBox.setText(text); msgBox.setInformativeText("Do you want to accept the file transfer?"); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); int ret = msgBox.exec(); if(ret == QMessageBox::Save) { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::AnyFile); dialog.selectFile(params.at(2)); if(dialog.exec()) { QStringList files = dialog.selectedFiles(); //qWarning()<<"destination = "<<files.at(0); TransferData* data = new TransferData; data->user = user; data->status = "Waiting"; data->file = params.at(2); data->destination = new QFile(files.at(0)); data->size = params.at(5).toInt(); data->position = 0; data->complete = 0; data->rate = 0; data->eta = -1; data->comms = new QTcpSocket; int currentRow = table->rowCount(); //qWarning()<<"currentRow="<<currentRow; table->insertRow(currentRow); table->setItem(currentRow, 0, new QTableWidgetItem(data->status)); table->setItem(currentRow, 1, new QTableWidgetItem(data->file)); table->setItem(currentRow, 2, new QTableWidgetItem(QString("%1kB").arg(data->size/1024))); table->setItem(currentRow, 3, new QTableWidgetItem(QString("%1").arg(data->position))); table->setItem(currentRow, 4, new QTableWidgetItem(QString("%1\%").arg(data->complete))); table->setItem(currentRow, 5, new QTableWidgetItem(QString("%1Kb/s").arg(data->rate))); table->setItem(currentRow, 6, new QTableWidgetItem(QString("%1min").arg(data->eta))); table->setItem(currentRow, 7, new QTableWidgetItem(data->user)); connect(data->comms,SIGNAL(connected()),this,SLOT(startTransfer())); connect(data->comms,SIGNAL(readyRead()),this,SLOT(processReadyRead())); transfers.append(data); table->resizeColumnsToContents(); if(table->selectedItems().isEmpty()) { table->selectRow(0); // start transfer... } } } show(); } else if(params.at(1).contains("CHAT")) { //qWarning()<<"got a CHAT message"; if(params.at(2).contains("call")) { //qWarning()<<"got a CHAT call"; // someone has requested a call QMessageBox msgBox; QString text = QString("%1 wants to talk").arg(user); msgBox.setText(text); msgBox.setInformativeText("Do you want to accept the call?"); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); int ret = msgBox.exec(); if(ret == QMessageBox::Ok) { // send accept message and setup for incoming. QString msg = QString("PRIVMSG %1 :\001DCC CHAT accept %2 %3 %4\001\r\n").arg(user).arg(ip).arg(AUDIO_PORT).arg(0); PhoneCallDialog* incoming = new PhoneCallDialog(this,user,ip,false); incoming->show(); emit ircMsg(msg); } } else if(params.at(2).contains("accept")) { //qWarning()<<"got a CHAT accept"; // your request has been accepted, connect to other end. //qWarning()<<"I should be able to connect to "<<ip<<QString(" on port %1").arg(AUDIO_PORT); if(call) delete call; call = new PhoneCallDialog(this,user,ip,true); call->show(); call->connectToHost(); } } } void DCCDialog::startTransfer() { //qWarning()<<"TODO:startTransfer()"; } void DCCDialog::processReadyRead() { //qWarning()<<"TODO:processReadyRead()"; } void DCCDialog::saveAndClose() { close(); }
Java
package cn.com.jautoitx; import org.apache.commons.lang3.StringUtils; import com.sun.jna.platform.win32.WinDef.HWND; /** * Build window title base on Advanced Window Descriptions. * * @author zhengbo.wang */ public class TitleBuilder { /** * Build window title base on Advanced Window Descriptions. * * @param bys * Selectors to build advanced window title. * @return Returns advanced window title. */ public static String by(By... bys) { StringBuilder title = new StringBuilder(); title.append('['); String separator = ""; for (int i = 0; i < bys.length; i++) { title.append(separator); String strBy = bys[i].toAdvancedTitle(); if (!strBy.isEmpty()) { title.append(strBy); separator = "; "; } } title.append(']'); return title.toString(); } /** * Build window title base on window title. * * @param title * Window title. * @return Returns advanced window title. */ public static String byTitle(String title) { return by(By.title(title)); } /** * Build window title base on the internal window classname. * * @param className * The internal window classname. * @return Returns advanced window title. */ public static String byClassName(String className) { return by(By.className(className)); } /** * Build window title base on window title using a regular expression. * * @param regexpTitle * Window title using a regular expression. * @return Returns advanced window title. */ public static String byRegexpTitle(String regexpTitle) { return by(By.regexpTitle(regexpTitle)); } /** * Build window title base on window classname using a regular expression. * * @param regexpClassName * Window classname using a regular expression. * @return Returns advanced window title. */ public static String byRegexpClassName(String regexpClassName) { return by(By.regexpClassName(regexpClassName)); } /** * Build window title base on window used in a previous AutoIt command. * * @return Returns advanced window title. */ public static String byLastWindow() { return by(By.lastWindow()); } /** * Build window title base on currently active window. * * @return Returns advanced window title. */ public static String byActiveWindow() { return by(By.activeWindow()); } /** * Build window title base on the position and size of a window. All * parameters are optional. * * @param x * Optional, the X coordinate of the window. * @param y * Optional, the Y coordinate of the window. * @param width * Optional, the width of the window. * @param height * Optional, the height of the window. * @return Returns advanced window title. */ public static String byBounds(Integer x, Integer y, Integer width, Integer height) { return by(By.bounds(x, y, width, height)); } /** * Build window title base on the position of a window. All parameters are * optional. * * @param x * Optional, the X coordinate of the window. * @param y * Optional, the Y coordinate of the window. * @return Returns advanced window title. */ public static String byPosition(Integer x, Integer y) { return by(By.position(x, y)); } /** * Build window title base on the size of a window. All parameters are * optional. * * @param width * Optional, the width of the window. * @param height * Optional, the height of the window. * @return Returns advanced window title. */ public static String bySize(Integer width, Integer height) { return by(By.size(width, height)); } /** * Build window title base on the 1-based instance when all given properties * match. * * @param instance * The 1-based instance when all given properties match. * @return Returns advanced window title. */ public static String byInstance(int instance) { return by(By.instance(instance)); } /** * Build window title base on the handle address as returned by a method * like Win.getHandle. * * @param handle * The handle address as returned by a method like Win.getHandle. * @return Returns advanced window title. */ public static String byHandle(String handle) { return by(By.handle(handle)); } /** * Build window title base on the handle address as returned by a method * like Win.getHandle_. * * @param hWnd * The handle address as returned by a method like * Win.getHandle_. * @return Returns advanced window title. */ public static String byHandle(HWND hWnd) { return by(By.handle(hWnd)); } /** * Selector to build advanced window title. * * @author zhengbo.wang */ public static abstract class By { private final String property; private final String value; public By(final String property) { this.property = property; this.value = null; } public By(final String property, final String value) { this.property = property; this.value = StringUtils.defaultString(value); } /** * @param title * Window title. * @return a By which locates window by the window title. */ public static By title(String title) { return new ByTitle(title); } /** * @param className * The internal window classname. * @return a By which locates window by the internal window classname. */ public static By className(String className) { return new ByClass(className); } /** * @param regexpTitle * Window title using a regular expression. * @return a By which locates window by the window title using a regular * expression. */ public static By regexpTitle(String regexpTitle) { return new ByRegexpTitle(regexpTitle); } /** * @param regexpClassName * Window classname using a regular expression. * @return a By which locates window by the window classname using a * regular expression. */ public static By regexpClassName(String regexpClassName) { return new ByRegexpClass(regexpClassName); } /** * @return a By which locates window used in a previous AutoIt command. */ public static By lastWindow() { return new ByLast(); } /** * @return a By which locates currently active window. */ public static By activeWindow() { return new ByActive(); } /** * All parameters are optional. * * @param x * Optional, the X coordinate of the window. * @param y * Optional, the Y coordinate of the window. * @param width * Optional, the width of the window. * @param height * Optional, the height of the window. * @return a By which locates window by the position and size of a * window. */ public static By bounds(Integer x, Integer y, Integer width, Integer height) { return new ByBounds(x, y, width, height); } /** * All parameters are optional. * * @param x * Optional, the X coordinate of the window. * @param y * Optional, the Y coordinate of the window. * @return a By which locates window by the position of a window. */ public static By position(Integer x, Integer y) { return bounds(x, y, null, null); } /** * All parameters are optional. * * @param width * Optional, the width of the window. * @param height * Optional, the height of the window. * @return a By which locates window by the size of a window. */ public static By size(Integer width, Integer height) { return bounds(null, null, width, height); } /** * @param instance * The 1-based instance when all given properties match. * @return a By which locates window by the instance when all given * properties match. */ public static By instance(int instance) { return new ByInstance(instance); } /** * @param handle * The handle address as returned by a method like * Win.getHandle. * @return a By which locates window by the handle address as returned * by a method like Win.getHandle. */ public static By handle(String handle) { return new ByHandle(handle); } /** * @param hWnd * The handle address as returned by a method like * Win.getHandle_. * @return a By which locates window by the handle address as returned * by a method like Win.getHandle. */ public static By handle(HWND hWnd) { return new ByHandle(hWnd); } public String toAdvancedTitle() { StringBuilder advancedTitle = new StringBuilder(); advancedTitle.append(property); if (value != null) { advancedTitle.append(':'); for (int i = 0; i < value.length(); i++) { char ch = value.charAt(i); advancedTitle.append(ch); // Note: if a Value must contain a ";" it must be doubled. if (ch == ';') { advancedTitle.append(';'); } } } return advancedTitle.toString(); } @Override public String toString() { return "By." + property + ": " + value; } } /** * Window title. * * @author zhengbo.wang */ public static class ByTitle extends By { public ByTitle(String title) { super("TITLE", title); } } /** * The internal window classname. * * @author zhengbo.wang */ public static class ByClass extends By { public ByClass(String clazz) { super("CLASS", clazz); } } /** * Window title using a regular expression. * * @author zhengbo.wang */ public static class ByRegexpTitle extends By { public ByRegexpTitle(String clazz) { super("REGEXPTITLE", clazz); } } /** * Window classname using a regular expression. * * @author zhengbo.wang */ public static class ByRegexpClass extends By { public ByRegexpClass(String regexpClass) { super("REGEXPCLASS", regexpClass); } } /** * Last window used in a previous AutoIt command. * * @author zhengbo.wang */ public static class ByLast extends By { public ByLast() { super("LAST"); } } /** * Currently active window. * * @author zhengbo.wang */ public static class ByActive extends By { public ByActive() { super("ACTIVE"); } } /** * The position and size of a window. * * @author zhengbo.wang */ public static class ByBounds extends By { private final Integer x; private final Integer y; private final Integer width; private final Integer height; public ByBounds(Integer x, Integer y, Integer width, Integer height) { super("POSITION AND SIZE", String.format("%s \\ %s \\ %s \\ %s", String.valueOf(x), String.valueOf(y), String.valueOf(width), String.valueOf(height))); this.x = x; this.y = y; this.width = width; this.height = height; } @Override public String toAdvancedTitle() { // see http://www.autoitscript.com/forum/topic/90848-x-y-w-h/ StringBuilder advancedTitle = new StringBuilder(); if (x != null) { advancedTitle.append("X:").append(x); } if (y != null) { if (!advancedTitle.toString().isEmpty()) { advancedTitle.append("\\"); } advancedTitle.append("Y:").append(y); } if (width != null) { if (!advancedTitle.toString().isEmpty()) { advancedTitle.append("\\"); } advancedTitle.append("W:").append(width); } if (height != null) { if (!advancedTitle.toString().isEmpty()) { advancedTitle.append("\\"); } advancedTitle.append("H:").append(height); } return advancedTitle.toString(); } } /** * The 1-based instance when all given properties match. * * @author zhengbo.wang */ public static class ByInstance extends By { public ByInstance(int instance) { super("INSTANCE", String.valueOf(instance)); } } /** * The handle address as returned by a method like Win.getHandle or * Win.getHandle_. * * @author zhengbo.wang */ public static class ByHandle extends By { public ByHandle(String handle) { super("HANDLE", handle); } public ByHandle(HWND hWnd) { this(AutoItX.hwndToHandle(hWnd)); } } }
Java
\begin{lstlisting}[caption=RoR installation] # install ruby sudo apt-get install ruby ruby-dev # install sqllite sudo apt-get install sqlite3 libsqlite3-dev # install postgresql sudo apt-get install postgresql # install java script sudo apt-get install nodejs # # download and cd to gems directory # sudo ruby setup.rb # or #gem update --system # optional sudo gem install execjs sudo gem install jquery-rails sudo gem install multi_json sudo gem install jquery-turbolinks sudo gem install sprockets sudo gem install sprockets sudo gem install rails sudo gem install activemodel sudo gem install actionmailer sudo gem install coffee-rails sudo gem install coffee-script sudo gem install json_pure sudo gem install activerecord-deprecated_finders sudo gem install arel sudo gem install sqlite3 \end{lstlisting}
Java
package me.vadik.instaclimb.view.adapter; import android.content.Context; import android.databinding.ViewDataBinding; import android.view.LayoutInflater; import android.view.ViewGroup; import me.vadik.instaclimb.databinding.RowLayoutRouteBinding; import me.vadik.instaclimb.databinding.UserCardBinding; import me.vadik.instaclimb.model.Route; import me.vadik.instaclimb.model.User; import me.vadik.instaclimb.view.adapter.abstr.AbstractRecyclerViewWithHeaderAdapter; import me.vadik.instaclimb.viewmodel.RouteItemViewModel; import me.vadik.instaclimb.viewmodel.UserViewModel; /** * User: vadik * Date: 4/13/16 */ public class UserRecyclerViewAdapter extends AbstractRecyclerViewWithHeaderAdapter<User, Route> { public UserRecyclerViewAdapter(Context context, User user) { super(context, user); } @Override protected ViewDataBinding onCreateHeader(LayoutInflater inflater, ViewGroup parent) { return UserCardBinding.inflate(inflater, parent, false); } @Override protected ViewDataBinding onCreateItem(LayoutInflater inflater, ViewGroup parent) { return RowLayoutRouteBinding.inflate(inflater, parent, false); } @Override protected void onBindHeader(ViewDataBinding binding, User user) { ((UserCardBinding) binding).setUser(new UserViewModel(mContext, user)); } @Override protected void onBindItem(ViewDataBinding binding, Route route) { ((RowLayoutRouteBinding) binding).setRoute(new RouteItemViewModel(mContext, route)); } }
Java
Ext.define('Omni.view.sizes.Explorer', { extend: 'Buildit.ux.explorer.Panel', alias: 'widget.omni-sizes-Explorer', initComponent: function() { var me = this; // EXPLORER INIT (Start) =============================================================== Ext.apply(this, { allowFind: true, store: Ext.create('Omni.store.Size'), contextMenuConfig: { xtype: 'omni-app-ExplorerContextMenu' }, newForms: [{ xtype: 'omni-sizes-Form', windowConfig: {} }], inspectorConfig: { xtype: 'omni-sizes-Inspector' } }); // EXPLORER INIT (End) // LABELS (Start) ====================================================================== Ext.applyIf(this, { size_nbrLabel: Omni.i18n.model.Size.size_nbr, size_typeLabel: Omni.i18n.model.Size.size_type, displayLabel: Omni.i18n.model.Size.display, concatenated_nameLabel: Omni.i18n.model.Size.concatenated_name, dimension_1Label: Omni.i18n.model.Size.dimension_1, dimension_2Label: Omni.i18n.model.Size.dimension_2, is_enabledLabel: Omni.i18n.model.Size.is_enabled }); // LABELS (End) // COLUMNS (Start) ===================================================================== Ext.apply(this, { columns: [{ header: this.displayLabel, dataIndex: 'display', flex: 1, sortable: false }, { header: this.concatenated_nameLabel, dataIndex: 'concatenated_name', flex: 1, sortable: false }, { header: this.dimension_1Label, dataIndex: 'dimension_1', flex: 1, sortable: false }, { header: this.dimension_2Label, dataIndex: 'dimension_2', flex: 1, sortable: false }, { header: this.size_typeLabel, dataIndex: 'size_type', flex: 1, sortable: false, renderer: Buildit.util.Format.lookupRenderer('SIZE_TYPE') }, { header: this.size_nbrLabel, dataIndex: 'size_nbr', flex: 1, sortable: false }, { header: this.is_enabledLabel, dataIndex: 'is_enabled', flex: 1, sortable: false }, ] }); // COLUMNS (End) // TITLES (Start) ====================================================================== Ext.apply(this, { title: 'Size', subtitle: 'All Product Sizes that are valid in the system' }); // TITLES (End) this.callParent(); } });
Java
# Copyright (C) 2012 Statoil ASA, Norway. # # The file 'enkf_node.py' is part of ERT - Ensemble based Reservoir Tool. # # ERT 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. # # ERT 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 at <http://www.gnu.org/licenses/gpl.html> # for more details. from ert.cwrap import BaseCClass, CWrapper from ert.enkf import ENKF_LIB, EnkfFs, NodeId from ert.enkf.data import EnkfConfigNode, GenKw, GenData, CustomKW from ert.enkf.enums import ErtImplType class EnkfNode(BaseCClass): def __init__(self, config_node, private=False): assert isinstance(config_node, EnkfConfigNode) if private: c_pointer = EnkfNode.cNamespace().alloc_private(config_node) else: c_pointer = EnkfNode.cNamespace().alloc(config_node) super(EnkfNode, self).__init__(c_pointer, config_node, True) def valuePointer(self): return EnkfNode.cNamespace().value_ptr(self) def asGenData(self): """ @rtype: GenData """ impl_type = EnkfNode.cNamespace().get_impl_type(self) assert impl_type == ErtImplType.GEN_DATA return GenData.createCReference(self.valuePointer(), self) def asGenKw(self): """ @rtype: GenKw """ impl_type = EnkfNode.cNamespace().get_impl_type(self) assert impl_type == ErtImplType.GEN_KW return GenKw.createCReference(self.valuePointer(), self) def asCustomKW(self): """ @rtype: CustomKW """ impl_type = EnkfNode.cNamespace().get_impl_type(self) assert impl_type == ErtImplType.CUSTOM_KW return CustomKW.createCReference(self.valuePointer(), self) def tryLoad(self, fs, node_id): """ @type fs: EnkfFS @type node_id: NodeId @rtype: bool """ assert isinstance(fs, EnkfFs) assert isinstance(node_id, NodeId) return EnkfNode.cNamespace().try_load(self, fs, node_id) def name(self): return EnkfNode.cNamespace().get_name(self) def load(self, fs, node_id): if not self.tryLoad(fs, node_id): raise Exception("Could not load node: %s iens: %d report: %d" % (self.name(), node_id.iens, node_id.report_step)) def save(self, fs, node_id): assert isinstance(fs, EnkfFs) assert isinstance(node_id, NodeId) EnkfNode.cNamespace().store(self, fs, True, node_id) def free(self): EnkfNode.cNamespace().free(self) cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("enkf_node", EnkfNode) EnkfNode.cNamespace().free = cwrapper.prototype("void enkf_node_free(enkf_node)") EnkfNode.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_node_alloc(enkf_node)") EnkfNode.cNamespace().alloc_private = cwrapper.prototype("c_void_p enkf_node_alloc_private_container(enkf_node)") EnkfNode.cNamespace().get_name = cwrapper.prototype("char* enkf_node_get_key(enkf_node)") EnkfNode.cNamespace().value_ptr = cwrapper.prototype("c_void_p enkf_node_value_ptr(enkf_node)") EnkfNode.cNamespace().try_load = cwrapper.prototype("bool enkf_node_try_load(enkf_node, enkf_fs, node_id)") EnkfNode.cNamespace().get_impl_type = cwrapper.prototype("ert_impl_type_enum enkf_node_get_impl_type(enkf_node)") EnkfNode.cNamespace().store = cwrapper.prototype("void enkf_node_store(enkf_node, enkf_fs, bool, node_id)")
Java
package task_config import ( "github.com/sonm-io/core/proto" "github.com/sonm-io/core/util/config" ) func LoadConfig(path string) (*sonm.TaskSpec, error) { // Manual renaming from snake_case to lowercase fields here to be able to // load them directly in the protobuf. cfg := &sonm.TaskSpec{} if err := config.LoadWith(cfg, path, config.SnakeToLower); err != nil { return nil, err } if err := cfg.Validate(); err != nil { return nil, err } return cfg, nil }
Java
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Web; using System.Xml; using System.Xml.XPath; using System.IO; using LyricsFetcher; using iTunesLib; using WMPLib; using WMFSDKWrapper; public class TestSong : Song { public TestSong(string title, string artist, string album, string genre) : base(title, artist, album, genre) { } public override string FullPath { get { return String.Empty; } } public override void Commit() { } public override void GetLyrics() { } } namespace LyricsFetcher.CommandLine { class Program { static void TestWMPLyrics() { WindowsMediaPlayer wmpPlayer = new WindowsMediaPlayer(); IWMPPlaylist playlist = wmpPlayer.mediaCollection.getByAttribute("MediaType", "audio"); IWMPMedia media = playlist.get_Item(100); Console.WriteLine(media.name); Console.WriteLine(media.getItemInfo("Lyrics")); //media.setItemInfo("Lyrics", ""); } static void TestSecondTry() { // Is it actually worthwhile doing the second or subsequent attempt? ITunesLibrary lib = new ITunesLibrary(); //lib.MaxSongsToFetch = 1000; lib.LoadSongs(); lib.WaitLoad(); List<Song> songs = lib.Songs.FindAll( delegate(Song s) { LyricsStatus status = s.LyricsStatus; return (status == LyricsStatus.Untried || status == LyricsStatus.Failed || status == LyricsStatus.Success); } ); ILyricsSource source2 = new LyricsSourceLyricsPlugin(); ILyricsSource source1 = new LyricsSourceLyrdb(); ILyricsSource source3 = new LyricsSourceLyricsFly(); Stopwatch sw1 = new Stopwatch(); Stopwatch sw2 = new Stopwatch(); Stopwatch sw3 = new Stopwatch(); int failures = 0; int success1 = 0; int success2 = 0; int success3 = 0; foreach (Song song in songs) { sw1.Start(); string lyrics = source1.GetLyrics(song); sw1.Stop(); if (lyrics == string.Empty) { sw2.Start(); lyrics = source2.GetLyrics(song); sw2.Stop(); if (lyrics == string.Empty) { sw3.Start(); lyrics = source3.GetLyrics(song); sw3.Stop(); if (lyrics == string.Empty) failures++; else success3++; } else success2++; } else success1++; } Console.WriteLine("1st try: successes: {0} ({1}%), time: {2} ({3} each)", success1, (success1 * 100 / songs.Count), sw1.Elapsed, sw1.ElapsedMilliseconds / songs.Count); Console.WriteLine("2st try: successes: {0} ({1}%), time: {2} ({3} each)", success2, (success2 * 100 / songs.Count), sw2.Elapsed, sw2.ElapsedMilliseconds / (songs.Count - success1)); Console.WriteLine("3st try: successes: {0} ({1}%), time: {2} ({3} each)", success3, (success3 * 100 / songs.Count), sw3.Elapsed, sw3.ElapsedMilliseconds / (songs.Count - success1 - success2)); Console.WriteLine("failures: {0} ({1}%)", failures, (failures * 100 / songs.Count)); } static void TestSources() { ITunesLibrary lib = new ITunesLibrary(); lib.MaxSongsToFetch = 150; lib.LoadSongs(); lib.WaitLoad(); List<Song> songs = lib.Songs.FindAll( delegate(Song s) { LyricsStatus status = s.LyricsStatus; return (status == LyricsStatus.Untried || status == LyricsStatus.Failed || status == LyricsStatus.Success); } ); songs = songs.GetRange(0, 10); //TestOneSource(songs, new LyricsSourceLyricWiki()); //TestOneSource(songs, new LyricsSourceLyricWikiHtml()); TestOneSource(songs, new LyricsSourceLyricsPlugin()); TestOneSource(songs, new LyricsSourceLyrdb()); TestOneSource(songs, new LyricsSourceLyricsFly()); } private static void TestOneSource(List<Song> songs, ILyricsSource source) { Console.WriteLine("Testing {0}...", source.Name); int successes = 0; int failures = 0; Stopwatch sw = new Stopwatch(); sw.Start(); foreach (Song song in songs) { if (source.GetLyrics(song) == string.Empty) failures++; else successes++; } sw.Stop(); Console.WriteLine("Successes: {0}, failure: {1}, time: {2} seconds ({3} per song)", successes, failures, sw.Elapsed, sw.ElapsedMilliseconds / songs.Count); } static void lfm_StatusEvent(object sender, LyricsFetchStatusEventArgs e) { System.Diagnostics.Debug.WriteLine(e.Status); } static void TestMetaDataEditor() { string file = @"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\After the fire\Der Kommissar\01 Der Kommissar.wma"; using (MetaDataEditor mde = new MetaDataEditor(file)) { //mde.SetFieldValue("WM/Lyrics", "These are some more of my favourite things"); //mde.SetFieldValue("WM/Genre", "80's rock"); Console.WriteLine(mde.GetFieldValue("WM/Year")); Console.WriteLine(mde.GetFieldValue("WM/Lyrics")); Console.WriteLine(mde.GetFieldValue("Genre")); Console.WriteLine(mde.GetFieldValue("WM/Publisher")); Console.WriteLine(mde.GetFieldValue("unknown")); } } static void TestMetaDataEditor2() { WindowsMediaPlayer wmpPlayer = new WindowsMediaPlayer(); IWMPPlaylist playlist = wmpPlayer.mediaCollection.getByAttribute("MediaType", "audio"); IWMPMedia media = playlist.get_Item(100); Console.WriteLine(media.name); Console.WriteLine(media.getItemInfo("WM/Genre")); Console.WriteLine("-"); using (MetaDataEditor mde = new MetaDataEditor(media.sourceURL)) { //mde.SetFieldValue("WM/Lyrics", "MORE LIKE THIS things"); //mde.SetFieldValue("WM/Genre", "80's rock"); Console.WriteLine(mde.GetFieldValue("WM/Year")); Console.WriteLine(mde.GetFieldValue("WM/Lyrics")); Console.WriteLine(mde.GetFieldValue("WM/Genre")); Console.WriteLine(mde.GetFieldValue("WM/Publisher")); Console.WriteLine(mde.GetFieldValue("unknown")); } } static void TestLyricsSource() { //ILyricsSource strategy = new LyricsSourceLyricWiki(); //ILyricsSource strategy = new LyricsSourceLyricWikiHtml(); //ILyricsSource strategy = new LyricsSourceLyrdb(); //ILyricsSource strategy = new LyricsSourceLyricsPlugin(); ILyricsSource strategy = new LyricsSourceLyricsFly(); //TestSong song = new TestSong("Lips don't hie", "Shakira", "Music of the Sun", ""); //TestSong song = new TestSong("Hips don't lie", "Shakira", "Music of the Sun", ""); //TestSong song = new TestSong("Pon de replay", "Rihanna", "Music of the Sun", ""); //TestSong song = new TestSong("I Love to Move in Here", "Moby", "Last Night", ""); TestSong song = new TestSong("Year 3000", "Busted", "", ""); Console.WriteLine(song); Console.WriteLine(strategy.GetLyrics(song)); } static void TestMetaDataLookup() { string file = @"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\After the fire\Der Kommissar\01 Der Kommissar.mp3"; //string file = @"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\Alanis Morissette\So-Called Chaos\01 Eight Easy Steps.mp3"; //string file = @"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\Unknown Artist\Unknown Album\16 Pump UP the jam.mp3"; //string file = @"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\Ziqo\Unknown Album\01 Vamos Embora.mp3"; MetaDataLookup req = new MetaDataLookup(); Console.WriteLine("looking up '{0}'...", file); req.Lookup(file); Console.WriteLine("puid={0}", req.MetaData.Puid); Console.WriteLine("title={0}", req.MetaData.Title); Console.WriteLine("artist={0}", req.MetaData.Artist); Console.WriteLine("genre={0}", req.MetaData.Genre); } static void TestManyMetaDataLookup() { ITunesLibrary lib = new ITunesLibrary(); lib.MaxSongsToFetch = 50; lib.LoadSongs(); lib.WaitLoad(); Stopwatch sw = new Stopwatch(); sw.Start(); try { foreach (Song song in lib.Songs) { MetaDataLookup req = new MetaDataLookup(); //MetaDataLookupOld req = new MetaDataLookupOld(); req.Lookup(song); if (req.Status == MetaDataStatus.Success) { if (song.Title == req.MetaData.Title && song.Artist == req.MetaData.Artist) System.Diagnostics.Debug.WriteLine(String.Format("same: {0}", song)); else System.Diagnostics.Debug.WriteLine(String.Format("different: {0}. title={1}, artist={2}", song, req.MetaData.Title, req.MetaData.Artist)); } else { System.Diagnostics.Debug.WriteLine(String.Format("failed: {0}", song)); } } } finally { sw.Stop(); System.Diagnostics.Debug.WriteLine(String.Format("Tried {0} song in {1} ({2} secs per song)", lib.Songs.Count, sw.Elapsed, (sw.ElapsedMilliseconds / lib.Songs.Count) / 1000)); } } static void Main(string[] args) { Console.WriteLine("start"); TestSources(); //TestManyMetaDataLookup(); //Console.WriteLine("start"); //string value = GetFieldByName(@"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\After the fire\Der Kommissar\01 Der Kommissar.mp3", "WM/Lyrics"); //Console.WriteLine(value); //Console.WriteLine(GetFieldByName(@"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\After the fire\Der Kommissar\01 Der Kommissar.mp3", "WM/Genre")); //Console.WriteLine(GetFieldByName(@"C:\Documents and Settings\Admin_2\My Documents\My Music\iTunes\iTunes Music\After the fire\Der Kommissar\01 Der Kommissar.mp3", "WM/Publisher")); //Console.ReadKey(); //------------------------------------------------------------ //System.Diagnostics.Debug.WriteLine("start"); //Stopwatch watch = new Stopwatch(); //SongLibrary library = new WmpLibrary(); ////SongLibrary library = new ITunesLibrary(); ////library.MaxSongsToFetch = 1000; //watch.Start(); //library.LoadSongs(); //library.WaitLoad(); //watch.Stop(); //System.Diagnostics.Debug.WriteLine(String.Format("Loaded {0} songs in {1}ms", // library.Songs.Count, watch.ElapsedMilliseconds)); //------------------------------------------------------------ //LyricsFetchManager lfm = new LyricsFetchManager(); //lfm.AutoUpdateLyrics = true; //lfm.StatusEvent += new EventHandler<FetchStatusEventArgs>(lfm_StatusEvent); //lfm.Sources.Add(new LyricsSourceLyrdb()); //lfm.Sources.Add(new LyricsSourceLyricWiki()); //System.Diagnostics.Debug.WriteLine("--------------"); //Song song = new TestSong("seconds", "u2", "Music of the Sun", ""); //lfm.Queue(song); //lfm.Start(); //lfm.WaitUntilFinished(); //System.Diagnostics.Debug.WriteLine(song); //System.Diagnostics.Debug.Write(song.Lyrics); //System.Diagnostics.Debug.WriteLine("========"); //------------------------------------------------------------ //System.Diagnostics.Debug.WriteLine(Wmp.Instance.Player.versionInfo); //SongLibrary library = new WmpLibrary(); //library.MaxSongsToFetch = 100; //foreach (Song x in library.Songs) // System.Diagnostics.Debug.WriteLine(x); //------------------------------------------------------------ //IWMPPlaylist playlist = Wmp.Instance.AllTracks; //System.Diagnostics.Debug.WriteLine(Wmp.Instance.Player.versionInfo); //for (int i = 0; i < playlist.count; i++) { // IWMPMedia media = playlist.get_Item(i); // System.Diagnostics.Debug.WriteLine(media.name); //} Console.WriteLine("done"); Console.ReadKey(); } } }
Java
#!/bin/sh # AwesomeTTS text-to-speech add-on for Anki # Copyright (C) 2010-Present Anki AwesomeTTS Development Team # # 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 <http://www.gnu.org/licenses/>. addon_id="301952613" set -e if [ -z "$1" ] then echo 'Please specify your Anki addons directory.' 1>&2 echo 1>&2 echo " Usage: $0 <target>" 1>&2 echo " e.g.: $0 ~/.local/share/Anki2/addons21" 1>&2 exit 1 fi target=${1%/} case $target in */addons21) ;; *) echo 'Expected target path to end in "/addons21".' 1>&2 exit 1 esac case $target in /*) ;; *) target=$PWD/$target esac if [ ! -d "$target" ] then echo "$target is not a directory." 1>&2 exit 1 fi mkdir -p "$target/$addon_id" if [ -f "$target/$addon_id/awesometts/config.db" ] then echo 'Saving configuration...' saveConf=$(mktemp /tmp/config.XXXXXXXXXX.db) cp -v "$target/$addon_id/awesometts/config.db" "$saveConf" fi if [ -d "$target/$addon_id/awesometts/.cache" ] then echo 'Saving cache...' saveCache=$(mktemp -d /tmp/anki_cacheXXXXXXXXXX) cp -rv "$target/$addon_id/awesometts/.cache/*" "$saveCache/" fi echo 'Cleaning up...' rm -fv "$target/$addon_id/__init__.py"* rm -rfv "$target/$addon_id/awesometts" oldPwd=$PWD cd "$(dirname "$0")/.." || exit 1 echo 'Linking...' ln -sv "$PWD/$addon_id/__init__.py" "$target" ln -sv "$PWD/$addon_id/awesometts" "$target" cd "$oldPwd" || exit 1 if [ -n "$saveConf" ] then echo 'Restoring configuration...' mv -v "$saveConf" "$target/$addon_id/awesometts/config.db" fi if [ -n "$saveCache" ] then echo 'Restoring cache...' mv -rv "$saveConf/*" "$target/$addon_id/awesometts/.cache/" fi
Java
#pragma once #ifndef HPTT_PARAM_PARAMETER_TRANS_H_ #define HPTT_PARAM_PARAMETER_TRANS_H_ #include <array> #include <utility> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <hptt/types.h> #include <hptt/tensor.h> #include <hptt/arch/compat.h> #include <hptt/util/util_trans.h> #include <hptt/kernels/kernel_trans.h> namespace hptt { template <typename FloatType, TensorUInt ORDER> class TensorMergedWrapper : public TensorWrapper<FloatType, ORDER> { public: TensorMergedWrapper() = delete; TensorMergedWrapper(const TensorWrapper<FloatType, ORDER> &tensor, const std::unordered_set<TensorUInt> &merge_set); HPTT_INL FloatType &operator[](const TensorIdx * RESTRICT indices); HPTT_INL const FloatType &operator[]( const TensorIdx * RESTRICT indices) const; HPTT_INL FloatType &operator[](TensorIdx **indices); HPTT_INL const FloatType &operator[](const TensorIdx **indices) const; private: TensorUInt begin_order_idx_, merged_order_; TensorUInt merge_idx_(const std::unordered_set<TensorUInt> &merge_set); }; template <typename TensorType, bool UPDATE_OUT> struct ParamTrans { // Type alias and constant values using Float = typename TensorType::Float; using Deduced = DeducedFloatType<Float>; using KernelPack = KernelPackTrans<Float, UPDATE_OUT>; static constexpr auto ORDER = TensorType::TENSOR_ORDER; ParamTrans(const TensorType &input_tensor, TensorType &output_tensor, const std::array<TensorUInt, ORDER> &perm, const Deduced alpha, const Deduced beta); HPTT_INL bool is_common_leading() const; HPTT_INL void set_coef(const Deduced alpha, const Deduced beta); HPTT_INL const KernelPack &get_kernel() const; void set_lin_wrapper_loop(const TensorUInt size_kn_inld, const TensorUInt size_kn_outld); void set_sca_wrapper_loop(const TensorUInt size_kn_in_inld, const TensorUInt size_kn_in_outld, const TensorUInt size_kn_out_inld, const TensorUInt size_kn_out_outld); void reset_data(const Float *data_in, Float *data_out); private: TensorUInt merge_idx_(const TensorType &input_tensor, const TensorType &output_tensor, const std::array<TensorUInt, ORDER> &perm); // They need to be initialized before merging std::unordered_set<TensorUInt> input_merge_set_, output_merge_set_; KernelPackTrans<Float, UPDATE_OUT> kn_; public: std::array<TensorUInt, ORDER> perm; Deduced alpha, beta; TensorIdx stride_in_inld, stride_in_outld, stride_out_inld, stride_out_outld; TensorUInt begin_order_idx; const TensorUInt merged_order; // Put the merged tensors here, they must be initialized after merging TensorMergedWrapper<Float, ORDER> input_tensor, output_tensor; }; /* * Import implementation */ #include "parameter_trans.tcc" } #endif // HPTT_PARAM_PARAMETER_TRANS_H_
Java
package tencentcloud.constant; /** * @author fanwh * @version v1.0 * @decription * @create on 2017/11/10 16:09 */ public class RegionConstants { /** * 北京 */ public static final String PEKING = "ap-beijing"; /** * 上海 */ public static final String SHANGHAI = "ap-shanghai"; /** * 香港 */ public static final String HONGKONG = "ap-hongkong"; /** * 多伦多 */ public static final String TORONTO = "na-toronto"; /** * 硅谷 */ public static final String SILICON_VALLEY = "na-siliconvalley"; /** * 新加坡 */ public static final String SINGAPORE = "ap-singapore"; /** * 上海金融 */ public static final String SHANGHAI_FSI = "ap-shanghai-fsi"; /** * 广州open专区 */ public static final String GUANGZHOU_OPEN = "ap-guangzhou-open"; /** * 深圳金融 */ public static final String SHENZHEN_FSI = "ap-shenzhen-fsi"; }
Java
/* The following code was generated by JFlex 1.6.1 */ package com.jim_project.interprete.parser.previo; import com.jim_project.interprete.parser.AnalizadorLexico; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.6.1 * from the specification file <tt>C:/Users/alber_000/Documents/NetBeansProjects/tfg-int-rpretes/jim/src/main/java/com/jim_project/interprete/parser/previo/lexico.l</tt> */ public class PrevioLex extends AnalizadorLexico { /** This character denotes the end of file */ public static final int YYEOF = -1; /** initial size of the lookahead buffer */ private static final int ZZ_BUFFERSIZE = 16384; /** lexical states */ public static final int YYINITIAL = 0; /** * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l * at the beginning of a line * l is of the form l = 2*k, k a non negative integer */ private static final int ZZ_LEXSTATE[] = { 0, 0 }; /** * Translates characters to character classes */ private static final String ZZ_CMAP_PACKED = "\11\0\1\3\1\2\1\51\1\3\1\1\22\0\1\3\1\16\1\0"+ "\1\5\1\0\1\20\2\0\3\20\1\15\1\20\1\14\1\0\1\20"+ "\1\10\11\7\2\0\1\13\1\17\3\0\3\6\1\50\1\42\1\24"+ "\1\30\1\40\1\23\2\4\1\41\1\4\1\47\1\31\1\44\3\4"+ "\1\32\2\4\1\37\1\11\1\12\1\11\1\20\1\0\1\20\3\0"+ "\3\6\1\46\1\36\1\22\1\25\1\34\1\21\2\4\1\35\1\4"+ "\1\45\1\26\1\43\3\4\1\27\2\4\1\33\1\11\1\12\1\11"+ "\12\0\1\51\u1fa2\0\1\51\1\51\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\udfe6\0"; /** * Translates characters to character classes */ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); /** * Translates DFA states to action switch labels. */ private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = "\1\0\1\1\2\2\1\1\1\2\1\3\2\4\2\5"+ "\1\1\2\6\1\1\1\6\6\1\1\3\2\1\1\3"+ "\1\7\1\3\1\5\1\10\1\11\1\12\1\0\1\13"+ "\10\7\1\14\4\7\1\15\2\7\1\16\1\7\1\17"+ "\1\7\1\20"; private static int [] zzUnpackAction() { int [] result = new int[55]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; } private static int zzUnpackAction(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ int l = packed.length(); while (i < l) { int count = packed.charAt(i++); int value = packed.charAt(i++); do result[j++] = value; while (--count > 0); } return j; } /** * Translates a state to a row index in the transition table */ private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\52\0\124\0\52\0\176\0\250\0\322\0\374"+ "\0\52\0\u0126\0\176\0\u0150\0\u017a\0\u01a4\0\u01ce\0\52"+ "\0\u01f8\0\u0222\0\u024c\0\u0276\0\u02a0\0\u02ca\0\u02f4\0\u031e"+ "\0\u0348\0\u0372\0\176\0\u039c\0\u03c6\0\52\0\52\0\52"+ "\0\u03f0\0\176\0\u041a\0\u0444\0\u046e\0\u0498\0\u04c2\0\u04ec"+ "\0\u0516\0\u0540\0\52\0\u056a\0\u0594\0\u05be\0\u05e8\0\176"+ "\0\u0612\0\u063c\0\176\0\u0666\0\176\0\u0690\0\176"; private static int [] zzUnpackRowMap() { int [] result = new int[55]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; } private static int zzUnpackRowMap(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ int l = packed.length(); while (i < l) { int high = packed.charAt(i++) << 16; result[j++] = high | packed.charAt(i++); } return j; } /** * The transition table of the DFA */ private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = "\1\2\1\3\2\4\1\5\1\6\1\7\1\10\1\11"+ "\1\12\1\13\1\14\1\15\1\16\1\17\1\2\1\20"+ "\1\21\1\5\1\22\1\5\1\23\2\5\1\24\2\5"+ "\1\25\1\5\1\26\1\27\1\30\1\5\1\31\1\32"+ "\3\5\1\7\1\5\1\7\55\0\1\4\53\0\1\33"+ "\1\0\1\33\2\0\2\33\6\0\30\33\1\0\1\6"+ "\1\3\1\4\47\6\4\0\1\33\1\0\1\33\1\34"+ "\1\0\2\33\6\0\30\33\10\0\2\10\45\0\1\33"+ "\1\0\1\33\1\35\1\0\2\33\6\0\30\33\15\0"+ "\1\36\51\0\1\37\52\0\1\40\53\0\1\41\36\0"+ "\1\33\1\0\1\33\2\0\2\33\6\0\1\33\1\42"+ "\26\33\5\0\1\33\1\0\1\33\2\0\2\33\6\0"+ "\3\33\1\42\24\33\5\0\1\33\1\0\1\33\2\0"+ "\2\33\6\0\5\33\1\43\22\33\5\0\1\33\1\0"+ "\1\33\2\0\2\33\6\0\10\33\1\44\17\33\5\0"+ "\1\33\1\0\1\33\2\0\2\33\6\0\13\33\1\45"+ "\14\33\5\0\1\33\1\0\1\33\2\0\2\33\6\0"+ "\5\33\1\46\22\33\5\0\1\33\1\0\1\33\1\34"+ "\1\0\2\33\6\0\24\33\1\47\3\33\5\0\1\33"+ "\1\0\1\33\2\0\2\33\6\0\17\33\1\50\10\33"+ "\5\0\1\33\1\0\1\33\2\0\2\33\6\0\10\33"+ "\1\51\17\33\5\0\1\33\1\0\1\33\1\34\1\0"+ "\2\33\6\0\26\33\1\52\1\33\10\0\2\34\50\0"+ "\2\35\44\0\1\41\4\0\1\53\45\0\1\33\1\0"+ "\1\33\2\0\2\33\6\0\6\33\1\54\21\33\5\0"+ "\1\33\1\0\1\33\2\0\2\33\6\0\11\33\1\55"+ "\16\33\5\0\1\33\1\0\1\33\2\0\2\33\6\0"+ "\1\56\27\33\5\0\1\33\1\0\1\33\2\0\2\33"+ "\6\0\5\33\1\57\22\33\5\0\1\33\1\0\1\33"+ "\2\0\2\33\6\0\25\33\1\60\2\33\5\0\1\33"+ "\1\0\1\33\2\0\2\33\6\0\2\33\1\61\25\33"+ "\5\0\1\33\1\0\1\33\2\0\2\33\6\0\10\33"+ "\1\62\17\33\5\0\1\33\1\0\1\33\2\0\2\33"+ "\6\0\27\33\1\60\5\0\1\33\1\0\1\33\2\0"+ "\2\33\6\0\5\33\1\63\22\33\5\0\1\33\1\0"+ "\1\33\2\0\2\33\6\0\10\33\1\63\17\33\5\0"+ "\1\33\1\0\1\33\2\0\2\33\6\0\14\33\1\64"+ "\13\33\5\0\1\33\1\0\1\33\2\0\2\33\6\0"+ "\22\33\1\65\5\33\5\0\1\33\1\0\1\33\2\0"+ "\2\33\6\0\20\33\1\66\7\33\5\0\1\33\1\0"+ "\1\33\2\0\2\33\6\0\23\33\1\65\4\33\5\0"+ "\1\33\1\0\1\33\2\0\2\33\6\0\15\33\1\67"+ "\12\33\5\0\1\33\1\0\1\33\2\0\2\33\6\0"+ "\21\33\1\67\6\33\1\0"; private static int [] zzUnpackTrans() { int [] result = new int[1722]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; } private static int zzUnpackTrans(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ int l = packed.length(); while (i < l) { int count = packed.charAt(i++); int value = packed.charAt(i++); value--; do result[j++] = value; while (--count > 0); } return j; } /* error codes */ private static final int ZZ_UNKNOWN_ERROR = 0; private static final int ZZ_NO_MATCH = 1; private static final int ZZ_PUSHBACK_2BIG = 2; /* error messages for the codes above */ private static final String ZZ_ERROR_MSG[] = { "Unknown internal scanner error", "Error: could not match input", "Error: pushback value was too large" }; /** * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> */ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = "\1\0\1\11\1\1\1\11\4\1\1\11\6\1\1\11"+ "\15\1\3\11\1\0\11\1\1\11\14\1"; private static int [] zzUnpackAttribute() { int [] result = new int[55]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; } private static int zzUnpackAttribute(String packed, int offset, int [] result) { int i = 0; /* index in packed string */ int j = offset; /* index in unpacked array */ int l = packed.length(); while (i < l) { int count = packed.charAt(i++); int value = packed.charAt(i++); do result[j++] = value; while (--count > 0); } return j; } /** the input device */ private java.io.Reader zzReader; /** the current state of the DFA */ private int zzState; /** the current lexical state */ private int zzLexicalState = YYINITIAL; /** this buffer contains the current text to be matched and is the source of the yytext() string */ private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; /** the textposition at the last accepting state */ private int zzMarkedPos; /** the current text position in the buffer */ private int zzCurrentPos; /** startRead marks the beginning of the yytext() string in the buffer */ private int zzStartRead; /** endRead marks the last character in the buffer, that has been read from input */ private int zzEndRead; /** number of newlines encountered up to the start of the matched text */ private int yyline; /** the number of characters up to the start of the matched text */ private int yychar; /** * the number of characters from the last newline up to the start of the * matched text */ private int yycolumn; /** * zzAtBOL == true <=> the scanner is currently at the beginning of a line */ private boolean zzAtBOL = true; /** zzAtEOF == true <=> the scanner is at the EOF */ private boolean zzAtEOF; /** denotes if the user-EOF-code has already been executed */ private boolean zzEOFDone; /** * The number of occupied positions in zzBuffer beyond zzEndRead. * When a lead/high surrogate has been read from the input stream * into the final zzBuffer position, this will have a value of 1; * otherwise, it will have a value of 0. */ private int zzFinalHighSurrogate = 0; /* user code: */ private PrevioParser yyparser; /** * Constructor de clase. * @param r Referencia al lector de entrada. * @param p Referencia al analizador sintáctico. */ public PrevioLex(java.io.Reader r, PrevioParser p) { this(r); yyparser = p; } /** * Creates a new scanner * * @param in the java.io.Reader to read input from. */ public PrevioLex(java.io.Reader in) { this.zzReader = in; } /** * Unpacks the compressed character translation table. * * @param packed the packed character translation table * @return the unpacked character translation table */ private static char [] zzUnpackCMap(String packed) { char [] map = new char[0x110000]; int i = 0; /* index in packed string */ int j = 0; /* index in unpacked array */ while (i < 184) { int count = packed.charAt(i++); char value = packed.charAt(i++); do map[j++] = value; while (--count > 0); } return map; } /** * Refills the input buffer. * * @return <code>false</code>, iff there was new input. * * @exception java.io.IOException if any I/O-Error occurs */ private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ if (zzStartRead > 0) { zzEndRead += zzFinalHighSurrogate; zzFinalHighSurrogate = 0; System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0, zzEndRead-zzStartRead); /* translate stored positions */ zzEndRead-= zzStartRead; zzCurrentPos-= zzStartRead; zzMarkedPos-= zzStartRead; zzStartRead = 0; } /* is the buffer big enough? */ if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) { /* if not: blow it up */ char newBuffer[] = new char[zzBuffer.length*2]; System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); zzBuffer = newBuffer; zzEndRead += zzFinalHighSurrogate; zzFinalHighSurrogate = 0; } /* fill the buffer with new input */ int requested = zzBuffer.length - zzEndRead; int numRead = zzReader.read(zzBuffer, zzEndRead, requested); /* not supposed to occur according to specification of java.io.Reader */ if (numRead == 0) { throw new java.io.IOException("Reader returned 0 characters. See JFlex examples for workaround."); } if (numRead > 0) { zzEndRead += numRead; /* If numRead == requested, we might have requested to few chars to encode a full Unicode character. We assume that a Reader would otherwise never return half characters. */ if (numRead == requested) { if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) { --zzEndRead; zzFinalHighSurrogate = 1; } } /* potentially more input available */ return false; } /* numRead < 0 ==> end of stream */ return true; } /** * Closes the input stream. */ public final void yyclose() throws java.io.IOException { zzAtEOF = true; /* indicate end of file */ zzEndRead = zzStartRead; /* invalidate buffer */ if (zzReader != null) zzReader.close(); } /** * Resets the scanner to read from a new input stream. * Does not close the old reader. * * All internal variables are reset, the old input stream * <b>cannot</b> be reused (internal buffer is discarded and lost). * Lexical state is set to <tt>ZZ_INITIAL</tt>. * * Internal scan buffer is resized down to its initial length, if it has grown. * * @param reader the new input stream */ public final void yyreset(java.io.Reader reader) { zzReader = reader; zzAtBOL = true; zzAtEOF = false; zzEOFDone = false; zzEndRead = zzStartRead = 0; zzCurrentPos = zzMarkedPos = 0; zzFinalHighSurrogate = 0; yyline = yychar = yycolumn = 0; zzLexicalState = YYINITIAL; if (zzBuffer.length > ZZ_BUFFERSIZE) zzBuffer = new char[ZZ_BUFFERSIZE]; } /** * Returns the current lexical state. */ public final int yystate() { return zzLexicalState; } /** * Enters a new lexical state * * @param newState the new lexical state */ public final void yybegin(int newState) { zzLexicalState = newState; } /** * Returns the text matched by the current regular expression. */ public final String yytext() { return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); } /** * Returns the character at position <tt>pos</tt> from the * matched text. * * It is equivalent to yytext().charAt(pos), but faster * * @param pos the position of the character to fetch. * A value from 0 to yylength()-1. * * @return the character at position pos */ public final char yycharat(int pos) { return zzBuffer[zzStartRead+pos]; } /** * Returns the length of the matched text region. */ public final int yylength() { return zzMarkedPos-zzStartRead; } /** * Reports an error that occured while scanning. * * In a wellformed scanner (no or only correct usage of * yypushback(int) and a match-all fallback rule) this method * will only be called with things that "Can't Possibly Happen". * If this method is called, something is seriously wrong * (e.g. a JFlex bug producing a faulty scanner etc.). * * Usual syntax/scanner level error handling should be done * in error fallback rules. * * @param errorCode the code of the errormessage to display */ private void zzScanError(int errorCode) { String message; try { message = ZZ_ERROR_MSG[errorCode]; } catch (ArrayIndexOutOfBoundsException e) { message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; } throw new Error(message); } /** * Pushes the specified amount of characters back into the input stream. * * They will be read again by then next call of the scanning method * * @param number the number of characters to be read again. * This number must not be greater than yylength()! */ public void yypushback(int number) { if ( number > yylength() ) zzScanError(ZZ_PUSHBACK_2BIG); zzMarkedPos -= number; } /** * Contains user EOF-code, which will be executed exactly once, * when the end of file is reached */ private void zzDoEOF() throws java.io.IOException { if (!zzEOFDone) { zzEOFDone = true; yyclose(); } } /** * Resumes scanning until the next regular expression is matched, * the end of input is encountered or an I/O-Error occurs. * * @return the next token * @exception java.io.IOException if any I/O-Error occurs */ public int yylex() throws java.io.IOException { int zzInput; int zzAction; // cached fields: int zzCurrentPosL; int zzMarkedPosL; int zzEndReadL = zzEndRead; char [] zzBufferL = zzBuffer; char [] zzCMapL = ZZ_CMAP; int [] zzTransL = ZZ_TRANS; int [] zzRowMapL = ZZ_ROWMAP; int [] zzAttrL = ZZ_ATTRIBUTE; while (true) { zzMarkedPosL = zzMarkedPos; zzAction = -1; zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; zzState = ZZ_LEXSTATE[zzLexicalState]; // set up zzAction for empty match case: int zzAttributes = zzAttrL[zzState]; if ( (zzAttributes & 1) == 1 ) { zzAction = zzState; } zzForAction: { while (true) { if (zzCurrentPosL < zzEndReadL) { zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL); zzCurrentPosL += Character.charCount(zzInput); } else if (zzAtEOF) { zzInput = YYEOF; break zzForAction; } else { // store back cached positions zzCurrentPos = zzCurrentPosL; zzMarkedPos = zzMarkedPosL; boolean eof = zzRefill(); // get translated positions and possibly new buffer zzCurrentPosL = zzCurrentPos; zzMarkedPosL = zzMarkedPos; zzBufferL = zzBuffer; zzEndReadL = zzEndRead; if (eof) { zzInput = YYEOF; break zzForAction; } else { zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL); zzCurrentPosL += Character.charCount(zzInput); } } int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; if (zzNext == -1) break zzForAction; zzState = zzNext; zzAttributes = zzAttrL[zzState]; if ( (zzAttributes & 1) == 1 ) { zzAction = zzState; zzMarkedPosL = zzCurrentPosL; if ( (zzAttributes & 8) == 8 ) break zzForAction; } } } // store back cached position zzMarkedPos = zzMarkedPosL; if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; zzDoEOF(); { return 0; } } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { case 1: { yyparser.programa().error().deCaracterNoReconocido(yytext()); } case 17: break; case 2: { } case 18: break; case 3: { yyparser.yylval = new PrevioParserVal(yytext()); return PrevioParser.ETIQUETA; } case 19: break; case 4: { yyparser.yylval = new PrevioParserVal(yytext()); return PrevioParser.NUMERO; } case 20: break; case 5: { yyparser.yylval = new PrevioParserVal(yytext()); return PrevioParser.VARIABLE; } case 21: break; case 6: { return yycharat(0); } case 22: break; case 7: { yyparser.yylval = new PrevioParserVal(yytext()); return PrevioParser.IDMACRO; } case 23: break; case 8: { return PrevioParser.FLECHA; } case 24: break; case 9: { return PrevioParser.DECREMENTO; } case 25: break; case 10: { return PrevioParser.INCREMENTO; } case 26: break; case 11: { return PrevioParser.IF; } case 27: break; case 12: { return PrevioParser.DISTINTO; } case 28: break; case 13: { return PrevioParser.END; } case 29: break; case 14: { return PrevioParser.GOTO; } case 30: break; case 15: { return PrevioParser.LOOP; } case 31: break; case 16: { return PrevioParser.WHILE; } case 32: break; default: zzScanError(ZZ_NO_MATCH); } } } } }
Java
#include "cdi.h" #include "mds_reader.h" #include "common.h" SessionInfo mds_ses; TocInfo mds_toc; DiscType mds_Disctype=CdRom; struct file_TrackInfo { u32 FAD; u32 Offset; u32 SectorSize; }; file_TrackInfo mds_Track[101]; FILE* fp_mdf=0; u8 mds_SecTemp[5120]; u32 mds_TrackCount; u32 mds_ReadSSect(u8* p_out,u32 sector,u32 secsz) { for (u32 i=0;i<mds_TrackCount;i++) { if (mds_Track[i+1].FAD>sector) { u32 fad_off=sector-mds_Track[i].FAD; fseek(fp_mdf,mds_Track[i].Offset+fad_off*mds_Track[i].SectorSize,SEEK_SET); fread(mds_SecTemp,mds_Track[i].SectorSize,1,fp_mdf); ConvertSector(mds_SecTemp,p_out,mds_Track[i].SectorSize,secsz,sector); return mds_Track[i].SectorSize; } } return 0; } void FASTCALL mds_DriveReadSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz) { // printf("MDS/NRG->Read : Sector %d , size %d , mode %d \n",StartSector,SectorCount,secsz); while(SectorCount--) { mds_ReadSSect(buff,StartSector,secsz); buff+=secsz; StartSector++; } } void mds_CreateToc() { //clear structs to 0xFF :) memset(mds_Track,0xFF,sizeof(mds_Track)); memset(&mds_ses,0xFF,sizeof(mds_ses)); memset(&mds_toc,0xFF,sizeof(mds_toc)); printf("\n--GD toc info start--\n"); int track=0; bool CD_DA=false; bool CD_M1=false; bool CD_M2=false; strack* last_track=&sessions[nsessions-1].tracks[sessions[nsessions-1].ntracks-1]; mds_ses.SessionCount=nsessions; mds_ses.SessionsEndFAD=last_track->sector+last_track->sectors+150; mds_toc.LeadOut.FAD=last_track->sector+last_track->sectors+150; mds_toc.LeadOut.Addr=0; mds_toc.LeadOut.Control=0; mds_toc.LeadOut.Session=0; printf("Last Sector : %d\n",mds_ses.SessionsEndFAD); printf("Session count : %d\n",mds_ses.SessionCount); mds_toc.FistTrack=1; for (int s=0;s<nsessions;s++) { printf("Session %d:\n",s); session* ses=&sessions[s]; printf(" Track Count: %d\n",ses->ntracks); for (int t=0;t< ses->ntracks ;t++) { strack* c_track=&ses->tracks[t]; //pre gap if (t==0) { mds_ses.SessionFAD[s]=c_track->sector+150; mds_ses.SessionStart[s]=track+1; printf(" Session start FAD: %d\n",mds_ses.SessionFAD[s]); } //verify(cdi_track->dwIndexCount==2); printf(" track %d:\n",t); printf(" Type : %d\n",c_track->mode); if (c_track->mode>=2) CD_M2=true; if (c_track->mode==1) CD_M1=true; if (c_track->mode==0) CD_DA=true; //verify((c_track->mode==236) || (c_track->mode==169)) mds_toc.tracks[track].Addr=0;//hmm is that ok ? mds_toc.tracks[track].Session=s; mds_toc.tracks[track].Control=c_track->mode>0?4:0;//mode 1 , 2 , else are data , 0 is audio :) mds_toc.tracks[track].FAD=c_track->sector+150; mds_Track[track].FAD=mds_toc.tracks[track].FAD; mds_Track[track].SectorSize=c_track->sectorsize; mds_Track[track].Offset=(u32)c_track->offset; printf(" Start FAD : %d\n",mds_Track[track].FAD); printf(" SectorSize : %d\n",mds_Track[track].SectorSize); printf(" File Offset : %d\n",mds_Track[track].Offset); //main track data track++; } } //normal CDrom : mode 1 tracks .All sectors on the track are mode 1.Mode 2 was defined on the same book , but is it ever used? if yes , how can i detect //cd XA ??? //CD Extra : session 1 is audio , session 2 is data //cd XA : mode 2 tracks.Form 1/2 are selected per sector.It allows mixing of mode1/mode2 tracks ? //CDDA : audio tracks only <- thats simple =P /* if ((CD_M1==true) && (CD_DA==false) && (CD_M2==false)) mds_Disctype = CdRom; else if (CD_M2) mds_Disctype = CdRom_XA; else if (CD_DA && CD_M1) mds_Disctype = CdRom_Extra; else mds_Disctype=CdRom;//hmm? */ if (nsessions==1 && (CD_M1 | CD_M2)) mds_Disctype = CdRom; //hack so that non selfboot stuff works on utopia else { if ((CD_M1==true) && (CD_DA==false) && (CD_M2==false)) mds_Disctype = CdRom; //is that even correct ? what if its multysessions ? ehh ? what then ??? else if (CD_M2) mds_Disctype = CdRom_XA; // XA XA ! its mode 2 wtf ? else if (CD_DA && CD_M1) mds_Disctype = CdRom_XA; //data + audio , duno wtf as@!#$ lets make it _XA since it seems to boot else if (CD_DA && !CD_M1 && !CD_M2) mds_Disctype = CdDA; //audio else mds_Disctype=CdRom_XA;//and hope for the best } /* bool data = CD_M1 | CD_M2; bool audio=CD_DA; if (data && audio) mds_Disctype = CdRom_XA; //Extra/CdRom won't boot , so meh else if (data) mds_Disctype = CdRom; //only data else mds_Disctype = CdDA; //only audio */ mds_toc.LastTrack=track; mds_TrackCount=track; printf("--GD toc info end--\n\n"); } bool mds_init(wchar* file) { wchar fn[512]=L""; bool rv=false; if (rv==false && parse_mds(file,false)) { bool found=false; if (wcslen(file)>4) { wcscpy(&fn[0],file); size_t len=wcslen(fn); wcscpy(&fn[len-4],L".mdf"); fp_mdf=_tfopen(fn,L"rb"); found=fp_mdf!=0; } if (!found) { if (GetFile(fn,L"mds images (*.mds) \0*.mdf\0\0")==1) { fp_mdf=_tfopen(fn,L"rb"); found=true; } } if (!found) return false; rv=true; } if (rv==false && parse_nrg(file,false)) { rv=true; fp_mdf=_tfopen(file,L"rb"); } if (rv==false) return false; /* for(int j=0;j<nsessions;j++) for(int i=0;i<sessions[j].ntracks;i++) { printf("Session %d Track %d mode %d/%d sector %d count %d offset %I64d\n", sessions[j].session_, sessions[j].tracks[i].track, sessions[j].tracks[i].mode, sessions[j].tracks[i].sectorsize, sessions[j].tracks[i].sector, sessions[j].tracks[i].sectors, sessions[j].tracks[i].offset); }*/ mds_CreateToc(); return true; } void mds_term() { if (fp_mdf) fclose(fp_mdf); fp_mdf=0; } u32 FASTCALL mds_DriveGetDiscType() { return mds_Disctype; } void mds_DriveGetTocInfo(TocInfo* toc,DiskArea area) { verify(area==SingleDensity); memcpy(toc,&mds_toc,sizeof(TocInfo)); } void mds_GetSessionsInfo(SessionInfo* sessions) { memcpy(sessions,&mds_ses,sizeof(SessionInfo)); } struct MDSDiskWrapper : Disc { MDSDiskWrapper() { } bool TryOpen(wchar* file) { if (mds_init(file)) { //printf("Session count %d:\n",nsessions); //s32 tr_c = 1; for (s32 s=0;s<nsessions;++s) { //printf("Session %d:\n",s); session* ses=&mds_sessions[s]; //printf(" Track Count: %d\n",ses->ntracks); Track tr; for (s32 t=0;t< ses->ntracks;++t) { strack* c_track=&ses->tracks[t]; if (t==0) { Session ts; ts.FirstTrack = t + 1;//(tr_c++); ts.StartFAD = c_track->sector+150; sessions.push_back(ts); //printf(" Session start FAD: %d\n",mds_ses.SessionFAD[s]); } tr.ADDR = 0; tr.StartFAD = c_track->sector+150; tr.EndFAD = 0; tr.CTRL = c_track->mode>0?4:0; //printf("SECTOR SIZE %u\n",c_track->sectorsize); tr.file = new RawTrackFile(fp_mdf,(u32)c_track->offset,tr.StartFAD,c_track->sectorsize,false); tracks.push_back(tr); } } type=mds_Disctype; LeadOut.ADDR=0; LeadOut.CTRL=0; LeadOut.StartFAD=549300; EndFAD=549300; return true; } return false; } ~MDSDiskWrapper() { mds_term(); } }; Disc* mds_parse(wchar* fname) { MDSDiskWrapper* dsk = new MDSDiskWrapper(); if (!dsk) { return 0; } if (dsk->TryOpen(fname)) { wprintf(L"\n\n Loaded %s\n\n",fname); } else { wprintf(L"\n\n Unable to load %s \n\n",fname); delete dsk; return 0; } return dsk; }
Java
<!DOCTYPE html> <html> <head> <title></title> <!--Import Google Icon Font--> <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script></head> <body> <a class="btn btn-floating btn-large waves-effect waves-light red"><i class="material-icons">add</i></a> <a class="waves-effect waves-teal btn-flat">Button</a> </body> </html>
Java
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Ksana Humanity Platform</title> <!--<script src="../node_webkit/jslib/ksanajslib.min.js"></script>//--> <script src="../node_webkit/jslib/require.js" data-main="../node_webkit/jslib/ksanajslib"></script> <link rel="stylesheet" href="../node_webkit/css/bootstrap.css"></link> <link rel="stylesheet" href="css/tags.css"></link> </head> <body style="overflow-x:hidden;"> <div class="mainview"> <div class="rows"> <div class="col-5" data-aura-widget="controller-widget"></div> <div class="col-7" data-aura-widget="tagset-widget"></div> </div> <div class="col-12" data-id="markable1" data-aura-widget="markable-widget"></div> </div> </body> </html>
Java
package visGrid.diagram.edit.parts; import java.io.File; import java.util.Collections; import java.util.List; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RunnableWithResult; import org.eclipse.gef.AccessibleEditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.Request; import org.eclipse.gef.requests.DirectEditRequest; import org.eclipse.gef.tools.DirectEditManager; import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; import org.eclipse.gmf.runtime.notation.FontStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.viewers.ICellEditorValidator; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; /** * @generated */ public class Series_reactorNameEditPart extends CompartmentEditPart implements ITextAwareEditPart { /** * @generated */ public static final int VISUAL_ID = 5072; /** * @generated */ private DirectEditManager manager; /** * @generated */ private IParser parser; /** * @generated */ private List<?> parserElements; /** * @generated */ private String defaultText; /** * @generated */ public Series_reactorNameEditPart(View view) { super(view); } /** * @generated */ protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy( EditPolicy.SELECTION_FEEDBACK_ROLE, new visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy()); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy( EditPolicy.PRIMARY_DRAG_ROLE, new visGrid.diagram.edit.parts.GridEditPart.NodeLabelDragPolicy()); } /** * @generated */ protected String getLabelTextHelper(IFigure figure) { if (figure instanceof WrappingLabel) { return ((WrappingLabel) figure).getText(); } else { return ((Label) figure).getText(); } } /** * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { if (figure instanceof WrappingLabel) { ((WrappingLabel) figure).setText(text); } else { ((Label) figure).setText(text); } } /** * @generated */ protected Image getLabelIconHelper(IFigure figure) { if (figure instanceof WrappingLabel) { return ((WrappingLabel) figure).getIcon(); } else { return ((Label) figure).getIcon(); } } /** * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { if (figure instanceof WrappingLabel) { ((WrappingLabel) figure).setIcon(icon); } else { ((Label) figure).setIcon(icon); } } /** * @generated */ public void setLabel(WrappingLabel figure) { unregisterVisuals(); setFigure(figure); defaultText = getLabelTextHelper(figure); registerVisuals(); refreshVisuals(); } /** * @generated */ @SuppressWarnings("rawtypes") protected List getModelChildren() { return Collections.EMPTY_LIST; } /** * @generated */ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { return null; } /** * @generated */ protected EObject getParserElement() { return resolveSemanticElement(); } /** * @generated */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); if (parserElement == null) { return null; } return visGrid.diagram.providers.VisGridElementTypes .getImage(parserElement.eClass()); } /** * @generated */ protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); if (parserElement != null && getParser() != null) { text = getParser().getPrintString( new EObjectAdapter(parserElement), getParserOptions().intValue()); } if (text == null || text.length() == 0) { text = defaultText; } return text; } /** * @generated */ public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if (pdEditPolicy instanceof visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) { ((visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) pdEditPolicy) .refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); if (sfEditPolicy instanceof visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) { ((visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) sfEditPolicy) .refreshFeedback(); } } /** * @generated */ public String getEditText() { if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } return getParser().getEditString( new EObjectAdapter(getParserElement()), getParserOptions().intValue()); } /** * @generated */ protected boolean isEditable() { return getParser() != null; } /** * @generated */ public ICellEditorValidator getEditTextValidator() { return new ICellEditorValidator() { public String isValid(final Object value) { if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { IParserEditStatus valid = (IParserEditStatus) getEditingDomain() .runExclusive( new RunnableWithResult.Impl<IParserEditStatus>() { public void run() { setResult(parser .isValidEditString( new EObjectAdapter( element), (String) value)); } }); return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } // shouldn't get here return null; } }; } /** * @generated */ public IContentAssistProcessor getCompletionProcessor() { if (getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor( new EObjectAdapter(getParserElement())); } /** * @generated */ public ParserOptions getParserOptions() { return ParserOptions.NONE; } /** * @generated */ public IParser getParser() { if (parser == null) { parser = visGrid.diagram.providers.VisGridParserProvider .getParser( visGrid.diagram.providers.VisGridElementTypes.Series_reactor_2032, getParserElement(), visGrid.diagram.part.VisGridVisualIDRegistry .getType(visGrid.diagram.edit.parts.Series_reactorNameEditPart.VISUAL_ID)); } return parser; } /** * @generated */ protected DirectEditManager getManager() { if (manager == null) { setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), visGrid.diagram.edit.parts.VisGridEditPartFactory .getTextCellEditorLocator(this))); } return manager; } /** * @generated */ protected void setManager(DirectEditManager manager) { this.manager = manager; } /** * @generated */ protected void performDirectEdit() { getManager().show(); } /** * @generated */ protected void performDirectEdit(Point eventLocation) { if (getManager().getClass() == TextDirectEditManager.class) { ((TextDirectEditManager) getManager()).show(eventLocation .getSWTPoint()); } } /** * @generated */ private void performDirectEdit(char initialCharacter) { if (getManager() instanceof TextDirectEditManager) { ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } } /** * @generated */ protected void performDirectEditRequest(Request request) { final Request theRequest = request; try { getEditingDomain().runExclusive(new Runnable() { public void run() { if (isActive() && isEditable()) { if (theRequest .getExtendedData() .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { Character initialChar = (Character) theRequest .getExtendedData() .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); } } } }); } catch (InterruptedException e) { e.printStackTrace(); } } /** * @generated */ protected void refreshVisuals() { super.refreshVisuals(); refreshLabel(); refreshFont(); refreshFontColor(); refreshUnderline(); refreshStrikeThrough(); refreshBounds(); } /** * @generated */ protected void refreshLabel() { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if (pdEditPolicy instanceof visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) { ((visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) pdEditPolicy) .refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); if (sfEditPolicy instanceof visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) { ((visGrid.diagram.edit.policies.VisGridTextSelectionEditPolicy) sfEditPolicy) .refreshFeedback(); } } /** * @generated */ protected void refreshUnderline() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle( NotationPackage.eINSTANCE.getFontStyle()); if (style != null && getFigure() instanceof WrappingLabel) { ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); } } /** * @generated */ protected void refreshStrikeThrough() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle( NotationPackage.eINSTANCE.getFontStyle()); if (style != null && getFigure() instanceof WrappingLabel) { ((WrappingLabel) getFigure()).setTextStrikeThrough(style .isStrikeThrough()); } } /** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle( NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } /** * @generated */ protected void setFontColor(Color color) { getFigure().setForegroundColor(color); } /** * @generated */ protected void addSemanticListeners() { if (getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); parserElements = ((ISemanticParser) getParser()) .getSemanticElementsBeingParsed(element); for (int i = 0; i < parserElements.size(); i++) { addListenerFilter( "SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); } } /** * @generated */ protected void removeSemanticListeners() { if (parserElements != null) { for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { super.removeSemanticListeners(); } } /** * @generated */ protected AccessibleEditPart getAccessibleEditPart() { if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { public void getName(AccessibleEvent e) { e.result = getLabelTextHelper(getFigure()); } }; } return accessibleEP; } /** * @generated */ private View getFontStyleOwnerView() { return getPrimaryView(); } /** * @generated */ protected void addNotationalListeners() { super.addNotationalListeners(); addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ } /** * @generated */ protected void removeNotationalListeners() { super.removeNotationalListeners(); removeListenerFilter("PrimaryView"); //$NON-NLS-1$ } /** * @generated */ protected void refreshBounds() { int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE .getSize_Width())).intValue(); int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE .getSize_Height())).intValue(); Dimension size = new Dimension(width, height); int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE .getLocation_X())).intValue(); int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE .getLocation_Y())).intValue(); Point loc = new Point(x, y); ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** * @generated */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { Integer c = (Integer) event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals( feature)) { refreshUnderline(); } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough() .equals(feature)) { refreshStrikeThrough(); } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals( feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals( feature) || NotationPackage.eINSTANCE.getFontStyle_Bold() .equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals( feature)) { refreshFont(); } else { if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } if (getParser() instanceof ISemanticParser) { ISemanticParser modelParser = (ISemanticParser) getParser(); if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } super.handleNotificationEvent(event); } /** * @generated */ protected IFigure createFigure() { // Parent should assign one using setLabel() method return null; } }
Java
#include "mainwindow.h" #include <exception> #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { //setWindowFlags(Qt::CustomizeWindowHint); menuBar()->close(); setStyleSheet("QPushButton{" "background-color:gray;" "color: white;" "width:55px;" "height:55px;" "font-size: 15px;" "border-radius: 10px;" "border: 2px groove gray;" "border-style: outset;}" "QPushButton:hover{" "background-color:white;" "color: black;}" "QPushButton:pressed,QPushButton:disabled{" "color: white;" "background-color:rgb(0, 0, 0);" "border-style: inset; }"); CentralWidget=new QWidget(this); setCentralWidget(CentralWidget); setWindowTitle(tr("Calculator")); buttonsLayout = new QGridLayout(); /* * 根据BUTTONS表添加,设置按钮 */ for(int i=0; i<BUTTONS.size(); ++i) { QVector<string> row = BUTTONS.at(i); //一行按钮 for(int j=0; j<row.size(); ++j) { const string &symbol = row.at(j); //按钮上显示的字符 if(!(symbol.empty())) { PushButton *pushButton = new PushButton(QString::fromStdString(symbol)); buttons.push_back(pushButton); //保存至按钮数组 connect(pushButton,&PushButton::clicked,this,&MainWindow::setInputText); buttonsLayout->addWidget(pushButton, i, j); } } } /* * 功能键 */ functionKeyButtonClear=new QPushButton(QString::fromStdString(CLEAR)); functionKeyButtonBackspace=new QPushButton(QString::fromStdString(BACKSPACE)); functionKeyButtonAns=new QPushButton(QString::fromStdString(ANS)); functionKeyButtonShift=new QPushButton(QString::fromStdString(SHIFT)); equalButton = new QPushButton(QString::fromStdString(EQUAL)); connect(functionKeyButtonBackspace,&QPushButton::clicked,this,&MainWindow::onBackspaceClicked); connect(functionKeyButtonClear,&QPushButton::clicked,this,&MainWindow::onClearClicked); connect(functionKeyButtonAns,&QPushButton::clicked,this,&MainWindow::onAnsClicked); connect(functionKeyButtonShift,&QPushButton::clicked,this,&MainWindow::onShiftClicked); connect(equalButton, &QPushButton::clicked, this, &MainWindow::onEqualClicked); buttonsLayout->addWidget(functionKeyButtonBackspace, 1, 0); buttonsLayout->addWidget(functionKeyButtonClear, 1, 1); buttonsLayout->addWidget(functionKeyButtonAns, 1, 2); buttonsLayout->addWidget(functionKeyButtonShift, 0, 4); //将等号添加至最后一行最后两格位置 buttonsLayout->addWidget(equalButton, BUTTONS.size(), BUTTONS.at(BUTTONS.size()-1).size()-2, 1, 2); MainLayout=new QGridLayout(CentralWidget); //设置表达式输入框 inputText=new QLineEdit("0"); inputText->setAlignment(Qt::AlignRight); inputText->setReadOnly(true); inputText->setStyleSheet("QLineEdit{height: 50px;" "border-style: plain;" "border-radius: 10px;" "font-size: 30px}"); //设置等于符号 equalLabel = new QLabel("="); equalLabel->setStyleSheet("width:55px;" "height:55px;" "font-size: 30px;"); //设置结果显示框 resultText = new QLineEdit("0"); resultText->setReadOnly(true); resultText->setStyleSheet("QLineEdit{height: 50px;" "border-style: plain;" "border-radius: 10px;" "font-size: 30px}"); MainLayout->addWidget(inputText, 0, 0, 1, 5); MainLayout->addWidget(equalLabel, 1, 1); MainLayout->addWidget(resultText, 1, 2, 1, 3); MainLayout->addLayout(buttonsLayout, 2, 0, 7, 5); MainLayout->setSizeConstraint(QLayout::SetFixedSize); setFixedSize(MainLayout->sizeHint()); } MainWindow::~MainWindow() { } QString MainWindow::cal(QString s) { QString temp; expression = new Expression(transformStdExpression(s)); try { temp=QString::fromStdString(expression->getResult()); }catch(runtime_error e){ QMessageBox messagebox(QMessageBox::Warning,"错误",QString::fromStdString(e.what())); messagebox.exec(); temp = "Error"; } calcFinished = true; delete expression; return temp; } string MainWindow::transformStdExpression(QString expression) { expression = expression.replace("×", "*").replace("÷", "/").replace("√", "#").replace("°", "`"); return expression.toStdString(); } void MainWindow::setInputText(PushButton *pushButton) { QString symbol = pushButton->text(); /* * 未计算完成,还在输入中,将输入的字符直接添加至表达式输入框文本后 */ if(calcFinished==false) { inputText->setText(inputText->text()+pushButton->text()); } /* * 已经计算完成,准备开始下一次计算 * 根据输入的内容,若为数字/括号/前置运算符/可省略第一个操作数的中置运算符,则直接将输入显示在输入框中 */ else { Metacharacter m = METACHARACTERS.at(transformStdExpression(symbol)); if(m.type == 0 || m.type == 2 || (m.type==1 && (m.position == 1 || m.e == "#" || m.e == "-"))) { //如果输入的是小数点,则在其前面添加小数点 if(symbol == ".") { inputText->setText(QString("0.")); } else { inputText->setText(pushButton->text()); } } else if(m.type == 1) { inputText->setText(Ans + pushButton->text()); } historySize.clear(); //清空上次输入的历史记录 calcFinished=false; //表示正在输入过程中 } historySize.push(pushButton->text().size()); //记录输入的操作词大小 } void MainWindow::onEqualClicked() { QString temp; temp=cal(inputText->text()); if(temp=="Error") //如果计算出错 { resultText->setText(tr("Error")); Ans = "0"; return; } /* * 由于返回值为double转换的QString,字符串小数位会有一串0,需要去除,并在小数位全为0时去除小数点 */ while(temp.right(1)=="0") temp=temp.left(temp.size()-1); if(temp.right(1)==".") temp=temp.left(temp.size()-1); resultText->setText(temp); /* * 如果计算结果为负数,为Ans加上括号便于下次计算使用 */ if(temp.at(0) == '-') Ans=QString("%1%2%3").arg("(").arg(temp).arg(")"); else Ans = temp; } void MainWindow::onClearClicked() { inputText->setText("0"); historySize.clear(); calcFinished=true; } void MainWindow::onAnsClicked() { if(inputText->text()=="0"||calcFinished==true) { inputText->setText(Ans); calcFinished=false; } else inputText->setText(inputText->text()+Ans); int length = Ans.size(); while(length--) historySize.push(1); } void MainWindow::onShiftClicked() { /* * 根据shift按下状态转换sin,cos,tan和lg四个按钮 */ if(isShifting) { isShifting = false; for(int i=0; i<4; ++i) { buttons[i]->setText(QString::fromStdString(BUTTONS.at(0).at(i))); } functionKeyButtonShift->setStyleSheet("QPushButton{background-color:gray;" "font-size: 15px;" "border-style: outset;}" "QPushButton:hover{" "background-color:white;" "color: black;}" "QPushButton:pressed{" "background-color:rgb(0, 0, 0);" "border-style: inset;}"); } else { isShifting = true; for(int i=0; i<4; ++i) { buttons[i]->setText(QString::fromStdString(SHIFT_TABLE[buttons[i]->text().toStdString()])); } functionKeyButtonShift->setStyleSheet("QPushButton:pressed{background-color:gray;" "border-style: outset;}" "QPushButton:hover{" "background-color:white;" "color: black;}" "QPushButton{" "font-size: 40px;" "font-style: bold;" "background-color:rgb(0, 0, 0);" "border-style: inset;}"); } } void MainWindow::onBackspaceClicked() { QString result=inputText->text(); calcFinished = false; //计算完成时若按下删除键,重新将计算完成标记置为正在输入中 if(result.size()==1) //输入框只剩一个字符 { historySize.clear(); inputText->setText("0"); calcFinished = true; } else { int length = historySize.empty() ? 1:historySize.pop(); //兼容手动输入字符情况 inputText->setText(result.left(result.size()-length)); } }
Java
/** * Scaffolding file used to store all the setups needed to run * tests automatically generated by EvoSuite * Thu Sep 20 14:23:56 GMT 2018 */ package uk.ac.sanger.artemis; import org.evosuite.runtime.annotation.EvoSuiteClassExclude; import org.junit.BeforeClass; import org.junit.Before; import org.junit.After; import org.junit.AfterClass; import org.evosuite.runtime.sandbox.Sandbox; import org.evosuite.runtime.sandbox.Sandbox.SandboxMode; import static org.evosuite.shaded.org.mockito.Mockito.*; @EvoSuiteClassExclude public class EntryChangeEvent_ESTest_scaffolding { @org.junit.Rule public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); @BeforeClass public static void initEvoSuiteFramework() { org.evosuite.runtime.RuntimeSettings.className = "uk.ac.sanger.artemis.EntryChangeEvent"; org.evosuite.runtime.GuiSupport.initialize(); org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); org.evosuite.runtime.classhandling.JDKClassResetter.init(); setSystemProperties(); initializeClasses(); org.evosuite.runtime.Runtime.getInstance().resetRuntime(); try { initMocksToAvoidTimeoutsInTheTests(); } catch(ClassNotFoundException e) {} } @AfterClass public static void clearEvoSuiteFramework(){ Sandbox.resetDefaultSecurityManager(); java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); } @Before public void initTestCase(){ threadStopper.storeCurrentThreads(); threadStopper.startRecordingTime(); org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); setSystemProperties(); org.evosuite.runtime.GuiSupport.setHeadless(); org.evosuite.runtime.Runtime.getInstance().resetRuntime(); org.evosuite.runtime.agent.InstrumentingAgent.activate(); } @After public void doneWithTestCase(){ threadStopper.killAndJoinClientThreads(); org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); org.evosuite.runtime.classhandling.JDKClassResetter.reset(); resetClasses(); org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); } public static void setSystemProperties() { java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); java.lang.System.setProperty("file.encoding", "UTF-8"); java.lang.System.setProperty("java.awt.headless", "true"); java.lang.System.setProperty("java.io.tmpdir", "/var/folders/r3/l648tx8s7hn8ppds6z2bk5cc000h2n/T/"); java.lang.System.setProperty("user.country", "GB"); java.lang.System.setProperty("user.dir", "/Users/kp11/workspace/applications/Artemis-build-ci/Artemis"); java.lang.System.setProperty("user.home", "/Users/kp11"); java.lang.System.setProperty("user.language", "en"); java.lang.System.setProperty("user.name", "kp11"); java.lang.System.setProperty("user.timezone", ""); } private static void initializeClasses() { org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(EntryChangeEvent_ESTest_scaffolding.class.getClassLoader() , "uk.ac.sanger.artemis.io.EntryInformationException", "uk.ac.sanger.artemis.io.Location", "uk.ac.sanger.artemis.io.PublicDBStreamFeature", "uk.ac.sanger.artemis.io.DocumentEntry", "uk.ac.sanger.artemis.FeatureSegmentVector", "uk.ac.sanger.artemis.io.OutOfDateException", "uk.ac.sanger.artemis.sequence.SequenceChangeListener", "uk.ac.sanger.artemis.OptionChangeEvent", "uk.ac.sanger.artemis.FeatureSegment", "uk.ac.sanger.artemis.io.InvalidRelationException", "uk.ac.sanger.artemis.io.ComparableFeature", "uk.ac.sanger.artemis.io.Feature", "uk.ac.sanger.artemis.io.SimpleDocumentFeature", "uk.ac.sanger.artemis.io.StreamFeature", "uk.ac.sanger.artemis.io.Key", "uk.ac.sanger.artemis.sequence.BasePatternFormatException", "uk.ac.sanger.artemis.util.ReadOnlyException", "uk.ac.sanger.artemis.io.LocationParseException", "uk.ac.sanger.artemis.io.SimpleDocumentEntry", "uk.ac.sanger.artemis.io.EntryInformation", "uk.ac.sanger.artemis.EntryChangeListener", "uk.ac.sanger.artemis.EntryChangeEvent", "uk.ac.sanger.artemis.Entry", "uk.ac.sanger.artemis.sequence.MarkerChangeListener", "uk.ac.sanger.artemis.sequence.AminoAcidSequence", "uk.ac.sanger.artemis.Selectable", "uk.ac.sanger.artemis.Feature", "uk.ac.sanger.artemis.io.EmblDocumentEntry", "uk.ac.sanger.artemis.io.ReadFormatException", "uk.ac.sanger.artemis.io.DocumentFeature", "uk.ac.sanger.artemis.io.EmblStreamFeature", "uk.ac.sanger.artemis.io.Range", "uk.ac.sanger.artemis.sequence.Bases", "uk.ac.sanger.artemis.io.PublicDBDocumentEntry", "uk.ac.sanger.artemis.io.Qualifier", "uk.ac.sanger.artemis.io.Entry", "uk.ac.sanger.artemis.util.StringVector", "uk.ac.sanger.artemis.ChangeListener", "uk.ac.sanger.artemis.LastSegmentException", "uk.ac.sanger.artemis.ChangeEvent", "uk.ac.sanger.artemis.sequence.Marker", "uk.ac.sanger.artemis.util.OutOfRangeException", "uk.ac.sanger.artemis.util.Document", "uk.ac.sanger.artemis.sequence.MarkerChangeEvent", "uk.ac.sanger.artemis.io.GFFDocumentEntry", "uk.ac.sanger.artemis.io.GFFStreamFeature", "uk.ac.sanger.artemis.FeatureVector", "uk.ac.sanger.artemis.io.EMBLObject", "uk.ac.sanger.artemis.sequence.Strand", "uk.ac.sanger.artemis.sequence.NoSequenceException", "uk.ac.sanger.artemis.FeaturePredicate", "uk.ac.sanger.artemis.sequence.SequenceChangeEvent", "uk.ac.sanger.artemis.OptionChangeListener", "uk.ac.sanger.artemis.io.QualifierVector", "uk.ac.sanger.artemis.FeatureChangeListener", "uk.ac.sanger.artemis.util.FileDocument", "uk.ac.sanger.artemis.FeatureChangeEvent", "uk.ac.sanger.artemis.FeatureEnumeration", "uk.ac.sanger.artemis.io.LineGroup" ); } private static void initMocksToAvoidTimeoutsInTheTests() throws ClassNotFoundException { mock(Class.forName("uk.ac.sanger.artemis.Entry", false, EntryChangeEvent_ESTest_scaffolding.class.getClassLoader())); mock(Class.forName("uk.ac.sanger.artemis.Feature", false, EntryChangeEvent_ESTest_scaffolding.class.getClassLoader())); } private static void resetClasses() { org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(EntryChangeEvent_ESTest_scaffolding.class.getClassLoader()); org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( "uk.ac.sanger.artemis.ChangeEvent", "uk.ac.sanger.artemis.EntryChangeEvent", "uk.ac.sanger.artemis.Feature", "uk.ac.sanger.artemis.Entry" ); } }
Java
// Copyright 2017 Ryan Wick (rrwick@gmail.com) // https://github.com/rrwick/Unicycler // This file is part of Unicycler. Unicycler 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. Unicycler 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 Genral Public // License along with Unicycler. If not, see <http://www.gnu.org/licenses/>. #include "overlap_align.h" #include "string_functions.h" #include <seqan/align.h> char * overlapAlignment(char * s1, char * s2, int matchScore, int mismatchScore, int gapOpenScore, int gapExtensionScore, int guessOverlap) { std::string sequence1(s1); std::string sequence2(s2); // Trim the sequences down to a bit more than the expected overlap. This will help save time // because the non-overlapping sequence isn't informative. int trim_size = int((guessOverlap + 100) * 1.5); if (trim_size < int(sequence1.length())) sequence1 = sequence1.substr(sequence1.length() - trim_size, trim_size); if (trim_size < int(sequence2.length())) sequence2 = sequence2.substr(0, trim_size); Dna5String sequenceH(sequence1); Dna5String sequenceV(sequence2); Align<Dna5String, ArrayGaps> alignment; resize(rows(alignment), 2); assignSource(row(alignment, 0), sequenceH); assignSource(row(alignment, 1), sequenceV); Score<int, Simple> scoringScheme(matchScore, mismatchScore, gapExtensionScore, gapOpenScore); // The alignment configuration allows for overlap from s1 -> s2. AlignConfig<true, false, true, false> alignConfig; try { globalAlignment(alignment, scoringScheme, alignConfig); } catch (...) { return cppStringToCString("-1,-1"); } std::ostringstream stream1; stream1 << row(alignment, 0); std::string seq1Alignment = stream1.str(); std::ostringstream stream2; stream2 << row(alignment, 1); std::string seq2Alignment = stream2.str(); int alignmentLength = std::max(seq1Alignment.size(), seq2Alignment.size()); if (alignmentLength == 0) return cppStringToCString("-1,-1"); int seq1Pos = 0, seq2Pos = 0; int seq1PosAtSeq2Start = -1, seq2PosAtSeq1End = -1; for (int i = 0; i < alignmentLength; ++i) { char base1 = seq1Alignment[i]; char base2 = seq2Alignment[i]; if (base1 != '-') seq2PosAtSeq1End = seq2Pos + 1; if (base2 != '-' && seq1PosAtSeq2Start == -1) seq1PosAtSeq2Start = seq1Pos; if (base1 != '-') ++seq1Pos; if (base2 != '-') ++seq2Pos; } int overlap1 = seq1Pos - seq1PosAtSeq2Start; int overlap2 = seq2PosAtSeq1End; return cppStringToCString(std::to_string(overlap1) + "," + std::to_string(overlap2)); }
Java
package me.anthonybruno.soccerSim.reader; import org.apache.pdfbox.io.RandomAccessFile; import org.apache.pdfbox.pdfparser.PDFParser; import org.apache.pdfbox.text.PDFTextStripperByArea; import java.awt.geom.Rectangle2D; import java.io.File; import java.io.IOException; /** * A class that parsers team PDF files into XML files. */ public class TeamPdfReader { private static final Rectangle2D.Double firstTeamFirstPageRegion = new Rectangle2D.Double(0, 0, 330, 550); private static final Rectangle2D.Double secondTeamFirstPageRegion = new Rectangle2D.Double(350, 0, 350, 550); private final File file; public TeamPdfReader(String fileName) { this.file = new File(fileName); } public TeamPdfReader(File file) { this.file = file; } // public String read() { //Using IText :( // try { // PdfReader pdfReader = new PdfReader(file.getAbsolutePath()); // PdfDocument pdfDocument = new PdfDocument(pdfReader); // // LocationTextExtractionStrategy strategy = new LocationTextExtractionStrategy(); // // PdfCanvasProcessor parser = new PdfCanvasProcessor(strategy); // parser.processPageContent(pdfDocument.getFirstPage()); // return strategy.getResultantText(); // // } catch (IOException e) { // e.printStackTrace(); // } // } public void readAllTeamsToFiles() { //Using PDFBox try { PDFParser parser = new PDFParser(new RandomAccessFile(file, "r")); parser.parse(); PDFTextStripperByArea pdfTextStripperByArea = new PDFTextStripperByArea(); pdfTextStripperByArea.addRegion("First", firstTeamFirstPageRegion); pdfTextStripperByArea.addRegion("Second", secondTeamFirstPageRegion); for (int i = 0; i < parser.getPDDocument().getNumberOfPages(); i++) { pdfTextStripperByArea.extractRegions(parser.getPDDocument().getPage(i)); writeTeamToFile(pdfTextStripperByArea.getTextForRegion("First"), "teams"); writeTeamToFile(pdfTextStripperByArea.getTextForRegion("Second"), "teams"); } } catch (IOException e) { e.printStackTrace(); } } public void writeTeamToFile(String teamExtractedFromPDf, String saveDirectory) { //FIXME: Reduce size of method if (teamExtractedFromPDf.isEmpty() || !teamExtractedFromPDf.contains(" ")) { return; //reached a blank page } XmlWriter xmlWriter = new XmlWriter("UTF-8"); String text = teamExtractedFromPDf; if (text.indexOf('\n') < text.indexOf(' ')) { text = text.substring(text.indexOf('\n') + 1); } xmlWriter.createOpenTag("team"); if (text.startsWith(" ")) { text = text.substring(text.indexOf('\n') + 1); //need this for El Salvador } String name = text.substring(0, text.indexOf(" ")); text = text.substring(text.indexOf(" ") + 1); if (!Character.isDigit(text.charAt(0))) { //handles countries with two words in name name += " " + text.substring(0, text.indexOf(" ")); } xmlWriter.createTagWithValue("name", name); for (int i = 0; i < 3; i++) { //skipping stuff we don't care about text = moveToNextLine(text); } text = text.substring(text.indexOf(':') + 2); String firstHalfAttempts = text.substring(0, text.indexOf(' ')); text = text.substring(text.indexOf(' ') + 1); String secondHalfAttempts = text.substring(0, text.indexOf('\n')); text = moveToNextLine(text); xmlWriter.createTagWithValue("goalRating", text.substring(text.indexOf('-') + 1, text.indexOf('\n'))); text = moveToNextLine(text); String[] defensiveAttempts = parseHalfValues(text); text = defensiveAttempts[0]; String firstHalfDefensiveAttempts = defensiveAttempts[1]; String secondHalfDefensiveAttempts = defensiveAttempts[2]; String[] defensiveSOG = parseHalfValues(text); text = defensiveSOG[0]; String firstHalfSOG = defensiveSOG[1]; String secondHalfSOG = defensiveSOG[2]; xmlWriter.createTagWithValue("formation", text.substring(text.indexOf(':') + 2, text.indexOf('\n'))); text = moveToNextLine(text); text = text.substring(text.indexOf(':') + 2); if (text.indexOf(' ') < text.indexOf('\n')) { xmlWriter.createTagWithValue("strategy", text.substring(0, text.indexOf(' '))); //team has fair play score } else { xmlWriter.createTagWithValue("strategy", text.substring(0, text.indexOf("\n"))); } text = moveToNextLine(text); text = moveToNextLine(text); parseHalfStats(xmlWriter, "halfStats", firstHalfAttempts, firstHalfDefensiveAttempts, firstHalfSOG); parseHalfStats(xmlWriter, "halfStats", secondHalfAttempts, secondHalfDefensiveAttempts, secondHalfSOG); xmlWriter.createOpenTag("players"); while (!text.startsWith("Goalies")) { text = parsePlayer(xmlWriter, text); } text = moveToNextLine(text); parseGoalies(xmlWriter, text); xmlWriter.createCloseTag("players"); xmlWriter.createCloseTag("team"); File saveDir = new File(saveDirectory); try { saveDir.createNewFile(); } catch (IOException e) { e.printStackTrace(); } if (!saveDir.exists()) { file.mkdir(); } xmlWriter.writeToFile(new File("src/main/resources/teams/" + name + ".xml")); } private void parseGoalies(XmlWriter xmlWriter, String text) { while (!text.isEmpty()) { xmlWriter.createOpenTag("goalie"); String playerName = ""; do { playerName += text.substring(0, text.indexOf(' ')); text = text.substring(text.indexOf(' ') + 1); } while (!isNumeric(text.substring(0, text.indexOf(' ')))); xmlWriter.createTagWithValue("name", playerName); xmlWriter.createTagWithValue("rating", text.substring(0, text.indexOf(' '))); text = text.substring(text.indexOf(' ') + 1); text = text.substring(text.indexOf(' ') + 1); text = parsePlayerAttribute(xmlWriter, "injury", text); createMultiplierTag(xmlWriter, text); text = moveToNextLine(text); xmlWriter.createCloseTag("goalie"); } } private boolean isNumeric(char c) { return isNumeric(c + ""); } private boolean isNumeric(String string) { return string.matches("^[-+]?\\d+$"); } private void createMultiplierTag(XmlWriter xmlWriter, String text) { if (text.charAt(0) != '-') { xmlWriter.createTagWithValue("multiplier", text.charAt(1) + ""); } else { xmlWriter.createTagWithValue("multiplier", "0"); } } private String parsePlayer(XmlWriter xmlWriter, String text) { xmlWriter.createOpenTag("player"); text = parsePlayerName(xmlWriter, text); text = parsePlayerAttribute(xmlWriter, "shotRange", text); text = parsePlayerAttribute(xmlWriter, "goal", text); text = parsePlayerAttribute(xmlWriter, "injury", text); createMultiplierTag(xmlWriter, text); xmlWriter.createCloseTag("player"); text = moveToNextLine(text); return text; } private String parsePlayerName(XmlWriter xmlWriter, String text) { if (isNumeric(text.charAt(text.indexOf(' ') + 1))) { return parsePlayerAttribute(xmlWriter, "name", text); //Player has single name } else { String playerName = text.substring(0, text.indexOf(' ')); text = text.substring(text.indexOf(' ') + 1); while (!isNumeric(text.charAt(0))) { playerName += ' ' + text.substring(0, text.indexOf(' ')); text = text.substring(text.indexOf(' ') + 1); } xmlWriter.createTagWithValue("name", playerName); return text; } } private String parsePlayerAttribute(XmlWriter xmlWriter, String tagName, String text) { xmlWriter.createTagWithValue(tagName, text.substring(0, text.indexOf(' '))); text = text.substring(text.indexOf(' ') + 1); return text; } private String[] parseHalfValues(String text) { text = text.substring(text.indexOf(':') + 2); String firstHalf = text.substring(0, text.indexOf(' ')); text = text.substring(text.indexOf(' ') + 1); String secondHalf = text.substring(0, text.indexOf('\n')); text = moveToNextLine(text); return new String[]{text, firstHalf, secondHalf}; } private void parseHalfStats(XmlWriter xmlWriter, String halfName, String attempts, String defensiveAttempts, String defensiveShotsOnGoal) { xmlWriter.createOpenTag(halfName); xmlWriter.createTagWithValue("attempts", attempts); xmlWriter.createTagWithValue("defensiveAttempts", defensiveAttempts); xmlWriter.createTagWithValue("defensiveShotsOnGoal", defensiveShotsOnGoal); xmlWriter.createCloseTag(halfName); } private String moveToNextLine(String text) { return text.substring(text.indexOf("\n") + 1); } public static void main(String[] args) { TeamPdfReader teamPdfReader = new TeamPdfReader("src/main/resources/ruleFiles/Cards1.pdf"); teamPdfReader.readAllTeamsToFiles(); teamPdfReader = new TeamPdfReader("src/main/resources/ruleFiles/Cards2.pdf"); teamPdfReader.readAllTeamsToFiles(); } }
Java
module TransactionChains class Lifetimes::ExpirationWarning < ::TransactionChain label 'Expiration' allow_empty def link_chain(klass, q) q.each do |obj| user = if obj.is_a?(::User) obj elsif obj.respond_to?(:user) obj.user else fail "Unable to find an owner for #{obj} of class #{klass}" end mail(:expiration_warning, { params: { object: klass.name.underscore, state: obj.object_state, }, user: user, vars: { object: obj, state: obj.current_object_state, klass.name.underscore => obj } }) if user.mailer_enabled end end end end
Java
--- --- InternalResource provides access to static resources in the class path. ## Related components * [AudioResource](AudioResource.html) * [ImageResource](ImageResource.html) * [VideoResource](VideoResource.html) * [WImage](WImage.html) * [WApplication](WApplication.html) * [WContent](WContent.html) * [WImage](WImage.html) * [WMultiFileWidget](WMultiFileWidget.html) * [WTree](WTree.html) ## Further information * [JavaDoc](../apidocs/com/github/bordertech/wcomponents/InternalResource.html); * [List of WComponents](List-of-WComponents.html).
Java
#pragma once #include <vector> #include <boost/thread.hpp> #include <boost/thread/condition_variable.hpp> #include <boost/bind.hpp> #include <boost/version.hpp> #include <boost/function.hpp> #include <boost/interprocess/detail/atomic.hpp> #if (BOOST_VERSION < 104800) using boost::interprocess::detail::atomic_inc32; #else using boost::interprocess::ipcdetail::atomic_inc32; #endif /* * TODO: * * - Better documentation of API * - deleting of ended thread:local memory * - by mean of Done function * - by DelThread * - Pause/Resume function * - use a barrier instead of a crappy sleep * - should this code move at the end of each blocks ? */ namespace scheduling { class Scheduler; class Thread; class Range; class Thread { public: virtual void Init() {} virtual void End() {} virtual ~Thread() {}; friend class Scheduler; friend class Range; private: static void Body(Thread* thread, Scheduler *scheduler); boost::thread thread; bool active; }; typedef boost::function<void(Range *range)> TaskType; class Scheduler { public: Scheduler(unsigned step); ~Scheduler(); void Launch(TaskType task, unsigned b_min, unsigned b_max, unsigned force_step=0); void Pause(); void Resume(); void Stop(); void Done(); void AddThread(Thread *thread); void DelThread(); unsigned ThreadCount() const { return threads.size(); } void FreeThreadLocalStorage(); friend class Thread; friend class Range; private: enum {PAUSED, RUNNING} state; TaskType GetTask(); bool EndTask(Thread* thread); std::vector<Thread*> threads; std::vector<Thread*> threads_finished; TaskType current_task; boost::mutex mutex; boost::condition_variable condition; unsigned counter; unsigned start; unsigned end; unsigned current; unsigned step; unsigned default_step; }; class Range { public: unsigned begin() { return atomic_init(); } unsigned end() { return ~0u; } unsigned next() { if(++current < max) return current; // handle pause while (scheduler->state == Scheduler::PAUSED) { boost::this_thread::sleep(boost::posix_time::seconds(1)); } return atomic_init(); } // public for thread local data access Thread *thread; friend class Thread; private: unsigned atomic_init() { if(!thread->active) return end(); unsigned new_value = scheduler->step * atomic_inc32(&scheduler->current); if(new_value < scheduler->end) { max = std::min(scheduler->end, new_value + scheduler->step); current = new_value; return new_value; } return end(); } Range(Scheduler *sched, Thread *thread_data); unsigned current; unsigned max; Scheduler *scheduler; }; }
Java
// This file belongs to the "MiniCore" game engine. // Copyright (C) 2012 Jussi Lind <jussi.lind@iki.fi> // // 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., 51 Franklin Street, Fifth Floor, Boston, // MA 02110-1301, USA. // #ifndef MCLOGGER_HH #define MCLOGGER_HH #include "mcmacros.hh" #include <cstdio> #include <sstream> /*! A logging class. A MCLogger instance flushes on destruction. * * Example initialization: * * MCLogger::init("myLog.txt"); * MCLogger::enableEchoMode(true); * * Example logging: * * MCLogger().info() << "Initialization finished."; * MCLogger().error() << "Foo happened!"; */ class MCLogger { public: //! Constructor. MCLogger(); //! Destructor. ~MCLogger(); /*! Initialize the logger. * \param fileName Log to fileName. Can be nullptr. * \param append The existing log will be appended if true. * \return false if file couldn't be opened. */ static bool init(const char * fileName, bool append = false); //! Enable/disable echo mode. //! \param enable Echo everything if true. Default is false. static void enableEchoMode(bool enable); //! Enable/disable date and time prefix. //! \param enable Prefix with date and time if true. Default is true. static void enableDateTimePrefix(bool enable); //! Get stream to the info log message. std::ostringstream & info(); //! Get stream to the warning log message. std::ostringstream & warning(); //! Get stream to the error log message. std::ostringstream & error(); //! Get stream to the fatal log message. std::ostringstream & fatal(); private: DISABLE_COPY(MCLogger); DISABLE_ASSI(MCLogger); void prefixDateTime(); static bool m_echoMode; static bool m_dateTime; static FILE * m_file; std::ostringstream m_oss; }; #endif // MCLOGGER_HH
Java
// // tcpconnection.cpp // // This implements RFC 793 with some changes in RFC 1122 and RFC 6298. // // Non-implemented features: // dynamic receive window // URG flag and urgent pointer // delayed ACK // queueing out-of-order TCP segments // security/compartment // precedence // user timeout // // Circle - A C++ bare metal environment for Raspberry Pi // Copyright (C) 2015-2021 R. Stange <rsta2@o2online.de> // // 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 <http://www.gnu.org/licenses/>. // #include <circle/net/tcpconnection.h> #include <circle/macros.h> #include <circle/util.h> #include <circle/logger.h> #include <circle/net/in.h> #include <assert.h> //#define TCP_DEBUG #define TCP_MAX_CONNECTIONS 1000 // maximum number of active TCP connections #define MSS_R 1480 // maximum segment size to be received from network layer #define MSS_S 1480 // maximum segment size to be send to network layer #define TCP_CONFIG_MSS (MSS_R - 20) #define TCP_CONFIG_WINDOW (TCP_CONFIG_MSS * 10) #define TCP_CONFIG_RETRANS_BUFFER_SIZE 0x10000 // should be greater than maximum send window size #define TCP_MAX_WINDOW ((u16) -1) // without Window extension option #define TCP_QUIET_TIME 30 // seconds after crash before another connection starts #define HZ_TIMEWAIT (60 * HZ) #define HZ_FIN_TIMEOUT (60 * HZ) // timeout in FIN-WAIT-2 state #define MAX_RETRANSMISSIONS 5 struct TTCPHeader { u16 nSourcePort; u16 nDestPort; u32 nSequenceNumber; u32 nAcknowledgmentNumber; u16 nDataOffsetFlags; // following #define(s) are valid without BE() #define TCP_DATA_OFFSET(field) (((field) >> 4) & 0x0F) #define TCP_DATA_OFFSET_SHIFT 4 //#define TCP_FLAG_NONCE (1 << 0) //#define TCP_FLAG_CWR (1 << 15) //#define TCP_FLAG_ECN_ECHO (1 << 14) #define TCP_FLAG_URGENT (1 << 13) #define TCP_FLAG_ACK (1 << 12) #define TCP_FLAG_PUSH (1 << 11) #define TCP_FLAG_RESET (1 << 10) #define TCP_FLAG_SYN (1 << 9) #define TCP_FLAG_FIN (1 << 8) u16 nWindow; u16 nChecksum; u16 nUrgentPointer; u32 Options[]; } PACKED; #define TCP_HEADER_SIZE 20 // valid for normal data segments without TCP options struct TTCPOption { u8 nKind; // Data: #define TCP_OPTION_END_OF_LIST 0 // None (no length field) #define TCP_OPTION_NOP 1 // None (no length field) #define TCP_OPTION_MSS 2 // Maximum segment size (2 byte) #define TCP_OPTION_WINDOW_SCALE 3 // Shift count (1 byte) #define TCP_OPTION_SACK_PERM 4 // None #define TCP_OPTION_TIMESTAMP 8 // Timestamp value, Timestamp echo reply (2*4 byte) u8 nLength; u8 Data[]; } PACKED; #define min(n, m) ((n) <= (m) ? (n) : (m)) #define max(n, m) ((n) >= (m) ? (n) : (m)) // Modulo 32 sequence number arithmetic #define lt(x, y) ((int) ((u32) (x) - (u32) (y)) < 0) #define le(x, y) ((int) ((u32) (x) - (u32) (y)) <= 0) #define gt(x, y) lt (y, x) #define ge(x, y) le (y, x) #define bw(l, x, h) (lt ((l), (x)) && lt ((x), (h))) // between #define bwl(l, x, h) (le ((l), (x)) && lt ((x), (h))) // low border inclusive #define bwh(l, x, h) (lt ((l), (x)) && le ((x), (h))) // high border inclusive #define bwlh(l, x, h) (le ((l), (x)) && le ((x), (h))) // both borders inclusive #if !defined (NDEBUG) && defined (TCP_DEBUG) #define NEW_STATE(state) NewState (state, __LINE__); #else #define NEW_STATE(state) (m_State = state) #endif #ifndef NDEBUG #define UNEXPECTED_STATE() UnexpectedState (__LINE__) #else #define UNEXPECTED_STATE() ((void) 0) #endif unsigned CTCPConnection::s_nConnections = 0; static const char FromTCP[] = "tcp"; CTCPConnection::CTCPConnection (CNetConfig *pNetConfig, CNetworkLayer *pNetworkLayer, CIPAddress &rForeignIP, u16 nForeignPort, u16 nOwnPort) : CNetConnection (pNetConfig, pNetworkLayer, rForeignIP, nForeignPort, nOwnPort, IPPROTO_TCP), m_bActiveOpen (TRUE), m_State (TCPStateClosed), m_nErrno (0), m_RetransmissionQueue (TCP_CONFIG_RETRANS_BUFFER_SIZE), m_bRetransmit (FALSE), m_bSendSYN (FALSE), m_bFINQueued (FALSE), m_nRetransmissionCount (0), m_bTimedOut (FALSE), m_pTimer (CTimer::Get ()), m_nSND_WND (TCP_CONFIG_WINDOW), m_nSND_UP (0), m_nRCV_NXT (0), m_nRCV_WND (TCP_CONFIG_WINDOW), m_nIRS (0), m_nSND_MSS (536) // RFC 1122 section 4.2.2.6 { s_nConnections++; for (unsigned nTimer = TCPTimerUser; nTimer < TCPTimerUnknown; nTimer++) { m_hTimer[nTimer] = 0; } m_nISS = CalculateISN (); m_RTOCalculator.Initialize (m_nISS); m_nSND_UNA = m_nISS; m_nSND_NXT = m_nISS+1; if (SendSegment (TCP_FLAG_SYN, m_nISS)) { m_RTOCalculator.SegmentSent (m_nISS); NEW_STATE (TCPStateSynSent); m_nRetransmissionCount = MAX_RETRANSMISSIONS; StartTimer (TCPTimerRetransmission, m_RTOCalculator.GetRTO ()); } } CTCPConnection::CTCPConnection (CNetConfig *pNetConfig, CNetworkLayer *pNetworkLayer, u16 nOwnPort) : CNetConnection (pNetConfig, pNetworkLayer, nOwnPort, IPPROTO_TCP), m_bActiveOpen (FALSE), m_State (TCPStateListen), m_nErrno (0), m_RetransmissionQueue (TCP_CONFIG_RETRANS_BUFFER_SIZE), m_bRetransmit (FALSE), m_bSendSYN (FALSE), m_bFINQueued (FALSE), m_nRetransmissionCount (0), m_bTimedOut (FALSE), m_pTimer (CTimer::Get ()), m_nSND_WND (TCP_CONFIG_WINDOW), m_nSND_UP (0), m_nRCV_NXT (0), m_nRCV_WND (TCP_CONFIG_WINDOW), m_nIRS (0), m_nSND_MSS (536) // RFC 1122 section 4.2.2.6 { s_nConnections++; for (unsigned nTimer = TCPTimerUser; nTimer < TCPTimerUnknown; nTimer++) { m_hTimer[nTimer] = 0; } } CTCPConnection::~CTCPConnection (void) { #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "Delete TCB"); #endif assert (m_State == TCPStateClosed); for (unsigned nTimer = TCPTimerUser; nTimer < TCPTimerUnknown; nTimer++) { StopTimer (nTimer); } // ensure no task is waiting any more m_Event.Set (); m_TxEvent.Set (); assert (s_nConnections > 0); s_nConnections--; } int CTCPConnection::Connect (void) { if (m_nErrno < 0) { return m_nErrno; } switch (m_State) { case TCPStateSynSent: case TCPStateSynReceived: m_Event.Clear (); m_Event.Wait (); break; case TCPStateEstablished: break; case TCPStateListen: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: UNEXPECTED_STATE (); // fall through case TCPStateClosed: return -1; } return m_nErrno; } int CTCPConnection::Accept (CIPAddress *pForeignIP, u16 *pForeignPort) { if (m_nErrno < 0) { return m_nErrno; } switch (m_State) { case TCPStateSynSent: UNEXPECTED_STATE (); // fall through case TCPStateClosed: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: return -1; case TCPStateListen: m_Event.Clear (); m_Event.Wait (); break; case TCPStateSynReceived: case TCPStateEstablished: break; } assert (pForeignIP != 0); pForeignIP->Set (m_ForeignIP); assert (pForeignPort != 0); *pForeignPort = m_nForeignPort; return m_nErrno; } int CTCPConnection::Close (void) { if (m_nErrno < 0) { return m_nErrno; } switch (m_State) { case TCPStateClosed: return -1; case TCPStateListen: case TCPStateSynSent: StopTimer (TCPTimerRetransmission); NEW_STATE (TCPStateClosed); break; case TCPStateSynReceived: case TCPStateEstablished: assert (!m_bFINQueued); m_StateAfterFIN = TCPStateFinWait1; m_nRetransmissionCount = MAX_RETRANSMISSIONS; m_bFINQueued = TRUE; break; case TCPStateFinWait1: case TCPStateFinWait2: break; case TCPStateCloseWait: assert (!m_bFINQueued); m_StateAfterFIN = TCPStateLastAck; // RFC 1122 section 4.2.2.20 (a) m_nRetransmissionCount = MAX_RETRANSMISSIONS; m_bFINQueued = TRUE; break; case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: return -1; } if (m_nErrno < 0) { return m_nErrno; } return 0; } int CTCPConnection::Send (const void *pData, unsigned nLength, int nFlags) { if ( nFlags != 0 && nFlags != MSG_DONTWAIT) { return -1; } if (m_nErrno < 0) { return m_nErrno; } switch (m_State) { case TCPStateClosed: case TCPStateListen: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: return -1; case TCPStateSynSent: case TCPStateSynReceived: case TCPStateEstablished: case TCPStateCloseWait: break; } unsigned nResult = nLength; assert (pData != 0); u8 *pBuffer = (u8 *) pData; while (nLength > FRAME_BUFFER_SIZE) { m_TxQueue.Enqueue (pBuffer, FRAME_BUFFER_SIZE); pBuffer += FRAME_BUFFER_SIZE; nLength -= FRAME_BUFFER_SIZE; } if (nLength > 0) { m_TxQueue.Enqueue (pBuffer, nLength); } if (!(nFlags & MSG_DONTWAIT)) { m_TxEvent.Clear (); m_TxEvent.Wait (); if (m_nErrno < 0) { return m_nErrno; } } return nResult; } int CTCPConnection::Receive (void *pBuffer, int nFlags) { if ( nFlags != 0 && nFlags != MSG_DONTWAIT) { return -1; } if (m_nErrno < 0) { return m_nErrno; } unsigned nLength; while ((nLength = m_RxQueue.Dequeue (pBuffer)) == 0) { switch (m_State) { case TCPStateClosed: case TCPStateListen: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: return -1; case TCPStateSynSent: case TCPStateSynReceived: case TCPStateEstablished: break; } if (nFlags & MSG_DONTWAIT) { return 0; } m_Event.Clear (); m_Event.Wait (); if (m_nErrno < 0) { return m_nErrno; } } return nLength; } int CTCPConnection::SendTo (const void *pData, unsigned nLength, int nFlags, CIPAddress &rForeignIP, u16 nForeignPort) { // ignore rForeignIP and nForeignPort return Send (pData, nLength, nFlags); } int CTCPConnection::ReceiveFrom (void *pBuffer, int nFlags, CIPAddress *pForeignIP, u16 *pForeignPort) { int nResult = Receive (pBuffer, nFlags); if (nResult <= 0) { return nResult; } if ( pForeignIP != 0 && pForeignPort != 0) { pForeignIP->Set (m_ForeignIP); *pForeignPort = m_nForeignPort; } return 0; } int CTCPConnection::SetOptionBroadcast (boolean bAllowed) { return 0; } boolean CTCPConnection::IsConnected (void) const { return m_State > TCPStateSynSent && m_State != TCPStateTimeWait; } boolean CTCPConnection::IsTerminated (void) const { return m_State == TCPStateClosed; } void CTCPConnection::Process (void) { if (m_bTimedOut) { m_nErrno = -1; NEW_STATE (TCPStateClosed); m_Event.Set (); return; } switch (m_State) { case TCPStateClosed: case TCPStateListen: case TCPStateFinWait2: case TCPStateTimeWait: return; case TCPStateSynSent: case TCPStateSynReceived: if (m_bSendSYN) { m_bSendSYN = FALSE; if (m_State == TCPStateSynSent) { SendSegment (TCP_FLAG_SYN, m_nISS); } else { SendSegment (TCP_FLAG_SYN | TCP_FLAG_ACK, m_nISS, m_nRCV_NXT); } m_RTOCalculator.SegmentSent (m_nISS); StartTimer (TCPTimerRetransmission, m_RTOCalculator.GetRTO ()); } return; case TCPStateEstablished: case TCPStateFinWait1: case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: if ( m_RetransmissionQueue.IsEmpty () && m_TxQueue.IsEmpty () && m_bFINQueued) { SendSegment (TCP_FLAG_FIN | TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); m_RTOCalculator.SegmentSent (m_nSND_NXT); m_nSND_NXT++; NEW_STATE (m_StateAfterFIN); m_bFINQueued = FALSE; StartTimer (TCPTimerRetransmission, m_RTOCalculator.GetRTO ()); } break; } u8 TempBuffer[FRAME_BUFFER_SIZE]; unsigned nLength; while ( m_RetransmissionQueue.GetFreeSpace () >= FRAME_BUFFER_SIZE && (nLength = m_TxQueue.Dequeue (TempBuffer)) > 0) { #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "Transfering %u bytes into RT buffer", nLength); #endif m_RetransmissionQueue.Write (TempBuffer, nLength); } // pacing transmit if ( ( m_State == TCPStateEstablished || m_State == TCPStateCloseWait) && m_TxQueue.IsEmpty ()) { m_TxEvent.Set (); } if (m_bRetransmit) { #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "Retransmission (nxt %u, una %u)", m_nSND_NXT-m_nISS, m_nSND_UNA-m_nISS); #endif m_bRetransmit = FALSE; m_RetransmissionQueue.Reset (); m_nSND_NXT = m_nSND_UNA; } u32 nBytesAvail; u32 nWindowLeft; while ( (nBytesAvail = m_RetransmissionQueue.GetBytesAvailable ()) > 0 && (nWindowLeft = m_nSND_UNA+m_nSND_WND-m_nSND_NXT) > 0) { nLength = min (nBytesAvail, nWindowLeft); nLength = min (nLength, m_nSND_MSS); #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "Transfering %u bytes into TX buffer", nLength); #endif assert (nLength <= FRAME_BUFFER_SIZE); m_RetransmissionQueue.Read (TempBuffer, nLength); unsigned nFlags = TCP_FLAG_ACK; if (m_TxQueue.IsEmpty ()) { nFlags |= TCP_FLAG_PUSH; } SendSegment (nFlags, m_nSND_NXT, m_nRCV_NXT, TempBuffer, nLength); m_RTOCalculator.SegmentSent (m_nSND_NXT, nLength); m_nSND_NXT += nLength; StartTimer (TCPTimerRetransmission, m_RTOCalculator.GetRTO ()); } } int CTCPConnection::PacketReceived (const void *pPacket, unsigned nLength, CIPAddress &rSenderIP, CIPAddress &rReceiverIP, int nProtocol) { if (nProtocol != IPPROTO_TCP) { return 0; } if (nLength < sizeof (TTCPHeader)) { return -1; } assert (pPacket != 0); TTCPHeader *pHeader = (TTCPHeader *) pPacket; if (m_nOwnPort != be2le16 (pHeader->nDestPort)) { return 0; } if (m_State != TCPStateListen) { if ( m_ForeignIP != rSenderIP || m_nForeignPort != be2le16 (pHeader->nSourcePort)) { return 0; } } else { if (!(pHeader->nDataOffsetFlags & TCP_FLAG_SYN)) { return 0; } m_Checksum.SetDestinationAddress (rSenderIP); } if (m_Checksum.Calculate (pPacket, nLength) != CHECKSUM_OK) { return 0; } u16 nFlags = pHeader->nDataOffsetFlags; u32 nDataOffset = TCP_DATA_OFFSET (pHeader->nDataOffsetFlags)*4; u32 nDataLength = nLength-nDataOffset; // Current Segment Variables u32 nSEG_SEQ = be2le32 (pHeader->nSequenceNumber); u32 nSEG_ACK = be2le32 (pHeader->nAcknowledgmentNumber); u32 nSEG_LEN = nDataLength; if (nFlags & TCP_FLAG_SYN) { nSEG_LEN++; } if (nFlags & TCP_FLAG_FIN) { nSEG_LEN++; } u32 nSEG_WND = be2le16 (pHeader->nWindow); //u16 nSEG_UP = be2le16 (pHeader->nUrgentPointer); //u32 nSEG_PRC; // segment precedence value ScanOptions (pHeader); #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "rx %c%c%c%c%c%c, seq %u, ack %u, win %u, len %u", nFlags & TCP_FLAG_URGENT ? 'U' : '-', nFlags & TCP_FLAG_ACK ? 'A' : '-', nFlags & TCP_FLAG_PUSH ? 'P' : '-', nFlags & TCP_FLAG_RESET ? 'R' : '-', nFlags & TCP_FLAG_SYN ? 'S' : '-', nFlags & TCP_FLAG_FIN ? 'F' : '-', nSEG_SEQ-m_nIRS, nFlags & TCP_FLAG_ACK ? nSEG_ACK-m_nISS : 0, nSEG_WND, nDataLength); DumpStatus (); #endif boolean bAcceptable = FALSE; // RFC 793 section 3.9 "SEGMENT ARRIVES" switch (m_State) { case TCPStateClosed: if (nFlags & TCP_FLAG_RESET) { // ignore } else if (!(nFlags & TCP_FLAG_ACK)) { m_ForeignIP.Set (rSenderIP); m_nForeignPort = be2le16 (pHeader->nSourcePort); m_Checksum.SetDestinationAddress (rSenderIP); SendSegment (TCP_FLAG_RESET | TCP_FLAG_ACK, 0, nSEG_SEQ+nSEG_LEN); } else { m_ForeignIP.Set (rSenderIP); m_nForeignPort = be2le16 (pHeader->nSourcePort); m_Checksum.SetDestinationAddress (rSenderIP); SendSegment (TCP_FLAG_RESET, nSEG_ACK); } break; case TCPStateListen: if (nFlags & TCP_FLAG_RESET) { // ignore } else if (nFlags & TCP_FLAG_ACK) { m_ForeignIP.Set (rSenderIP); m_nForeignPort = be2le16 (pHeader->nSourcePort); m_Checksum.SetDestinationAddress (rSenderIP); SendSegment (TCP_FLAG_RESET, nSEG_ACK); } else if (nFlags & TCP_FLAG_SYN) { if (s_nConnections >= TCP_MAX_CONNECTIONS) { m_ForeignIP.Set (rSenderIP); m_nForeignPort = be2le16 (pHeader->nSourcePort); m_Checksum.SetDestinationAddress (rSenderIP); SendSegment (TCP_FLAG_RESET | TCP_FLAG_ACK, 0, nSEG_SEQ+nSEG_LEN); break; } m_nRCV_NXT = nSEG_SEQ+1; m_nIRS = nSEG_SEQ; m_nSND_WND = nSEG_WND; m_nSND_WL1 = nSEG_SEQ; m_nSND_WL2 = nSEG_ACK; assert (nSEG_LEN > 0); if (nDataLength > 0) { m_RxQueue.Enqueue ((u8 *) pPacket+nDataOffset, nDataLength); } m_nISS = CalculateISN (); m_RTOCalculator.Initialize (m_nISS); m_ForeignIP.Set (rSenderIP); m_nForeignPort = be2le16 (pHeader->nSourcePort); m_Checksum.SetDestinationAddress (rSenderIP); SendSegment (TCP_FLAG_SYN | TCP_FLAG_ACK, m_nISS, m_nRCV_NXT); m_RTOCalculator.SegmentSent (m_nISS); m_nSND_NXT = m_nISS+1; m_nSND_UNA = m_nISS; NEW_STATE (TCPStateSynReceived); m_Event.Set (); } break; case TCPStateSynSent: if (nFlags & TCP_FLAG_ACK) { if (!bwh (m_nISS, nSEG_ACK, m_nSND_NXT)) { if (!(nFlags & TCP_FLAG_RESET)) { SendSegment (TCP_FLAG_RESET, nSEG_ACK); } return 1; } else if (bwlh (m_nSND_UNA, nSEG_ACK, m_nSND_NXT)) { bAcceptable = TRUE; } } if (nFlags & TCP_FLAG_RESET) { if (bAcceptable) { NEW_STATE (TCPStateClosed); m_bSendSYN = FALSE; m_nErrno = -1; m_Event.Set (); } break; } if ( (nFlags & TCP_FLAG_ACK) && !bAcceptable) { break; } if (nFlags & TCP_FLAG_SYN) { m_nRCV_NXT = nSEG_SEQ+1; m_nIRS = nSEG_SEQ; if (nFlags & TCP_FLAG_ACK) { m_RTOCalculator.SegmentAcknowledged (nSEG_ACK); if (nSEG_ACK-m_nSND_UNA > 1) { m_RetransmissionQueue.Advance (nSEG_ACK-m_nSND_UNA-1); } m_nSND_UNA = nSEG_ACK; } if (gt (m_nSND_UNA, m_nISS)) { NEW_STATE (TCPStateEstablished); m_bSendSYN = FALSE; StopTimer (TCPTimerRetransmission); // next transmission starts with this count m_nRetransmissionCount = MAX_RETRANSMISSIONS; m_Event.Set (); // RFC 1122 section 4.2.2.20 (c) m_nSND_WND = nSEG_WND; m_nSND_WL1 = nSEG_SEQ; m_nSND_WL2 = nSEG_ACK; SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); if ( (nFlags & TCP_FLAG_FIN) // other controls? || nDataLength > 0) { goto StepSix; } break; } else { NEW_STATE (TCPStateSynReceived); m_bSendSYN = FALSE; SendSegment (TCP_FLAG_SYN | TCP_FLAG_ACK, m_nISS, m_nRCV_NXT); m_RTOCalculator.SegmentSent (m_nISS); m_nRetransmissionCount = MAX_RETRANSMISSIONS; StartTimer (TCPTimerRetransmission, m_RTOCalculator.GetRTO ()); if ( (nFlags & TCP_FLAG_FIN) // other controls? || nDataLength > 0) { if (nFlags & TCP_FLAG_FIN) { SendSegment (TCP_FLAG_RESET, m_nSND_NXT); NEW_STATE (TCPStateClosed); m_nErrno = -1; m_Event.Set (); } if (nDataLength > 0) { m_RxQueue.Enqueue ((u8 *) pPacket+nDataOffset, nDataLength); } break; } } } break; case TCPStateSynReceived: case TCPStateEstablished: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: // step 1 ( check sequence number) if (m_nRCV_WND > 0) { if (nSEG_LEN == 0) { if (bwl (m_nRCV_NXT, nSEG_SEQ, m_nRCV_NXT+m_nRCV_WND)) { bAcceptable = TRUE; } } else { if ( bwl (m_nRCV_NXT, nSEG_SEQ, m_nRCV_NXT+m_nRCV_WND) || bwl (m_nRCV_NXT, nSEG_SEQ+nSEG_LEN-1, m_nRCV_NXT+m_nRCV_WND)) { bAcceptable = TRUE; } } } else { if (nSEG_LEN == 0) { if (nSEG_SEQ == m_nRCV_NXT) { bAcceptable = TRUE; } } } if ( !bAcceptable && m_State != TCPStateSynReceived) { SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); break; } // step 2 (check RST bit) if (nFlags & TCP_FLAG_RESET) { switch (m_State) { case TCPStateSynReceived: m_RetransmissionQueue.Flush (); if (!m_bActiveOpen) { NEW_STATE (TCPStateListen); return 1; } else { m_nErrno = -1; NEW_STATE (TCPStateClosed); m_Event.Set (); return 1; } break; case TCPStateEstablished: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: m_nErrno = -1; m_RetransmissionQueue.Flush (); m_TxQueue.Flush (); m_RxQueue.Flush (); NEW_STATE (TCPStateClosed); m_Event.Set (); return 1; case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: NEW_STATE (TCPStateClosed); m_Event.Set (); return 1; default: UNEXPECTED_STATE (); return 1; } } // step 3 (check security and precedence, not supported) // step 4 (check SYN bit) if (nFlags & TCP_FLAG_SYN) { // RFC 1122 section 4.2.2.20 (e) if ( m_State == TCPStateSynReceived && !m_bActiveOpen) { NEW_STATE (TCPStateListen); return 1; } SendSegment (TCP_FLAG_RESET, m_nSND_NXT); m_nErrno = -1; m_RetransmissionQueue.Flush (); m_TxQueue.Flush (); m_RxQueue.Flush (); NEW_STATE (TCPStateClosed); m_Event.Set (); return 1; } // step 5 (check ACK field) if (!(nFlags & TCP_FLAG_ACK)) { return 1; } switch (m_State) { case TCPStateSynReceived: if (bwlh (m_nSND_UNA, nSEG_ACK, m_nSND_NXT)) { // RFC 1122 section 4.2.2.20 (f) m_nSND_WND = nSEG_WND; m_nSND_WL1 = nSEG_SEQ; m_nSND_WL2 = nSEG_ACK; m_nSND_UNA = nSEG_ACK; // got ACK for SYN m_RTOCalculator.SegmentAcknowledged (nSEG_ACK); NEW_STATE (TCPStateEstablished); // next transmission starts with this count m_nRetransmissionCount = MAX_RETRANSMISSIONS; } else { SendSegment (TCP_FLAG_RESET, nSEG_ACK); } break; case TCPStateEstablished: case TCPStateFinWait1: case TCPStateFinWait2: case TCPStateCloseWait: case TCPStateClosing: if (bwh (m_nSND_UNA, nSEG_ACK, m_nSND_NXT)) { m_RTOCalculator.SegmentAcknowledged (nSEG_ACK); unsigned nBytesAck = nSEG_ACK-m_nSND_UNA; m_nSND_UNA = nSEG_ACK; if (nSEG_ACK == m_nSND_NXT) // all segments are acknowledged { StopTimer (TCPTimerRetransmission); // next transmission starts with this count m_nRetransmissionCount = MAX_RETRANSMISSIONS; } if ( m_State == TCPStateFinWait1 || m_State == TCPStateClosing) { nBytesAck--; // acknowledged FIN does not count m_bFINQueued = FALSE; } if ( m_State == TCPStateEstablished && nBytesAck == 1) { nBytesAck--; } if (nBytesAck > 0) { m_RetransmissionQueue.Advance (nBytesAck); } // update send window if ( lt (m_nSND_WL1, nSEG_SEQ) || ( m_nSND_WL1 == nSEG_SEQ && le (m_nSND_WL2, nSEG_ACK))) { m_nSND_WND = nSEG_WND; m_nSND_WL1 = nSEG_SEQ; m_nSND_WL2 = nSEG_ACK; } } else if (le (nSEG_ACK, m_nSND_UNA)) // RFC 1122 section 4.2.2.20 (g) { // ignore duplicate ACK ... // RFC 1122 section 4.2.2.20 (g) if (bwlh (m_nSND_UNA, nSEG_ACK, m_nSND_NXT)) { // ... but update send window if ( lt (m_nSND_WL1, nSEG_SEQ) || ( m_nSND_WL1 == nSEG_SEQ && le (m_nSND_WL2, nSEG_ACK))) { m_nSND_WND = nSEG_WND; m_nSND_WL1 = nSEG_SEQ; m_nSND_WL2 = nSEG_ACK; } } } else if (gt (nSEG_ACK, m_nSND_NXT)) { SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); return 1; } switch (m_State) { case TCPStateEstablished: case TCPStateCloseWait: break; case TCPStateFinWait1: if (nSEG_ACK == m_nSND_NXT) // if our FIN is now acknowledged { m_RTOCalculator.SegmentAcknowledged (nSEG_ACK); m_bFINQueued = FALSE; StopTimer (TCPTimerRetransmission); NEW_STATE (TCPStateFinWait2); StartTimer (TCPTimerTimeWait, HZ_FIN_TIMEOUT); } else { break; } // fall through case TCPStateFinWait2: if (m_RetransmissionQueue.IsEmpty ()) { m_Event.Set (); } break; case TCPStateClosing: if (nSEG_ACK == m_nSND_NXT) // if our FIN is now acknowledged { m_RTOCalculator.SegmentAcknowledged (nSEG_ACK); m_bFINQueued = FALSE; StopTimer (TCPTimerRetransmission); NEW_STATE (TCPStateTimeWait); StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); } break; default: UNEXPECTED_STATE (); break; } break; case TCPStateLastAck: if (nSEG_ACK == m_nSND_NXT) // if our FIN is now acknowledged { m_bFINQueued = FALSE; NEW_STATE (TCPStateClosed); m_Event.Set (); return 1; } break; case TCPStateTimeWait: if (nSEG_ACK == m_nSND_NXT) // if our FIN is now acknowledged { m_bFINQueued = FALSE; SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); } break; default: UNEXPECTED_STATE (); break; } // step 6 (check URG bit, not supported) StepSix: // step 7 (process text segment) if (nSEG_LEN == 0) { return 1; } switch (m_State) { case TCPStateEstablished: case TCPStateFinWait1: case TCPStateFinWait2: if (nSEG_SEQ == m_nRCV_NXT) { if (nDataLength > 0) { m_RxQueue.Enqueue ((u8 *) pPacket+nDataOffset, nDataLength); m_nRCV_NXT += nDataLength; // m_nRCV_WND should be adjusted here (section 3.7) // following ACK could be piggybacked with data SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); if (nFlags & TCP_FLAG_PUSH) { m_Event.Set (); } } } else { SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); return 1; } break; case TCPStateSynReceived: // this state not in RFC 793 case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: case TCPStateTimeWait: break; default: UNEXPECTED_STATE (); break; } // step 8 (check FIN bit) if ( m_State == TCPStateClosed || m_State == TCPStateListen || m_State == TCPStateSynSent) { return 1; } if (!(nFlags & TCP_FLAG_FIN)) { return 1; } // connection is closing m_nRCV_NXT++; SendSegment (TCP_FLAG_ACK, m_nSND_NXT, m_nRCV_NXT); switch (m_State) { case TCPStateSynReceived: case TCPStateEstablished: NEW_STATE (TCPStateCloseWait); m_Event.Set (); break; case TCPStateFinWait1: if (nSEG_ACK == m_nSND_NXT) // if our FIN is now acknowledged { m_bFINQueued = FALSE; StopTimer (TCPTimerRetransmission); StopTimer (TCPTimerUser); NEW_STATE (TCPStateTimeWait); StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); } else { NEW_STATE (TCPStateClosing); } break; case TCPStateFinWait2: StopTimer (TCPTimerRetransmission); StopTimer (TCPTimerUser); NEW_STATE (TCPStateTimeWait); StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); break; case TCPStateCloseWait: case TCPStateClosing: case TCPStateLastAck: break; case TCPStateTimeWait: StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); break; default: UNEXPECTED_STATE (); break; } break; } return 1; } int CTCPConnection::NotificationReceived (TICMPNotificationType Type, CIPAddress &rSenderIP, CIPAddress &rReceiverIP, u16 nSendPort, u16 nReceivePort, int nProtocol) { if (nProtocol != IPPROTO_TCP) { return 0; } if (m_State < TCPStateSynSent) { return 0; } if ( m_ForeignIP != rSenderIP || m_nForeignPort != nSendPort) { return 0; } assert (m_pNetConfig != 0); if ( rReceiverIP != *m_pNetConfig->GetIPAddress () || m_nOwnPort != nReceivePort) { return 0; } m_nErrno = -1; StopTimer (TCPTimerRetransmission); NEW_STATE (TCPStateTimeWait); StartTimer (TCPTimerTimeWait, HZ_TIMEWAIT); m_Event.Set (); return 1; } boolean CTCPConnection::SendSegment (unsigned nFlags, u32 nSequenceNumber, u32 nAcknowledgmentNumber, const void *pData, unsigned nDataLength) { unsigned nDataOffset = 5; assert (nDataOffset * 4 == sizeof (TTCPHeader)); if (nFlags & TCP_FLAG_SYN) { nDataOffset++; } unsigned nHeaderLength = nDataOffset * 4; unsigned nPacketLength = nHeaderLength + nDataLength; // may wrap assert (nPacketLength >= nHeaderLength); assert (nHeaderLength <= FRAME_BUFFER_SIZE); u8 TxBuffer[FRAME_BUFFER_SIZE]; TTCPHeader *pHeader = (TTCPHeader *) TxBuffer; pHeader->nSourcePort = le2be16 (m_nOwnPort); pHeader->nDestPort = le2be16 (m_nForeignPort); pHeader->nSequenceNumber = le2be32 (nSequenceNumber); pHeader->nAcknowledgmentNumber = nFlags & TCP_FLAG_ACK ? le2be32 (nAcknowledgmentNumber) : 0; pHeader->nDataOffsetFlags = (nDataOffset << TCP_DATA_OFFSET_SHIFT) | nFlags; pHeader->nWindow = le2be16 (m_nRCV_WND); pHeader->nUrgentPointer = le2be16 (m_nSND_UP); if (nFlags & TCP_FLAG_SYN) { TTCPOption *pOption = (TTCPOption *) pHeader->Options; pOption->nKind = TCP_OPTION_MSS; pOption->nLength = 4; pOption->Data[0] = TCP_CONFIG_MSS >> 8; pOption->Data[1] = TCP_CONFIG_MSS & 0xFF; } if (nDataLength > 0) { assert (pData != 0); memcpy (TxBuffer+nHeaderLength, pData, nDataLength); } pHeader->nChecksum = 0; // must be 0 for calculation pHeader->nChecksum = m_Checksum.Calculate (TxBuffer, nPacketLength); #ifdef TCP_DEBUG CLogger::Get ()->Write (FromTCP, LogDebug, "tx %c%c%c%c%c%c, seq %u, ack %u, win %u, len %u", nFlags & TCP_FLAG_URGENT ? 'U' : '-', nFlags & TCP_FLAG_ACK ? 'A' : '-', nFlags & TCP_FLAG_PUSH ? 'P' : '-', nFlags & TCP_FLAG_RESET ? 'R' : '-', nFlags & TCP_FLAG_SYN ? 'S' : '-', nFlags & TCP_FLAG_FIN ? 'F' : '-', nSequenceNumber-m_nISS, nFlags & TCP_FLAG_ACK ? nAcknowledgmentNumber-m_nIRS : 0, m_nRCV_WND, nDataLength); #endif assert (m_pNetworkLayer != 0); return m_pNetworkLayer->Send (m_ForeignIP, TxBuffer, nPacketLength, IPPROTO_TCP); } void CTCPConnection::ScanOptions (TTCPHeader *pHeader) { assert (pHeader != 0); unsigned nDataOffset = TCP_DATA_OFFSET (pHeader->nDataOffsetFlags)*4; u8 *pHeaderEnd = (u8 *) pHeader+nDataOffset; TTCPOption *pOption = (TTCPOption *) pHeader->Options; while ((u8 *) pOption+2 <= pHeaderEnd) { switch (pOption->nKind) { case TCP_OPTION_END_OF_LIST: return; case TCP_OPTION_NOP: pOption = (TTCPOption *) ((u8 *) pOption+1); break; case TCP_OPTION_MSS: if ( pOption->nLength == 4 && (u8 *) pOption+4 <= pHeaderEnd) { u32 nMSS = (u16) pOption->Data[0] << 8 | pOption->Data[1]; // RFC 1122 section 4.2.2.6 nMSS = min (nMSS+20, MSS_S) - TCP_HEADER_SIZE - IP_OPTION_SIZE; if (nMSS >= 10) // self provided sanity check { m_nSND_MSS = (u16) nMSS; } } // fall through default: pOption = (TTCPOption *) ((u8 *) pOption+pOption->nLength); break; } } } u32 CTCPConnection::CalculateISN (void) { assert (m_pTimer != 0); return ( m_pTimer->GetTime () * HZ + m_pTimer->GetTicks () % HZ) * (TCP_MAX_WINDOW / TCP_QUIET_TIME / HZ); } void CTCPConnection::StartTimer (unsigned nTimer, unsigned nHZ) { assert (nTimer < TCPTimerUnknown); assert (nHZ > 0); assert (m_pTimer != 0); StopTimer (nTimer); m_hTimer[nTimer] = m_pTimer->StartKernelTimer (nHZ, TimerStub, (void *) (uintptr) nTimer, this); } void CTCPConnection::StopTimer (unsigned nTimer) { assert (nTimer < TCPTimerUnknown); assert (m_pTimer != 0); m_TimerSpinLock.Acquire (); if (m_hTimer[nTimer] != 0) { m_pTimer->CancelKernelTimer (m_hTimer[nTimer]); m_hTimer[nTimer] = 0; } m_TimerSpinLock.Release (); } void CTCPConnection::TimerHandler (unsigned nTimer) { assert (nTimer < TCPTimerUnknown); m_TimerSpinLock.Acquire (); if (m_hTimer[nTimer] == 0) // timer was stopped in the meantime { m_TimerSpinLock.Release (); return; } m_hTimer[nTimer] = 0; m_TimerSpinLock.Release (); switch (nTimer) { case TCPTimerRetransmission: m_RTOCalculator.RetransmissionTimerExpired (); if (m_nRetransmissionCount-- == 0) { m_bTimedOut = TRUE; break; } switch (m_State) { case TCPStateClosed: case TCPStateListen: case TCPStateFinWait2: case TCPStateTimeWait: UNEXPECTED_STATE (); break; case TCPStateSynSent: case TCPStateSynReceived: assert (!m_bSendSYN); m_bSendSYN = TRUE; break; case TCPStateEstablished: case TCPStateCloseWait: assert (!m_bRetransmit); m_bRetransmit = TRUE; break; case TCPStateFinWait1: case TCPStateClosing: case TCPStateLastAck: assert (!m_bFINQueued); m_bFINQueued = TRUE; break; } break; case TCPTimerTimeWait: NEW_STATE (TCPStateClosed); break; case TCPTimerUser: case TCPTimerUnknown: assert (0); break; } } void CTCPConnection::TimerStub (TKernelTimerHandle hTimer, void *pParam, void *pContext) { CTCPConnection *pThis = (CTCPConnection *) pContext; assert (pThis != 0); unsigned nTimer = (unsigned) (uintptr) pParam; assert (nTimer < TCPTimerUnknown); pThis->TimerHandler (nTimer); } #ifndef NDEBUG void CTCPConnection::DumpStatus (void) { CLogger::Get ()->Write (FromTCP, LogDebug, "sta %u, una %u, snx %u, swn %u, rnx %u, rwn %u, fprt %u", m_State, m_nSND_UNA-m_nISS, m_nSND_NXT-m_nISS, m_nSND_WND, m_nRCV_NXT-m_nIRS, m_nRCV_WND, (unsigned) m_nForeignPort); } TTCPState CTCPConnection::NewState (TTCPState State, unsigned nLine) { const static char *StateName[] = // must match TTCPState { "CLOSED", "LISTEN", "SYN-SENT", "SYN-RECEIVED", "ESTABLISHED", "FIN-WAIT-1", "FIN-WAIT-2", "CLOSE-WAIT", "CLOSING", "LAST-ACK", "TIME-WAIT" }; assert (m_State < sizeof StateName / sizeof StateName[0]); assert (State < sizeof StateName / sizeof StateName[0]); CLogger::Get ()->Write (FromTCP, LogDebug, "State %s -> %s at line %u", StateName[m_State], StateName[State], nLine); return m_State = State; } void CTCPConnection::UnexpectedState (unsigned nLine) { DumpStatus (); CLogger::Get ()->Write (FromTCP, LogPanic, "Unexpected state %u at line %u", m_State, nLine); } #endif
Java
# Controller generated by Typus, use it to extend admin functionality. class Admin::UserInterestsController < Admin::MasterController =begin ## # You can overwrite and extend Admin::MasterController with your methods. # # Actions have to be defined in <tt>config/typus/application.yml</tt>: # # UserInterest: # actions: # index: custom_action # edit: custom_action_for_an_item # # And you have to add permissions on <tt>config/typus/application_roles.yml</tt> # to have access to them. # # admin: # UserInterest: create, read, update, destroy, custom_action # # editor: # UserInterest: create, read, update, custom_action_for_an_item # def index end def custom_action end def custom_action_for_an_item end =end end
Java
#include "template_components.h" #include <QtGui/QSpacerItem> TemplateComponents::TemplateComponents(const QSharedPointer<const Template>& templ, QWidget *parent) : QWidget(parent), templ(templ) { ui.setupUi(this); QList<FoodComponent> components = templ->getComponents(); for (QList<FoodComponent>::iterator i = components.begin(); i != components.end(); ++i) { componentWidgetGroups.append(ComponentWidgetGroup(i->getFoodAmount(), this)); } ui.componentLayout->addItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding), ui.componentLayout->rowCount(), 0); } TemplateComponents::~TemplateComponents() { } QSharedPointer<FoodCollection> TemplateComponents::getCollection() const { QSharedPointer<FoodCollection> collection = FoodCollection::createFoodCollection(templ->getDisplayName()); for (QList<ComponentWidgetGroup>::const_iterator i = componentWidgetGroups.begin(); i != componentWidgetGroups.end(); ++i) { collection->addComponent(i->getFoodAmount()); } return collection; } TemplateComponents::ComponentWidgetGroup::ComponentWidgetGroup (FoodAmount foodAmount, TemplateComponents* parent) : food(foodAmount.getFood()), lblFoodName(new QLabel(parent)), txtAmount(new QLineEdit(parent)), cbUnit(new QComboBox(parent)), chkIncludeRefuse(new QCheckBox(parent)) { int row = parent->ui.componentLayout->rowCount(); parent->ui.componentLayout->addWidget(lblFoodName, row, 0); parent->ui.componentLayout->addWidget(txtAmount, row, 1); parent->ui.componentLayout->addWidget(cbUnit, row, 2); parent->ui.componentLayout->addWidget(chkIncludeRefuse, row, 3); lblFoodName->setText(food->getDisplayName()); lblFoodName->setWordWrap(true); txtAmount->setText(QString::number(foodAmount.getAmount())); txtAmount->setMinimumWidth(50); txtAmount->setMaximumWidth(80); txtAmount->setAlignment(Qt::AlignRight); QMap<QString, QSharedPointer<const Unit> > unitsToShow; QList<Unit::Dimensions::Dimension> validDimensions = food->getValidDimensions(); for (QList<Unit::Dimensions::Dimension>::const_iterator i = validDimensions.begin(); i != validDimensions.end(); ++i) { QVector<QSharedPointer<const Unit> > units = Unit::getAllUnits(*i); for (QVector<QSharedPointer<const Unit> >::const_iterator i = units.begin(); i != units.end(); ++i) { unitsToShow.insert((*i)->getName(), *i); } } for (QMap<QString, QSharedPointer<const Unit> >::iterator i = unitsToShow.begin(); i != unitsToShow.end(); ++i) { cbUnit->addItem(i.value()->getNameAndAbbreviation(), i.value()->getAbbreviation()); } cbUnit->setCurrentIndex(cbUnit->findData(foodAmount.getUnit()->getAbbreviation())); chkIncludeRefuse->setText("Including inedible parts"); chkIncludeRefuse->setChecked (foodAmount.includesRefuse() && foodAmount.getFood()->getPercentRefuse() > 0); chkIncludeRefuse->setEnabled(foodAmount.getFood()->getPercentRefuse() > 0); } FoodAmount TemplateComponents::ComponentWidgetGroup::getFoodAmount() const { return FoodAmount(food, txtAmount->text().toDouble(), Unit::getUnit(cbUnit->itemData(cbUnit->currentIndex()).toString()), !chkIncludeRefuse->isEnabled() || chkIncludeRefuse->isChecked()); }
Java
/* * Copyright (c) 2014-2016 Alex Spataru <alex_spataru@outlook.com> * * This file is part of the QSimpleUpdater library, which is released under * the DBAD license, you can read a copy of it below: * * DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, * DISTRIBUTION AND MODIFICATION: * * Do whatever you like with the original work, just don't be a dick. * Being a dick includes - but is not limited to - the following instances: * * 1a. Outright copyright infringement - Don't just copy this and change the * name. * 1b. Selling the unmodified original with no work done what-so-ever, that's * REALLY being a dick. * 1c. Modifying the original work to contain hidden harmful content. * That would make you a PROPER dick. * * If you become rich through modifications, related works/services, or * supporting the original work, share the love. * Only a dick would make loads off this work and not buy the original works * creator(s) a pint. * * Code is provided with no warranty. Using somebody else's code and bitching * when it goes wrong makes you a DONKEY dick. * Fix the problem yourself. A non-dick would submit the fix back. */ #ifndef _QSIMPLEUPDATER_MAIN_H #define _QSIMPLEUPDATER_MAIN_H #include <QUrl> #include <QList> #include <QObject> #if defined (QSU_SHARED) #define QSU_DECL Q_DECL_EXPORT #elif defined (QSU_IMPORT) #define QSU_DECL Q_DECL_IMPORT #else #define QSU_DECL #endif class Updater; /** * \brief Manages the updater instances * * The \c QSimpleUpdater class manages the updater system and allows for * parallel application modules to check for updates and download them. * * The behavior of each updater can be regulated by specifying the update * definitions URL (from where we download the individual update definitions) * and defining the desired options by calling the individual "setter" * functions (e.g. \c setNotifyOnUpdate()). * * The \c QSimpleUpdater also implements an integrated downloader. * If you need to use a custom install procedure/code, just create a function * that is called when the \c downloadFinished() signal is emitted to * implement your own install procedures. * * By default, the downloader will try to open the file as if you opened it * from a file manager or a web browser (with the "file:*" url). */ class QSU_DECL QSimpleUpdater : public QObject { Q_OBJECT signals: void checkingFinished (const QString& url); void appcastDownloaded (const QString& url, const QByteArray& data); void downloadFinished (const QString& url, const QString& filepath); void installerOpened(); void updateDeclined(); public: static QSimpleUpdater* getInstance(); bool usesCustomAppcast (const QString& url) const; bool getNotifyOnUpdate (const QString& url) const; bool getNotifyOnFinish (const QString& url) const; bool getUpdateAvailable (const QString& url) const; bool getDownloaderEnabled (const QString& url) const; bool usesCustomInstallProcedures (const QString& url) const; QString getOpenUrl (const QString& url) const; QString getChangelog (const QString& url) const; QString getModuleName (const QString& url) const; QString getDownloadUrl (const QString& url) const; QString getPlatformKey (const QString& url) const; QString getLatestVersion (const QString& url) const; QString getModuleVersion (const QString& url) const; public slots: void checkForUpdates (const QString& url); void setModuleName (const QString& url, const QString& name); void setNotifyOnUpdate (const QString& url, const bool notify); void setNotifyOnFinish (const QString& url, const bool notify); void setPlatformKey (const QString& url, const QString& platform); void setModuleVersion (const QString& url, const QString& version); void setDownloaderEnabled (const QString& url, const bool enabled); void setUseCustomAppcast (const QString& url, const bool customAppcast); void setUseCustomInstallProcedures (const QString& url, const bool custom); protected: ~QSimpleUpdater(); private: Updater* getUpdater (const QString& url) const; }; #endif
Java
/* ------------------------------------------------------------------------------- This file is part of the weather information collector. Copyright (C) 2018, 2019, 2020, 2021 Dirk Stolle 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 <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------------- */ #include <iostream> #include <string> #include <utility> #include "../conf/Configuration.hpp" #include "../db/mariadb/SourceMariaDB.hpp" #include "../db/mariadb/StoreMariaDB.hpp" #include "../db/mariadb/StoreMariaDBBatch.hpp" #include "../db/mariadb/Utilities.hpp" #include "../db/mariadb/client_version.hpp" #include "../db/mariadb/guess.hpp" #include "../util/SemVer.hpp" #include "../util/Strings.hpp" #include "../ReturnCodes.hpp" #include "../Version.hpp" const int defaultBatchSize = 40; void showHelp() { std::cout << "weather-information-collector-synchronizer [OPTIONS]\n" << "\n" << "Synchronizes data between two collector databases.\n" << "\n" << "options:\n" << " -? | --help - shows this help message\n" << " -v | --version - shows version information\n" << " -c1 FILE | --src-conf FILE\n" << " - sets the file name of the configuration file that\n" << " contains the database connection settings for the\n" << " source database.\n" << " -c2 FILE | --dest-conf FILE\n" << " - sets the file name of the configuration file that\n" << " contains the database connection settings for the\n" << " destination database.\n" << " -b N | --batch-size N - sets the number of records per batch insert to N.\n" << " Higher numbers mean increased performance, but it\n" << " could also result in hitting MySQL's limit for the\n" << " maximum packet size, called max_allowed_packet.\n" << " Defaults to " << defaultBatchSize << ", if no value is given.\n" << " --skip-update-check - skips the check to determine whether the databases\n" << " are up to date during program startup.\n"; } bool isLess(const wic::WeatherMeta& lhs, const wic::Weather& rhs) { return (lhs.dataTime() < rhs.dataTime()) || ((lhs.dataTime() == rhs.dataTime()) && (lhs.requestTime() < rhs.requestTime())); } bool isLess(const wic::ForecastMeta& lhs, const wic::Forecast& rhs) { return (lhs.requestTime() < rhs.requestTime()); } std::pair<int, bool> parseArguments(const int argc, char** argv, std::string& srcConfigurationFile, std::string& destConfigurationFile, int& batchSize, bool& skipUpdateCheck) { if ((argc <= 1) || (argv == nullptr)) return std::make_pair(0, false); for (int i = 1; i < argc; ++i) { if (argv[i] == nullptr) { std::cerr << "Error: Parameter at index " << i << " is null pointer!\n"; return std::make_pair(wic::rcInvalidParameter, true); } const std::string param(argv[i]); if ((param == "-v") || (param == "--version")) { wic::showVersion("weather-information-collector-synchronizer"); showMariaDbClientVersion(); return std::make_pair(0, true); } // if version else if ((param == "-?") || (param == "/?") || (param == "--help")) { showHelp(); return std::make_pair(0, true); } // if help else if ((param == "--src-conf") || (param == "-c1")) { if (!srcConfigurationFile.empty()) { std::cerr << "Error: Source configuration was already set to " << srcConfigurationFile << "!" << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } // enough parameters? if ((i+1 < argc) && (argv[i+1] != nullptr)) { srcConfigurationFile = std::string(argv[i+1]); // Skip next parameter, because it's already used as file path. ++i; } else { std::cerr << "Error: You have to enter a file path after \"" << param << "\"." << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } } // if source configuration file else if ((param == "--dest-conf") || (param == "-c2")) { if (!destConfigurationFile.empty()) { std::cerr << "Error: Destination configuration was already set to " << destConfigurationFile << "!" << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } // enough parameters? if ((i+1 < argc) && (argv[i+1] != nullptr)) { destConfigurationFile = std::string(argv[i+1]); // Skip next parameter, because it's already used as file path. ++i; } else { std::cerr << "Error: You have to enter a file path after \"" << param << "\"." << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } } // if destination configuration file else if ((param == "--batch-size") || (param == "-b")) { if (batchSize >= 0) { std::cerr << "Error: Batch size was already set to " << batchSize << "!" << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } // enough parameters? if ((i+1 < argc) && (argv[i+1] != nullptr)) { const std::string bsString = std::string(argv[i+1]); if (!wic::stringToInt(bsString, batchSize) || (batchSize <= 0)) { std::cerr << "Error: Batch size must be a positive integer!" << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } if (batchSize > 1000) { std::cout << "Info: Batch size " << batchSize << " will be reduced " << " to 1000, because too large batch sizes might cause " << "the database server to reject inserts." << std::endl; batchSize = 1000; } // Skip next parameter, because it's already used as batch size. ++i; } else { std::cerr << "Error: You have to enter a number after \"" << param << "\"." << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } } // if batch size else if ((param == "--skip-update-check") || (param == "--no-update-check")) { if (skipUpdateCheck) { std::cerr << "Error: Parameter " << param << " was already specified!" << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } skipUpdateCheck = true; } // if database update check shall be skipped else { std::cerr << "Error: Unknown parameter " << param << "!\n" << "Use --help to show available parameters." << std::endl; return std::make_pair(wic::rcInvalidParameter, true); } } // for i return std::make_pair(0, false); } int main(int argc, char** argv) { std::string srcConfigurationFile; /**< path of configuration file for source */ std::string destConfigurationFile; /**< path of configuration file for destination */ int batchSize = -1; /**< number of records per batch insert */ bool skipUpdateCheck = false; /**< whether to skip check for up to date DB */ const auto [exitCode, forceExit] = parseArguments(argc, argv, srcConfigurationFile, destConfigurationFile, batchSize, skipUpdateCheck); if (forceExit || (exitCode != 0)) return exitCode; if (srcConfigurationFile.empty()) { std::cerr << "Error: No source configuration file was specified!" << std::endl; return wic::rcInvalidParameter; } if (destConfigurationFile.empty()) { std::cerr << "Error: No destination configuration file was specified!" << std::endl; return wic::rcInvalidParameter; } // load source configuration file wic::Configuration srcConfig; if (!srcConfig.load(srcConfigurationFile, true, true)) { std::cerr << "Error: Could not load source configuration!" << std::endl; return wic::rcConfigurationError; } // load destination configuration file wic::Configuration destConfig; if (!destConfig.load(destConfigurationFile, true, true)) { std::cerr << "Error: Could not load destination configuration!" << std::endl; return wic::rcConfigurationError; } // Check that synchronization happens between different databases. const auto& srcDb = srcConfig.connectionInfo(); const auto& destDb = destConfig.connectionInfo(); if (srcDb.port() == destDb.port() && srcDb.db() == destDb.db() && wic::toLowerString(srcDb.hostname()) == wic::toLowerString(destDb.hostname())) { std::cerr << "Error: Source and destination databases are identical!" << std::endl; return wic::rcConfigurationError; } // If there is no batch size, use the default value. if (batchSize < 0) { std::cout << "Info: Using default batch size value of " << defaultBatchSize << "." << std::endl; batchSize = defaultBatchSize; } // Check whether databases are up to date. if (!skipUpdateCheck) { for (const wic::Configuration& config : { srcConfig, destConfig }) { const wic::SemVer currentVersion = wic::guessVersionFromDatabase(config.connectionInfo()); if (wic::SemVer() == currentVersion) { // Some database error must have occurred, so quit right here. std::cerr << "Error: Could not check version of database!" << std::endl; return wic::rcDatabaseError; } if (currentVersion < wic::mostUpToDateVersion) { const auto& ci = config.connectionInfo(); std::cerr << "Error: The database " << ci.db() << " at " << ci.hostname() << ":" << ci.port() << " seems to be from an older version of" << " weather-information-collector. Please run " << "weather-information-collector-update to update the database." << std::endl; std::cerr << "If this is wrong and you want to skip that check instead," << " then call this program with the parameter --skip-update-check." << " Be warned that this may result in incomplete data being " << "written to the destination database though." << std::endl; return wic::rcDatabaseError; } } // for } // if update check shall be performed else { // Give a warning to the user, so nobody can say "But why did nobody tell // me about these possible problems there?" std::cout << "Warning: Check whether the databases are up to date has been" << " skipped, as requested by user. This could possibly result" << " in incomplete data being written to the destination database" << " as well as other database errors. Only use this if you are " << " certain that both databases are up to date." << std::endl; } // else // Get list of location-API pairs that need to be synchronized. wic::SourceMariaDB dataSource = wic::SourceMariaDB(srcConfig.connectionInfo()); std::vector<std::pair<wic::Location, wic::ApiType> > locations; if (!dataSource.listWeatherLocationsWithApi(locations)) { std::cerr << "Error: Could not load locations from source database!" << std::endl; return wic::rcDatabaseError; } std::cout << "Found " << locations.size() << " locations with weather data in the database." << std::endl; for(const auto& [location, api] : locations) { std::cout << "\t" << location.toString() << ", " << wic::toString(api) << std::endl; } // for // Get available APIs in destination database. wic::SourceMariaDB dataDest = wic::SourceMariaDB(destConfig.connectionInfo()); std::map<wic::ApiType, int> apis; if (!dataDest.listApis(apis)) { std::cerr << "Error: Could not load API information from destination database!" << std::endl; return wic::rcDatabaseError; } // connection to destination database try { wic::db::mariadb::Connection conn(destConfig.connectionInfo()); std::clog << "Info: Connection attempt to destination database succeeded." << std::endl; } catch (const std::exception& ex) { std::cerr << "Could not connect to destination database: " << ex.what() << "\n"; return wic::rcDatabaseError; } // scope for synchronization of weather data { wic::StoreMariaDBBatch destinationStore(destConfig.connectionInfo(), batchSize); for(const auto& [location, api] : locations) { std::cout << "Synchronizing weather data for " << location.toString() << ", " << wic::toString(api) << "..." << std::endl; if (apis.find(api) == apis.end()) { std::cerr << "Error: Destination database has no API entry for " << wic::toString(api) << "!" << std::endl; return wic::rcDatabaseError; } const int apiId = apis[api]; std::vector<wic::Weather> sourceWeather; if (!dataSource.getCurrentWeather(api, location, sourceWeather)) { std::cerr << "Error: Could not load weather data for " << location.toString() << ", " << wic::toString(api) << " from source database!" << std::endl; return wic::rcDatabaseError; } // Get corresponding location ID in destination database. // If it does not exist, it will be created. const int locationId = dataDest.getLocationId(location); if (locationId <= 0) { std::cerr << "Error: Could find or create location " << location.toString() << ", " << wic::toString(api) << " in destination database!" << std::endl; return wic::rcDatabaseError; } // Get existing entries in destination database. std::vector<wic::WeatherMeta> destinationWeatherMeta; if (!dataDest.getMetaCurrentWeather(api, location, destinationWeatherMeta)) { std::cerr << "Error: Could not load weather data for " << location.toString() << ", " << wic::toString(api) << " from destination database!" << std::endl; return wic::rcDatabaseError; } // Iterate over data. auto sourceIterator = sourceWeather.begin(); const auto sourceEnd = sourceWeather.end(); auto destinationIterator = destinationWeatherMeta.begin(); const auto destinationEnd = destinationWeatherMeta.end(); while (sourceIterator != sourceEnd) { while (destinationIterator != destinationEnd && isLess(*destinationIterator, *sourceIterator)) { ++destinationIterator; } // while (inner) // Element was not found in destination, if we are at the end of the // container or if the dereferenced iterator is not equal to the source. if ((destinationIterator == destinationEnd) || (destinationIterator->dataTime() != sourceIterator->dataTime()) || (destinationIterator->requestTime() != sourceIterator->requestTime())) { // Insert data set. if (!destinationStore.saveCurrentWeather(apiId, locationId, *sourceIterator)) { std::cerr << "Error: Could insert weather data into destination database!" << std::endl; return wic::rcDatabaseError; } } // if ++sourceIterator; } // while } // range-based for (locations) } // scope for weather data sync // synchronize forecast data { if (!dataSource.listForecastLocationsWithApi(locations)) { std::cerr << "Error: Could not load locations from source database!" << std::endl; return wic::rcDatabaseError; } std::cout << "Found " << locations.size() << " locations with forecast data in the database." << std::endl; for(const auto& [location, api] : locations) { std::cout << "\t" << location.toString() << ", " << wic::toString(api) << std::endl; } // for for(const auto& [location, api] : locations) { std::cout << "Synchronizing forecast data for " << location.toString() << ", " << wic::toString(api) << "..." << std::endl; std::vector<wic::Forecast> sourceForecast; if (!dataSource.getForecasts(api, location, sourceForecast)) { std::cerr << "Error: Could not load forecast data for " << location.toString() << ", " << wic::toString(api) << " from source database!" << std::endl; return wic::rcDatabaseError; } // Get existing entries in destination database. std::vector<wic::ForecastMeta> destinationForecastMeta; if (!dataDest.getMetaForecasts(api, location, destinationForecastMeta)) { std::cerr << "Error: Could not load forecast data for " << location.toString() << ", " << wic::toString(api) << " from destination database!" << std::endl; return wic::rcDatabaseError; } wic::StoreMariaDB destinationStore = wic::StoreMariaDB(destConfig.connectionInfo()); // Iterate over data. auto sourceIterator = sourceForecast.begin(); const auto sourceEnd = sourceForecast.end(); auto destinationIterator = destinationForecastMeta.begin(); const auto destinationEnd = destinationForecastMeta.end(); while (sourceIterator != sourceEnd) { while (destinationIterator != destinationEnd && isLess(*destinationIterator, *sourceIterator)) { ++destinationIterator; } // while (inner) // Element was not found in destination, if we are at the end of the // container or if the dereferenced iterator is not equal to the source. if ((destinationIterator == destinationEnd) || (destinationIterator->requestTime() != sourceIterator->requestTime())) { // Insert data set. if (!destinationStore.saveForecast(api, location, *sourceIterator)) { std::cerr << "Error: Could insert forecast data into destination database!" << std::endl; return wic::rcDatabaseError; } } // if ++sourceIterator; } // while } // for (locations) } // scope for forecast data sync // All is done. std::cout << "Done." << std::endl; return 0; }
Java
#define BOOST_TEST_MODULE segmentize tests #include <boost/test/unit_test.hpp> #include <ostream> #include "segmentize.hpp" #include "bg_operators.hpp" using namespace std; BOOST_AUTO_TEST_SUITE(segmentize_tests) void print_result(const vector<std::pair<linestring_type_fp, bool>>& result) { cout << result; } BOOST_AUTO_TEST_CASE(abuts) { vector<pair<linestring_type_fp, bool>> ms = { {{{0,0}, {2,2}}, true}, {{{1,1}, {2,0}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 3UL); } BOOST_AUTO_TEST_CASE(x_shape) { vector<pair<linestring_type_fp, bool>> ms = { {{{0,10000}, {10000,9000}}, true}, {{{10000,10000}, {0,0}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 4UL); } BOOST_AUTO_TEST_CASE(plus_shape) { vector<pair<linestring_type_fp, bool>> ms = { {{{1,2}, {3,2}}, true}, {{{2,1}, {2,3}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 4UL); } BOOST_AUTO_TEST_CASE(touching_no_overlap) { vector<pair<linestring_type_fp, bool>> ms = { {{{1,20}, {40,50}}, true}, {{{40,50}, {80,90}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 2UL); } BOOST_AUTO_TEST_CASE(parallel_with_overlap) { vector<pair<linestring_type_fp, bool>> ms = { {{{10,10}, {0,0}}, false}, {{{9,9}, {20,20}}, true}, {{{30,30}, {15,15}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 7UL); //print_result(result); } BOOST_AUTO_TEST_CASE(parallel_with_overlap_directed) { vector<pair<linestring_type_fp, bool>> ms = { {{{10,10}, {0,0}}, true}, {{{9,9}, {20,20}}, false}, {{{30,30}, {15,15}}, false}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 7UL); //print_result(result); } BOOST_AUTO_TEST_CASE(sort_segments) { vector<pair<linestring_type_fp, bool>> ms = { {{{10,10}, {13,-4}}, true}, {{{13,-4}, {10,10}}, true}, {{{13,-4}, {10,10}}, true}, {{{10, 10}, {13, -4}}, true}, {{{10, 10}, {13, -4}}, true}, }; const auto& result = segmentize::segmentize_paths(ms); BOOST_CHECK_EQUAL(result.size(), 5UL); //print_result(result); } BOOST_AUTO_TEST_SUITE_END()
Java
<?php /** * Simple product add to cart * * @author WooThemes * @package WooCommerce/Templates * @version 2.1.0 */ global $woocommerce, $product; if ( ! $product->is_purchasable() ) return; ?> <?php // Availability $availability = $product->get_availability(); if ($availability['availability']) : echo apply_filters( 'woocommerce_stock_html', '<p class="stock '.$availability['class'].'">'.$availability['availability'].'</p>', $availability['availability'] ); endif; ?> <?php if ( $product->is_in_stock() && is_shop_enabled() ) : ?> <?php do_action('woocommerce_before_add_to_cart_form'); ?> <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'> <?php do_action('woocommerce_before_add_to_cart_button'); ?> <?php if ( ! $product->is_sold_individually() ){ ?><label><?php _e( 'Quantity', 'yit' ) ?></label><?php woocommerce_quantity_input( array( 'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ) ) ); } $label = apply_filters( 'single_simple_add_to_cart_text', yit_get_option( 'add-to-cart-text' ) ); ?> <button type="submit" class="single_add_to_cart_button button alt"><?php echo $label ?></button> <?php do_action('woocommerce_after_add_to_cart_button'); ?> </form> <?php do_action('woocommerce_after_add_to_cart_form'); ?> <?php endif; ?>
Java
#include <stdio.h> #include "aeb.h" #include <string.h> #include <math.h> int main() { Aeb * raiz, *esq, * dir; Aeb * arvore; double r; char s[127]; /*arvore = criaRaiz('*'); esq = criaFolha(10.0); dir = criaFolha(7.0); conectaNodos(arvore, esq, dir); raiz = criaRaiz('+'); dir = criaFolha(8.0); conectaNodos(raiz, arvore, dir); printf("Resultado: %g\n", resolveExpressao(raiz));*/ printf("\nExpressão: "); scanf("%s",s); arvore = criaArvore(s); printf("Expressão após conversão: "); mostraArvore(arvore); puts(""); r=resolveExpressao(arvore); printf("\nO resultado é= %g\n",r); }
Java
/** * dfs 找 LCA. 只有一次查询,所以不需要 tarjan 或者 rmq * 个人感觉 rmq 好理解一些,dfs标号一下然后转化成区间最小值。( u v 之间最短路径上深度最小的节点) */ using namespace std; /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode *dfs(TreeNode *root, TreeNode* p, TreeNode *q) { if(!root) return NULL; if(root == p) return root; if(root == q) return root; TreeNode *u = dfs(root->left, p, q); TreeNode *v = dfs(root->right, p, q); if(u == NULL) { u = v; v = NULL; } if(v) return root; return u; } TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { return dfs(root, p, q); } };
Java
using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using NFluent; using SmallWorld.BusinessEntities.Football.DeedDetectors; using SmallWorld.BusinessEntities.Interfaces.Football.Agents; namespace SmallWorld.BusinessEntities.UnitTests.Football.DeedDetectors { [TestClass] public class MoveDetectorTest { [TestMethod] public void When_Detect_Then_Return_MoveDeed_For_All_SensedPlayer_With_Origin_As_Origin() { var moveDetector = new MoveDetector(); var origin = new Mock<IFootballPlayer>(); var playerOne = new Mock<IFootballPlayer>(); var playerTwo = new Mock<IFootballPlayer>(); var sensedPlayers = new List<IFootballPlayer> { playerOne.Object, playerTwo.Object }; var result = moveDetector.Detect(origin.Object, sensedPlayers); foreach (var tmpFootballDeed in result) { Check.That(tmpFootballDeed.Player).IsSameReferenceThan(origin.Object); } } } }
Java
/* * Symphony - A modern community (forum/SNS/blog) platform written in Java. * Copyright (C) 2012-2017, b3log.org & hacpai.com * * 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 <http://www.gnu.org/licenses/>. */ package org.b3log.symphony.service; import java.util.List; import java.util.Locale; import javax.inject.Inject; import org.apache.commons.lang.StringUtils; import org.b3log.latke.Keys; import org.b3log.latke.event.Event; import org.b3log.latke.event.EventException; import org.b3log.latke.event.EventManager; import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Logger; import org.b3log.latke.model.User; import org.b3log.latke.repository.RepositoryException; import org.b3log.latke.repository.Transaction; import org.b3log.latke.repository.annotation.Transactional; import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.annotation.Service; import org.b3log.latke.util.Ids; import org.b3log.symphony.event.EventTypes; import org.b3log.symphony.model.Article; import org.b3log.symphony.model.Comment; import org.b3log.symphony.model.Common; import org.b3log.symphony.model.Liveness; import org.b3log.symphony.model.Notification; import org.b3log.symphony.model.Option; import org.b3log.symphony.model.Pointtransfer; import org.b3log.symphony.model.Reward; import org.b3log.symphony.model.Role; import org.b3log.symphony.model.Tag; import org.b3log.symphony.model.UserExt; import org.b3log.symphony.repository.ArticleRepository; import org.b3log.symphony.repository.CommentRepository; import org.b3log.symphony.repository.NotificationRepository; import org.b3log.symphony.repository.OptionRepository; import org.b3log.symphony.repository.TagArticleRepository; import org.b3log.symphony.repository.TagRepository; import org.b3log.symphony.repository.UserRepository; import org.b3log.symphony.util.Emotions; import org.b3log.symphony.util.Symphonys; import org.json.JSONObject; /** * Comment management service. * * @author <a href="http://88250.b3log.org">Liang Ding</a> * @version 2.12.10.19, Feb 2, 2017 * @since 0.2.0 */ @Service public class CommentMgmtService { /** * Logger. */ private static final Logger LOGGER = Logger.getLogger(CommentMgmtService.class.getName()); /** * Comment repository. */ @Inject private CommentRepository commentRepository; /** * Article repository. */ @Inject private ArticleRepository articleRepository; /** * Option repository. */ @Inject private OptionRepository optionRepository; /** * Tag repository. */ @Inject private TagRepository tagRepository; /** * Tag-Article repository. */ @Inject private TagArticleRepository tagArticleRepository; /** * User repository. */ @Inject private UserRepository userRepository; /** * Notification repository. */ @Inject private NotificationRepository notificationRepository; /** * Event manager. */ @Inject private EventManager eventManager; /** * Language service. */ @Inject private LangPropsService langPropsService; /** * Pointtransfer management service. */ @Inject private PointtransferMgmtService pointtransferMgmtService; /** * Reward management service. */ @Inject private RewardMgmtService rewardMgmtService; /** * Reward query service. */ @Inject private RewardQueryService rewardQueryService; /** * Notification management service. */ @Inject private NotificationMgmtService notificationMgmtService; /** * Liveness management service. */ @Inject private LivenessMgmtService livenessMgmtService; /** * Removes a comment specified with the given comment id. * * @param commentId the given comment id */ @Transactional public void removeComment(final String commentId) { try { final JSONObject comment = commentRepository.get(commentId); if (null == comment) { return; } final String articleId = comment.optString(Comment.COMMENT_ON_ARTICLE_ID); final JSONObject article = articleRepository.get(articleId); article.put(Article.ARTICLE_COMMENT_CNT, article.optInt(Article.ARTICLE_COMMENT_CNT) - 1); // Just clear latest time and commenter name, do not get the real latest comment to update article.put(Article.ARTICLE_LATEST_CMT_TIME, 0); article.put(Article.ARTICLE_LATEST_CMTER_NAME, ""); articleRepository.update(articleId, article); final String commentAuthorId = comment.optString(Comment.COMMENT_AUTHOR_ID); final JSONObject commenter = userRepository.get(commentAuthorId); commenter.put(UserExt.USER_COMMENT_COUNT, commenter.optInt(UserExt.USER_COMMENT_COUNT) - 1); userRepository.update(commentAuthorId, commenter); commentRepository.remove(comment.optString(Keys.OBJECT_ID)); final JSONObject commentCntOption = optionRepository.get(Option.ID_C_STATISTIC_CMT_COUNT); commentCntOption.put(Option.OPTION_VALUE, commentCntOption.optInt(Option.OPTION_VALUE) - 1); optionRepository.update(Option.ID_C_STATISTIC_CMT_COUNT, commentCntOption); notificationRepository.removeByDataId(commentId); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Removes a comment error [id=" + commentId + "]", e); } } /** * A user specified by the given sender id thanks the author of a comment specified by the given comment id. * * @param commentId the given comment id * @param senderId the given sender id * @throws ServiceException service exception */ public void thankComment(final String commentId, final String senderId) throws ServiceException { try { final JSONObject comment = commentRepository.get(commentId); if (null == comment) { return; } if (Comment.COMMENT_STATUS_C_INVALID == comment.optInt(Comment.COMMENT_STATUS)) { return; } final JSONObject sender = userRepository.get(senderId); if (null == sender) { return; } if (UserExt.USER_STATUS_C_VALID != sender.optInt(UserExt.USER_STATUS)) { return; } final String receiverId = comment.optString(Comment.COMMENT_AUTHOR_ID); final JSONObject receiver = userRepository.get(receiverId); if (null == receiver) { return; } if (UserExt.USER_STATUS_C_VALID != receiver.optInt(UserExt.USER_STATUS)) { return; } if (receiverId.equals(senderId)) { throw new ServiceException(langPropsService.get("thankSelfLabel")); } final int rewardPoint = Symphonys.getInt("pointThankComment"); if (rewardQueryService.isRewarded(senderId, commentId, Reward.TYPE_C_COMMENT)) { return; } final String rewardId = Ids.genTimeMillisId(); if (Comment.COMMENT_ANONYMOUS_C_PUBLIC == comment.optInt(Comment.COMMENT_ANONYMOUS)) { final boolean succ = null != pointtransferMgmtService.transfer(senderId, receiverId, Pointtransfer.TRANSFER_TYPE_C_COMMENT_REWARD, rewardPoint, rewardId, System.currentTimeMillis()); if (!succ) { throw new ServiceException(langPropsService.get("transferFailLabel")); } } final JSONObject reward = new JSONObject(); reward.put(Keys.OBJECT_ID, rewardId); reward.put(Reward.SENDER_ID, senderId); reward.put(Reward.DATA_ID, commentId); reward.put(Reward.TYPE, Reward.TYPE_C_COMMENT); rewardMgmtService.addReward(reward); final JSONObject notification = new JSONObject(); notification.put(Notification.NOTIFICATION_USER_ID, receiverId); notification.put(Notification.NOTIFICATION_DATA_ID, rewardId); notificationMgmtService.addCommentThankNotification(notification); livenessMgmtService.incLiveness(senderId, Liveness.LIVENESS_THANK); } catch (final RepositoryException e) { LOGGER.log(Level.ERROR, "Thanks a comment[id=" + commentId + "] failed", e); throw new ServiceException(e); } } /** * Adds a comment with the specified request json object. * * @param requestJSONObject the specified request json object, for example, <pre> * { * "commentContent": "", * "commentAuthorId": "", * "commentOnArticleId": "", * "commentOriginalCommentId": "", // optional * "clientCommentId": "" // optional, * "commentAuthorName": "" // If from client * "commenter": { * // User model * }, * "commentIP": "", // optional, default to "" * "commentUA": "", // optional, default to "" * "commentAnonymous": int, // optional, default to 0 (public) * "userCommentViewMode": int * } * </pre>, see {@link Comment} for more details * * @return generated comment id * @throws ServiceException service exception */ public synchronized String addComment(final JSONObject requestJSONObject) throws ServiceException { final long currentTimeMillis = System.currentTimeMillis(); final JSONObject commenter = requestJSONObject.optJSONObject(Comment.COMMENT_T_COMMENTER); final String commentAuthorId = requestJSONObject.optString(Comment.COMMENT_AUTHOR_ID); final boolean fromClient = requestJSONObject.has(Comment.COMMENT_CLIENT_COMMENT_ID); final String articleId = requestJSONObject.optString(Comment.COMMENT_ON_ARTICLE_ID); final String ip = requestJSONObject.optString(Comment.COMMENT_IP); String ua = requestJSONObject.optString(Comment.COMMENT_UA); final int commentAnonymous = requestJSONObject.optInt(Comment.COMMENT_ANONYMOUS); final int commentViewMode = requestJSONObject.optInt(UserExt.USER_COMMENT_VIEW_MODE); if (currentTimeMillis - commenter.optLong(UserExt.USER_LATEST_CMT_TIME) < Symphonys.getLong("minStepCmtTime") && !Role.ROLE_ID_C_ADMIN.equals(commenter.optString(User.USER_ROLE)) && !UserExt.DEFAULT_CMTER_ROLE.equals(commenter.optString(User.USER_ROLE))) { LOGGER.log(Level.WARN, "Adds comment too frequent [userName={0}]", commenter.optString(User.USER_NAME)); throw new ServiceException(langPropsService.get("tooFrequentCmtLabel")); } final String commenterName = commenter.optString(User.USER_NAME); JSONObject article = null; try { // check if admin allow to add comment final JSONObject option = optionRepository.get(Option.ID_C_MISC_ALLOW_ADD_COMMENT); if (!"0".equals(option.optString(Option.OPTION_VALUE))) { throw new ServiceException(langPropsService.get("notAllowAddCommentLabel")); } final int balance = commenter.optInt(UserExt.USER_POINT); if (Comment.COMMENT_ANONYMOUS_C_ANONYMOUS == commentAnonymous) { final int anonymousPoint = Symphonys.getInt("anonymous.point"); if (balance < anonymousPoint) { String anonymousEnabelPointLabel = langPropsService.get("anonymousEnabelPointLabel"); anonymousEnabelPointLabel = anonymousEnabelPointLabel.replace("${point}", String.valueOf(anonymousPoint)); throw new ServiceException(anonymousEnabelPointLabel); } } article = articleRepository.get(articleId); if (!fromClient && !TuringQueryService.ROBOT_NAME.equals(commenterName)) { int pointSum = Pointtransfer.TRANSFER_SUM_C_ADD_COMMENT; // Point final String articleAuthorId = article.optString(Article.ARTICLE_AUTHOR_ID); if (articleAuthorId.equals(commentAuthorId)) { pointSum = Pointtransfer.TRANSFER_SUM_C_ADD_SELF_ARTICLE_COMMENT; } if (balance - pointSum < 0) { throw new ServiceException(langPropsService.get("insufficientBalanceLabel")); } } } catch (final RepositoryException e) { throw new ServiceException(e); } final int articleAnonymous = article.optInt(Article.ARTICLE_ANONYMOUS); final Transaction transaction = commentRepository.beginTransaction(); try { article.put(Article.ARTICLE_COMMENT_CNT, article.optInt(Article.ARTICLE_COMMENT_CNT) + 1); article.put(Article.ARTICLE_LATEST_CMTER_NAME, commenter.optString(User.USER_NAME)); if (Comment.COMMENT_ANONYMOUS_C_ANONYMOUS == commentAnonymous) { article.put(Article.ARTICLE_LATEST_CMTER_NAME, UserExt.ANONYMOUS_USER_NAME); } article.put(Article.ARTICLE_LATEST_CMT_TIME, currentTimeMillis); final String ret = Ids.genTimeMillisId(); final JSONObject comment = new JSONObject(); comment.put(Keys.OBJECT_ID, ret); String content = requestJSONObject.optString(Comment.COMMENT_CONTENT). replace("_esc_enter_88250_", "<br/>"); // Solo client escape comment.put(Comment.COMMENT_AUTHOR_ID, commentAuthorId); comment.put(Comment.COMMENT_ON_ARTICLE_ID, articleId); if (fromClient) { comment.put(Comment.COMMENT_CLIENT_COMMENT_ID, requestJSONObject.optString(Comment.COMMENT_CLIENT_COMMENT_ID)); // Appends original commenter name final String authorName = requestJSONObject.optString(Comment.COMMENT_T_AUTHOR_NAME); content += " <i class='ft-small'>by " + authorName + "</i>"; } final String originalCmtId = requestJSONObject.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, originalCmtId); if (StringUtils.isNotBlank(originalCmtId)) { final JSONObject originalCmt = commentRepository.get(originalCmtId); final int originalCmtReplyCnt = originalCmt.optInt(Comment.COMMENT_REPLY_CNT); originalCmt.put(Comment.COMMENT_REPLY_CNT, originalCmtReplyCnt + 1); commentRepository.update(originalCmtId, originalCmt); } content = Emotions.toAliases(content); // content = StringUtils.trim(content) + " "; https://github.com/b3log/symphony/issues/389 content = content.replace(langPropsService.get("uploadingLabel", Locale.SIMPLIFIED_CHINESE), ""); content = content.replace(langPropsService.get("uploadingLabel", Locale.US), ""); comment.put(Comment.COMMENT_CONTENT, content); comment.put(Comment.COMMENT_CREATE_TIME, System.currentTimeMillis()); comment.put(Comment.COMMENT_SHARP_URL, "/article/" + articleId + "#" + ret); comment.put(Comment.COMMENT_STATUS, Comment.COMMENT_STATUS_C_VALID); comment.put(Comment.COMMENT_IP, ip); if (StringUtils.length(ua) > Common.MAX_LENGTH_UA) { LOGGER.log(Level.WARN, "UA is too long [" + ua + "]"); ua = StringUtils.substring(ua, 0, Common.MAX_LENGTH_UA); } comment.put(Comment.COMMENT_UA, ua); comment.put(Comment.COMMENT_ANONYMOUS, commentAnonymous); final JSONObject cmtCntOption = optionRepository.get(Option.ID_C_STATISTIC_CMT_COUNT); final int cmtCnt = cmtCntOption.optInt(Option.OPTION_VALUE); cmtCntOption.put(Option.OPTION_VALUE, String.valueOf(cmtCnt + 1)); articleRepository.update(articleId, article); // Updates article comment count, latest commenter name and time optionRepository.update(Option.ID_C_STATISTIC_CMT_COUNT, cmtCntOption); // Updates global comment count // Updates tag comment count and User-Tag relation final String tagsString = article.optString(Article.ARTICLE_TAGS); final String[] tagStrings = tagsString.split(","); for (int i = 0; i < tagStrings.length; i++) { final String tagTitle = tagStrings[i].trim(); final JSONObject tag = tagRepository.getByTitle(tagTitle); tag.put(Tag.TAG_COMMENT_CNT, tag.optInt(Tag.TAG_COMMENT_CNT) + 1); tag.put(Tag.TAG_RANDOM_DOUBLE, Math.random()); tagRepository.update(tag.optString(Keys.OBJECT_ID), tag); } // Updates user comment count, latest comment time commenter.put(UserExt.USER_COMMENT_COUNT, commenter.optInt(UserExt.USER_COMMENT_COUNT) + 1); commenter.put(UserExt.USER_LATEST_CMT_TIME, currentTimeMillis); userRepository.update(commenter.optString(Keys.OBJECT_ID), commenter); comment.put(Comment.COMMENT_GOOD_CNT, 0); comment.put(Comment.COMMENT_BAD_CNT, 0); comment.put(Comment.COMMENT_SCORE, 0D); comment.put(Comment.COMMENT_REPLY_CNT, 0); // Adds the comment final String commentId = commentRepository.add(comment); // Updates tag-article relation stat. final List<JSONObject> tagArticleRels = tagArticleRepository.getByArticleId(articleId); for (final JSONObject tagArticleRel : tagArticleRels) { tagArticleRel.put(Article.ARTICLE_LATEST_CMT_TIME, currentTimeMillis); tagArticleRel.put(Article.ARTICLE_COMMENT_CNT, article.optInt(Article.ARTICLE_COMMENT_CNT)); tagArticleRepository.update(tagArticleRel.optString(Keys.OBJECT_ID), tagArticleRel); } transaction.commit(); if (!fromClient && Comment.COMMENT_ANONYMOUS_C_PUBLIC == commentAnonymous && Article.ARTICLE_ANONYMOUS_C_PUBLIC == articleAnonymous && !TuringQueryService.ROBOT_NAME.equals(commenterName)) { // Point final String articleAuthorId = article.optString(Article.ARTICLE_AUTHOR_ID); if (articleAuthorId.equals(commentAuthorId)) { pointtransferMgmtService.transfer(commentAuthorId, Pointtransfer.ID_C_SYS, Pointtransfer.TRANSFER_TYPE_C_ADD_COMMENT, Pointtransfer.TRANSFER_SUM_C_ADD_SELF_ARTICLE_COMMENT, commentId, System.currentTimeMillis()); } else { pointtransferMgmtService.transfer(commentAuthorId, articleAuthorId, Pointtransfer.TRANSFER_TYPE_C_ADD_COMMENT, Pointtransfer.TRANSFER_SUM_C_ADD_COMMENT, commentId, System.currentTimeMillis()); } livenessMgmtService.incLiveness(commentAuthorId, Liveness.LIVENESS_COMMENT); } // Event final JSONObject eventData = new JSONObject(); eventData.put(Comment.COMMENT, comment); eventData.put(Common.FROM_CLIENT, fromClient); eventData.put(Article.ARTICLE, article); eventData.put(UserExt.USER_COMMENT_VIEW_MODE, commentViewMode); try { eventManager.fireEventAsynchronously(new Event<JSONObject>(EventTypes.ADD_COMMENT_TO_ARTICLE, eventData)); } catch (final EventException e) { LOGGER.log(Level.ERROR, e.getMessage(), e); } return ret; } catch (final RepositoryException e) { if (transaction.isActive()) { transaction.rollback(); } LOGGER.log(Level.ERROR, "Adds a comment failed", e); throw new ServiceException(e); } } /** * Updates the specified comment by the given comment id. * * @param commentId the given comment id * @param comment the specified comment * @throws ServiceException service exception */ public void updateComment(final String commentId, final JSONObject comment) throws ServiceException { final Transaction transaction = commentRepository.beginTransaction(); try { String content = comment.optString(Comment.COMMENT_CONTENT); content = Emotions.toAliases(content); content = StringUtils.trim(content) + " "; content = content.replace(langPropsService.get("uploadingLabel", Locale.SIMPLIFIED_CHINESE), ""); content = content.replace(langPropsService.get("uploadingLabel", Locale.US), ""); comment.put(Comment.COMMENT_CONTENT, content); commentRepository.update(commentId, comment); transaction.commit(); } catch (final RepositoryException e) { if (transaction.isActive()) { transaction.rollback(); } LOGGER.log(Level.ERROR, "Updates a comment[id=" + commentId + "] failed", e); throw new ServiceException(e); } } }
Java
static inline struct pthread *__pthread_self() { struct pthread *self; __asm__ ("mov %%fs:0,%0" : "=r" (self) ); return self; } #define TP_ADJ(p) (p) #define MC_PC gregs[REG_RIP]
Java
/* * Copyright (C) 2010-2019 The ESPResSo project * * This file is part of ESPResSo. * * ESPResSo 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. * * ESPResSo 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 <http://www.gnu.org/licenses/>. */ /** \file * %Lattice Boltzmann implementation on GPUs. * * Implementation in lbgpu.cpp. */ #ifndef LBGPU_HPP #define LBGPU_HPP #include "config.hpp" #ifdef CUDA #include "OptionalCounter.hpp" #include <utils/Vector.hpp> #include <utils/index.hpp> #include <cstddef> #include <cstdint> #include <vector> /* For the D3Q19 model most functions have a separate implementation * where the coefficients and the velocity vectors are hardcoded * explicitly. This saves a lot of multiplications with 1's and 0's * thus making the code more efficient. */ #define LBQ 19 /** Parameters for the lattice Boltzmann system for GPU. */ struct LB_parameters_gpu { /** number density (LB units) */ float rho; /** mu (LJ units) */ float mu; /** viscosity (LJ) units */ float viscosity; /** relaxation rate of shear modes */ float gamma_shear; /** relaxation rate of bulk modes */ float gamma_bulk; /** */ float gamma_odd; float gamma_even; /** flag determining whether gamma_shear, gamma_odd, and gamma_even are * calculated from gamma_shear in such a way to yield a TRT LB with minimized * slip at bounce-back boundaries */ bool is_TRT; float bulk_viscosity; /** lattice spacing (LJ units) */ float agrid; /** time step for fluid propagation (LJ units) * Note: Has to be larger than MD time step! */ float tau; /** MD timestep */ float time_step; Utils::Array<unsigned int, 3> dim; unsigned int number_of_nodes; #ifdef LB_BOUNDARIES_GPU unsigned int number_of_boundnodes; #endif /** to calculate and print out physical values */ int calc_val; int external_force_density; Utils::Array<float, 3> ext_force_density; unsigned int reinit; // Thermal energy float kT; }; /* this structure is almost duplicated for memory efficiency. When the stress tensor element are needed at every timestep, this features should be explicitly switched on */ struct LB_rho_v_pi_gpu { /** density of the node */ float rho; /** velocity of the node */ Utils::Array<float, 3> v; /** pressure tensor */ Utils::Array<float, 6> pi; }; struct LB_node_force_density_gpu { Utils::Array<float, 3> *force_density; #if defined(VIRTUAL_SITES_INERTIALESS_TRACERS) || defined(EK_DEBUG) // We need the node forces for the velocity interpolation at the virtual // particles' position. However, LBM wants to reset them immediately // after the LBM update. This variable keeps a backup Utils::Array<float, 3> *force_density_buf; #endif }; /************************************************************/ /** \name Exported Variables */ /************************************************************/ /**@{*/ /** Switch indicating momentum exchange between particles and fluid */ extern LB_parameters_gpu lbpar_gpu; extern std::vector<LB_rho_v_pi_gpu> host_values; #ifdef ELECTROKINETICS extern LB_node_force_density_gpu node_f; extern bool ek_initialized; #endif extern OptionalCounter rng_counter_fluid_gpu; extern OptionalCounter rng_counter_coupling_gpu; /**@}*/ /************************************************************/ /** \name Exported Functions */ /************************************************************/ /**@{*/ /** Conserved quantities for the lattice Boltzmann system. */ struct LB_rho_v_gpu { /** density of the node */ float rho; /** velocity of the node */ Utils::Array<float, 3> v; }; void lb_GPU_sanity_checks(); void lb_get_device_values_pointer(LB_rho_v_gpu **pointer_address); void lb_get_boundary_force_pointer(float **pointer_address); void lb_get_para_pointer(LB_parameters_gpu **pointer_address); void lattice_boltzmann_update_gpu(); /** Perform a full initialization of the lattice Boltzmann system. * All derived parameters and the fluid are reset to their default values. */ void lb_init_gpu(); /** (Re-)initialize the derived parameters for the lattice Boltzmann system. * The current state of the fluid is unchanged. */ void lb_reinit_parameters_gpu(); /** (Re-)initialize the fluid. */ void lb_reinit_fluid_gpu(); /** Reset the forces on the fluid nodes */ void reset_LB_force_densities_GPU(bool buffer = true); void lb_init_GPU(const LB_parameters_gpu &lbpar_gpu); void lb_integrate_GPU(); void lb_get_values_GPU(LB_rho_v_pi_gpu *host_values); void lb_print_node_GPU(unsigned single_nodeindex, LB_rho_v_pi_gpu *host_print_values); #ifdef LB_BOUNDARIES_GPU void lb_init_boundaries_GPU(std::size_t n_lb_boundaries, unsigned number_of_boundnodes, int *host_boundary_node_list, int *host_boundary_index_list, float *lb_bounday_velocity); #endif void lb_set_agrid_gpu(double agrid); template <std::size_t no_of_neighbours> void lb_calc_particle_lattice_ia_gpu(bool couple_virtual, double friction); void lb_calc_fluid_mass_GPU(double *mass); void lb_calc_fluid_momentum_GPU(double *host_mom); void lb_get_boundary_flag_GPU(unsigned int single_nodeindex, unsigned int *host_flag); void lb_get_boundary_flags_GPU(unsigned int *host_bound_array); void lb_set_node_velocity_GPU(unsigned single_nodeindex, float *host_velocity); void lb_set_node_rho_GPU(unsigned single_nodeindex, float host_rho); void reinit_parameters_GPU(LB_parameters_gpu *lbpar_gpu); void lb_reinit_extern_nodeforce_GPU(LB_parameters_gpu *lbpar_gpu); void lb_reinit_GPU(LB_parameters_gpu *lbpar_gpu); void lb_gpu_get_boundary_forces(std::vector<double> &forces); void lb_save_checkpoint_GPU(float *host_checkpoint_vd); void lb_load_checkpoint_GPU(float const *host_checkpoint_vd); void lb_lbfluid_set_population(const Utils::Vector3i &, float[LBQ]); void lb_lbfluid_get_population(const Utils::Vector3i &, float[LBQ]); template <std::size_t no_of_neighbours> void lb_get_interpolated_velocity_gpu(double const *positions, double *velocities, int length); void linear_velocity_interpolation(double const *positions, double *velocities, int length); void quadratic_velocity_interpolation(double const *positions, double *velocities, int length); Utils::Array<float, 6> stress_tensor_GPU(); uint64_t lb_fluid_get_rng_state_gpu(); void lb_fluid_set_rng_state_gpu(uint64_t counter); uint64_t lb_coupling_get_rng_state_gpu(); void lb_coupling_set_rng_state_gpu(uint64_t counter); /** Calculate the node index from its coordinates */ inline unsigned int calculate_node_index(LB_parameters_gpu const &lbpar, Utils::Vector3i const &coord) { return static_cast<unsigned>( Utils::get_linear_index(coord, Utils::Vector3i(lbpar_gpu.dim))); } /**@}*/ #endif /* CUDA */ #endif /* LBGPU_HPP */
Java
/* * Copyright (C) 2000 - 2011 TagServlet Ltd * * This file is part of Open BlueDragon (OpenBD) CFML Server Engine. * * OpenBD is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * Free Software Foundation,version 3. * * OpenBD 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 OpenBD. If not, see http://www.gnu.org/licenses/ * * Additional permission under GNU GPL version 3 section 7 * * If you modify this Program, or any covered work, by linking or combining * it with any of the JARS listed in the README.txt (or a modified version of * (that library), containing parts covered by the terms of that JAR, the * licensors of this Program grant you additional permission to convey the * resulting work. * README.txt @ http://www.openbluedragon.org/license/README.txt * * http://openbd.org/ * * $Id: CronSetDirectory.java 1765 2011-11-04 07:55:52Z alan $ */ package org.alanwilliamson.openbd.plugin.crontab; import com.naryx.tagfusion.cfm.engine.cfArgStructData; import com.naryx.tagfusion.cfm.engine.cfBooleanData; import com.naryx.tagfusion.cfm.engine.cfData; import com.naryx.tagfusion.cfm.engine.cfSession; import com.naryx.tagfusion.cfm.engine.cfmRunTimeException; import com.naryx.tagfusion.expression.function.functionBase; public class CronSetDirectory extends functionBase { private static final long serialVersionUID = 1L; public CronSetDirectory(){ min = max = 1; setNamedParams( new String[]{ "directory" } ); } public String[] getParamInfo(){ return new String[]{ "uri directory - will be created if not exists", }; } public java.util.Map getInfo(){ return makeInfo( "system", "Sets the URI directory that the cron tasks will run from. Calling this function will enable the crontab scheduler to start. This persists across server restarts", ReturnType.BOOLEAN ); } public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException { CronExtension.setRootPath( getNamedStringParam(argStruct, "directory", null ) ); return cfBooleanData.TRUE; } }
Java
package com.gentasaurus.ubahfood.inventory; import com.gentasaurus.ubahfood.init.ModBlocks; import com.gentasaurus.ubahfood.item.crafting.SCMCraftingManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.*; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerSCM extends Container { /** The crafting matrix inventory (3x3). */ public InventoryCrafting craftMatrix; public IInventory craftResult; private World worldObj; private int posX; private int posY; private int posZ; public ContainerSCM(InventoryPlayer invPlayer, World world, int x, int y, int z) { craftMatrix = new InventoryCrafting(this, 3, 1); craftResult = new InventoryCraftResult(); worldObj = world; posX = x; posY = y; posZ = z; this.addSlotToContainer(new SlotSCM(invPlayer.player, craftMatrix, craftResult, 0, 124, 35)); int i; int i1; for (i = 0; i < 3; i++) { for (i1 = 0; i1 < 1; i1++) { this.addSlotToContainer(new Slot(this.craftMatrix, i1 + i * 1, 57 + i1 * 18, 17 + i * 18)); } } for (i = 0; i < 3; ++i) { for (i1 = 0; i1 < 9; ++i1) { this.addSlotToContainer(new Slot(invPlayer, i1 + i * 9 + 9, 8 + i1 * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142)); } this.onCraftMatrixChanged(craftMatrix); } /** * Callback for when the crafting matrix is changed. */ public void onCraftMatrixChanged(IInventory p_75130_1_) { craftResult.setInventorySlotContents(0, SCMCraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); } /** * Called when the container is closed. */ public void onContainerClosed(EntityPlayer p_75134_1_) { super.onContainerClosed(p_75134_1_); if (!this.worldObj.isRemote) { for (int i = 0; i < 3; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); } } } } public boolean canInteractWith(EntityPlayer p_75145_1_) { return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.snowConeMachine ? false : p_75145_1_.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { return null; } public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) { return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); } }
Java
#ifndef __MACROS_H__ #define __MACROS_H__ #include "config.h" #define __KERNELNAME__ "code0" /* * This file is automatically included before the first line of any * source file, using gcc's -imacro command line option. Only macro * definitions will be extracted. */ #define INC_ARCH(x) <l4/arch/__ARCH__/x> #define INC_SUBARCH(x) <l4/arch/__ARCH__/__SUBARCH__/x> #define INC_CPU(x) <l4/arch/__ARCH__/__SUBARCH__/__CPU__/x> #define INC_PLAT(x) <l4/platform/__PLATFORM__/x> #define INC_API(x) <l4/api/x> #define INC_GLUE(x) <l4/glue/__ARCH__/x> #define __initdata SECTION(".init.data") /* * FIXME: Remove __CPP__ * This is defined in kernel linker.lds.in, * find some better way. */ #if !defined(__CPP__) /* use this to place code/data in a certain section */ #define SECTION(x) __attribute__((section(x))) #define ALIGN(x) __attribute__((aligned (x))) #endif /* Functions for critical path optimizations */ #if (__GNUC__ >= 3) #define unlikely(x) __builtin_expect((x), false) #define likely(x) __builtin_expect((x), true) #define likelyval(x,val) __builtin_expect((x), (val)) #else /* __GNUC__ < 3 */ #define likely(x) (x) #define unlikely(x) (x) #define likelyval(x,val) (x) #endif /* __GNUC__ < 3 */ /* This guard is needed because tests use host C library and NULL is defined */ #ifndef NULL #define NULL 0 #endif /* Convenience functions for memory sizes. */ #define SZ_1K 1024 #define SZ_2K 2048 #define SZ_4K 0x1000 #define SZ_16K 0x4000 #define SZ_32K 0x8000 #define SZ_64K 0x10000 #define SZ_1MB 0x100000 #define SZ_2MB 0x200000 #define SZ_4MB (4*SZ_1MB) #define SZ_8MB (8*SZ_1MB) #define SZ_16MB (16*SZ_1MB) #define SZ_1K_BITS 10 #define SZ_4K_BITS 12 #define SZ_16K_BITS 14 #define SZ_1MB_BITS 20 /* Per-cpu variables */ #if defined CONFIG_SMP #define DECLARE_PERCPU(type, name) \ type name[CONFIG_NCPU] #define per_cpu(val) (val)[smp_get_cpuid()] #define per_cpu_byid(val, cpu) (val)[(cpu)] #else /* Not CONFIG_SMP */ #define DECLARE_PERCPU(type, name) \ type name #define per_cpu(val) (val) #define per_cpu_byid(val, cpu) val #endif /* End of Not CONFIG_SMP */ #ifndef __ASSEMBLY__ #include <stddef.h> /* offsetof macro, defined in the `standard' way. */ #endif #define container_of(ptr, struct_type, field) \ ({ \ const typeof(((struct_type *)0)->field) *field_ptr = (ptr); \ (struct_type *)((char *)field_ptr - offsetof(struct_type, field)); \ }) /* Prefetching is noop for now */ #define prefetch(x) x #if !defined(__KERNEL__) #define printk printf #endif /* Converts an int-sized field offset in a struct into a bit offset in a word */ #define FIELD_TO_BIT(type, field) (1 << (offsetof(type, field) >> 2)) /* Functions who may either return a pointer or an error code can use these: */ #define PTR_ERR(x) ((void *)(x)) /* checks up to -1000, the rest might be valid pointers!!! E.g. 0xE0000000 */ // #define IS_ERR(x) ((((int)(x)) < 0) && (((int)(x) > -1000))) #if !defined(__ASSEMBLY__) #define IS_ERR(x) is_err((int)(x)) static inline int is_err(int x) { return x < 0 && x > -0x1000; } #endif /* TEST: Is this type of printk well tested? */ #define BUG() {do { \ printk("BUG in file: %s function: %s line: %d\n", \ __FILE__, __FUNCTION__, __LINE__); \ } while(0); \ while(1);} #define BUG_ON(x) {if (x) BUG();} #define WARN_ON(x) {if (x) printk("%s, %s, %s: Warning something is off here.\n", __FILE__, __FUNCTION__, __LINE__); } #define BUG_ON_MSG(msg, x) do { \ printk(msg); \ BUG_ON(x) \ } while(0) #define BUG_MSG(msg...) do { \ printk(msg); \ BUG(); \ } while(0) #endif /* __MACROS_H__ */
Java
#include "prism/animation.h" #include <stdlib.h> #include "prism/log.h" #include "prism/datastructures.h" #include "prism/memoryhandler.h" #include "prism/system.h" #include "prism/timer.h" #include "prism/stlutil.h" using namespace std; static struct { int mIsPaused; } gPrismAnimationData; int getDurationInFrames(Duration tDuration){ return (int)(tDuration * getInverseFramerateFactor()); } int handleDurationAndCheckIfOver(Duration* tNow, Duration tDuration) { if(gPrismAnimationData.mIsPaused) return 0; (*tNow)++; return isDurationOver(*tNow, tDuration); } int isDurationOver(Duration tNow, Duration tDuration) { if (tNow >= getDurationInFrames(tDuration)) { return 1; } return 0; } int handleTickDurationAndCheckIfOver(Tick * tNow, Tick tDuration) { if (gPrismAnimationData.mIsPaused) return 0; (*tNow)++; return isTickDurationOver(*tNow, tDuration); } int isTickDurationOver(Tick tNow, Tick tDuration) { if (tNow >= tDuration) { return 1; } return 0; } AnimationResult animateWithoutLoop(Animation* tAnimation) { AnimationResult ret = ANIMATION_CONTINUING; if (handleDurationAndCheckIfOver(&tAnimation->mNow, tAnimation->mDuration)) { tAnimation->mNow = 0; tAnimation->mFrame++; if (tAnimation->mFrame >= tAnimation->mFrameAmount) { tAnimation->mFrame = tAnimation->mFrameAmount-1; tAnimation->mNow = getDurationInFrames(tAnimation->mDuration); ret = ANIMATION_OVER; } } return ret; } void animate(Animation* tAnimation) { AnimationResult ret = animateWithoutLoop(tAnimation); if(ret == ANIMATION_OVER){ resetAnimation(tAnimation); } } void resetAnimation(Animation* tAnimation) { tAnimation->mNow = 0; tAnimation->mFrame = 0; } Animation createAnimation(int tFrameAmount, Duration tDuration) { Animation ret = createEmptyAnimation(); ret.mFrameAmount = tFrameAmount; ret.mDuration = tDuration; return ret; } Animation createEmptyAnimation(){ Animation ret; ret.mFrame = 0; ret.mFrameAmount = 0; ret.mNow = 0; ret.mDuration = 1000000000; return ret; } Animation createOneFrameAnimation(){ Animation ret = createEmptyAnimation(); ret.mFrameAmount = 1; return ret; } void pauseDurationHandling() { gPrismAnimationData.mIsPaused = 1; } void resumeDurationHandling() { gPrismAnimationData.mIsPaused = 0; } double getDurationPercentage(Duration tNow, Duration tDuration) { int duration = getDurationInFrames(tDuration); return tNow / (double)duration; } static struct{ map<int, AnimationHandlerElement> mList; int mIsLoaded; } gAnimationHandler; void setupAnimationHandler(){ if(gAnimationHandler.mIsLoaded){ logWarning("Setting up non-empty animation handler; Cleaning up."); shutdownAnimationHandler(); } gAnimationHandler.mList.clear(); gAnimationHandler.mIsLoaded = 1; } static int updateAndRemoveCB(void* tCaller, AnimationHandlerElement& tData) { (void) tCaller; AnimationHandlerElement* cur = &tData; AnimationResult res = animateWithoutLoop(&cur->mAnimation); if(res == ANIMATION_OVER) { if(cur->mCB != NULL) { cur->mCB(cur->mCaller); } if(cur->mIsLooped) { resetAnimation(&cur->mAnimation); } else { return 1; } } return 0; } void updateAnimationHandler(){ stl_int_map_remove_predicate(gAnimationHandler.mList, updateAndRemoveCB); } static Position getAnimationPositionWithAllReferencesIncluded(AnimationHandlerElement* cur) { Position p = cur->mPosition; if (cur->mScreenPositionReference != NULL) { p = vecAdd(p, vecScale(*cur->mScreenPositionReference, -1)); } if (cur->mBasePositionReference != NULL) { p = vecAdd(p, *(cur->mBasePositionReference)); } return p; } static void drawAnimationHandlerCB(void* tCaller, AnimationHandlerElement& tData) { (void) tCaller; AnimationHandlerElement* cur = &tData; if (!cur->mIsVisible) return; int frame = cur->mAnimation.mFrame; Position p = getAnimationPositionWithAllReferencesIncluded(cur); if (cur->mIsRotated) { Position rPosition = cur->mRotationEffectCenter; rPosition = vecAdd(rPosition, p); setDrawingRotationZ(cur->mRotationZ, rPosition); } if(cur->mIsScaled) { Position sPosition = cur->mScaleEffectCenter; sPosition = vecAdd(sPosition, p); scaleDrawing3D(cur->mScale, sPosition); } if (cur->mHasBaseColor) { setDrawingBaseColorAdvanced(cur->mBaseColor.x, cur->mBaseColor.y, cur->mBaseColor.z); } if (cur->mHasTransparency) { setDrawingTransparency(cur->mTransparency); } Rectangle texturePos = cur->mTexturePosition; if(cur->mInversionState.x) { Position center = vecAdd(cur->mCenter, p); double deltaX = center.x - p.x; double nRightX = center.x + deltaX; double nLeftX = nRightX - abs(cur->mTexturePosition.bottomRight.x - cur->mTexturePosition.topLeft.x); p.x = nLeftX; texturePos.topLeft.x = cur->mTexturePosition.bottomRight.x; texturePos.bottomRight.x = cur->mTexturePosition.topLeft.x; } if (cur->mInversionState.y) { Position center = vecAdd(cur->mCenter, p); double deltaY = center.y - p.y; double nDownY = center.y + deltaY; double nUpY = nDownY - abs(cur->mTexturePosition.bottomRight.y - cur->mTexturePosition.topLeft.y); p.y = nUpY; texturePos.topLeft.y = cur->mTexturePosition.bottomRight.y; texturePos.bottomRight.y = cur->mTexturePosition.topLeft.y; } drawSprite(cur->mTextureData[frame], p, texturePos); if(cur->mIsScaled || cur->mIsRotated || cur->mHasBaseColor || cur->mHasTransparency) { setDrawingParametersToIdentity(); } } void drawHandledAnimations() { stl_int_map_map(gAnimationHandler.mList, drawAnimationHandlerCB); } static void emptyAnimationHandler(){ gAnimationHandler.mList.clear(); } static AnimationHandlerElement* playAnimationInternal(const Position& tPosition, TextureData* tTextures, const Animation& tAnimation, const Rectangle& tTexturePosition, AnimationPlayerCB tOptionalCB, void* tCaller, int tIsLooped){ AnimationHandlerElement e; e.mCaller = tCaller; e.mCB = tOptionalCB; e.mIsLooped = tIsLooped; e.mPosition = tPosition; e.mTexturePosition = tTexturePosition; e.mTextureData = tTextures; e.mAnimation = tAnimation; e.mScreenPositionReference = NULL; e.mBasePositionReference = NULL; e.mIsScaled = 0; e.mIsRotated = 0; e.mHasBaseColor = 0; e.mHasTransparency = 0; e.mCenter = Vector3D(0,0,0); e.mInversionState = Vector3DI(0,0,0); e.mIsVisible = 1; int id = stl_int_map_push_back(gAnimationHandler.mList, e); auto& element = gAnimationHandler.mList[id]; element.mID = id; return &element; } AnimationHandlerElement* playAnimation(const Position& tPosition, TextureData* tTextures, const Animation& tAnimation, const Rectangle& tTexturePosition, AnimationPlayerCB tOptionalCB, void* tCaller){ return playAnimationInternal(tPosition, tTextures, tAnimation, tTexturePosition, tOptionalCB, tCaller, 0); } AnimationHandlerElement* playAnimationLoop(const Position& tPosition, TextureData* tTextures, const Animation& tAnimation, const Rectangle& tTexturePosition){ return playAnimationInternal(tPosition, tTextures, tAnimation, tTexturePosition, NULL, NULL, 1); } AnimationHandlerElement* playOneFrameAnimationLoop(const Position& tPosition, TextureData* tTextures) { Animation anim = createOneFrameAnimation(); Rectangle rect = makeRectangleFromTexture(tTextures[0]); return playAnimationLoop(tPosition, tTextures, anim, rect); } void changeAnimation(AnimationHandlerElement* e, TextureData* tTextures, const Animation& tAnimation, const Rectangle& tTexturePosition) { e->mTexturePosition = tTexturePosition; e->mTextureData = tTextures; e->mAnimation = tAnimation; } void setAnimationScreenPositionReference(AnimationHandlerElement* e, Position* tScreenPositionReference) { e->mScreenPositionReference = tScreenPositionReference; } void setAnimationBasePositionReference(AnimationHandlerElement* e, Position* tBasePositionReference) { e->mBasePositionReference = tBasePositionReference; } void setAnimationScale(AnimationHandlerElement* e, const Vector3D& tScale, const Position& tCenter) { e->mIsScaled = 1; e->mScaleEffectCenter = tCenter; e->mScale = tScale; } void setAnimationSize(AnimationHandlerElement* e, const Vector3D& tSize, const Position& tCenter) { e->mIsScaled = 1; e->mScaleEffectCenter = tCenter; double dx = tSize.x / e->mTextureData[0].mTextureSize.x; double dy = tSize.y / e->mTextureData[0].mTextureSize.y; e->mScale = Vector3D(dx, dy, 1); } static void setAnimationRotationZ_internal(AnimationHandlerElement* e, double tAngle, const Vector3D& tCenter) { e->mIsRotated = 1; e->mRotationEffectCenter = tCenter; e->mRotationZ = tAngle; } void setAnimationRotationZ(AnimationHandlerElement* e, double tAngle, const Position& tCenter) { setAnimationRotationZ_internal(e, tAngle, tCenter); } static void setAnimationColor_internal(AnimationHandlerElement* e, double r, double g, double b) { e->mHasBaseColor = 1; e->mBaseColor = Vector3D(r, g, b); } void setAnimationColor(AnimationHandlerElement* e, double r, double g, double b) { setAnimationColor_internal(e, r, g, b); } void setAnimationColorType(AnimationHandlerElement* e, Color tColor) { double r, g, b; getRGBFromColor(tColor, &r, &g, &b); setAnimationColor(e, r, g, b); } void setAnimationTransparency(AnimationHandlerElement* e, double a) { e->mHasTransparency = 1; e->mTransparency = a; } void setAnimationVisibility(AnimationHandlerElement* e, int tIsVisible) { e->mIsVisible = tIsVisible; } void setAnimationCenter(AnimationHandlerElement* e, const Position& tCenter) { e->mCenter = tCenter; } void setAnimationCB(AnimationHandlerElement* e, AnimationPlayerCB tCB, void* tCaller) { e->mCB = tCB; e->mCaller = tCaller; } void setAnimationPosition(AnimationHandlerElement* e, const Position& tPosition) { e->mPosition = tPosition; } void setAnimationTexturePosition(AnimationHandlerElement* e, const Rectangle& tTexturePosition) { e->mTexturePosition = tTexturePosition; } void setAnimationLoop(AnimationHandlerElement* e, int tIsLooping) { e->mIsLooped = tIsLooping; } void removeAnimationCB(AnimationHandlerElement* e) { setAnimationCB(e, NULL, NULL); } typedef struct { AnimationHandlerElement* mElement; Vector3D mColor; Duration mDuration; } AnimationColorIncrease; static void increaseAnimationColor(void* tCaller) { AnimationColorIncrease* e = (AnimationColorIncrease*)tCaller; e->mColor = vecAdd(e->mColor, Vector3D(1.0 / e->mDuration, 1.0 / e->mDuration, 1.0 / e->mDuration)); if (e->mColor.x >= 1) e->mColor = Vector3D(1, 1, 1); setAnimationColor(e->mElement, e->mColor.x, e->mColor.y, e->mColor.z); if (e->mColor.x >= 1) { freeMemory(e); } else addTimerCB(0,increaseAnimationColor, e); } void fadeInAnimation(AnimationHandlerElement* tElement, Duration tDuration) { AnimationColorIncrease* e = (AnimationColorIncrease*)allocMemory(sizeof(AnimationColorIncrease)); e->mElement = tElement; e->mColor = Vector3D(0, 0, 0); e->mDuration = tDuration; addTimerCB(0, increaseAnimationColor, e); setAnimationColor(tElement, e->mColor.x, e->mColor.y, e->mColor.z); } void inverseAnimationVertical(AnimationHandlerElement* e) { e->mInversionState.x ^= 1; } void inverseAnimationHorizontal(AnimationHandlerElement* e) { e->mInversionState.y ^= 1; } void setAnimationVerticalInversion(AnimationHandlerElement* e, int tValue) { e->mInversionState.x = tValue; } void setAnimationHorizontalInversion(AnimationHandlerElement* e, int tValue) { e->mInversionState.y = tValue; } typedef struct { double mAngle; Vector3D mCenter; } ScreenRotationZ; static void setScreenRotationZForSingleAnimation(ScreenRotationZ* tRot, AnimationHandlerElement& tData) { AnimationHandlerElement* e = &tData; const auto p = getAnimationPositionWithAllReferencesIncluded(e); const auto center = vecSub(tRot->mCenter, p); setAnimationRotationZ_internal(e, tRot->mAngle, center); } void setAnimationHandlerScreenRotationZ(double tAngle, const Vector3D& tCenter) { ScreenRotationZ rot; rot.mAngle = tAngle; rot.mCenter = tCenter; stl_int_map_map(gAnimationHandler.mList, setScreenRotationZForSingleAnimation, &rot); } typedef struct { double r; double g; double b; } AnimationHandlerScreenTint; static void setAnimationHandlerScreenTintSingle(AnimationHandlerScreenTint* tTint, AnimationHandlerElement& tData) { AnimationHandlerElement* e = &tData; setAnimationColor_internal(e, tTint->r, tTint->g, tTint->b); } void setAnimationHandlerScreenTint(double r, double g, double b) { AnimationHandlerScreenTint tint; tint.r = r; tint.g = g; tint.b = b; stl_int_map_map(gAnimationHandler.mList, setAnimationHandlerScreenTintSingle, &tint); } void resetAnimationHandlerScreenTint() { setAnimationHandlerScreenTint(1, 1, 1); } double* getAnimationTransparencyReference(AnimationHandlerElement* e) { return &e->mTransparency; } Position* getAnimationPositionReference(AnimationHandlerElement* e) { return &e->mPosition; } void removeHandledAnimation(AnimationHandlerElement* e) { gAnimationHandler.mList.erase(e->mID); } int isHandledAnimation(AnimationHandlerElement* e) { return stl_map_contains(gAnimationHandler.mList, e->mID); } void shutdownAnimationHandler(){ emptyAnimationHandler(); gAnimationHandler.mList.clear(); gAnimationHandler.mIsLoaded = 0; }
Java
/* * Copyright (c) 2011-2013 Lp digital system * * This file is part of BackBee. * * BackBee 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. * * BackBee 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 BackBee. If not, see <http://www.gnu.org/licenses/>. */ define(['Core', 'Core/Renderer', 'BackBone'], function (Core, Renderer, Backbone) { 'use strict'; var HiddenView = Backbone.View.extend({ initialize: function (template, formTag, element) { this.el = formTag; this.template = template; this.element = element; this.bindEvents(); }, bindEvents: function () { var self = this; Core.Mediator.subscribe('before:form:submit', function (form) { if (form.attr('id') === self.el) { var element = form.find('.element_' + self.element.getKey()), input = element.find('input[name="' + self.element.getKey() + '"]'), span = element.find('span.updated'), oldValue = self.element.value; if (input.val() !== oldValue) { span.text('updated'); } else { span.text(''); } } }); }, /** * Render the template into the DOM with the Renderer * @returns {String} html */ render: function () { return Renderer.render(this.template, {element: this.element}); } }); return HiddenView; });
Java
/* RWImporter Copyright (C) 2017 Martin Smith 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 <http://www.gnu.org/licenses/>. */ #include "rw_snippet.h" #include <QXmlStreamWriter> #include <QBuffer> #include <QDebug> #include <QModelIndex> #include <QMetaEnum> #include <QFile> #include <QFileInfo> #include <QMessageBox> #include <QNetworkAccessManager> #include <QNetworkReply> #include <QCoreApplication> #include "datafield.h" #include "rw_domain.h" #include "rw_facet.h" static QMetaEnum snip_type_enum = QMetaEnum::fromType<RWFacet::SnippetType>(); static QMetaEnum snip_veracity_enum = QMetaEnum::fromType<RWContentsItem::SnippetVeracity>(); static QMetaEnum snip_style_enum = QMetaEnum::fromType<RWContentsItem::SnippetStyle>(); static QMetaEnum snip_purpose_enum = QMetaEnum::fromType<RWContentsItem::SnippetPurpose>(); const int NAME_TYPE_LENGTH = 50; const QString DEFAULT_IMAGE_NAME("image.png"); const char *DEFAULT_IMAGE_FORMAT = "PNG"; #define CONTENTS_TOKEN "contents" RWSnippet::RWSnippet(RWFacet *facet, RWContentsItem *parent) : RWContentsItem(facet, parent), facet(facet) { } static QString to_gregorian(const QString &from) { // TODO - Realm Works does not like "gregorian" fields in this format! /* Must be [Y]YYYY-MM-DD hh:mm:ss[ BCE] * year limit is 20000 */ if (from.length() >= 19) return from; // If no time in the field, then simply append midnight time */ if (from.length() == 10 || from.length() == 11) return from + " 00:00:00"; qWarning() << "INVALID DATE FORMAT:" << from << "(should be [Y]YYYY-MM-DD HH:MM:SS)"; return from; } void RWSnippet::writeToContents(QXmlStreamWriter *writer, const QModelIndex &index) const { Q_UNUSED(index); bool bold = false; // Ignore date snippets if no data available const QString start_date = startDate().valueString(index); if ((facet->snippetType() == RWFacet::Date_Game || facet->snippetType() == RWFacet::Date_Range) && start_date.isEmpty()) { return; } writer->writeStartElement("snippet"); { const QString user_text = contentsText().valueString(index); const QString gm_dir = gmDirections().valueString(index); const QVariant asset = filename().value(index); const QString finish_date = finishDate().valueString(index); QString digits = number().valueString(index); if (!structure->id().isEmpty()) writer->writeAttribute("facet_id", structure->id()); writer->writeAttribute("type", snip_type_enum.valueToKey(facet->snippetType())); if (snippetVeracity() != RWContentsItem::Truth) writer->writeAttribute("veracity", snip_veracity_enum.valueToKey(snippetVeracity())); if (snippetStyle() != RWContentsItem::Normal) writer->writeAttribute("style", snip_style_enum.valueToKey(snippetStyle())); if (snippetPurpose() != RWContentsItem::Story_Only) writer->writeAttribute("purpose", snip_purpose_enum.valueToKey(snippetPurpose())); if (isRevealed()) writer->writeAttribute("is_revealed", "true"); if (!gm_dir.isEmpty()) { RWFacet::SnippetType ft = facet->snippetType(); writer->writeAttribute("purpose", ((ft == RWFacet::Multi_Line || ft == RWFacet::Labeled_Text || ft == RWFacet::Tag_Standard || ft == RWFacet::Numeric) && user_text.isEmpty() && p_tags.valueString(index).isEmpty()) ? "Directions_Only" : "Both"); } #if 0 QString label_text = p_label_text.valueString(index); if (id().isEmpty() && facet->snippetType() == Labeled_Text && !label_text.isEmpty()) { // For locally added snippets of the Labeled_Text variety writer->writeAttribute("label", label_text); } #endif // // CHILDREN have to be in a specific order: // contents | smart_image | ext_object | game_date | date_range // annotation // gm_directions // X x (link | dlink) // X x tag_assign // Maybe an ANNOTATION or CONTENTS if (!user_text.isEmpty() || !asset.isNull() || !start_date.isEmpty() || !digits.isEmpty()) { bool check_annotation = true; switch (facet->snippetType()) { case RWFacet::Multi_Line: case RWFacet::Labeled_Text: { QString text; for (auto para: user_text.split("\n\n")) text.append(xmlParagraph(xmlSpan(para, bold))); writer->writeTextElement(CONTENTS_TOKEN, text); // No annotation for these two snippet types check_annotation = false; break; } case RWFacet::Tag_Standard: case RWFacet::Hybrid_Tag: // annotation done later break; case RWFacet::Numeric: if (!digits.isEmpty()) { bool ok; #if 1 digits.toFloat(&ok); if (!ok) qWarning() << tr("Non-numeric characters in numeric field: %1").arg(digits); else writer->writeTextElement(CONTENTS_TOKEN, digits); #else const QLocale &locale = QLocale::system(); locale.toFloat(digits, &ok); if (!ok) qWarning() << tr("Non-numeric characters in numeric field: %1").arg(digits); else { // Handle locale details: // Remove occurrences of the group character; // Replace the locale's decimal point with the ISO '.' character digits.remove(locale.groupSeparator()); digits.replace(locale.decimalPoint(),'.'); writer->writeTextElement(CONTENTS_TOKEN, digits); } #endif } break; // There are a lot of snippet types which have an ext_object child (which has an asset child) case RWFacet::Foreign: write_ext_object(writer, "Foreign", asset); break; case RWFacet::Statblock: // this might require an .rtf file? write_ext_object(writer, "Statblock", asset); break; case RWFacet::Portfolio: // requires a HeroLab portfolio write_ext_object(writer, "Portfolio", asset); break; case RWFacet::Picture: write_ext_object(writer, "Picture", asset); break; case RWFacet::Rich_Text: write_ext_object(writer, "Rich_Text", asset); break; case RWFacet::PDF: write_ext_object(writer, "PDF", asset); break; case RWFacet::Audio: write_ext_object(writer, "Audio", asset); break; case RWFacet::Video: write_ext_object(writer, "Video", asset); break; case RWFacet::HTML: write_ext_object(writer, "HTML", asset); break; case RWFacet::Smart_Image: // Slightly different format since it has a smart_image child (which has an asset child) write_smart_image(writer, asset); break; case RWFacet::Date_Game: writer->writeStartElement("game_date"); //writer->writeAttribute("canonical", start_date); writer->writeAttribute("gregorian", to_gregorian(start_date)); writer->writeEndElement(); break; case RWFacet::Date_Range: writer->writeStartElement("date_range"); //writer->writeAttribute("canonical_start", start_date); writer->writeAttribute("gregorian_start", to_gregorian(start_date)); //writer->writeAttribute("canonical_end", finish_date); writer->writeAttribute("gregorian_end", to_gregorian(finish_date)); writer->writeEndElement(); break; case RWFacet::Tag_Multi_Domain: qFatal("RWSnippet::writeToContents: invalid snippet type: %d", facet->snippetType()); } /* switch snippet type */ if (check_annotation && !user_text.isEmpty()) { writer->writeTextElement("annotation", xmlParagraph(xmlSpan(user_text, /*bold*/ false))); } } // Maybe some GM directions if (!gm_dir.isEmpty()) { writer->writeTextElement("gm_directions", xmlParagraph(xmlSpan(gm_dir, /*bold*/ false))); } // Maybe one or more TAG_ASSIGN (to be entered AFTER the contents/annotation) QString tag_names = p_tags.valueString(index); if (!tag_names.isEmpty()) { // Find the domain to use QString domain_id = structure->attributes().value("domain_id").toString(); RWDomain *domain = RWDomain::getDomainById(domain_id); if (domain) { for (auto tag_name: tag_names.split(",")) { QString tag_id = domain->tagId(tag_name.trimmed()); if (!tag_id.isEmpty()) { writer->writeStartElement("tag_assign"); writer->writeAttribute("tag_id", tag_id); writer->writeAttribute("type","Indirect"); writer->writeAttribute("is_auto_assign", "true"); writer->writeEndElement(); } else qWarning() << "No TAG defined for" << tag_name.trimmed() << "in DOMAIN" << domain->name(); } } else if (!domain_id.isEmpty()) qWarning() << "DOMAIN not found for" << domain_id << "on FACET" << structure->id(); else qWarning() << "domain_id does not exist on FACET" << structure->id(); } } writer->writeEndElement(); // snippet } void RWSnippet::write_asset(QXmlStreamWriter *writer, const QVariant &asset) const { const int FILENAME_TYPE_LENGTH = 200; // Images can be put inside immediately if (asset.type() == QVariant::Image) { QImage image = asset.value<QImage>(); writer->writeStartElement("asset"); writer->writeAttribute("filename", DEFAULT_IMAGE_NAME.right(FILENAME_TYPE_LENGTH)); QByteArray databytes; QBuffer buffer(&databytes); buffer.open(QIODevice::WriteOnly); image.save(&buffer, DEFAULT_IMAGE_FORMAT); writer->writeTextElement(CONTENTS_TOKEN, databytes.toBase64()); writer->writeEndElement(); // asset return; } QFile file(asset.toString()); QUrl url(asset.toString()); if (file.open(QFile::ReadOnly)) { QFileInfo info(file); writer->writeStartElement("asset"); writer->writeAttribute("filename", info.fileName().right(FILENAME_TYPE_LENGTH)); //writer->writeAttribute("thumbnail_size", info.fileName()); QByteArray contents = file.readAll(); writer->writeTextElement(CONTENTS_TOKEN, contents.toBase64()); //writer->writeTextElement("thumbnail", thumbnail.toBase64()); //writer->writeTextElement("summary", thing.toBase64()); //writer->writeTextElement("url", filename); writer->writeEndElement(); // asset } else if (url.isValid()) { static QNetworkAccessManager *nam = nullptr; if (nam == nullptr) { nam = new QNetworkAccessManager; nam->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); } QNetworkRequest request(url); QNetworkReply *reply = nam->get(request); while (!reply->isFinished()) { qApp->processEvents(QEventLoop::WaitForMoreEvents); } if (reply->error() != QNetworkReply::NoError) { qWarning() << "Failed to locate URL:" << asset.toString(); } // A redirect has ContentType of "text/html; charset=UTF-8, image/png" // which is an ordered comma-separated list of types. // So we need to check the LAST type which will be for readAll() else if (reply->header(QNetworkRequest::ContentTypeHeader).toString().split(',').last().trimmed().startsWith("image/")) { QString tempname = QFileInfo(url.path()).baseName() + '.' + reply->header(QNetworkRequest::ContentTypeHeader).toString().split("/").last(); writer->writeStartElement("asset"); writer->writeAttribute("filename", tempname.right(FILENAME_TYPE_LENGTH)); QByteArray contents = reply->readAll(); writer->writeTextElement(CONTENTS_TOKEN, contents.toBase64()); //writer->writeTextElement("url", filename); writer->writeEndElement(); // asset } else { // A redirect has QPair("Content-Type","text/html; charset=UTF-8, image/png") // note the comma-separated list of content types (legal?) // the body of the message is actually PNG binary data. // QPair("Server","Microsoft-IIS/8.5, Microsoft-IIS/8.5") so maybe ISS sent wrong content type qWarning() << "Only URLs to images are supported (not" << reply->header(QNetworkRequest::ContentTypeHeader) << ")! Check source at" << asset.toString(); //if (reply->header(QNetworkRequest::ContentTypeHeader).toString().startsWith("text/")) // qWarning() << "Body =" << reply->readAll(); //qWarning() << "Raw Header List =" << reply->rawHeaderPairs(); } reply->deleteLater(); } else { #if 1 qWarning() << "File/URL does not exist:" + asset.toString(); #else QString message = "File/URL does not exist: " + asset.toString(); static QMessageBox *warning = nullptr; if (warning == nullptr) { warning = new QMessageBox; warning->setText("Issues encountered during GENERATE:\n"); } warning->setText(warning->text() + '\n' + message); warning->show(); #endif } } /** * @brief RWSnippet::write_ext_object * @param writer * @param exttype one of Foreign, Statblock, Portfolio, Picture, Rich_Text, PDF, Audio, Video, HTML * @param filename */ void RWSnippet::write_ext_object(QXmlStreamWriter *writer, const QString &exttype, const QVariant &asset) const { if (asset.isNull()) return; writer->writeStartElement("ext_object"); if (asset.type() == QVariant::String) writer->writeAttribute("name", QFileInfo(asset.toString()).fileName().right(NAME_TYPE_LENGTH)); else // What name to use for QImage? writer->writeAttribute("name", DEFAULT_IMAGE_NAME.right(NAME_TYPE_LENGTH)); writer->writeAttribute("type", exttype); write_asset(writer, asset); writer->writeEndElement(); } void RWSnippet::write_smart_image(QXmlStreamWriter *writer, const QVariant &asset) const { if (asset.isNull()) return; writer->writeStartElement("smart_image"); writer->writeAttribute("name", QFileInfo(asset.toString()).fileName().right(NAME_TYPE_LENGTH)); write_asset(writer, asset); // write_overlay (0-1) // write_subset_mask (0-1) // write_superset_mask (0-1) // write_map_pan (0+) writer->writeEndElement(); } QDataStream &operator<<(QDataStream &stream, const RWSnippet &snippet) { //qDebug() << " RWSnippet<<" << snippet.structure->name(); // write base class items stream << *dynamic_cast<const RWContentsItem*>(&snippet); // write this class items stream << snippet.p_tags; stream << snippet.p_label_text; stream << snippet.p_filename; stream << snippet.p_start_date; stream << snippet.p_finish_date; stream << snippet.p_number; return stream; } QDataStream &operator>>(QDataStream &stream, RWSnippet &snippet) { //qDebug() << " RWSnippet>>" << snippet.structure->name(); // read base class items stream >> *dynamic_cast<RWContentsItem*>(&snippet); // read this class items stream >> snippet.p_tags; stream >> snippet.p_label_text; stream >> snippet.p_filename; stream >> snippet.p_start_date; stream >> snippet.p_finish_date; stream >> snippet.p_number; return stream; }
Java
#include "podcastclient.h" QStringList PodcastClient::getFeedsFromSettings() { QStringList resultList = settings.value("feeds").toStringList(); if(resultList.isEmpty()) { QString string = settings.value("feeds").toString(); if(!string.isEmpty()) resultList.push_back(string); } return resultList; } PodcastClient::PodcastClient(QObject *parent) : QObject(parent) { if(settings.value("NumDownloads").isNull()) settings.setValue("NumDownloads",10); if(settings.value("Dest").isNull()) settings.setValue("Dest","."); else { if(!QDir(settings.value("Dest").toString()).exists()) { settings.setValue("Dest",","); } } downloader.setMaxConnections(settings.value("NumDownloads").toInt()); foreach(QString url, getFeedsFromSettings()) { Podcast* podcast = new Podcast(QUrl(url), &downloader, this); podcast->setTargetFolder(QDir(settings.value("Dest").toString())); podcasts.push_back(podcast); connect(podcast,&Podcast::done,this,&PodcastClient::podcastDone); connect(podcast,&Podcast::writingFailed,this,&PodcastClient::podcastWritingFailed); } } bool PodcastClient::downloadAll() { if(podcasts.isEmpty()) { out << "No podcasts in list. Done." << endl; return true; } finishedCtr = 0; foreach(Podcast* podcast, podcasts) { podcast->update(); } return false; } bool PodcastClient::addPodcast(const QUrl &url, const QString &mode) { podcasts.clear(); finishedCtr = 0; if(!url.isValid()) { out << "Invalid URL." << endl; return true; } if(mode=="last" || mode.isEmpty()) { Podcast* podcast = new Podcast(url, &downloader, this); podcasts.push_back(podcast); connect(podcast,&Podcast::done,this,&PodcastClient::podcastDone); podcast->init(true); QStringList feeds; foreach(QString url, getFeedsFromSettings()) { feeds.push_back(url); } feeds.push_back(url.toString()); settings.setValue("feeds",feeds); return false; } else if(mode=="all") { QStringList feeds; foreach(QString url, getFeedsFromSettings()) { feeds.push_back(url); } feeds.push_back(url.toString()); settings.setValue("feeds",feeds); return true; } else if(mode=="none") { Podcast* podcast = new Podcast(url, &downloader, this); podcasts.push_back(podcast); connect(podcast,&Podcast::done,this,&PodcastClient::podcastDone); podcast->init(false); QStringList feeds; foreach(QString url, getFeedsFromSettings()) { feeds.push_back(url); } feeds.push_back(url.toString()); settings.setValue("feeds",feeds); return false; } else { out << "Invalid adding mode: " << mode << endl; out << "Modes are: last, all, none" << endl; return true; } } void PodcastClient::removePodcast(const QUrl &url) { QStringList feeds; foreach(QString url, getFeedsFromSettings()) { feeds.push_back(url); } feeds.removeAll(url.toString()); if(feeds.isEmpty()) settings.remove("feeds"); else settings.setValue("feeds",feeds); } void PodcastClient::setDest(const QString &dest) { QDir dir(dest); settings.setValue("Dest",dest); settings.sync(); if(!dir.exists()) { out << "Target directory does not exist." << endl; } } QString PodcastClient::getDest() { return settings.value("Dest").toString(); } void PodcastClient::list() { foreach(QString url, getFeedsFromSettings()) { out << url << endl; } } void PodcastClient::setMaxDownloads(int num) { downloader.setMaxConnections(num); settings.setValue("NumDownloads",num); settings.sync(); } int PodcastClient::getMaxDownloads() { return downloader.getMaxConnections(); } void PodcastClient::podcastDone() { finishedCtr++; if(finishedCtr==podcasts.size()) { settings.sync(); QCoreApplication::exit(0); } } void PodcastClient::podcastWritingFailed() { out << "Aborting downloads..." << endl; foreach(Podcast* podcast, podcasts) { podcast->abort(); } }
Java
package org.epilot.ccf.codec; import org.apache.mina.common.ByteBuffer; import org.epilot.ccf.core.code.AbstractMessageEncode; import org.epilot.ccf.core.protocol.Message; import org.epilot.ccf.core.protocol.MessageBody; import org.epilot.ccf.core.protocol.MessageHeader; import org.epilot.ccf.core.util.ByteBufferDataHandle; public class MessageEncode extends AbstractMessageEncode { private String serviceName; public MessageEncode(String serviceName) { this.serviceName = serviceName; } protected void encodeMessage(GameMessageDataHandle messageDataHandle,Message message,ByteBuffer buffer) { ByteBufferDataHandle byteBufferDataHandle =new ByteBufferDataHandle(buffer); MessageHeader header = message.getHeader(); MessageBody body = message.getBody(); if(header ==null)//无消息头 { return; } messageDataHandle.getHeaderBuffer(serviceName,header, byteBufferDataHandle); if(body !=null) { messageDataHandle.getBodyBuffer(String.valueOf(header.getProtocolId()),body, byteBufferDataHandle); } } @Override protected void encodeMessage(DefaultMessageDataHandle messageDataHandle, Message message, ByteBuffer buffer) { } }
Java
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>Description of create_links_stl</title> <meta name="keywords" content="create_links_stl"> <meta name="description" content="%%%%%%%%%%%%%%%%%"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../../../../m2html.css"> </head> <body> <a name="_top"></a> <div><a href="../../../../index.html">Home</a> &gt; <a href="../../../index.html">arte3.1.4</a> &gt; <a href="#">robots</a> &gt; <a href="#">MITSUBISHI</a> &gt; <a href="index.html">PA-10</a> &gt; create_links_stl.m</div> <!--<table width="100%"><tr><td align="left"><a href="../../../../index.html"><img alt="<" border="0" src="../../../../left.png">&nbsp;Master index</a></td> <td align="right"><a href="index.html">Index for arte3.1.4/robots/MITSUBISHI/PA-10&nbsp;<img alt=">" border="0" src="../../../../right.png"></a></td></tr></table>--> <h1>create_links_stl </h1> <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../../up.png"></a></h2> <div class="box"><strong>%%%%%%%%%%%%%%%%%</strong></div> <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../../up.png"></a></h2> <div class="box"><strong>This is a script file. </strong></div> <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../../up.png"></a></h2> <div class="fragment"><pre class="comment">%%%%%%%%%%%%%%%%% LINK 0: BASE %%%%%%%%%%%%%%%%%</pre></div> <!-- crossreference --> <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../../up.png"></a></h2> This function calls: <ul style="list-style-image:url(../../../../matlabicon.gif)"> <li><a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a> SURF2STL Write STL file from surface data.</li></ul> This function is called by: <ul style="list-style-image:url(../../../../matlabicon.gif)"> </ul> <!-- crossreference --> <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../../up.png"></a></h2> <div class="fragment"><pre>0001 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0002 <span class="comment">% LINK 0: BASE</span> 0003 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0004 filename=<span class="string">'link0.stl'</span>; <span class="comment">%base</span> 0005 cyl_radius=0.075; 0006 cyl_height = 0.290; 0007 precision = 10; <span class="comment">% increase to obtain a more accurate drawing</span> 0008 0009 <span class="comment">%create a unit height cylinder with 100 points. Radius 75</span> 0010 [X,Y,Z] = cylinder([cyl_radius], precision); 0011 <span class="comment">%Multiply Z by height</span> 0012 Z=Z*cyl_height; 0013 0014 <span class="comment">%Save in stl format, create new file</span> 0015 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0016 0017 <span class="comment">%now create a disk, bottom</span> 0018 radius = linspace(0,cyl_radius,precision); <span class="comment">% For ten rings</span> 0019 theta = (pi/180)*[0:15:360]; <span class="comment">% For eight angles</span> 0020 [R,T] = meshgrid(radius,theta); <span class="comment">% Make radius/theta grid</span> 0021 X = R.*cos(T); <span class="comment">% Convert grid to cartesian coordintes</span> 0022 Y = R.*sin(T); 0023 0024 <span class="comment">%append this solid to already created file, bottom disk</span> 0025 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, 0.*X, <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0026 <span class="comment">%top disk</span> 0027 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, cyl_height.*ones(size(X,1), size(X,2)), <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0028 0029 0030 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0031 <span class="comment">% LINK 1</span> 0032 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0033 filename=<span class="string">'link1.stl'</span>; 0034 cyl_radius=0.05; 0035 cyl_height = 0.150; 0036 0037 <span class="comment">%create a unit height cylinder with 100 points. Radius 75</span> 0038 [X,Y,Z] = cylinder([cyl_radius], precision); 0039 <span class="comment">% draw Z correspondingly</span> 0040 Z(1,:)=Z(1,:) -cyl_height/2; 0041 Z(2,:)=Z(2,:).*(cyl_height/2); 0042 0043 <span class="comment">%Save in stl format, create new file</span> 0044 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0045 0046 <span class="comment">%now create a disk, bottom</span> 0047 radius = linspace(0,cyl_radius,precision); <span class="comment">% For ten rings</span> 0048 theta = (pi/180)*[0:15:360]; <span class="comment">% For eight angles</span> 0049 [R,T] = meshgrid(radius,theta); <span class="comment">% Make radius/theta grid</span> 0050 X = R.*cos(T); <span class="comment">% Convert grid to cartesian coordintes</span> 0051 Y = R.*sin(T); 0052 0053 <span class="comment">%append this solid to already created file, bottom disk</span> 0054 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, (-cyl_height/2).*ones(size(X,1), size(X,2)), <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0055 <span class="comment">%top disk</span> 0056 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, (cyl_height/2).*ones(size(X,1), size(X,2)), <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0057 0058 0059 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0060 <span class="comment">% LINK 2</span> 0061 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0062 filename=<span class="string">'link2.stl'</span>; 0063 <span class="comment">%cylinder 1</span> 0064 cyl_radius=0.03; 0065 cyl_height = 0.1; 0066 [X,Y,Z] = cylinder([cyl_radius], precision); 0067 <span class="comment">% draw Z correspondingly</span> 0068 Z(1,:)=Z(1,:) -cyl_height/2; 0069 Z(2,:)=Z(2,:).*(cyl_height/2); 0070 0071 <span class="comment">%Save in stl format, create new file</span> 0072 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0073 0074 cyl_radius=0.05; 0075 cyl_height = 0.450; 0076 <span class="comment">%draw arm, swap X and Z</span> 0077 [Z,Y,X] = cylinder([cyl_radius cyl_radius*0.8], precision); 0078 <span class="comment">% draw Z correspondingly</span> 0079 X(1,:)=X(1,:) -cyl_height; 0080 X(2,:)=X(2,:).*0; 0081 0082 <span class="comment">%surf(X, Y, Z)</span> 0083 0084 <span class="comment">%Save in stl format, create new file</span> 0085 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0086 0087 0088 0089 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0090 <span class="comment">% LINK 3</span> 0091 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0092 filename=<span class="string">'link3.stl'</span>; 0093 <span class="comment">%cylinder 1</span> 0094 <span class="comment">% cyl_radius=0.03;</span> 0095 <span class="comment">% cyl_height = 0.1;</span> 0096 <span class="comment">% [X,Y,Z] = cylinder([cyl_radius], precision);</span> 0097 <span class="comment">% % draw Z correspondingly</span> 0098 <span class="comment">% Z(1,:)=Z(1,:) -cyl_height/2;</span> 0099 <span class="comment">% Z(2,:)=Z(2,:).*(cyl_height/2);</span> 0100 <span class="comment">%</span> 0101 <span class="comment">% %Save in stl format, create new file</span> 0102 <span class="comment">% surf2stl(filename, X, Y, Z, 'ascii', 'w');</span> 0103 0104 cyl_radius=0.04; 0105 cyl_height = 0.50; 0106 <span class="comment">%draw arm, swap X and Z</span> 0107 [X, Y, Z] = cylinder([cyl_radius cyl_radius*0.8], precision); 0108 <span class="comment">% draw Z correspondingly</span> 0109 0110 Z(2,:)=Z(2,:).*(cyl_height); 0111 0112 <span class="comment">%Save in stl format, create new file</span> 0113 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0114 0115 0116 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0117 <span class="comment">% LINK 4</span> 0118 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0119 filename=<span class="string">'link4.stl'</span>; 0120 0121 cyl_radius=0.03; 0122 cyl_height = 0.07; 0123 <span class="comment">%draw arm, swap X and Z</span> 0124 [X, Y, Z] = cylinder([cyl_radius], precision); 0125 <span class="comment">% draw Z correspondingly</span> 0126 Z(1,:)=Z(1,:) -cyl_height/2; 0127 Z(2,:)=Z(2,:).*(cyl_height/2); 0128 0129 <span class="comment">%Save in stl format, create new file</span> 0130 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0131 0132 0133 0134 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0135 <span class="comment">% LINK 5</span> 0136 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0137 filename=<span class="string">'link5.stl'</span>; 0138 0139 cyl_radius=0.03; 0140 cyl_height = 0.07; 0141 <span class="comment">%draw arm, swap X and Z</span> 0142 [X, Y, Z] = cylinder([cyl_radius], precision); 0143 <span class="comment">% draw Z correspondingly</span> 0144 Z(2,:)=Z(2,:).*(cyl_height); 0145 0146 <span class="comment">%Save in stl format, create new file</span> 0147 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0148 0149 0150 0151 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0152 <span class="comment">% LINK 6</span> 0153 <span class="comment">%%%%%%%%%%%%%%%%%%</span> 0154 filename=<span class="string">'link6.stl'</span>; 0155 0156 cyl_radius=0.05; 0157 cyl_height = 0.01; 0158 <span class="comment">%draw arm, swap X and Z</span> 0159 [X, Y, Z] = cylinder([cyl_radius], precision); 0160 <span class="comment">% draw Z correspondingly</span> 0161 Z(1,:)=Z(1,:) -cyl_height; 0162 Z(2,:)=Z(2,:).*0; 0163 <span class="comment">%Save in stl format, create new file</span> 0164 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, Z, <span class="string">'ascii'</span>, <span class="string">'w'</span>); 0165 0166 <span class="comment">%now create a disk, bottom</span> 0167 radius = linspace(0,cyl_radius,precision); 0168 theta = (pi/180)*[0:15:360]; 0169 [R,T] = meshgrid(radius,theta); <span class="comment">% Make radius/theta grid</span> 0170 X = R.*cos(T); 0171 Y = R.*sin(T); 0172 0173 <span class="comment">%append this solid to already created file, bottom disk</span> 0174 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, (-cyl_height).*ones(size(X,1), size(X,2)), <span class="string">'ascii'</span>, <span class="string">'a+'</span>); 0175 <span class="comment">%append this solid to already created file, bottom disk</span> 0176 <a href="../../../../arte3.1.4/tools/surf2stl/surf2stl.html" class="code" title="function surf2stl(filename,x,y,z,mode,writemode)">surf2stl</a>(filename, X, Y, 0.*ones(size(X,1), size(X,2)), <span class="string">'ascii'</span>, <span class="string">'a+'</span>);</pre></div> <hr><address>Generated on Wed 29-May-2013 19:30:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address> </body> </html>
Java
var _i_x_n_annotation_format_8h = [ [ "IXNAnnotationFormat", "_i_x_n_annotation_format_8h.html#a607464fe85fc01c26df0c51826fd4841", [ [ "IXNAnnotationFormatPlainString", "_i_x_n_annotation_format_8h.html#a607464fe85fc01c26df0c51826fd4841a7b4fb91d85f0776a7abe6e0623f6b0fc", null ], [ "IXNAnnotationFormatJson", "_i_x_n_annotation_format_8h.html#a607464fe85fc01c26df0c51826fd4841a91b8ae8f1bcb5c68a714026c4674231d", null ], [ "IXNAnnotationFormatOsc", "_i_x_n_annotation_format_8h.html#a607464fe85fc01c26df0c51826fd4841a611da1ac0a3eccbea277aad5ca3d57f1", null ] ] ] ];
Java
// This file was generated based on /usr/local/share/uno/Packages/Fuse.Controls.Navigation/1.3.1/Transition.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Int.h> namespace g{ namespace Fuse{ namespace Triggers{ // public enum TransitionMode :181 uEnumType* TransitionMode_typeof(); }}} // ::g::Fuse::Triggers
Java
#include <unistd.h> #include <sys/stat.h> int remove(const char *pathname) { struct stat buf; stat(pathname, &buf); if (S_ISDIR(buf.st_mode)) { return rmdir(pathname); } else { return unlink(pathname); } }
Java
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dal.SOFD { public interface IRepo<IEntity> { IQueryable<IEntity> Query { get; } } }
Java
package com.baeldung.iteratorguide; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; public class IteratorGuide { public static void main(String[] args) { List<String> items = new ArrayList<>(); items.add("ONE"); items.add("TWO"); items.add("THREE"); Iterator<String> iter = items.iterator(); while (iter.hasNext()) { String next = iter.next(); System.out.println(next); iter.remove(); } ListIterator<String> listIterator = items.listIterator(); while(listIterator.hasNext()) { String nextWithIndex = items.get(listIterator.nextIndex()); String next = listIterator.next(); if( "ONE".equals(next)) { listIterator.set("SWAPPED"); } } listIterator.add("FOUR"); while(listIterator.hasPrevious()) { String previousWithIndex = items.get(listIterator.previousIndex()); String previous = listIterator.previous(); System.out.println(previous); } listIterator.forEachRemaining(e -> { System.out.println(e); }); } }
Java
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace SPCtoMML { public partial class Form2 : Form { /// <summary> /// Callback for updating progress /// </summary> private Func<double> updateProgressHandler; /// <summary> /// Initializes the form. /// </summary> /// <param name="updateProgress">The callback for updating progress bar ratio.</param> public Form2(Func<double> updateProgress) { InitializeComponent(); this.Text = Program.GetProgramName(); this.updateProgressHandler = updateProgress; } public void UpdateHandler(Func<double> updateProgress) { this.updateProgressHandler = updateProgress; } /// <summary> /// Updates the progress dialog status. /// </summary> /// <param name="status">The new status to use.</param> public void UpdateStatus(string status) { this.label1.Text = status; } /// <summary> /// Updates the progress bar. /// </summary> /// <param name="ratio">The progress ratio.</param> public void UpdateProgress(double ratio) { try { this.progressBar1.Value = (int)Math.Round(ratio * 1000); } catch { this.progressBar1.Value = 0; } } private void Form2_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; } } private void timer1_Tick(object sender, EventArgs e) { if (updateProgressHandler != null) { UpdateProgress(updateProgressHandler()); } } } }
Java
/*! * \file in_memory_configuration.h * \brief A ConfigurationInterface for testing purposes. * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * * This implementation accepts configuration parameters upon instantiation and * it is intended to be used in unit testing. * * ------------------------------------------------------------------------- * * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver * * This file is part of GNSS-SDR. * * GNSS-SDR 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. * * GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. * * ------------------------------------------------------------------------- */ #ifndef GNSS_SDR_IN_MEMORY_CONFIGURATION_H_ #define GNSS_SDR_IN_MEMORY_CONFIGURATION_H_ #include <map> #include <memory> #include <string> #include "configuration_interface.h" class StringConverter; /*! * \brief This class is an implementation of the interface ConfigurationInterface. * * This implementation accepts configuration parameters upon instantiation and * it is intended to be used in unit testing. */ class InMemoryConfiguration : public ConfigurationInterface { public: InMemoryConfiguration(); virtual ~InMemoryConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); long property(std::string property_name, long default_value); int property(std::string property_name, int default_value); unsigned int property(std::string property_name, unsigned int default_value); float property(std::string property_name, float default_value); double property(std::string property_name, double default_value); void set_property(std::string property_name, std::string value); bool is_present(std::string property_name); private: std::map<std::string, std::string> properties_; std::unique_ptr<StringConverter> converter_; }; #endif /*GNSS_SDR_IN_MEMORY_CONFIGURATION_H_*/
Java
#coding=UTF-8 from pyspark import SparkContext, SparkConf, SQLContext, Row, HiveContext from pyspark.sql.types import * from datetime import date, datetime, timedelta import sys, re, os st = datetime.now() conf = SparkConf().setAppName('PROC_A_SUBJECT_D002015').setMaster(sys.argv[2]) sc = SparkContext(conf = conf) sc.setLogLevel('WARN') if len(sys.argv) > 5: if sys.argv[5] == "hive": sqlContext = HiveContext(sc) else: sqlContext = SQLContext(sc) hdfs = sys.argv[3] dbname = sys.argv[4] #处理需要使用的日期 etl_date = sys.argv[1] #etl日期 V_DT = etl_date #上一日日期 V_DT_LD = (date(int(etl_date[0:4]), int(etl_date[4:6]), int(etl_date[6:8])) + timedelta(-1)).strftime("%Y%m%d") #月初日期 V_DT_FMD = date(int(etl_date[0:4]), int(etl_date[4:6]), 1).strftime("%Y%m%d") #上月末日期 V_DT_LMD = (date(int(etl_date[0:4]), int(etl_date[4:6]), 1) + timedelta(-1)).strftime("%Y%m%d") #10位日期 V_DT10 = (date(int(etl_date[0:4]), int(etl_date[4:6]), int(etl_date[6:8]))).strftime("%Y-%m-%d") V_STEP = 0 ACRM_F_CI_ASSET_BUSI_PROTO = sqlContext.read.parquet(hdfs+'/ACRM_F_CI_ASSET_BUSI_PROTO/*') ACRM_F_CI_ASSET_BUSI_PROTO.registerTempTable("ACRM_F_CI_ASSET_BUSI_PROTO") #任务[21] 001-01:: V_STEP = V_STEP + 1 sql = """ SELECT CAST(A.CUST_ID AS VARCHAR(32)) AS CUST_ID ,CAST('' AS VARCHAR(20)) AS ORG_ID --插入的空值,包顺龙2017/05/13 ,CAST('D002015' AS VARCHAR(20)) AS INDEX_CODE ,CAST(SUM(TAKE_CGT_LINE) AS DECIMAL(22,2)) AS INDEX_VALUE ,CAST(SUBSTR(V_DT, 1, 7) AS VARCHAR(7)) AS YEAR_MONTH ,CAST(V_DT AS DATE) AS ETL_DATE ,CAST(A.CUST_TYP AS VARCHAR(5)) AS CUST_TYPE ,CAST(A.FR_ID AS VARCHAR(5)) AS FR_ID FROM ACRM_F_CI_ASSET_BUSI_PROTO A WHERE A.BAL > 0 AND A.LN_APCL_FLG = 'N' AND(A.PRODUCT_ID LIKE '1010%' OR A.PRODUCT_ID LIKE '1030%' OR A.PRODUCT_ID LIKE '1040%' OR A.PRODUCT_ID LIKE '1050%' OR A.PRODUCT_ID LIKE '1060%' OR A.PRODUCT_ID LIKE '1070%' OR A.PRODUCT_ID LIKE '2010%' OR A.PRODUCT_ID LIKE '2020%' OR A.PRODUCT_ID LIKE '2030%' OR A.PRODUCT_ID LIKE '2040%' OR A.PRODUCT_ID LIKE '2050%') GROUP BY A.CUST_ID ,A.CUST_TYP ,A.FR_ID """ sql = re.sub(r"\bV_DT\b", "'"+V_DT10+"'", sql) ACRM_A_TARGET_D002015 = sqlContext.sql(sql) ACRM_A_TARGET_D002015.registerTempTable("ACRM_A_TARGET_D002015") dfn="ACRM_A_TARGET_D002015/"+V_DT+".parquet" ACRM_A_TARGET_D002015.cache() nrows = ACRM_A_TARGET_D002015.count() ACRM_A_TARGET_D002015.write.save(path=hdfs + '/' + dfn, mode='overwrite') ACRM_A_TARGET_D002015.unpersist() ACRM_F_CI_ASSET_BUSI_PROTO.unpersist() ret = os.system("hdfs dfs -rm -r /"+dbname+"/ACRM_A_TARGET_D002015/"+V_DT_LD+".parquet") et = datetime.now() print("Step %d start[%s] end[%s] use %d seconds, insert ACRM_A_TARGET_D002015 lines %d") % (V_STEP, st.strftime("%H:%M:%S"), et.strftime("%H:%M:%S"), (et-st).seconds, nrows)
Java
/*=================================================================================*/ /* File: bayes_MonoExpAnalysisBinned.h */ /*---------------------------------------------------------------------------------*/ /* Purpose: Header file for bayes_MonoExpAnalysisBinned.c. */ /*---------------------------------------------------------------------------------*/ /* References: [1] - "Bayesian data analysis and parameter inference and */ /* applications to imaging based on photon counting", */ /* ACC Coolen, KCL, December 8th 2006. */ /*---------------------------------------------------------------------------------*/ /* Notes: None. */ /*=================================================================================*/ /* Revision history: */ /*---------------------------------------------------------------------------------*/ /* Date | Modification */ /*---------------------------------------------------------------------------------*/ /* 090424 | Creation, mrowley. */ /*---------------------------------------------------------------------------------*/ /* | */ /*=================================================================================*/ #ifndef BAYES_MONO_EXP_RAPID_ANALYSIS_H #define BAYES_MONO_EXP_RAPID_ANALYSIS_H int bayes_RapidMonoExpDirectMostProbW0W1( int *data, int nbins, int fitstart, int nphotons, double *w0, double *w1, float *val, BayesInstrRsp_t *instr, float interval, float modulationperiod, float alpha, BayesRapidMonoExpValueStore_t *grid, BayesAveErrDistn_t *distr); int bayes_RapidMonoExpAvgAndErrors( int *data, int nbins, int fitstart, int nphotons, double *w0_mp, double *w1_mp, double *w0_ave, double *w1_ave, double *dw0, double *dw1, BayesInstrRsp_t *instr, float interval, float modulationperiod, float alpha, float precision, int p,/* hmm, this is actually nphotons */ int quick, BayesAveErrDistn_t *distr, BayesRapidMonoExpValueStore_t *grid, float *value); #if 0 int bayes_RapidMonoExpIndirectMostProbableW0W1( int *data, int nbins, int nphotons, float *w0, float *w1, //float *val, float delay, float width, float interval, float modulationperiod, float alpha, BayesRapidMonoExpValueStore_t *grid); #endif #endif /* BAYES_MONO_EXP_RAPID_ANALYSIS_H */
Java
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>SUMO - Simulation of Urban MObility: NBTrafficLightLogicCont.h File Reference</title> <link href="../../tabs.css" rel="stylesheet" type="text/css"/> <link href="../../doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="../../main.html"><span>Main&nbsp;Page</span></a></li> <li><a href="../../pages.html"><span>Related&nbsp;Pages</span></a></li> <li><a href="../../modules.html"><span>Modules</span></a></li> <li><a href="../../annotated.html"><span>Data&nbsp;Structures</span></a></li> <li class="current"><a href="../../files.html"><span>Files</span></a></li> <li><a href="../../dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="../../files.html"><span>File&nbsp;List</span></a></li> <li><a href="../../globals.html"><span>Globals</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="../../dir_75b82e7e4a5feb05200b9ad7adf06257.html">home</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_46b8f36974b309f038ffc35aa047a32b.html">boni</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_52e5be8ca53cec2b5437a8ba83e8e4f0.html">Desktop</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_7de3ce0f65e0314f747915173f89e60e.html">DanielTouched</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_a0096e276045b3ff0719c75e0b3c59bf.html">sumo-0.14.0</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_e9b8d709919855cd07b0394009af2578.html">src</a>&nbsp;&raquo;&nbsp;<a class="el" href="../../dir_fef730b7af99b175e444dabf8b9377e8.html">netbuild</a> </div> </div> <div class="contents"> <h1>NBTrafficLightLogicCont.h File Reference</h1><code>#include &lt;<a class="el" href="../../db/d16/config_8h_source.html">config.h</a>&gt;</code><br/> <code>#include &lt;map&gt;</code><br/> <code>#include &lt;string&gt;</code><br/> <code>#include &quot;<a class="el" href="../../dc/da1/_n_b_traffic_light_definition_8h_source.html">NBTrafficLightDefinition.h</a>&quot;</code><br/> <p><a href="../../d3/dd9/_n_b_traffic_light_logic_cont_8h_source.html">Go to the source code of this file.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Data Structures</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d9/d5e/class_n_b_traffic_light_logic_cont.html">NBTrafficLightLogicCont</a></td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A container for traffic light definitions and built programs. <a href="../../d9/d5e/class_n_b_traffic_light_logic_cont.html#_details">More...</a><br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <dl class="author"><dt><b>Author:</b></dt><dd>Daniel Krajzewicz </dd> <dd> Jakob Erdmann </dd> <dd> Michael Behrisch </dd></dl> <dl class="date"><dt><b>Date:</b></dt><dd>Sept 2002 </dd></dl> <dl class="version"><dt><b>Version:</b></dt><dd></dd></dl> <dl class="rcs"><dt><b>Id</b></dt><dd><a class="el" href="../../d3/dd9/_n_b_traffic_light_logic_cont_8h.html">NBTrafficLightLogicCont.h</a> 11671 2012-01-07 20:14:30Z behrisch </dd></dl> <p>Definition in file <a class="el" href="../../d3/dd9/_n_b_traffic_light_logic_cont_8h_source.html">NBTrafficLightLogicCont.h</a>.</p> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 17 12:16:15 2012 for SUMO - Simulation of Urban MObility by&nbsp; <a href="http://www.doxygen.org/index.html"> <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>
Java
/** ****************************************************************************** * @file BSP/Inc/main.h * @author MCD Application Team * @version V1.2.6 * @date 06-May-2016 * @brief Header for main.c module ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2> * * 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 STMicroelectronics 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. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stdio.h" #include "stm32f429i_discovery.h" #include "stm32f429i_discovery_ts.h" #include "stm32f429i_discovery_io.h" #include "stm32f429i_discovery_lcd.h" #include "stm32f429i_discovery_gyroscope.h" #ifdef EE_M24LR64 #include "stm32f429i_discovery_eeprom.h" #endif /*EE_M24LR64*/ /* Exported types ------------------------------------------------------------*/ typedef struct { void (*DemoFunc)(void); uint8_t DemoName[50]; uint32_t DemoIndex; }BSP_DemoTypedef; extern const unsigned char stlogo[]; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ #define COUNT_OF_EXAMPLE(x) (sizeof(x)/sizeof(BSP_DemoTypedef)) /* Exported functions ------------------------------------------------------- */ void Joystick_demo (void); void Touchscreen_demo (void); void LCD_demo (void); void MEMS_demo (void); void Log_demo(void); #ifdef EE_M24LR64 void EEPROM_demo (void); #endif /*EE_M24LR64*/ void SD_demo (void); void Touchscreen_Calibration (void); uint16_t Calibration_GetX(uint16_t x); uint16_t Calibration_GetY(uint16_t y); uint8_t IsCalibrationDone(void); uint8_t CheckForUserInput(void); void Toggle_Leds(void); #endif /* __MAIN_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Java
/* ID: zhou.yo1 PROG: palsquare LANG: C++ */ #include <iostream> #include <fstream> #include <vector> #include <string> #include <cstring> #include <set> #include <map> #include <algorithm> using namespace std; const char* digits = "0123456789ABCDEFGHIJKLMN"; void to_base( int num, int base, char* out ) { char* p = out; while( num ) { *p++ = digits[ num % base ]; num /= base; } *p = '\0'; reverse( out, p ); //cout << out << endl; } bool is_pal( char* in, int len ) { for(int i = 0; i < len/2; ++i ) { if( in[i] != in[len-1-i] ) return false; } return true; } int main() { ifstream fin( "palsquare.in" ); ofstream out( "palsquare.out" ); int base; fin >> base; char N[256]; char S[256]; for(int i = 1; i <= 300; ++i ) { to_base(i, base, N); to_base(i*i, base, S); if( is_pal(S, strlen(S)) ) { out << N << ' ' << S << endl; } } return 0; }
Java
{% extends "base.html" %} {% block content %} <p> <h2>What is NLGIS?</h2> In the nineteenth century there were more than 800 municipalities in the Netherlands, where today only about 450 remain. The NLGIS (Netherlands Geographic Information System) project is an effort to plot data for these municipalities on historically accurate municipality <a href="/site?code=TXGE&year=1986">boundaries</a> for the period 1812 - 1997. </p> <table border=0 valign=top width="100%"> <tr> <td width="48%"> <h2>Key Features</h2> The project's aim is twofold: to allow non-GIS experts to easily plot data on historical maps and to disseminate information on the maps and the underlying data from the Historical Database of Dutch Municipalities (HDNG). We do so in the following manner: <li>Upload your own datasets and visualize the data on historically accurate map boundaries</li> <li>Get access to the map of Netherlands on the <a href="/site?code=TXGE&year=1982&province=Noord-Holland">provincial level</a></li> <li>Download the map in Vector (<a href="/download?year=1982&province=&code=TXGE&format=SVG">SVG</a>, <a href="/download?year=1982&province=&code=TXGE&format=shapefile">ShapeFile</a>) or Raster quality (<a href="/download?year=1982&code=TXGE">PNG</a>, <a href="/download?year=1982&province=&code=TXGE&format=PDF">PDF</a>)</li> <li>Integrate the map with your data with popular public map services like Google Maps or Leaflet</li> <li>Use NLGIS <a href="/developers">public Data and Geo APIs</a> and shapefiles to build your own map visualization</li> <li>Customize your map selecting projection, colormap, data categories, number of colors, etc</li> <li>Use <a href="/index">NLGIS datasets</a> free of charge to do your own research</li> <table> <tr> <td><br/><a href="https://iisg.amsterdam"><img src="/static/socialhistory.png"></a></td> </tr> </table> </td> <td width=2%"></td> <td width="50%"> <p> <a href="/site?year=1889&code=VIB1"><img width=300px height=400px src="/static/map1.png"></a> <a href="/site?code=TXGE&year=1982"><img width=300px height=400px src="/static/map2.png"></a> </td> </tr> </table> {% endblock %}
Java
<div class='fossil-doc' data-title='fileutil - file utilities'> <style> HTML { background: #FFFFFF; color: black; } BODY { background: #FFFFFF; color: black; } DIV.doctools { margin-left: 10%; margin-right: 10%; } DIV.doctools H1,DIV.doctools H2 { margin-left: -5%; } H1, H2, H3, H4 { margin-top: 1em; font-family: sans-serif; font-size: large; color: #005A9C; background: transparent; text-align: left; } H1.doctools_title { text-align: center; } UL,OL { margin-right: 0em; margin-top: 3pt; margin-bottom: 3pt; } UL LI { list-style: disc; } OL LI { list-style: decimal; } DT { padding-top: 1ex; } UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL { font: normal 12pt/14pt sans-serif; list-style: none; } LI.doctools_section, LI.doctools_subsection { list-style: none; margin-left: 0em; text-indent: 0em; padding: 0em; } PRE { display: block; font-family: monospace; white-space: pre; margin: 0%; padding-top: 0.5ex; padding-bottom: 0.5ex; padding-left: 1ex; padding-right: 1ex; width: 100%; } PRE.doctools_example { color: black; background: #f5dcb3; border: 1px solid black; } UL.doctools_requirements LI, UL.doctools_syntax LI { list-style: none; margin-left: 0em; text-indent: 0em; padding: 0em; } DIV.doctools_synopsis { color: black; background: #80ffff; border: 1px solid black; font-family: serif; margin-top: 1em; margin-bottom: 1em; } UL.doctools_syntax { margin-top: 1em; border-top: 1px solid black; } UL.doctools_requirements { margin-bottom: 1em; border-bottom: 1px solid black; } </style> <hr> [ <a href="../../../../toc.html">Main Table Of Contents</a> | <a href="../../../toc.html">Table Of Contents</a> | <a href="../../../../index.html">Keyword Index</a> | <a href="../../../../toc0.html">Categories</a> | <a href="../../../../toc1.html">Modules</a> | <a href="../../../../toc2.html">Applications</a> ] <hr> <div class="doctools"> <h1 class="doctools_title">fileutil(n) 1.15 tcllib &quot;file utilities&quot;</h1> <div id="name" class="doctools_section"><h2><a name="name">Name</a></h2> <p>fileutil - Procedures implementing some file utilities</p> </div> <div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2> <ul class="doctools_toc"> <li class="doctools_section"><a href="#toc">Table Of Contents</a></li> <li class="doctools_section"><a href="#synopsis">Synopsis</a></li> <li class="doctools_section"><a href="#section1">Description</a></li> <li class="doctools_section"><a href="#section2">Warnings and Incompatibilities</a></li> <li class="doctools_section"><a href="#section3">Bugs, Ideas, Feedback</a></li> <li class="doctools_section"><a href="#keywords">Keywords</a></li> <li class="doctools_section"><a href="#category">Category</a></li> </ul> </div> <div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2> <div class="doctools_synopsis"> <ul class="doctools_requirements"> <li>package require <b class="pkgname">Tcl 8</b></li> <li>package require <b class="pkgname">fileutil <span class="opt">?1.15?</span></b></li> </ul> <ul class="doctools_syntax"> <li><a href="#1"><b class="cmd">::fileutil::lexnormalize</b> <i class="arg">path</i></a></li> <li><a href="#2"><b class="cmd">::fileutil::fullnormalize</b> <i class="arg">path</i></a></li> <li><a href="#3"><b class="cmd">::fileutil::test</b> <i class="arg">path</i> <i class="arg">codes</i> <span class="opt">?<i class="arg">msgvar</i>?</span> <span class="opt">?<i class="arg">label</i>?</span></a></li> <li><a href="#4"><b class="cmd">::fileutil::cat</b> (<span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i>)...</a></li> <li><a href="#5"><b class="cmd">::fileutil::writeFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">data</i></a></li> <li><a href="#6"><b class="cmd">::fileutil::appendToFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">data</i></a></li> <li><a href="#7"><b class="cmd">::fileutil::insertIntoFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">data</i></a></li> <li><a href="#8"><b class="cmd">::fileutil::removeFromFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">n</i></a></li> <li><a href="#9"><b class="cmd">::fileutil::replaceInFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">n</i> <i class="arg">data</i></a></li> <li><a href="#10"><b class="cmd">::fileutil::updateInPlace</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">cmd</i></a></li> <li><a href="#11"><b class="cmd">::fileutil::fileType</b> <i class="arg">filename</i></a></li> <li><a href="#12"><b class="cmd">::fileutil::find</b> <span class="opt">?<i class="arg">basedir</i> <span class="opt">?<i class="arg">filtercmd</i>?</span>?</span></a></li> <li><a href="#13"><b class="cmd">::fileutil::findByPattern</b> <i class="arg">basedir</i> <span class="opt">?<b class="option">-regexp</b>|<b class="option">-glob</b>?</span> <span class="opt">?<b class="option">--</b>?</span> <i class="arg">patterns</i></a></li> <li><a href="#14"><b class="cmd">::fileutil::foreachLine</b> <i class="arg">var filename cmd</i></a></li> <li><a href="#15"><b class="cmd">::fileutil::grep</b> <i class="arg">pattern</i> <span class="opt">?<i class="arg">files</i>?</span></a></li> <li><a href="#16"><b class="cmd">::fileutil::install</b> <span class="opt">?<b class="option">-m</b> <i class="arg">mode</i>?</span> <i class="arg">source</i> <i class="arg">destination</i></a></li> <li><a href="#17"><b class="cmd">::fileutil::stripN</b> <i class="arg">path</i> <i class="arg">n</i></a></li> <li><a href="#18"><b class="cmd">::fileutil::stripPwd</b> <i class="arg">path</i></a></li> <li><a href="#19"><b class="cmd">::fileutil::stripPath</b> <i class="arg">prefix</i> <i class="arg">path</i></a></li> <li><a href="#20"><b class="cmd">::fileutil::jail</b> <i class="arg">jail</i> <i class="arg">path</i></a></li> <li><a href="#21"><b class="cmd">::fileutil::touch</b> <span class="opt">?<b class="option">-a</b>?</span> <span class="opt">?<b class="option">-c</b>?</span> <span class="opt">?<b class="option">-m</b>?</span> <span class="opt">?<b class="option">-r</b> <i class="arg">ref_file</i>?</span> <span class="opt">?<b class="option">-t</b> <i class="arg">time</i>?</span> <i class="arg">filename</i> <span class="opt">?<i class="arg">...</i>?</span></a></li> <li><a href="#22"><b class="cmd">::fileutil::tempdir</b></a></li> <li><a href="#23"><b class="cmd">::fileutil::tempdir</b> <i class="arg">path</i></a></li> <li><a href="#24"><b class="cmd">::fileutil::tempdirReset</b></a></li> <li><a href="#25"><b class="cmd">::fileutil::tempfile</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></li> <li><a href="#26"><b class="cmd">::fileutil::maketempdir</b> <span class="opt">?<b class="option">-prefix</b> <i class="arg">str</i>?</span> <span class="opt">?<b class="option">-suffix</b> <i class="arg">str</i>?</span> <span class="opt">?<b class="option">-dir</b> <i class="arg">str</i>?</span></a></li> <li><a href="#27"><b class="cmd">::fileutil::relative</b> <i class="arg">base</i> <i class="arg">dst</i></a></li> <li><a href="#28"><b class="cmd">::fileutil::relativeUrl</b> <i class="arg">base</i> <i class="arg">dst</i></a></li> </ul> </div> </div> <div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2> <p>This package provides implementations of standard unix utilities.</p> <dl class="doctools_definitions"> <dt><a name="1"><b class="cmd">::fileutil::lexnormalize</b> <i class="arg">path</i></a></dt> <dd><p>This command performs purely lexical normalization on the <i class="arg">path</i> and returns the changed path as its result. Symbolic links in the path are <em>not</em> resolved.</p> <p>Examples:</p> <pre class="doctools_example"> fileutil::lexnormalize /foo/./bar =&gt; /foo/bar fileutil::lexnormalize /foo/../bar =&gt; /bar </pre> </dd> <dt><a name="2"><b class="cmd">::fileutil::fullnormalize</b> <i class="arg">path</i></a></dt> <dd><p>This command resolves all symbolic links in the <i class="arg">path</i> and returns the changed path as its result. In contrast to the builtin <b class="cmd">file normalize</b> this command resolves a symbolic link in the last element of the path as well.</p></dd> <dt><a name="3"><b class="cmd">::fileutil::test</b> <i class="arg">path</i> <i class="arg">codes</i> <span class="opt">?<i class="arg">msgvar</i>?</span> <span class="opt">?<i class="arg">label</i>?</span></a></dt> <dd><p>A command for the testing of several properties of a <i class="arg">path</i>. The properties to test for are specified in <i class="arg">codes</i>, either as a list of keywords describing the properties, or as a string where each letter is a shorthand for a property to test. The recognized keywords, shorthands, and associated properties are shown in the list below. The tests are executed in the order given to the command.</p> <p>The result of the command is a boolean value. It will be true if and only if the <i class="arg">path</i> passes all the specified tests. In the case of the <i class="arg">path</i> not passing one or more test the first failing test will leave a message in the variable referenced by <i class="arg">msgvar</i>, if such is specified. The message will be prefixed with <i class="arg">label</i>, if it is specified. <em>Note</em> that the variabled referenced by <i class="arg">msgvar</i> is not touched at all if all the tests pass.</p> <dl class="doctools_definitions"> <dt><em>r</em>ead</dt> <dd><p><b class="cmd">file readable</b></p></dd> <dt><em>w</em>rite</dt> <dd><p><b class="cmd">file writable</b></p></dd> <dt><em>e</em>xists</dt> <dd><p><b class="cmd">file exists</b></p></dd> <dt>e<em>x</em>ec</dt> <dd><p><b class="cmd">file executable</b></p></dd> <dt><em>f</em>ile</dt> <dd><p><b class="cmd">file isfile</b></p></dd> <dt><em>d</em>ir</dt> <dd><p><b class="cmd">file isdirectory</b></p></dd> </dl></dd> <dt><a name="4"><b class="cmd">::fileutil::cat</b> (<span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i>)...</a></dt> <dd><p>A tcl implementation of the UNIX <b class="syscmd"><a href="../../../../index.html#key314">cat</a></b> command. Returns the contents of the specified file(s). The arguments are files to read, with interspersed options configuring the process. If there are problems reading any of the files, an error will occur, and no data will be returned.</p> <p>The options accepted are <b class="option">-encoding</b>, <b class="option">-translation</b>, <b class="option">-eofchar</b>, and <b class="option">--</b>. With the exception of the last all options take a single value as argument, as specified by the tcl builtin command <b class="cmd">fconfigure</b>. The <b class="option">--</b> has to be used to terminate option processing before a file if that file's name begins with a dash.</p> <p>Each file can have its own set of options coming before it, and for anything not specified directly the defaults are inherited from the options of the previous file. The first file inherits the system default for unspecified options.</p></dd> <dt><a name="5"><b class="cmd">::fileutil::writeFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">data</i></a></dt> <dd><p>The command replaces the current contents of the specified <i class="arg">file</i> with <i class="arg">data</i>, with the process configured by the options. The command accepts the same options as <b class="cmd">::fileutil::cat</b>. The specification of a non-existent file is legal and causes the command to create the file (and all required but missing directories).</p></dd> <dt><a name="6"><b class="cmd">::fileutil::appendToFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">data</i></a></dt> <dd><p>This command is like <b class="cmd">::fileutil::writeFile</b>, except that the previous contents of <i class="arg">file</i> are not replaced, but appended to. The command accepts the same options as <b class="cmd">::fileutil::cat</b></p></dd> <dt><a name="7"><b class="cmd">::fileutil::insertIntoFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">data</i></a></dt> <dd><p>This comment is similar to <b class="cmd">::fileutil::appendToFile</b>, except that the new data is not appended at the end, but inserted at a specified location within the file. In further contrast this command has to be given the path to an existing file. It will not create a missing file, but throw an error instead.</p> <p>The specified location <i class="arg">at</i> has to be an integer number in the range <b class="const">0</b> ... [file size <i class="arg">file</i>]. <b class="const">0</b> will cause insertion of the new data before the first character of the existing content, whereas [file size <i class="arg">file</i>] causes insertion after the last character of the existing content, i.e. appending.</p> <p>The command accepts the same options as <b class="cmd">::fileutil::cat</b>.</p></dd> <dt><a name="8"><b class="cmd">::fileutil::removeFromFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">n</i></a></dt> <dd><p>This command is the complement to <b class="cmd">::fileutil::insertIntoFile</b>, removing <i class="arg">n</i> characters from the <i class="arg">file</i>, starting at location <i class="arg">at</i>. The specified location <i class="arg">at</i> has to be an integer number in the range <b class="const">0</b> ... [file size <i class="arg">file</i>] - <i class="arg">n</i>. <b class="const">0</b> will cause the removal of the new data to start with the first character of the existing content, whereas [file size <i class="arg">file</i>] - <i class="arg">n</i> causes the removal of the tail of the existing content, i.e. the truncation of the file.</p> <p>The command accepts the same options as <b class="cmd">::fileutil::cat</b>.</p></dd> <dt><a name="9"><b class="cmd">::fileutil::replaceInFile</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">at</i> <i class="arg">n</i> <i class="arg">data</i></a></dt> <dd><p>This command is a combination of <b class="cmd">::fileutil::removeFromFile</b> and <b class="cmd">::fileutil::insertIntoFile</b>. It first removes the part of the contents specified by the arguments <i class="arg">at</i> and <i class="arg">n</i>, and then inserts <i class="arg">data</i> at the given location, effectively replacing the removed by content with <i class="arg">data</i>. All constraints imposed on <i class="arg">at</i> and <i class="arg">n</i> by <b class="cmd">::fileutil::removeFromFile</b> and <b class="cmd">::fileutil::insertIntoFile</b> are obeyed.</p> <p>The command accepts the same options as <b class="cmd">::fileutil::cat</b>.</p></dd> <dt><a name="10"><b class="cmd">::fileutil::updateInPlace</b> <span class="opt">?<i class="arg">options</i>?</span> <i class="arg">file</i> <i class="arg">cmd</i></a></dt> <dd><p>This command can be seen as the generic core functionality of <b class="cmd">::fileutil::replaceInFile</b>. It first reads the contents of the specified <i class="arg">file</i>, then runs the command prefix <i class="arg">cmd</i> with that data appended to it, and at last writes the result of that invokation back as the new contents of the file.</p> <p>If the executed command throws an error the <i class="arg">file</i> is not changed.</p> <p>The command accepts the same options as <b class="cmd">::fileutil::cat</b>.</p></dd> <dt><a name="11"><b class="cmd">::fileutil::fileType</b> <i class="arg">filename</i></a></dt> <dd><p>An implementation of the UNIX <b class="syscmd"><a href="../../../../index.html#key31">file</a></b> command, which uses various heuristics to guess the type of a file. Returns a list specifying as much type information as can be determined about the file, from most general (eg, &quot;binary&quot; or &quot;text&quot;) to most specific (eg, &quot;gif&quot;). For example, the return value for a GIF file would be &quot;binary graphic gif&quot;. The command will detect the following types of files: directory, empty, binary, text, script (with interpreter), executable elf, executable dos, executable ne, executable pe, graphic gif, graphic jpeg, graphic png, graphic tiff, graphic bitmap, html, xml (with doctype if available), message pgp, binary pdf, text ps, text eps, binary gravity_wave_data_frame, compressed bzip, compressed gzip, compressed zip, compressed tar, audio wave, audio mpeg, and link. It further detects doctools, doctoc, and docidx documentation files, and tklib diagrams.</p></dd> <dt><a name="12"><b class="cmd">::fileutil::find</b> <span class="opt">?<i class="arg">basedir</i> <span class="opt">?<i class="arg">filtercmd</i>?</span>?</span></a></dt> <dd><p>An implementation of the unix command <b class="syscmd"><a href="../../../../index.html#key630">find</a></b>. Adapted from the Tcler's Wiki. Takes at most two arguments, the path to the directory to start searching from and a command to use to evaluate interest in each file. The path defaults to &quot;<b class="file">.</b>&quot;, i.e. the current directory. The command defaults to the empty string, which means that all files are of interest. The command takes care <em>not</em> to lose itself in infinite loops upon encountering circular link structures. The result of the command is a list containing the paths to the interesting files.</p> <p>The <i class="arg">filtercmd</i>, if specified, is interpreted as a command prefix and one argument is added to it, the name of the file or directory find is currently looking at. Note that this name is <em>not</em> fully qualified. It has to be joined it with the result of <b class="cmd">pwd</b> to get an absolute filename.</p> <p>The result of <i class="arg">filtercmd</i> is a boolean value that indicates if the current file should be included in the list of interesting files.</p> <p>Example:</p> <pre class="doctools_example"> # find .tcl files package require fileutil proc is_tcl {name} {return [string match *.tcl $name]} set tcl_files [fileutil::find . is_tcl] </pre> </dd> <dt><a name="13"><b class="cmd">::fileutil::findByPattern</b> <i class="arg">basedir</i> <span class="opt">?<b class="option">-regexp</b>|<b class="option">-glob</b>?</span> <span class="opt">?<b class="option">--</b>?</span> <i class="arg">patterns</i></a></dt> <dd><p>This command is based upon the <b class="package">TclX</b> command <b class="cmd">recursive_glob</b>, except that it doesn't allow recursion over more than one directory at a time. It uses <b class="cmd">::fileutil::find</b> internally and is thus able to and does follow symbolic links, something the <b class="package">TclX</b> command does not do. First argument is the directory to start the search in, second argument is a list of <i class="arg">patterns</i>. The command returns a list of all files reachable through <i class="arg">basedir</i> whose names match at least one of the patterns. The options before the pattern-list determine the style of matching, either regexp or glob. glob-style matching is the default if no options are given. Usage of the option <b class="option">--</b> stops option processing. This allows the use of a leading '-' in the patterns.</p></dd> <dt><a name="14"><b class="cmd">::fileutil::foreachLine</b> <i class="arg">var filename cmd</i></a></dt> <dd><p>The command reads the file <i class="arg">filename</i> and executes the script <i class="arg">cmd</i> for every line in the file. During the execution of the script the variable <i class="arg">var</i> is set to the contents of the current line. The return value of this command is the result of the last invocation of the script <i class="arg">cmd</i> or the empty string if the file was empty.</p></dd> <dt><a name="15"><b class="cmd">::fileutil::grep</b> <i class="arg">pattern</i> <span class="opt">?<i class="arg">files</i>?</span></a></dt> <dd><p>Implementation of <b class="syscmd"><a href="../../../../index.html#key316">grep</a></b>. Adapted from the Tcler's Wiki. The first argument defines the <i class="arg">pattern</i> to search for. This is followed by a list of <i class="arg">files</i> to search through. The list is optional and <b class="const">stdin</b> will be used if it is missing. The result of the procedures is a list containing the matches. Each match is a single element of the list and contains filename, number and contents of the matching line, separated by a colons.</p></dd> <dt><a name="16"><b class="cmd">::fileutil::install</b> <span class="opt">?<b class="option">-m</b> <i class="arg">mode</i>?</span> <i class="arg">source</i> <i class="arg">destination</i></a></dt> <dd><p>The <b class="cmd">install</b> command is similar in functionality to the <b class="syscmd">install</b> command found on many unix systems, or the shell script distributed with many source distributions (unix/install-sh in the Tcl sources, for example). It copies <i class="arg">source</i>, which can be either a file or directory to <i class="arg">destination</i>, which should be a directory, unless <i class="arg">source</i> is also a single file. The <span class="opt">?-m?</span> option lets the user specify a unix-style mode (either octal or symbolic - see <b class="cmd">file attributes</b>.</p></dd> <dt><a name="17"><b class="cmd">::fileutil::stripN</b> <i class="arg">path</i> <i class="arg">n</i></a></dt> <dd><p>Removes the first <i class="arg">n</i> elements from the specified <i class="arg">path</i> and returns the modified path. If <i class="arg">n</i> is greater than the number of components in <i class="arg">path</i> an empty string is returned. The number of components in a given path may be determined by performing <b class="cmd">llength</b> on the list returned by <b class="cmd">file split</b>.</p></dd> <dt><a name="18"><b class="cmd">::fileutil::stripPwd</b> <i class="arg">path</i></a></dt> <dd><p>If, and only if the <i class="arg">path</i> is inside of the directory returned by [<b class="cmd">pwd</b>] (or the current working directory itself) it is made relative to that directory. In other words, the current working directory is stripped from the <i class="arg">path</i>. The possibly modified path is returned as the result of the command. If the current working directory itself was specified for <i class="arg">path</i> the result is the string &quot;<b class="const">.</b>&quot;.</p></dd> <dt><a name="19"><b class="cmd">::fileutil::stripPath</b> <i class="arg">prefix</i> <i class="arg">path</i></a></dt> <dd><p>If, and only of the <i class="arg">path</i> is inside of the directory &quot;<b class="file">prefix</b>&quot; (or the prefix directory itself) it is made relative to that directory. In other words, the prefix directory is stripped from the <i class="arg">path</i>. The possibly modified path is returned as the result of the command. If the prefix directory itself was specified for <i class="arg">path</i> the result is the string &quot;<b class="const">.</b>&quot;.</p></dd> <dt><a name="20"><b class="cmd">::fileutil::jail</b> <i class="arg">jail</i> <i class="arg">path</i></a></dt> <dd><p>This command ensures that the <i class="arg">path</i> is not escaping the directory <i class="arg">jail</i>. It always returns an absolute path derived from <i class="arg">path</i> which is within <i class="arg">jail</i>.</p> <p>If <i class="arg">path</i> is an absolute path and already within <i class="arg">jail</i> it is returned unmodified.</p> <p>An absolute path outside of <i class="arg">jail</i> is stripped of its root element and then put into the <i class="arg">jail</i> by prefixing it with it. The same happens if <i class="arg">path</i> is relative, except that nothing is stripped of it. Before adding the <i class="arg">jail</i> prefix the <i class="arg">path</i> is lexically normalized to prevent the caller from using <b class="const">..</b> segments in <i class="arg">path</i> to escape the jail.</p></dd> <dt><a name="21"><b class="cmd">::fileutil::touch</b> <span class="opt">?<b class="option">-a</b>?</span> <span class="opt">?<b class="option">-c</b>?</span> <span class="opt">?<b class="option">-m</b>?</span> <span class="opt">?<b class="option">-r</b> <i class="arg">ref_file</i>?</span> <span class="opt">?<b class="option">-t</b> <i class="arg">time</i>?</span> <i class="arg">filename</i> <span class="opt">?<i class="arg">...</i>?</span></a></dt> <dd><p>Implementation of <b class="syscmd"><a href="../../../../index.html#key317">touch</a></b>. Alter the atime and mtime of the specified files. If <b class="option">-c</b>, do not create files if they do not already exist. If <b class="option">-r</b>, use the atime and mtime from <i class="arg">ref_file</i>. If <b class="option">-t</b>, use the integer clock value <i class="arg">time</i>. It is illegal to specify both <b class="option">-r</b> and <b class="option">-t</b>. If <b class="option">-a</b>, only change the atime. If <b class="option">-m</b>, only change the mtime.</p> <p><em>This command is not available for Tcl versions less than 8.3.</em></p></dd> <dt><a name="22"><b class="cmd">::fileutil::tempdir</b></a></dt> <dd><p>The command returns the path of a directory where the caller can place temporary files, such as &quot;<b class="file">/tmp</b>&quot; on Unix systems. The algorithm we use to find the correct directory is as follows:</p> <ol class="doctools_enumerated"> <li><p>The directory set by an invokation of <b class="cmd">::fileutil::tempdir</b> with an argument. If this is present it is tried exclusively and none of the following item are tried.</p></li> <li><p>The directory named in the TMPDIR environment variable.</p></li> <li><p>The directory named in the TEMP environment variable.</p></li> <li><p>The directory named in the TMP environment variable.</p></li> <li><p>A platform specific location:</p> <dl class="doctools_definitions"> <dt>Windows</dt> <dd><p>&quot;<b class="file">C:\TEMP</b>&quot;, &quot;<b class="file">C:\TMP</b>&quot;, &quot;<b class="file">\TEMP</b>&quot;, and &quot;<b class="file">\TMP</b>&quot; are tried in that order.</p></dd> <dt>(classic) Macintosh</dt> <dd><p>The TRASH_FOLDER environment variable is used. This is most likely not correct.</p></dd> <dt>Unix</dt> <dd><p>The directories &quot;<b class="file">/tmp</b>&quot;, &quot;<b class="file">/var/tmp</b>&quot;, and &quot;<b class="file">/usr/tmp</b>&quot; are tried in that order.</p></dd> </dl> </li> </ol> <p>The algorithm utilized is mainly that used in the Python standard library. The exception is the first item, the ability to have the search overridden by a user-specified directory.</p></dd> <dt><a name="23"><b class="cmd">::fileutil::tempdir</b> <i class="arg">path</i></a></dt> <dd><p>In this mode the command sets the <i class="arg">path</i> as the first and only directory to try as a temp. directory. See the previous item for the use of the set directory. The command returns the empty string.</p></dd> <dt><a name="24"><b class="cmd">::fileutil::tempdirReset</b></a></dt> <dd><p>Invoking this command clears the information set by the last call of [<b class="cmd">::fileutil::tempdir</b> <i class="arg">path</i>]. See the last item too.</p></dd> <dt><a name="25"><b class="cmd">::fileutil::tempfile</b> <span class="opt">?<i class="arg">prefix</i>?</span></a></dt> <dd><p>The command generates a temporary file name suitable for writing to, and the associated file. The file name will be unique, and the file will be writable and contained in the appropriate system specific temp directory. The name of the file will be returned as the result of the command.</p> <p>The code was taken from <a href="http://wiki.tcl.tk/772">http://wiki.tcl.tk/772</a>, attributed to Igor Volobouev and anon.</p></dd> <dt><a name="26"><b class="cmd">::fileutil::maketempdir</b> <span class="opt">?<b class="option">-prefix</b> <i class="arg">str</i>?</span> <span class="opt">?<b class="option">-suffix</b> <i class="arg">str</i>?</span> <span class="opt">?<b class="option">-dir</b> <i class="arg">str</i>?</span></a></dt> <dd><p>The command generates a temporary directory suitable for writing to. The directory name will be unique, and the directory will be writable and contained in the appropriate system specific temp directory. The name of the directory will be returned as the result of the command.</p> <p>The three options can used to tweak the behaviour of the command:</p> <dl class="doctools_options"> <dt><b class="option">-prefix</b> str</dt> <dd><p>The initial, fixed part of the directory name. Defaults to <b class="const">tmp</b> if not specified.</p></dd> <dt><b class="option">-suffix</b> str</dt> <dd><p>The fixed tail of the directory. Defaults to the empty string if not specified.</p></dd> <dt><b class="option">-dir</b> str</dt> <dd><p>The directory to place the new directory into. Defaults to the result of <b class="cmd">fileutil::tempdir</b> if not specified.</p></dd> </dl> <p>The initial code for this was supplied by <a href="mailto:aplicacionamedida@gmail.com">Miguel Martinez Lopez</a>.</p></dd> <dt><a name="27"><b class="cmd">::fileutil::relative</b> <i class="arg">base</i> <i class="arg">dst</i></a></dt> <dd><p>This command takes two directory paths, both either absolute or relative and computes the path of <i class="arg">dst</i> relative to <i class="arg">base</i>. This relative path is returned as the result of the command. As implied in the previous sentence, the command is not able to compute this relationship between the arguments if one of the paths is absolute and the other relative.</p> <p><em>Note:</em> The processing done by this command is purely lexical. Symbolic links are <em>not</em> taken into account.</p></dd> <dt><a name="28"><b class="cmd">::fileutil::relativeUrl</b> <i class="arg">base</i> <i class="arg">dst</i></a></dt> <dd><p>This command takes two file paths, both either absolute or relative and computes the path of <i class="arg">dst</i> relative to <i class="arg">base</i>, as seen from inside of the <i class="arg">base</i>. This is the algorithm how a browser resolves a relative link found in the currently shown file.</p> <p>The computed relative path is returned as the result of the command. As implied in the previous sentence, the command is not able to compute this relationship between the arguments if one of the paths is absolute and the other relative.</p> <p><em>Note:</em> The processing done by this command is purely lexical. Symbolic links are <em>not</em> taken into account.</p></dd> </dl> </div> <div id="section2" class="doctools_section"><h2><a name="section2">Warnings and Incompatibilities</a></h2> <dl class="doctools_definitions"> <dt><b class="const">1.14.9</b></dt> <dd><p>In this version <b class="cmd">fileutil::find</b>'s broken system for handling symlinks was replaced with one working correctly and properly enumerating all the legal non-cyclic paths under a base directory.</p> <p>While correct this means that certain pathological directory hierarchies with cross-linked sym-links will now take about O(n**2) time to enumerate whereas the original broken code managed O(n) due to its brokenness.</p> <p>A concrete example and extreme case is the &quot;<b class="file">/sys</b>&quot; hierarchy under Linux where some hundred devices exist under both &quot;<b class="file">/sys/devices</b>&quot; and &quot;<b class="file">/sys/class</b>&quot; with the two sub-hierarchies linking to the other, generating millions of legal paths to enumerate. The structure, reduced to three devices, roughly looks like</p> <pre class="doctools_example"> /sys/class/tty/tty0 --&gt; ../../dev/tty0 /sys/class/tty/tty1 --&gt; ../../dev/tty1 /sys/class/tty/tty2 --&gt; ../../dev/tty1 /sys/dev/tty0/bus /sys/dev/tty0/subsystem --&gt; ../../class/tty /sys/dev/tty1/bus /sys/dev/tty1/subsystem --&gt; ../../class/tty /sys/dev/tty2/bus /sys/dev/tty2/subsystem --&gt; ../../class/tty </pre> <p>The command <b class="cmd">fileutil::find</b> currently has no way to escape this. When having to handle such a pathological hierarchy It is recommended to switch to package <b class="package">fileutil::traverse</b> and the same-named command it provides, and then use the <b class="option">-prefilter</b> option to prevent the traverser from following symbolic links, like so:</p> <pre class="doctools_example"> package require fileutil::traverse proc NoLinks {fileName} { if {[string equal [file type $fileName] link]} { return 0 } return 1 } fileutil::traverse T /sys/devices -prefilter NoLinks T foreach p { puts $p } T destroy </pre> </dd> </dl> </div> <div id="section3" class="doctools_section"><h2><a name="section3">Bugs, Ideas, Feedback</a></h2> <p>This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category <em>fileutil</em> of the <a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>. Please also report any ideas for enhancements you may have for either package and/or documentation.</p> </div> <div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2> <p><a href="../../../../index.html#key314">cat</a>, <a href="../../../../index.html#key115">file utilities</a>, <a href="../../../../index.html#key316">grep</a>, <a href="../../../../index.html#key315">temp file</a>, <a href="../../../../index.html#key313">test</a>, <a href="../../../../index.html#key317">touch</a>, <a href="../../../../index.html#key117">type</a></p> </div> <div id="category" class="doctools_section"><h2><a name="category">Category</a></h2> <p>Programming tools</p> </div> </div>
Java
/* Copyright (C) 2004 Jacquelin POTIER <jacquelin.potier@free.fr> Dynamic aspect ratio code Copyright (C) 2004 Jacquelin POTIER <jacquelin.potier@free.fr> originally based from APISpy32 v2.1 from Yariv Kaplan @ WWW.INTERNALS.COM 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; version 2 of the License. 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. */ //----------------------------------------------------------------------------- // Object: exported structs (needed for overriding api) //----------------------------------------------------------------------------- #pragma once #include <windows.h> #include "registers.h" // assume that structs share between WinAPIOverride and the FakeAPI dll // will have the same alignment #pragma pack(push) #pragma pack(4) typedef struct tagPrePostApiCallHookInfos { PBYTE Rbp; PBYTE ReturnAddress; HMODULE CallingModuleHandle; BOOL OverridingModulesFiltersSuccessfullyChecked; }PRE_POST_API_CALL_HOOK_INFOS,*PPRE_POST_API_CALL_HOOK_INFOS; #pragma pack(pop) #ifdef _WIN64 // StackParameters : adjusted stack parameters (no shadow for x64, only parameters passed through stack) typedef BOOL (__stdcall *pfPreApiCallCallBack)(PBYTE StackParameters,REGISTERS* pBeforeCallRegisters,XMM_REGISTERS* pBeforeCallXmmRegisters,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos,PVOID UserParam);// return FALSE to stop pre api call chain functions // StackParameters : adjusted stack parameters (no shadow for x64, only parameters passed through stack) typedef BOOL (__stdcall *pfPostApiCallCallBack)(PBYTE StackParameters,REGISTERS* pBeforeCallRegisters,XMM_REGISTERS* pBeforeCallXmmRegisters,REGISTERS* pAfterCallRegisters,XMM_REGISTERS* pAfterCallXmmRegisters,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos,PVOID UserParam);// return FALSE to stop calling post api call chain functions #else typedef BOOL (__stdcall *pfPreApiCallCallBack)(PBYTE StackParameters,REGISTERS* pBeforeCallRegisters,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos,PVOID UserParam);// return FALSE to stop pre api call chain functions typedef BOOL (__stdcall *pfPostApiCallCallBack)(PBYTE StackParameters,REGISTERS* pBeforeCallRegisters,REGISTERS* pAfterCallRegisters,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos,PVOID UserParam);// return FALSE to stop calling post api call chain functions #endif typedef BOOL (__stdcall *pfCOMObjectCreationCallBack)(CLSID* pClsid,IID* pIid,PVOID pInterface,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos);// return FALSE to stop calling post api call chain functions typedef BOOL (__stdcall *pfCOMObjectDeletionCallBack)(CLSID* pClsid,PVOID pIUnknownInterface,PVOID pInterfaceReturnedAtObjectCreation,PRE_POST_API_CALL_HOOK_INFOS* pHookInfos);// return FALSE to stop calling post api call chain functions
Java
/* * $Id: channel_manager.h 44 2011-02-15 12:32:29Z kaori $ * * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2011, Professor Benoit Macq * Copyright (c) 2010-2011, Kaori Hagihara * 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. * * 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. */ #ifndef CHANNEL_MANAGER_H_ # define CHANNEL_MANAGER_H_ #include <time.h> #include "query_parser.h" #include "cachemodel_manager.h" #include "auxtrans_manager.h" /** maximum length of channel identifier*/ #define MAX_LENOFCID 30 /** Channel parameters*/ typedef struct channel_param{ cachemodel_param_t *cachemodel; /**< reference pointer to the cache model*/ char cid[MAX_LENOFCID]; /**< channel identifier*/ cnew_transport_t aux; /**< auxiliary transport*/ /* - a record of the client's capabilities and preferences to the extent that the server queues requests*/ time_t start_tm; /**< starting time*/ struct channel_param *next; /**< pointer to the next channel*/ } channel_param_t; /** Channel list parameters*/ typedef struct channellist_param{ channel_param_t *first; /**< first channel pointer of the list*/ channel_param_t *last; /**< last channel pointer of the list*/ } channellist_param_t; /** * generate a channel list * * @return pointer to the generated channel list */ channellist_param_t * gene_channellist(void); /** * generate a channel under the channel list * * @param[in] query_param query parameters * @param[in] auxtrans auxiliary transport * @param[in] cachemodel reference cachemodel * @param[in] channellist channel list pointer * @return pointer to the generated channel */ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist); /** * set channel variable parameters * * @param[in] query_param query parameters * @param[in,out] channel pointer to the modifying channel */ void set_channel_variable_param( query_param_t query_param, channel_param_t *channel); /** * delete a channel * * @param[in] channel address of the deleting channel pointer * @param[in,out] channellist channel list pointer */ void delete_channel( channel_param_t **channel, channellist_param_t *channellist); /** * delete channel list * * @param[in,out] channellist address of the channel list pointer */ void delete_channellist( channellist_param_t **channellist); /** * print all channel parameters * * @param[in] channellist channel list pointer */ void print_allchannel( channellist_param_t *channellist); /** * search a channel by channel ID * * @param[in] cid channel identifier * @param[in] channellist channel list pointer * @return found channel pointer */ channel_param_t * search_channel( char cid[], channellist_param_t *channellist); #endif /* !CHANNEL_MANAGER_H_ */
Java
#ifndef PLANG_TOKENIZER #define PLANG_TOKENIZER #include <map> #include <vector> #include <string> #include <cstring> #include <cstdlib> #include <cctype> #include <algorithm> class PlangTokenizer { // Input buffer std::string m_input; // Current possition in input buffer std::size_t m_input_pos; // Currently read element from input int m_ch; // Counterss int m_input_line; // Which line it is in the source code (0, 1,2,3...) int m_input_column; // Which column it is in the source code (0, 1,2,3...) // Simple input + counters initializer void input_init() { m_input.clear(); m_input_pos = 0; // Counters m_input_line = 0; m_input_column = 0; } public: // Return counter with current line int get_line() { return m_input_line; } // Return counter with current column int get_column() { return m_input_column; } // Returns nth line of input std::string get_line_str(const int line) { std::string::iterator b = m_input.begin(); std::string::iterator e = m_input.end(); for (int i = 0 ; i < line ; ++i) { b = std::find(b, e, '\n'); } return std::string(b, std::find(b, e, '\n')); } // Token values struct TokenValue { std::string s; int i; float f; } m_token_value; // Token types outputed by tokenizer struct Token { enum { // Language values END = -1, // EOF! ID = -2, INT = -3, FLT = -4, STR = -5, // Language keywords RETURN = -100, IF = -200, ELSE = -201, AS = -202, }; }; // Last read token // Mapping between keyword and token std::map<std::string, int> m_keyword_token_map = { {"return", Token::RETURN}, {"if", Token::IF}, {"else", Token::ELSE}, {"as", Token::AS}, }; // Load all characters from input void load_input(const char *input, int size) { input_init(); m_input = std::string(input, input + size); } // Load from string input void load_input(const char *input) { input_init(); m_input = std::string(input); } // Return next element of input buffer int get_next_consume() { if (m_input_pos == m_input.size()) return Token::END; return m_input[m_input_pos++]; } // Get next element from the input and store it // in m_ch temporary value buffer to use after call int get_next() { m_ch = get_next_consume(); // Collect some counter statistics m_input_column++; if (m_ch == '\n') { m_input_column = 0; m_input_line++; } return m_ch; } // Sneak-peak next token int get_next_preview() { if (m_input_pos == m_input.size()) return Token::END; return m_input[m_input_pos]; } // like isalpha checks if c is in set of allowed // identifier charset int isidchar(int c) { return std::isalpha(c) || std::isdigit(c) || c == '_'; } // Parse input and get next token int get_token_val() { while (std::isspace(get_next())) { // Skipping all whitespaces } if (m_ch == Token::END) return Token::END; if (std::isalpha(m_ch)) { // ID: alphanumeric // KEYWORD: alphanumeric m_token_value.s = m_ch; while (isidchar(get_next_preview())) { m_token_value.s += get_next(); } // If identifier is a keyword return keyword token if (m_keyword_token_map.find(m_token_value.s) != m_keyword_token_map.end()) { return m_keyword_token_map.at(m_token_value.s); } // Generic identifier return Token::ID; } else if (std::isdigit(m_ch)) { // INT: plain integer m_token_value.s = m_ch; while (std::isdigit(get_next_preview())) { m_token_value.s += get_next(); } m_token_value.i = std::atoi(m_token_value.s.c_str()); return Token::INT; } // Return read character m_token_value.s = m_ch; return m_ch; } // Get next token and saves int vaue in the buffer int get_token() { return get_token_val(); } const TokenValue& get_token_value() { return m_token_value; } }; #endif
Java
// Author: // Noah Ablaseau <nablaseau@hotmail.com> // // Copyright (c) 2017 // // 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 <http://www.gnu.org/licenses/>. using System; using System.IO; using System.Diagnostics; using System.Collections.Generic; using System.Configuration; using System.Drawing; namespace linerider.IO.ffmpeg { public static class FFMPEG { private const int MaximumBuffers = 25; private static bool inited = false; public static bool HasExecutable { get { return File.Exists(ffmpeg_path); } } public static string ffmpeg_dir { get { string dir = Program.UserDirectory + "ffmpeg" + Path.DirectorySeparatorChar; if (OpenTK.Configuration.RunningOnMacOS) dir += "mac" + Path.DirectorySeparatorChar; else if (OpenTK.Configuration.RunningOnWindows) dir += "win" + Path.DirectorySeparatorChar; else if (OpenTK.Configuration.RunningOnUnix) { dir += "linux" + Path.DirectorySeparatorChar; } else { return null; } return dir; } } public static string ffmpeg_path { get { var dir = ffmpeg_dir; if (dir == null) return null; if (OpenTK.Configuration.RunningOnWindows) return dir + "ffmpeg.exe"; else return dir + "ffmpeg"; } } static FFMPEG() { } private static void TryInitialize() { if (inited) return; inited = true; if (ffmpeg_path == null) throw new Exception("Unable to detect platform for ffmpeg"); MakeffmpegExecutable(); } public static string ConvertSongToOgg(string file, Func<string, bool> stdout) { TryInitialize(); if (!file.EndsWith(".ogg", true, Program.Culture)) { var par = new IO.ffmpeg.FFMPEGParameters(); par.AddOption("i", "\"" + file + "\""); par.OutputFilePath = file.Remove(file.IndexOf(".", StringComparison.Ordinal)) + ".ogg"; if (File.Exists(par.OutputFilePath)) { if (File.Exists(file)) { File.Delete(par.OutputFilePath); } else { return par.OutputFilePath; } } Execute(par, stdout); file = par.OutputFilePath; } return file; } public static void Execute(FFMPEGParameters parameters, Func<string, bool> stdout) { TryInitialize(); if (String.IsNullOrWhiteSpace(ffmpeg_path)) { throw new Exception("Path to FFMPEG executable cannot be null"); } if (parameters == null) { throw new Exception("FFMPEG parameters cannot be completely null"); } using (Process ffmpegProcess = new Process()) { ProcessStartInfo info = new ProcessStartInfo(ffmpeg_path) { Arguments = parameters.ToString(), WorkingDirectory = Path.GetDirectoryName(ffmpeg_dir), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = false, RedirectStandardError = false }; info.RedirectStandardOutput = true; info.RedirectStandardError = true; ffmpegProcess.StartInfo = info; ffmpegProcess.Start(); if (stdout != null) { while (true) { string str = ""; try { str = ffmpegProcess.StandardError.ReadLine(); } catch { Console.WriteLine("stdout log failed"); break; //ignored } if (ffmpegProcess.HasExited) break; if (str == null) str = ""; if (!stdout.Invoke(str)) { ffmpegProcess.Kill(); return; } } } else { /*if (debug) { string processOutput = ffmpegProcess.StandardError.ReadToEnd(); }*/ ffmpegProcess.WaitForExit(); } } } private static void MakeffmpegExecutable() { if (OpenTK.Configuration.RunningOnUnix) { try { using (Process chmod = new Process()) { ProcessStartInfo info = new ProcessStartInfo("/bin/chmod") { Arguments = "+x ffmpeg", WorkingDirectory = Path.GetDirectoryName(ffmpeg_dir), UseShellExecute = false, }; chmod.StartInfo = info; chmod.Start(); if (!chmod.WaitForExit(1000)) { chmod.Close(); } } } catch (Exception e) { linerider.Utils.ErrorLog.WriteLine( "chmod error on ffmpeg" + Environment.NewLine + e.ToString()); } } } } }
Java
/* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * Change log: * 06/29/95 - Modified to handle flow control for writing (Tuyen Nguyen) * Modified for MP, 1996 by Tuyen Nguyen * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX. */ #define RESOLVE_DBG #include <sys/errno.h> #include <sys/types.h> #include <sys/param.h> #include <machine/spl.h> #include <sys/systm.h> #include <sys/kernel.h> #include <sys/proc.h> #include <sys/filedesc.h> #include <sys/fcntl.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <netat/sysglue.h> #include <netat/appletalk.h> #include <netat/at_pcb.h> #include <netat/ddp.h> #include <netat/adsp.h> #include <netat/adsp_internal.h> #ifdef notdefn struct adsp_debug adsp_dtable[1025]; int ad_entry = 0; #endif int adspAllocateCCB(gref) register gref_t *gref; /* READ queue */ { gbuf_t *ccb_mp; register CCBPtr sp; if (!(ccb_mp = gbuf_alloc(sizeof(CCB), PRI_LO))) { return (0); } bzero((caddr_t) gbuf_rptr(ccb_mp), sizeof(CCB)); gbuf_wset(ccb_mp,sizeof(CCB)); gref->info = (caddr_t) ccb_mp; sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); sp->pid = gref->pid; /* save the caller process pointer */ sp->gref = gref; /* save a back pointer to the WRITE queue */ sp->sp_mp = ccb_mp; /* and its message block */ return 1; } int adspRelease(gref) register gref_t *gref; /* READ queue */ { register CCBPtr sp; if (gref->info) { sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); /* Tells completion routine of close */ /* packet to remove us. */ if (sp->state == sPassive || sp->state == sClosed || sp->state == sOpening || sp->state == sListening) { if (sp->state == sListening) CompleteQueue(&sp->opb, errAborted); sp->removing = 1; /* Prevent allowing another dspClose. */ DoClose(sp, errAborted, 0); /* will remove CCB */ return 0; } else { /* sClosing & sOpen */ sp->state = sClosing; } if (CheckOkToClose(sp)) { /* going to close */ sp->sendCtl = B_CTL_CLOSE; /* Send close advice */ } else { CheckSend(sp); /* try one more time to send out data */ if (sp->state != sClosed) sp->sendCtl = B_CTL_CLOSE; /* Setup to send close advice */ } CheckSend(sp); /* and force out the close */ sp->removing = 1; /* Prevent allowing another dspClose. */ sp->state = sClosed; DoClose(sp, errAborted, 0); /* to closed and remove CCB */ } return 0; } int adspWriteHandler(gref, mp) gref_t *gref; /* WRITE queue */ gbuf_t *mp; { register ioc_t *iocbp; register struct adspcmd *ap; int error, flag; void *sp; switch(gbuf_type(mp)) { case MSG_DATA: if (gref->info == 0) { gbuf_freem(mp); return(STR_IGNORE); } /* * Fill in the global stuff */ ap = (struct adspcmd *)gbuf_rptr(mp); ap->gref = gref; ap->ioc = 0; ap->mp = mp; sp = (void *)gbuf_rptr(((gbuf_t *)gref->info)); switch(ap->csCode) { case dspWrite: if ((error = adspWrite(sp, ap))) gbuf_freem(mp); return(STR_IGNORE); case dspAttention: if ((error = adspAttention(sp, (CCBPtr)ap))) gbuf_freem(mp); return(STR_IGNORE); } case MSG_IOCTL: if (gref->info == 0) { adspioc_ack(EPROTOTYPE, mp, gref); return(STR_IGNORE); } iocbp = (ioc_t *) gbuf_rptr(mp); if (ADSP_IOCTL(iocbp->ioc_cmd)) { iocbp->ioc_count = sizeof(*ap) - 1; if (gbuf_cont(mp) == 0) { adspioc_ack(EINVAL, mp, gref); return(STR_IGNORE); } ap = (struct adspcmd *) gbuf_rptr(gbuf_cont(mp)); ap->gref = gref; ap->ioc = (caddr_t) mp; ap->mp = gbuf_cont(mp); /* request head */ ap->ioResult = 0; if ((gref->info == 0) && ((iocbp->ioc_cmd != ADSPOPEN) && (iocbp->ioc_cmd != ADSPCLLISTEN))) { ap->ioResult = errState; adspioc_ack(EINVAL, mp, gref); return(STR_IGNORE); } } else return(STR_PUTNEXT); /* pass it on down */ sp = (void *)gbuf_rptr(((gbuf_t *)gref->info)); switch(iocbp->ioc_cmd) { case ADSPOPEN: case ADSPCLLISTEN: ap->socket = ((CCBPtr)sp)->localSocket; flag = (adspMode(ap) == ocAccept) ? 1 : 0; if (flag && ap->socket) { if (adspDeassignSocket((CCBPtr)sp) >= 0) ap->socket = 0; } if ((ap->socket == 0) && ((ap->socket = (at_socket)adspAssignSocket(gref, flag)) == 0)) { adspioc_ack(EADDRNOTAVAIL, mp, gref); return(STR_IGNORE); } ap->csCode = iocbp->ioc_cmd == ADSPOPEN ? dspInit : dspCLInit; if ((error = adspInit(sp, ap)) == 0) { switch(ap->csCode) { case dspInit: /* and open the connection */ ap->csCode = dspOpen; error = adspOpen(sp, ap); break; case dspCLInit: /* ADSPCLLISTEN */ ap->csCode = dspCLListen; error = adspCLListen(sp, ap); break; } } if (error) adspioc_ack(error, mp, gref); /* if this failed req complete */ return(STR_IGNORE); case ADSPCLOSE: ap->csCode = dspClose; if ((error = adspClose(sp, ap))) { adspioc_ack(error, mp, gref); break; } break; case ADSPCLREMOVE: ap->csCode = dspCLRemove; error = adspClose(sp, ap); adspioc_ack(error, mp, gref); return(STR_IGNORE); case ADSPCLDENY: ap->csCode = dspCLDeny; if ((error = adspCLDeny(sp, (CCBPtr)ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPSTATUS: ap->csCode = dspStatus; if ((error = adspStatus(sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPREAD: ap->csCode = dspRead; if ((error = adspRead(sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPATTENTION: ap->csCode = dspAttention; if ((error = adspReadAttention((CCBPtr)sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPOPTIONS: ap->csCode = dspOptions; if ((error = adspOptions(sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPRESET: ap->csCode = dspReset; if ((error = adspReset(sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); case ADSPNEWCID: ap->csCode = dspNewCID; if ((error = adspNewCID(sp, ap))) { adspioc_ack(error, mp, gref); } return(STR_IGNORE); default: return(STR_PUTNEXT); /* pass it on down */ } return(STR_IGNORE); case MSG_PROTO: default: gbuf_freem(mp); } return(STR_IGNORE); } int adspReadHandler(gref, mp) gref_t *gref; gbuf_t *mp; { int error; switch(gbuf_type(mp)) { case MSG_DATA: if ((error = adspPacket(gref, mp))) { gbuf_freem(mp); } break; case MSG_IOCTL: default: return(STR_PUTNEXT); break; } return(STR_IGNORE); } /* * adsp_sendddp() * * Description: * This procedure a formats a DDP datagram header and calls the * DDP module to queue it for routing and transmission according to * the DDP parameters. We always take control of the datagram; * if there is an error we free it, otherwise we pass it to the next * layer. We don't need to set the src address fileds because the * DDP layer fills these in for us. * * Calling Sequence: * ret_status = adsp_sendddp(q, sp, mp, length, dstnetaddr, ddptype); * * Formal Parameters: * sp Caller stream pointer * mp gbuf_t chain containing the datagram to transmit * The first mblk contains the ADSP header and space * for the DDP header. * length size of data portion of datagram * dstnetaddr address of 4-byte destination internet address * ddptype DDP protocol to assign to the datagram * * Completion Status: * 0 Procedure successful completed. * EMSGSIZE Specified datagram length is too big. * * Side Effects: * NONE */ int adsp_sendddp(sp, mp, length, dstnetaddr, ddptype) CCBPtr sp; gbuf_t *mp; int length; AddrUnion *dstnetaddr; int ddptype; { DDPX_FRAME *ddp; gbuf_t *mlist = mp; if (mp == 0) return EINVAL; if (length > DDP_DATA_SIZE) { gbuf_freel(mlist); return EMSGSIZE; } while (mp) { if (length == 0) length = gbuf_msgsize(mp) - DDPL_FRAME_LEN; /* Set up the DDP header */ ddp = (DDPX_FRAME *) gbuf_rptr(mp); UAS_ASSIGN_HTON(ddp->ddpx_length, (length + DDPL_FRAME_LEN)); UAS_ASSIGN(ddp->ddpx_cksm, 0); if (sp) { if (sp->useCheckSum) UAS_ASSIGN_HTON(ddp->ddpx_cksm, 1); } NET_ASSIGN(ddp->ddpx_dnet, dstnetaddr->a.net); ddp->ddpx_dnode = dstnetaddr->a.node; ddp->ddpx_source = sp ? sp->localSocket : ddp->ddpx_dest; ddp->ddpx_dest = dstnetaddr->a.socket; ddp->ddpx_type = ddptype; length = 0; mp = gbuf_next(mp); } DDP_OUTPUT(mlist); return 0; } void NotifyUser( __unused CCBPtr sp) { /* pidsig(sp->pid, SIGIO); */ } void UrgentUser( __unused CCBPtr sp) { /* pidsig(sp->pid, SIGURG); */ }
Java
/************************************************************************ * This file is part of EspoCRM. * * EspoCRM - Open Source CRM application. * Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko * Website: http://www.espocrm.com * * EspoCRM 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. * * EspoCRM 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 EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ Espo.define('Views.EmailAccount.Record.Edit', ['Views.Record.Edit', 'Views.EmailAccount.Record.Detail'], function (Dep, Detail) { return Dep.extend({ afterRender: function () { Dep.prototype.afterRender.call(this); Detail.prototype.initSslFieldListening.call(this); }, }); });
Java
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. # config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # Use a specific assets manifest file. config.assets.manifest = "#{Rails.root}/config/manifest.json" # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :info # Prepend all log lines with the following tags. # config.log_tags = [ :request_id ] # Use a different cache store in production. config.cache_store = :memory_store config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. config.action_mailer.raise_delivery_errors = false # Send email with Amazon Simple Email Service config.action_mailer.delivery_method = :ses # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. # config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
Java
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers /***************************************************************************** * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * OpenRCT2 is the work of many authors, a full list can be found in contributors.md * For more information, visit https://github.com/OpenRCT2/OpenRCT2 * * OpenRCT2 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. * * A full copy of the GNU General Public License can be found in licence.txt *****************************************************************************/ #pragma endregion #include "../../drawing/drawing.h" #include "../../interface/viewport.h" #include "../../paint/map_element/map_element.h" #include "../../paint/paint.h" #include "../../paint/supports.h" #include "../../sprites.h" #include "../../world/map.h" #include "../../world/sprite.h" #include "../ride_data.h" #include "../track_data.h" #include "../track_paint.h" /** rct2: 0x008A6370 */ static void looping_rc_track_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15006, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15007, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15008, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15009, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15004, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15005, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } static void looping_rc_track_station(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { static const uint32 imageIds[4][2] = { { 15016, SPR_STATION_BASE_B_SW_NE }, { 15017, SPR_STATION_BASE_B_NW_SE }, { 15016, SPR_STATION_BASE_B_SW_NE }, { 15017, SPR_STATION_BASE_B_NW_SE }, }; sub_98197C_rotated(session, direction, imageIds[direction][0] | session->TrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6, height + 3); sub_98196C_rotated(session, direction, imageIds[direction][1] | session->TrackColours[SCHEME_MISC], 0, 0, 32, 32, 1, height); track_paint_util_draw_station_metal_supports_2(session, direction, height, session->TrackColours[SCHEME_SUPPORTS], 0); track_paint_util_draw_station(session, rideIndex, trackSequence, direction, height, mapElement); paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_6); paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6380 */ static void looping_rc_track_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15060, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15061, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15062, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15063, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15032, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15033, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15034, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15035, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6390 */ static void looping_rc_track_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15076, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15077, 0, 0, 32, 1, 98, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15078, 0, 0, 32, 1, 98, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15079, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 32, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15048, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15049, 0, 0, 32, 1, 98, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15050, 0, 0, 32, 1, 98, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15051, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 32, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 56, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); } /** rct2: 0x008A63A0 */ static void looping_rc_track_flat_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15052, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15053, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15054, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15055, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15024, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15025, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15026, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15027, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A63B0 */ static void looping_rc_track_25_deg_up_to_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15064, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15065, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15068, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15066, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15069, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15067, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 12, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15036, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15037, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15040, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15038, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15041, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15039, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 12, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); } /** rct2: 0x008A63C0 */ static void looping_rc_track_60_deg_up_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15070, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15071, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15074, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15072, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15075, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15073, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15042, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15043, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15046, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15044, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15047, 0, 0, 32, 1, 66, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15045, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); } /** rct2: 0x008A63D0 */ static void looping_rc_track_25_deg_up_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15056, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15057, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15058, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15059, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15028, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15029, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15030, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15031, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A63E0 */ static void looping_rc_track_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A63F0 */ static void looping_rc_track_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_60_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6400 */ static void looping_rc_track_flat_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_flat(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6410 */ static void looping_rc_track_25_deg_down_to_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_60_deg_up_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6420 */ static void looping_rc_track_60_deg_down_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_60_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6430 */ static void looping_rc_track_25_deg_down_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_flat_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6440 */ static void looping_rc_track_left_quarter_turn_5(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15183, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15188, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15193, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15178, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15182, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15187, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15192, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15177, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15181, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15186, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15191, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15176, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15180, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15185, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15190, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15175, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15179, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15184, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15189, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15174, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6450 */ static void looping_rc_track_right_quarter_turn_5(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_left_quarter_turn_5(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6460 */ static void looping_rc_track_flat_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15080, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15092, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15081, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15093, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15082, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15083, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6470 */ static void looping_rc_track_flat_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15084, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15085, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15086, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15094, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15087, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15095, 0, 0, 32, 1, 26, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6480 */ static void looping_rc_track_left_bank_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15086, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15094, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15087, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15095, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15084, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15085, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6490 */ static void looping_rc_track_right_bank_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15082, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15083, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15080, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15092, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15081, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15093, 0, 0, 32, 1, 26, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A64A0 */ static void looping_rc_track_banked_left_quarter_turn_5(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15203, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15214, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15208, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15213, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15198, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15202, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15207, 0, 0, 32, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15212, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15197, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15201, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15206, 0, 0, 16, 16, 1, height, 16, 16, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15211, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15196, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15200, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15205, 0, 0, 16, 32, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15210, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15195, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15199, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15204, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15209, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15215, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15194, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A64B0 */ static void looping_rc_track_banked_right_quarter_turn_5(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_banked_left_quarter_turn_5(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A64C0 */ static void looping_rc_track_left_bank_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15096, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15112, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15097, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15113, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15098, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15099, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A64D0 */ static void looping_rc_track_right_bank_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15100, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15101, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15102, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15114, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15103, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15115, 0, 0, 32, 1, 34, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A64E0 */ static void looping_rc_track_25_deg_up_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15104, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15116, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15105, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15117, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15106, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15107, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A64F0 */ static void looping_rc_track_25_deg_up_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15108, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15109, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15110, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15118, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15111, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15119, 0, 0, 32, 1, 34, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A6500 */ static void looping_rc_track_left_bank_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_right_bank(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6510 */ static void looping_rc_track_right_bank_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_left_bank(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6520 */ static void looping_rc_track_25_deg_down_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_bank_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6530 */ static void looping_rc_track_25_deg_down_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_bank_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6540 */ static void looping_rc_track_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15088, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15089, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15090, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15091, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6550 */ static void looping_rc_track_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_bank(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6560 */ static void looping_rc_track_left_quarter_turn_5_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15296, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15301, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15306, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15311, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15297, 0, 0, 32, 16, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15302, 0, 0, 32, 16, 3, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15307, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15312, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15298, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15303, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15308, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15313, 0, 0, 16, 16, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 64, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15299, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15304, 0, 0, 16, 32, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15309, 0, 0, 16, 32, 3, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15314, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15300, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15305, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15310, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15315, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6570 */ static void looping_rc_track_right_quarter_turn_5_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15276, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15281, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15286, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15291, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15277, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15282, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15287, 0, 0, 32, 16, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15292, 0, 0, 32, 16, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15278, 0, 0, 16, 16, 3, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15283, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15288, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15293, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 64, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15279, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15284, 0, 0, 16, 32, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15289, 0, 0, 16, 32, 3, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15294, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15280, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15285, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15290, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15295, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6580 */ static void looping_rc_track_left_quarter_turn_5_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_right_quarter_turn_5_25_deg_up(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A6590 */ static void looping_rc_track_right_quarter_turn_5_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_left_quarter_turn_5_25_deg_up(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A65A0 */ static void looping_rc_track_s_bend_left(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15260, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15264, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15263, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15267, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15261, 0, 0, 32, 26, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15265, 0, 0, 32, 26, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 6, 1, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15262, 0, 0, 32, 26, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15266, 0, 0, 32, 26, 3, height, 0, 6, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15262, 0, 0, 32, 26, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15266, 0, 0, 32, 26, 3, height, 0, 6, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15261, 0, 0, 32, 26, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15265, 0, 0, 32, 26, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 6, 1, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15263, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15267, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15260, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15264, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 1: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 2: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A65B0 */ static void looping_rc_track_s_bend_right(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15268, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15272, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15271, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15275, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15269, 0, 0, 32, 26, 3, height, 0, 6, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15273, 0, 0, 32, 26, 3, height, 0, 6, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15270, 0, 0, 32, 26, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15274, 0, 0, 32, 26, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15270, 0, 0, 32, 26, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15274, 0, 0, 32, 26, 3, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15269, 0, 0, 32, 26, 3, height, 0, 6, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15273, 0, 0, 32, 26, 3, height, 0, 6, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15271, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15275, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15268, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15272, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 1: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 2: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A65C0 */ static void looping_rc_track_left_vertical_loop(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15348, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15356, 0, 6, 32, 20, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15355, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15363, 0, 6, 32, 20, 7, height); break; } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15349, 0, 0, 32, 26, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15357, 0, 14, 32, 2, 63, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15354, 0, 6, 32, 26, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15362, 0, 6, 32, 26, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15350, 16, 0, 3, 16, 119, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_CENTRED, 1, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15364, 16, 0, 3, 16, 119, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15358, 12, 0, 3, 16, 119, height, 12, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT_CENTRED, 0, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15366, 12, 0, 3, 16, 119, height, 12, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15353, 10, 16, 4, 16, 119, height, 10, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK, 2, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15365, 10, 16, 4, 16, 119, height, 10, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15361, 16, 16, 2, 16, 119, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT, 3, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15367, 16, 16, 2, 16, 119, height, 16, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 168, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15351, 0, 0, 32, 16, 3, height + 32); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15359, 0, 0, 32, 16, 3, height + 32); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15352, 0, 16, 32, 16, 3, height + 32); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15360, 0, 16, 32, 16, 3, height + 32); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 48, 0x20); break; case 5: paint_util_set_general_support_height(session, height + 48, 0x20); break; case 6: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15352, 0, 16, 32, 16, 3, height + 32); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15360, 0, 16, 32, 16, 3, height + 32); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15351, 0, 0, 32, 16, 3, height + 32); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15359, 0, 0, 32, 16, 3, height + 32); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15353, 10, 16, 4, 16, 119, height, 10, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK, 2, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15365, 10, 16, 4, 16, 119, height, 10, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15361, 16, 16, 2, 16, 119, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT, 3, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15367, 16, 16, 2, 16, 119, height, 16, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15350, 16, 0, 3, 16, 119, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_CENTRED, 1, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15364, 16, 0, 3, 16, 119, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15358, 12, 0, 3, 16, 119, height, 12, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT_CENTRED, 0, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15366, 12, 0, 3, 16, 119, height, 12, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 168, 0x20); break; case 8: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15354, 0, 6, 32, 26, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15362, 0, 6, 32, 26, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15349, 0, 0, 32, 26, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15357, 0, 14, 32, 2, 63, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 9: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15355, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15363, 0, 6, 32, 20, 7, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15348, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15356, 0, 6, 32, 20, 3, height); break; } switch (direction) { case 1: paint_util_push_tunnel_right(session, height - 8, TUNNEL_1); break; case 2: paint_util_push_tunnel_left(session, height - 8, TUNNEL_1); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A65D0 */ static void looping_rc_track_right_vertical_loop(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15383, 0, 6, 32, 20, 7, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15375, 0, 6, 32, 20, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15376, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15368, 0, 6, 32, 20, 3, height); break; } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15382, 0, 6, 32, 26, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15374, 0, 6, 32, 26, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15377, 0, 14, 32, 2, 63, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15369, 0, 0, 32, 26, 3, height); break; } paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15381, 16, 16, 2, 16, 119, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK, 3, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15384, 16, 16, 2, 16, 119, height, 16, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15373, 10, 16, 4, 16, 119, height, 10, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT, 1, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15386, 10, 16, 4, 16, 119, height, 10, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15378, 12, 0, 3, 16, 119, height, 12, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_CENTRED, 0, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15385, 12, 0, 3, 16, 119, height, 12, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15370, 16, 0, 2, 16, 119, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT_CENTRED, 2, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15387, 16, 0, 2, 16, 119, height, 16, 0, height); break; } paint_util_set_general_support_height(session, height + 168, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15380, 0, 16, 32, 16, 3, height + 32); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15372, 0, 16, 32, 16, 3, height + 32); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15379, 0, 0, 32, 16, 3, height + 32); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15371, 0, 0, 32, 16, 3, height + 32); break; } paint_util_set_general_support_height(session, height + 48, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 48, 0x20); break; case 5: paint_util_set_general_support_height(session, height + 48, 0x20); break; case 6: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15379, 0, 0, 32, 16, 3, height + 32); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15371, 0, 0, 32, 16, 3, height + 32); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15380, 0, 16, 32, 16, 3, height + 32); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15372, 0, 16, 32, 16, 3, height + 32); break; } paint_util_set_general_support_height(session, height + 48, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15378, 12, 0, 3, 16, 119, height, 12, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_CENTRED, 0, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15385, 12, 0, 3, 16, 119, height, 12, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15370, 16, 0, 2, 16, 119, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT_CENTRED, 2, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15387, 16, 0, 2, 16, 119, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15381, 16, 16, 2, 16, 119, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK, 3, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15384, 16, 16, 2, 16, 119, height, 16, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15373, 10, 16, 4, 16, 119, height, 10, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_THICK_ALT, 1, 0, height - 8, session->TrackColours[SCHEME_TRACK]); sub_98199C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15386, 10, 16, 4, 16, 119, height, 10, 16, height); break; } paint_util_set_general_support_height(session, height + 168, 0x20); break; case 8: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15377, 0, 14, 32, 2, 63, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15369, 0, 0, 32, 26, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15382, 0, 6, 32, 26, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15374, 0, 6, 32, 26, 3, height); break; } paint_util_set_general_support_height(session, height + 72, 0x20); break; case 9: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15376, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15368, 0, 6, 32, 20, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15383, 0, 6, 32, 20, 7, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15375, 0, 6, 32, 20, 3, height); break; } switch (direction) { case 1: paint_util_push_tunnel_right(session, height - 8, TUNNEL_1); break; case 2: paint_util_push_tunnel_left(session, height - 8, TUNNEL_1); break; } paint_util_set_general_support_height(session, height + 56, 0x20); break; } track_paint_util_right_vertical_loop_segments(session, direction, trackSequence); } /** rct2: 0x008A6630 */ static void looping_rc_track_left_quarter_turn_3(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15125, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15128, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15131, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15122, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15124, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15127, 0, 0, 16, 16, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15130, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15121, 0, 0, 16, 16, 3, height, 16, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15123, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15126, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15129, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15120, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6640 */ static void looping_rc_track_right_quarter_turn_3(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_left_quarter_turn_3(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6650 */ static void looping_rc_track_left_quarter_turn_3_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15137, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15144, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15140, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15143, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15134, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15136, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15139, 0, 0, 16, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15142, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15133, 0, 0, 16, 16, 3, height, 16, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15135, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15138, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15141, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15145, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15132, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6660 */ static void looping_rc_track_right_quarter_turn_3_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_left_quarter_turn_3_bank(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6670 */ static void looping_rc_track_left_quarter_turn_3_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15327, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15329, 0, 6, 32, 20, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15331, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15325, 0, 6, 32, 20, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15326, 6, 0, 20, 32, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15328, 6, 0, 20, 32, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15330, 6, 0, 20, 32, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15324, 6, 0, 20, 32, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6680 */ static void looping_rc_track_right_quarter_turn_3_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15316, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15318, 0, 6, 32, 20, 3, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15320, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15322, 0, 6, 32, 20, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15317, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15319, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15321, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15323, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6690 */ static void looping_rc_track_left_quarter_turn_3_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_right_quarter_turn_3_25_deg_up(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A66A0 */ static void looping_rc_track_right_quarter_turn_3_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_left_quarter_turn_3_25_deg_up(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A66B0 */ static void looping_rc_track_left_half_banked_helix_up_small(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15165, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15172, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15168, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15171, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15162, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15164, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15167, 0, 0, 16, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15170, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15161, 0, 0, 16, 16, 3, height, 16, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15163, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15166, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15169, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15173, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15160, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15162, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15165, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15172, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15168, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15171, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 1: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15161, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15164, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15167, 0, 0, 16, 16, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15170, 0, 0, 16, 16, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15160, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15163, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15166, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15169, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15173, 0, 0, 32, 1, 26, height, 0, 27, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A66C0 */ static void looping_rc_track_right_half_banked_helix_up_small(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15146, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15149, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15152, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15155, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15159, 0, 0, 32, 1, 26, height, 0, 27, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15147, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15150, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15153, 0, 0, 16, 16, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15156, 0, 0, 16, 16, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15148, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15151, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15158, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15154, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15157, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_0); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15149, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15152, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15155, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15159, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15146, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15150, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15153, 0, 0, 16, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15156, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15147, 0, 0, 16, 16, 3, height, 16, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15151, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15158, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15154, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15157, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15148, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A66D0 */ static void looping_rc_track_left_half_banked_helix_down_small(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (trackSequence >= 4) { trackSequence -= 4; direction = (direction - 1) & 3; } trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_right_half_banked_helix_up_small(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A66E0 */ static void looping_rc_track_right_half_banked_helix_down_small(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (trackSequence >= 4) { trackSequence -= 4; direction = (direction + 1) & 3; } trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_left_half_banked_helix_up_small(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A66F0 */ static void looping_rc_track_left_half_banked_helix_up_large(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15247, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15258, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15252, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15257, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15242, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15246, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15251, 0, 0, 32, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15256, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15241, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15245, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15250, 0, 0, 16, 16, 1, height, 16, 16, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15255, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15240, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15244, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15249, 0, 0, 16, 32, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15254, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15239, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15243, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15248, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15253, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15259, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15238, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15242, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15247, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15258, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15252, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15257, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 1: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 8: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 9: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15241, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15246, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15251, 0, 0, 16, 32, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15256, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 10: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15240, 0, 0, 16, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15245, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15250, 0, 0, 16, 16, 1, height, 16, 16, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15255, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 11: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 12: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15239, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15244, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15249, 0, 0, 32, 16, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15254, 0, 0, 32, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 13: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15238, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15243, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15248, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15253, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15259, 0, 0, 32, 1, 26, height, 0, 27, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6700 */ static void looping_rc_track_right_half_banked_helix_up_large(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15216, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15221, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15226, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15231, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15237, 0, 0, 32, 1, 26, height, 0, 27, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15217, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15222, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15227, 0, 0, 32, 16, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15232, 0, 0, 32, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15218, 0, 0, 16, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15223, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15228, 0, 0, 16, 16, 1, height, 16, 16, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15233, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15219, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15224, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15229, 0, 0, 16, 32, 1, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15234, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15220, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15225, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15236, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15230, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15235, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_0); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 7: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15221, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15226, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15231, 0, 0, 20, 32, 3, height, 6, 0, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15237, 0, 0, 1, 32, 26, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15216, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height, TUNNEL_0); break; case 3: paint_util_push_tunnel_left(session, height, TUNNEL_0); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 8: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 9: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15222, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15227, 0, 0, 16, 32, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15232, 0, 0, 16, 32, 3, height, 0, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15217, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 10: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15223, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15228, 0, 0, 16, 16, 1, height, 16, 16, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15233, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15218, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 11: paint_util_set_general_support_height(session, height + 32, 0x20); break; case 12: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15224, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15229, 0, 0, 32, 16, 1, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15234, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15219, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 13: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15225, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15236, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15230, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15235, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15220, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6710 */ static void looping_rc_track_left_half_banked_helix_down_large(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (trackSequence >= 7) { trackSequence -= 7; direction = (direction - 1) & 3; } trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_right_half_banked_helix_up_large(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A6720 */ static void looping_rc_track_right_half_banked_helix_down_large(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (trackSequence >= 7) { trackSequence -= 7; direction = (direction + 1) & 3; } trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_left_half_banked_helix_up_large(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6750 */ static void looping_rc_track_left_quarter_turn_1_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15341, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15345, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15342, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15346, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15343, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15347, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15340, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15344, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; } track_paint_util_left_quarter_turn_1_tile_tunnel(session, direction, height, -8, TUNNEL_1, +56, TUNNEL_2); paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); } /** rct2: 0x008A6730 */ static void looping_rc_track_right_quarter_turn_1_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15332, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15336, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15333, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15337, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15334, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15338, 0, 0, 2, 28, 59, height, 28, 2, height + 2); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15335, 0, 0, 28, 28, 3, height, 2, 2, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15339, 0, 0, 28, 28, 1, height, 2, 2, height + 99); break; } track_paint_util_right_quarter_turn_1_tile_tunnel(session, direction, height, -8, TUNNEL_1, +56, TUNNEL_2); paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); } /** rct2: 0x008A6740 */ static void looping_rc_track_left_quarter_turn_1_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_quarter_turn_1_60_deg_up(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A6760 */ static void looping_rc_track_right_quarter_turn_1_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_quarter_turn_1_60_deg_up(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6770 */ static void looping_rc_track_brakes(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15012, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15014, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15013, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15015, 0, 0, 32, 1, 26, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6A40 */ static void looping_rc_track_25_deg_up_left_banked(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15594, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15595, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15596, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15597, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6A50 */ static void looping_rc_track_25_deg_up_right_banked(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15598, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15599, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15600, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15601, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6780 */ static void looping_rc_track_on_ride_photo(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_MISC] | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15004, 0, 0, 32, 20, 0, height, 0, 6, height + 3); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_MISC] | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 6, 0, height, session->TrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15005, 0, 0, 32, 20, 0, height, 0, 6, height + 3); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_MISC] | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15004, 0, 0, 32, 20, 0, height, 0, 6, height + 3); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_MISC] | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 6, 0, height, session->TrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15005, 0, 0, 32, 20, 0, height, 0, 6, height + 3); break; } track_paint_util_onride_photo_paint(session, direction, height + 3, mapElement); paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A6A60 */ static void looping_rc_track_25_deg_down_left_banked(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_right_banked(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6A70 */ static void looping_rc_track_25_deg_down_right_banked(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_left_banked(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6860 */ static void looping_rc_track_left_eighth_to_diag(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15526, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15530, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15534, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15538, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15527, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15531, 0, 0, 34, 16, 3, height, 0, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15535, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15539, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15528, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15532, 0, 0, 16, 16, 3, height, 16, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15536, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15540, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15529, 0, 0, 16, 16, 3, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15533, 0, 0, 16, 18, 3, height, 0, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15537, 0, 0, 16, 16, 3, height, 0, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15541, 0, 0, 16, 16, 3, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6870 */ static void looping_rc_track_right_eighth_to_diag(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15510, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15514, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15518, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15522, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15511, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15515, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15519, 0, 0, 34, 16, 3, height, 0, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15523, 0, 0, 32, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15512, 0, 0, 16, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15516, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15520, 0, 0, 28, 28, 3, height, 4, 4, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15524, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15513, 0, 0, 16, 16, 3, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15517, 0, 0, 16, 16, 3, height, 0, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15521, 0, 0, 16, 18, 3, height, 0, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15525, 0, 0, 16, 16, 3, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6880 */ static void looping_rc_track_left_eighth_to_orthogonal(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence]; looping_rc_track_right_eighth_to_diag(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6890 */ static void looping_rc_track_right_eighth_to_orthogonal(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence]; looping_rc_track_left_eighth_to_diag(session, rideIndex, trackSequence, (direction + 3) & 3, height, mapElement); } /** rct2: 0x008A68A0 */ static void looping_rc_track_left_eighth_bank_to_diag(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15558, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15562, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15566, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15570, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15559, 0, 0, 32, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15563, 0, 0, 34, 16, 0, height, 0, 0, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15567, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15571, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15560, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15564, 0, 0, 16, 16, 0, height, 16, 16, height + 27); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15568, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15572, 0, 0, 16, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15561, 0, 0, 16, 16, 3, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15565, 0, 0, 16, 18, 0, height, 0, 16, height + 27); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15569, 0, 0, 16, 16, 3, height, 0, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15573, 0, 0, 16, 16, 3, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A68B0 */ static void looping_rc_track_right_eighth_bank_to_diag(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15542, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15546, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15550, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15554, 0, 0, 32, 1, 26, height, 0, 27, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15543, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15547, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15551, 0, 0, 34, 16, 0, height, 0, 0, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15555, 0, 0, 32, 16, 3, height, 0, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15544, 0, 0, 16, 16, 3, height, 0, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15548, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15552, 0, 0, 28, 28, 0, height, 4, 4, height + 27); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15556, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 4: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15545, 0, 0, 16, 16, 3, height, 16, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15549, 0, 0, 16, 16, 3, height, 0, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15553, 0, 0, 16, 18, 0, height, 0, 16, height + 27); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15557, 0, 0, 16, 16, 3, height, 16, 16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A68C0 */ static void looping_rc_track_left_eighth_bank_to_orthogonal(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence]; looping_rc_track_right_eighth_bank_to_diag(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A68D0 */ static void looping_rc_track_right_eighth_bank_to_orthogonal(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence]; looping_rc_track_left_eighth_bank_to_diag(session, rideIndex, trackSequence, (direction + 3) & 3, height, mapElement); } /** rct2: 0x008A6790 */ static void looping_rc_track_diag_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15451, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15423, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15448, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15420, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15450, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15422, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15449, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15421, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A67C0 */ static void looping_rc_track_diag_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15463, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15435, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15460, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15432, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15462, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15434, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15461, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15433, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A67F0 */ static void looping_rc_track_diag_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15475, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15447, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15472, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15444, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15474, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15446, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15473, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15445, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 36, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; } } /** rct2: 0x008A67A0 */ static void looping_rc_track_diag_flat_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15455, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15427, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15452, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15424, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15454, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15426, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15453, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15425, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A67D0 */ static void looping_rc_track_diag_25_deg_up_to_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15467, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15439, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15464, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15436, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15466, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15438, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15465, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15437, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A67E0 */ static void looping_rc_track_diag_60_deg_up_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15471, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15443, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15468, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15440, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15470, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15442, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15469, -16, -16, 16, 16, 3, height, 0, 0, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15441, -16, -16, 16, 16, 3, height, 0, 0, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 21, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A67B0 */ static void looping_rc_track_diag_25_deg_up_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15459, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15431, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15456, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15428, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15458, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15430, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15457, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15429, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A6820 */ static void looping_rc_track_diag_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15461, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15433, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15462, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15434, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15460, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15432, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15463, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15435, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A6850 */ static void looping_rc_track_diag_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15473, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15445, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15474, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15446, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15472, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15444, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15475, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15447, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 28, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 104, 0x20); break; } } /** rct2: 0x008A6800 */ static void looping_rc_track_diag_flat_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15457, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15429, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15458, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15430, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15456, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15428, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15459, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15431, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); break; } paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6830 */ static void looping_rc_track_diag_25_deg_down_to_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15469, -16, -16, 16, 16, 3, height, 0, 0, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15441, -16, -16, 16, 16, 3, height, 0, 0, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15470, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15442, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15468, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15440, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15471, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15443, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 17, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6840 */ static void looping_rc_track_diag_60_deg_down_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15465, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15437, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15466, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15438, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15464, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15436, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15467, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15439, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6810 */ static void looping_rc_track_diag_25_deg_down_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15453, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15425, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15454, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15426, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15452, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } else { switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15424, -16, -16, 32, 32, 3, height, -16, -16, height); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: if (track_element_is_lift_hill(mapElement)) { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15455, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } else { switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15427, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A6900 */ static void looping_rc_track_diag_flat_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15503, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15500, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15504, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15502, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15501, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6910 */ static void looping_rc_track_diag_flat_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15508, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15505, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15507, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15509, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15506, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6920 */ static void looping_rc_track_diag_left_bank_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15506, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15507, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15509, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15505, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15508, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6930 */ static void looping_rc_track_diag_right_bank_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15501, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15502, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15500, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15504, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15503, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6960 */ static void looping_rc_track_diag_left_bank_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15493, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15490, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15494, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15492, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15491, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A6970 */ static void looping_rc_track_diag_right_bank_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15498, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15495, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15497, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15499, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15496, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A6940 */ static void looping_rc_track_diag_25_deg_up_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15483, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15480, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15484, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15482, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15481, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A6950 */ static void looping_rc_track_diag_25_deg_up_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15488, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15485, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15487, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15489, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15486, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); break; } } /** rct2: 0x008A6980 */ static void looping_rc_track_diag_left_bank_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15486, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15487, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15489, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15485, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15488, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); break; } paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6990 */ static void looping_rc_track_diag_right_bank_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15481, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15482, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15480, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15484, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15483, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); break; } paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A69A0 */ static void looping_rc_track_diag_25_deg_down_to_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15496, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15497, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15499, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15495, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15498, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A69B0 */ static void looping_rc_track_diag_25_deg_down_to_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15491, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15492, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15490, -16, -16, 32, 32, 3, height, -16, -16, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15494, -16, -16, 32, 32, 0, height, -16, -16, height + 35); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; case 3: switch (direction) { case 0: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15493, -16, -16, 32, 32, 3, height, -16, -16, height); metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_b_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); break; } } /** rct2: 0x008A68E0 */ static void looping_rc_track_diag_left_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15479, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15476, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15478, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15477, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A68F0 */ static void looping_rc_track_diag_right_bank(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15477, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 1: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15478, -16, -16, 32, 32, 3, height, -16, -16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 2: switch (direction) { case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15476, -16, -16, 32, 32, 0, height, -16, -16, height + 27); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; case 3: switch (direction) { case 0: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15479, -16, -16, 32, 32, 3, height, -16, -16, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); break; } } /** rct2: 0x008A6C00 */ static void looping_rc_track_block_brakes(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15012, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15014, 0, 0, 32, 1, 26, height, 0, 27, height); break; case 1: case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15013, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15015, 0, 0, 32, 1, 26, height, 0, 27, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } /** rct2: 0x008A6BC0 */ static void looping_rc_track_left_banked_quarter_turn_3_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15689, 0, 6, 32, 20, 3, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15691, 0, 6, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15693, 0, 6, 32, 20, 3, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15687, 0, 6, 32, 20, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15688, 6, 0, 20, 32, 3, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15690, 6, 0, 1, 32, 34, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15692, 6, 0, 1, 32, 34, height, 27, 0, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15686, 6, 0, 20, 32, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6BD0 */ static void looping_rc_track_right_banked_quarter_turn_3_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15678, 0, 6, 32, 20, 3, height); break; case 1: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15680, 0, 6, 32, 20, 3, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15682, 0, 6, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15684, 0, 6, 32, 20, 3, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 2: paint_util_set_general_support_height(session, height + 56, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15679, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15681, 6, 0, 1, 32, 34, height, 27, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15683, 6, 0, 1, 32, 34, height, 27, 0, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15685, 6, 0, 20, 32, 3, height); metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); break; } switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6BE0 */ static void looping_rc_track_left_banked_quarter_turn_3_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_right_banked_quarter_turn_3_25_deg_up(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A6BF0 */ static void looping_rc_track_right_banked_quarter_turn_3_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; looping_rc_track_left_banked_quarter_turn_3_25_deg_up(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6B80 */ static void looping_rc_track_left_banked_quarter_turn_5_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15658, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15663, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15668, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15673, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15659, 0, 0, 32, 16, 3, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15664, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15669, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15674, 0, 0, 32, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15660, 0, 0, 16, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15665, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15670, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15675, 0, 0, 16, 16, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 64, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15661, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15666, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15671, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15676, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15662, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15667, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15672, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15677, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 2: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 3: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6B90 */ static void looping_rc_track_right_banked_quarter_turn_5_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (trackSequence) { case 0: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15638, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15643, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15648, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15653, 0, 0, 32, 20, 3, height, 0, 6, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 1: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 2: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15639, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15644, 0, 0, 32, 16, 3, height, 0, 16, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15649, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 3: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15654, 0, 0, 32, 16, 3, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 3: switch (direction) { case 0: sub_98196C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15640, 0, 0, 16, 16, 3, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15645, 0, 0, 16, 16, 3, height, 16, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15650, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15655, 0, 0, 16, 16, 3, height, 0, 16, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 64, 0x20); break; case 4: paint_util_set_general_support_height(session, height + 72, 0x20); break; case 5: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15641, 0, 0, 16, 32, 3, height, 16, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15646, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15651, 0, 0, 1, 1, 34, height, 30, 30, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15656, 0, 0, 16, 32, 3, height, 16, 0, height); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; case 6: switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15642, 0, 0, 20, 32, 3, height, 6, 0, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15647, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15652, 0, 0, 1, 32, 34, height, 27, 0, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15657, 0, 0, 20, 32, 3, height, 6, 0, height); break; } metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); switch (direction) { case 0: paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); break; case 1: paint_util_push_tunnel_left(session, height + 8, TUNNEL_2); break; } paint_util_set_segment_support_height( session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 72, 0x20); break; } } /** rct2: 0x008A6BA0 */ static void looping_rc_track_left_banked_quarter_turn_5_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_right_banked_quarter_turn_5_25_deg_up(session, rideIndex, trackSequence, (direction + 1) & 3, height, mapElement); } /** rct2: 0x008A6BB0 */ static void looping_rc_track_right_banked_quarter_turn_5_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; looping_rc_track_left_banked_quarter_turn_5_25_deg_up(session, rideIndex, trackSequence, (direction - 1) & 3, height, mapElement); } /** rct2: 0x008A6A80 */ static void looping_rc_track_25_deg_up_to_left_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15602, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15603, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15610, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15604, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15605, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6A90 */ static void looping_rc_track_25_deg_up_to_right_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15606, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15607, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15608, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15611, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15609, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6AA0 */ static void looping_rc_track_left_banked_25_deg_up_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15612, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15613, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15620, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15614, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15615, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6AB0 */ static void looping_rc_track_right_banked_25_deg_up_to_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15616, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15617, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15618, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15621, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15619, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_1); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 56, 0x20); } /** rct2: 0x008A6AC0 */ static void looping_rc_track_25_deg_down_to_left_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_banked_25_deg_up_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6AD0 */ static void looping_rc_track_25_deg_down_to_right_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_banked_25_deg_up_to_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6AE0 */ static void looping_rc_track_left_banked_25_deg_down_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_right_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6AF0 */ static void looping_rc_track_right_banked_25_deg_down_to_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_25_deg_up_to_left_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6B00 */ static void looping_rc_track_left_banked_flat_to_left_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15622, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15623, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15624, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15625, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A6B10 */ static void looping_rc_track_right_banked_flat_to_right_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15626, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15627, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15628, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15629, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A6B40 */ static void looping_rc_track_left_banked_25_deg_up_to_left_banked_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15630, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15631, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15632, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15633, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A6B50 */ static void looping_rc_track_right_banked_25_deg_up_to_right_banked_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15634, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15635, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15636, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15637, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A6B60 */ static void looping_rc_track_left_banked_flat_to_left_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_banked_25_deg_up_to_right_banked_flat(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6B70 */ static void looping_rc_track_right_banked_flat_to_right_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_banked_25_deg_up_to_left_banked_flat(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6B20 */ static void looping_rc_track_left_banked_25_deg_down_to_left_banked_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_banked_flat_to_right_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6B30 */ static void looping_rc_track_right_banked_25_deg_down_to_right_banked_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_banked_flat_to_left_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A69C0 */ static void looping_rc_track_flat_to_left_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15574, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15575, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15582, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15576, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15577, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A69D0 */ static void looping_rc_track_flat_to_right_banked_25_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15578, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15579, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15580, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15583, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15581, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_2); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 48, 0x20); } /** rct2: 0x008A69E0 */ static void looping_rc_track_left_banked_25_deg_up_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15584, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15585, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15592, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15586, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15587, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A69F0 */ static void looping_rc_track_right_banked_25_deg_up_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { switch (direction) { case 0: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15588, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15589, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15590, 0, 0, 32, 20, 3, height, 0, 6, height); sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15593, 0, 0, 32, 1, 34, height, 0, 27, height); break; case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | 15591, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]); } if (direction == 0 || direction == 3) { paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_0); } else { paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_12); } paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 40, 0x20); } /** rct2: 0x008A6A00 */ static void looping_rc_track_flat_to_left_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_right_banked_25_deg_up_to_flat(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6A10 */ static void looping_rc_track_flat_to_right_banked_25_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_left_banked_25_deg_up_to_flat(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6A20 */ static void looping_rc_track_left_banked_25_deg_down_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_flat_to_right_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } /** rct2: 0x008A6A30 */ static void looping_rc_track_right_banked_25_deg_down_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { looping_rc_track_flat_to_left_banked_25_deg_up(session, rideIndex, trackSequence, (direction + 2) & 3, height, mapElement); } static void looping_rc_track_booster(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) { if (!is_csg_loaded()) { looping_rc_track_brakes(session, rideIndex, trackSequence, direction, height, mapElement); return; } uint32 sprite_ne_sw = SPR_CSG_BEGIN + 55679; uint32 sprite_nw_se = SPR_CSG_BEGIN + 55680; switch (direction) { case 0: case 2: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | sprite_ne_sw, 0, 0, 32, 20, 3, height, 0, 6, height); break; case 1: case 3: sub_98197C_rotated(session, direction, session->TrackColours[SCHEME_TRACK] | sprite_nw_se, 0, 0, 32, 20, 3, height, 0, 6, height); break; } if (track_paint_util_should_paint_supports(session->MapPosition)) { metal_a_supports_paint_setup(session, METAL_SUPPORTS_TUBES, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_0); paint_util_set_segment_support_height(session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0); paint_util_set_general_support_height(session, height + 32, 0x20); } TRACK_PAINT_FUNCTION get_track_paint_function_looping_rc(sint32 trackType, sint32 direction) { switch (trackType) { case TRACK_ELEM_FLAT: return looping_rc_track_flat; case TRACK_ELEM_END_STATION: case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: return looping_rc_track_station; case TRACK_ELEM_25_DEG_UP: return looping_rc_track_25_deg_up; case TRACK_ELEM_60_DEG_UP: return looping_rc_track_60_deg_up; case TRACK_ELEM_FLAT_TO_25_DEG_UP: return looping_rc_track_flat_to_25_deg_up; case TRACK_ELEM_25_DEG_UP_TO_60_DEG_UP: return looping_rc_track_25_deg_up_to_60_deg_up; case TRACK_ELEM_60_DEG_UP_TO_25_DEG_UP: return looping_rc_track_60_deg_up_to_25_deg_up; case TRACK_ELEM_25_DEG_UP_TO_FLAT: return looping_rc_track_25_deg_up_to_flat; case TRACK_ELEM_25_DEG_DOWN: return looping_rc_track_25_deg_down; case TRACK_ELEM_60_DEG_DOWN: return looping_rc_track_60_deg_down; case TRACK_ELEM_FLAT_TO_25_DEG_DOWN: return looping_rc_track_flat_to_25_deg_down; case TRACK_ELEM_25_DEG_DOWN_TO_60_DEG_DOWN: return looping_rc_track_25_deg_down_to_60_deg_down; case TRACK_ELEM_60_DEG_DOWN_TO_25_DEG_DOWN: return looping_rc_track_60_deg_down_to_25_deg_down; case TRACK_ELEM_25_DEG_DOWN_TO_FLAT: return looping_rc_track_25_deg_down_to_flat; case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES: return looping_rc_track_left_quarter_turn_5; case TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES: return looping_rc_track_right_quarter_turn_5; case TRACK_ELEM_FLAT_TO_LEFT_BANK: return looping_rc_track_flat_to_left_bank; case TRACK_ELEM_FLAT_TO_RIGHT_BANK: return looping_rc_track_flat_to_right_bank; case TRACK_ELEM_LEFT_BANK_TO_FLAT: return looping_rc_track_left_bank_to_flat; case TRACK_ELEM_RIGHT_BANK_TO_FLAT: return looping_rc_track_right_bank_to_flat; case TRACK_ELEM_BANKED_LEFT_QUARTER_TURN_5_TILES: return looping_rc_track_banked_left_quarter_turn_5; case TRACK_ELEM_BANKED_RIGHT_QUARTER_TURN_5_TILES: return looping_rc_track_banked_right_quarter_turn_5; case TRACK_ELEM_LEFT_BANK_TO_25_DEG_UP: return looping_rc_track_left_bank_to_25_deg_up; case TRACK_ELEM_RIGHT_BANK_TO_25_DEG_UP: return looping_rc_track_right_bank_to_25_deg_up; case TRACK_ELEM_25_DEG_UP_TO_LEFT_BANK: return looping_rc_track_25_deg_up_to_left_bank; case TRACK_ELEM_25_DEG_UP_TO_RIGHT_BANK: return looping_rc_track_25_deg_up_to_right_bank; case TRACK_ELEM_LEFT_BANK_TO_25_DEG_DOWN: return looping_rc_track_left_bank_to_25_deg_down; case TRACK_ELEM_RIGHT_BANK_TO_25_DEG_DOWN: return looping_rc_track_right_bank_to_25_deg_down; case TRACK_ELEM_25_DEG_DOWN_TO_LEFT_BANK: return looping_rc_track_25_deg_down_to_left_bank; case TRACK_ELEM_25_DEG_DOWN_TO_RIGHT_BANK: return looping_rc_track_25_deg_down_to_right_bank; case TRACK_ELEM_LEFT_BANK: return looping_rc_track_left_bank; case TRACK_ELEM_RIGHT_BANK: return looping_rc_track_right_bank; case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES_25_DEG_UP: return looping_rc_track_left_quarter_turn_5_25_deg_up; case TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES_25_DEG_UP: return looping_rc_track_right_quarter_turn_5_25_deg_up; case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES_25_DEG_DOWN: return looping_rc_track_left_quarter_turn_5_25_deg_down; case TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES_25_DEG_DOWN: return looping_rc_track_right_quarter_turn_5_25_deg_down; case TRACK_ELEM_S_BEND_LEFT: return looping_rc_track_s_bend_left; case TRACK_ELEM_S_BEND_RIGHT: return looping_rc_track_s_bend_right; case TRACK_ELEM_LEFT_VERTICAL_LOOP: return looping_rc_track_left_vertical_loop; case TRACK_ELEM_RIGHT_VERTICAL_LOOP: return looping_rc_track_right_vertical_loop; case TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES: return looping_rc_track_left_quarter_turn_3; case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES: return looping_rc_track_right_quarter_turn_3; case TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES_BANK: return looping_rc_track_left_quarter_turn_3_bank; case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_BANK: return looping_rc_track_right_quarter_turn_3_bank; case TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES_25_DEG_UP: return looping_rc_track_left_quarter_turn_3_25_deg_up; case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_25_DEG_UP: return looping_rc_track_right_quarter_turn_3_25_deg_up; case TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES_25_DEG_DOWN: return looping_rc_track_left_quarter_turn_3_25_deg_down; case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_25_DEG_DOWN: return looping_rc_track_right_quarter_turn_3_25_deg_down; case TRACK_ELEM_LEFT_HALF_BANKED_HELIX_UP_SMALL: return looping_rc_track_left_half_banked_helix_up_small; case TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_UP_SMALL: return looping_rc_track_right_half_banked_helix_up_small; case TRACK_ELEM_LEFT_HALF_BANKED_HELIX_DOWN_SMALL: return looping_rc_track_left_half_banked_helix_down_small; case TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_DOWN_SMALL: return looping_rc_track_right_half_banked_helix_down_small; case TRACK_ELEM_LEFT_HALF_BANKED_HELIX_UP_LARGE: return looping_rc_track_left_half_banked_helix_up_large; case TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_UP_LARGE: return looping_rc_track_right_half_banked_helix_up_large; case TRACK_ELEM_LEFT_HALF_BANKED_HELIX_DOWN_LARGE: return looping_rc_track_left_half_banked_helix_down_large; case TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_DOWN_LARGE: return looping_rc_track_right_half_banked_helix_down_large; case TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE_60_DEG_UP: return looping_rc_track_left_quarter_turn_1_60_deg_up; case TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE_60_DEG_UP: return looping_rc_track_right_quarter_turn_1_60_deg_up; case TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE_60_DEG_DOWN: return looping_rc_track_left_quarter_turn_1_60_deg_down; case TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE_60_DEG_DOWN: return looping_rc_track_right_quarter_turn_1_60_deg_down; case TRACK_ELEM_BRAKES: return looping_rc_track_brakes; case TRACK_ELEM_25_DEG_UP_LEFT_BANKED: return looping_rc_track_25_deg_up_left_banked; case TRACK_ELEM_25_DEG_UP_RIGHT_BANKED: return looping_rc_track_25_deg_up_right_banked; case TRACK_ELEM_ON_RIDE_PHOTO: return looping_rc_track_on_ride_photo; case TRACK_ELEM_25_DEG_DOWN_LEFT_BANKED: return looping_rc_track_25_deg_down_left_banked; case TRACK_ELEM_25_DEG_DOWN_RIGHT_BANKED: return looping_rc_track_25_deg_down_right_banked; case TRACK_ELEM_LEFT_EIGHTH_TO_DIAG: return looping_rc_track_left_eighth_to_diag; case TRACK_ELEM_RIGHT_EIGHTH_TO_DIAG: return looping_rc_track_right_eighth_to_diag; case TRACK_ELEM_LEFT_EIGHTH_TO_ORTHOGONAL: return looping_rc_track_left_eighth_to_orthogonal; case TRACK_ELEM_RIGHT_EIGHTH_TO_ORTHOGONAL: return looping_rc_track_right_eighth_to_orthogonal; case TRACK_ELEM_LEFT_EIGHTH_BANK_TO_DIAG: return looping_rc_track_left_eighth_bank_to_diag; case TRACK_ELEM_RIGHT_EIGHTH_BANK_TO_DIAG: return looping_rc_track_right_eighth_bank_to_diag; case TRACK_ELEM_LEFT_EIGHTH_BANK_TO_ORTHOGONAL: return looping_rc_track_left_eighth_bank_to_orthogonal; case TRACK_ELEM_RIGHT_EIGHTH_BANK_TO_ORTHOGONAL: return looping_rc_track_right_eighth_bank_to_orthogonal; case TRACK_ELEM_DIAG_FLAT: return looping_rc_track_diag_flat; case TRACK_ELEM_DIAG_25_DEG_UP: return looping_rc_track_diag_25_deg_up; case TRACK_ELEM_DIAG_60_DEG_UP: return looping_rc_track_diag_60_deg_up; case TRACK_ELEM_DIAG_FLAT_TO_25_DEG_UP: return looping_rc_track_diag_flat_to_25_deg_up; case TRACK_ELEM_DIAG_25_DEG_UP_TO_60_DEG_UP: return looping_rc_track_diag_25_deg_up_to_60_deg_up; case TRACK_ELEM_DIAG_60_DEG_UP_TO_25_DEG_UP: return looping_rc_track_diag_60_deg_up_to_25_deg_up; case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT: return looping_rc_track_diag_25_deg_up_to_flat; case TRACK_ELEM_DIAG_25_DEG_DOWN: return looping_rc_track_diag_25_deg_down; case TRACK_ELEM_DIAG_60_DEG_DOWN: return looping_rc_track_diag_60_deg_down; case TRACK_ELEM_DIAG_FLAT_TO_25_DEG_DOWN: return looping_rc_track_diag_flat_to_25_deg_down; case TRACK_ELEM_DIAG_25_DEG_DOWN_TO_60_DEG_DOWN: return looping_rc_track_diag_25_deg_down_to_60_deg_down; case TRACK_ELEM_DIAG_60_DEG_DOWN_TO_25_DEG_DOWN: return looping_rc_track_diag_60_deg_down_to_25_deg_down; case TRACK_ELEM_DIAG_25_DEG_DOWN_TO_FLAT: return looping_rc_track_diag_25_deg_down_to_flat; case TRACK_ELEM_DIAG_FLAT_TO_LEFT_BANK: return looping_rc_track_diag_flat_to_left_bank; case TRACK_ELEM_DIAG_FLAT_TO_RIGHT_BANK: return looping_rc_track_diag_flat_to_right_bank; case TRACK_ELEM_DIAG_LEFT_BANK_TO_FLAT: return looping_rc_track_diag_left_bank_to_flat; case TRACK_ELEM_DIAG_RIGHT_BANK_TO_FLAT: return looping_rc_track_diag_right_bank_to_flat; case TRACK_ELEM_DIAG_LEFT_BANK_TO_25_DEG_UP: return looping_rc_track_diag_left_bank_to_25_deg_up; case TRACK_ELEM_DIAG_RIGHT_BANK_TO_25_DEG_UP: return looping_rc_track_diag_right_bank_to_25_deg_up; case TRACK_ELEM_DIAG_25_DEG_UP_TO_LEFT_BANK: return looping_rc_track_diag_25_deg_up_to_left_bank; case TRACK_ELEM_DIAG_25_DEG_UP_TO_RIGHT_BANK: return looping_rc_track_diag_25_deg_up_to_right_bank; case TRACK_ELEM_DIAG_LEFT_BANK_TO_25_DEG_DOWN: return looping_rc_track_diag_left_bank_to_25_deg_down; case TRACK_ELEM_DIAG_RIGHT_BANK_TO_25_DEG_DOWN: return looping_rc_track_diag_right_bank_to_25_deg_down; case TRACK_ELEM_DIAG_25_DEG_DOWN_TO_LEFT_BANK: return looping_rc_track_diag_25_deg_down_to_left_bank; case TRACK_ELEM_DIAG_25_DEG_DOWN_TO_RIGHT_BANK: return looping_rc_track_diag_25_deg_down_to_right_bank; case TRACK_ELEM_DIAG_LEFT_BANK: return looping_rc_track_diag_left_bank; case TRACK_ELEM_DIAG_RIGHT_BANK: return looping_rc_track_diag_right_bank; case TRACK_ELEM_BLOCK_BRAKES: return looping_rc_track_block_brakes; case TRACK_ELEM_LEFT_BANKED_QUARTER_TURN_3_TILE_25_DEG_UP: return looping_rc_track_left_banked_quarter_turn_3_25_deg_up; case TRACK_ELEM_RIGHT_BANKED_QUARTER_TURN_3_TILE_25_DEG_UP: return looping_rc_track_right_banked_quarter_turn_3_25_deg_up; case TRACK_ELEM_LEFT_BANKED_QUARTER_TURN_3_TILE_25_DEG_DOWN: return looping_rc_track_left_banked_quarter_turn_3_25_deg_down; case TRACK_ELEM_RIGHT_BANKED_QUARTER_TURN_3_TILE_25_DEG_DOWN: return looping_rc_track_right_banked_quarter_turn_3_25_deg_down; case TRACK_ELEM_LEFT_BANKED_QUARTER_TURN_5_TILE_25_DEG_UP: return looping_rc_track_left_banked_quarter_turn_5_25_deg_up; case TRACK_ELEM_RIGHT_BANKED_QUARTER_TURN_5_TILE_25_DEG_UP: return looping_rc_track_right_banked_quarter_turn_5_25_deg_up; case TRACK_ELEM_LEFT_BANKED_QUARTER_TURN_5_TILE_25_DEG_DOWN: return looping_rc_track_left_banked_quarter_turn_5_25_deg_down; case TRACK_ELEM_RIGHT_BANKED_QUARTER_TURN_5_TILE_25_DEG_DOWN: return looping_rc_track_right_banked_quarter_turn_5_25_deg_down; case TRACK_ELEM_25_DEG_UP_TO_LEFT_BANKED_25_DEG_UP: return looping_rc_track_25_deg_up_to_left_banked_25_deg_up; case TRACK_ELEM_25_DEG_UP_TO_RIGHT_BANKED_25_DEG_UP: return looping_rc_track_25_deg_up_to_right_banked_25_deg_up; case TRACK_ELEM_LEFT_BANKED_25_DEG_UP_TO_25_DEG_UP: return looping_rc_track_left_banked_25_deg_up_to_25_deg_up; case TRACK_ELEM_RIGHT_BANKED_25_DEG_UP_TO_25_DEG_UP: return looping_rc_track_right_banked_25_deg_up_to_25_deg_up; case TRACK_ELEM_25_DEG_DOWN_TO_LEFT_BANKED_25_DEG_DOWN: return looping_rc_track_25_deg_down_to_left_banked_25_deg_down; case TRACK_ELEM_25_DEG_DOWN_TO_RIGHT_BANKED_25_DEG_DOWN: return looping_rc_track_25_deg_down_to_right_banked_25_deg_down; case TRACK_ELEM_LEFT_BANKED_25_DEG_DOWN_TO_25_DEG_DOWN: return looping_rc_track_left_banked_25_deg_down_to_25_deg_down; case TRACK_ELEM_RIGHT_BANKED_25_DEG_DOWN_TO_25_DEG_DOWN: return looping_rc_track_right_banked_25_deg_down_to_25_deg_down; case TRACK_ELEM_LEFT_BANKED_FLAT_TO_LEFT_BANKED_25_DEG_UP: return looping_rc_track_left_banked_flat_to_left_banked_25_deg_up; case TRACK_ELEM_RIGHT_BANKED_FLAT_TO_RIGHT_BANKED_25_DEG_UP: return looping_rc_track_right_banked_flat_to_right_banked_25_deg_up; case TRACK_ELEM_LEFT_BANKED_25_DEG_UP_TO_LEFT_BANKED_FLAT: return looping_rc_track_left_banked_25_deg_up_to_left_banked_flat; case TRACK_ELEM_RIGHT_BANKED_25_DEG_UP_TO_RIGHT_BANKED_FLAT: return looping_rc_track_right_banked_25_deg_up_to_right_banked_flat; case TRACK_ELEM_LEFT_BANKED_FLAT_TO_LEFT_BANKED_25_DEG_DOWN: return looping_rc_track_left_banked_flat_to_left_banked_25_deg_down; case TRACK_ELEM_RIGHT_BANKED_FLAT_TO_RIGHT_BANKED_25_DEG_DOWN: return looping_rc_track_right_banked_flat_to_right_banked_25_deg_down; case TRACK_ELEM_LEFT_BANKED_25_DEG_DOWN_TO_LEFT_BANKED_FLAT: return looping_rc_track_left_banked_25_deg_down_to_left_banked_flat; case TRACK_ELEM_RIGHT_BANKED_25_DEG_DOWN_TO_RIGHT_BANKED_FLAT: return looping_rc_track_right_banked_25_deg_down_to_right_banked_flat; case TRACK_ELEM_FLAT_TO_LEFT_BANKED_25_DEG_UP: return looping_rc_track_flat_to_left_banked_25_deg_up; case TRACK_ELEM_FLAT_TO_RIGHT_BANKED_25_DEG_UP: return looping_rc_track_flat_to_right_banked_25_deg_up; case TRACK_ELEM_LEFT_BANKED_25_DEG_UP_TO_FLAT: return looping_rc_track_left_banked_25_deg_up_to_flat; case TRACK_ELEM_RIGHT_BANKED_25_DEG_UP_TO_FLAT: return looping_rc_track_right_banked_25_deg_up_to_flat; case TRACK_ELEM_FLAT_TO_LEFT_BANKED_25_DEG_DOWN: return looping_rc_track_flat_to_left_banked_25_deg_down; case TRACK_ELEM_FLAT_TO_RIGHT_BANKED_25_DEG_DOWN: return looping_rc_track_flat_to_right_banked_25_deg_down; case TRACK_ELEM_LEFT_BANKED_25_DEG_DOWN_TO_FLAT: return looping_rc_track_left_banked_25_deg_down_to_flat; case TRACK_ELEM_RIGHT_BANKED_25_DEG_DOWN_TO_FLAT: return looping_rc_track_right_banked_25_deg_down_to_flat; case TRACK_ELEM_BOOSTER: return looping_rc_track_booster; } return NULL; }
Java
package com.tikaji.halocraft; import com.tikaji.halocraft.common.handlers.ConfigurationHandler; import com.tikaji.halocraft.common.proxy.IProxy; import com.tikaji.halocraft.common.utility.Reference; import com.tikaji.halocraft.common.utility.VersionChecker; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; /** * Created by Jacob Williams on 6/17/2015. */ @Mod(modid = Reference.ModInfo.MOD_ID, name = Reference.ModInfo.MOD_NAME, version = Reference.ModInfo.VERSION) public class HaloCraft { @Mod.Instance public static HaloCraft INSTANCE; public static boolean haveWarnedVersionIsOutOfDate = false; @SidedProxy(clientSide = Reference.ModInfo.CLIENT_PROXY_CLASS, serverSide = Reference.ModInfo.SERVER_PROXY_CLASS) public static IProxy proxy; public static VersionChecker versionChecker; public static String prependModID(String name) { return Reference.ModInfo.MOD_ID + ":" + name; } @Mod.EventHandler public void initialize(FMLInitializationEvent event) { proxy.init(); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { proxy.postInit(); ConfigurationHandler.postInit(); } @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { ConfigurationHandler.init(new Configuration(event.getSuggestedConfigurationFile())); proxy.preInit(); ConfigurationHandler.save(); } }
Java
<?php /** * @link https://github.com/old-town/workflow-doctrine * @author Malofeykin Andrey <and-rey2@yandex.ru> */ namespace OldTown\Workflow\Spi\Doctrine\EntityRepository\Exception; use OldTown\Workflow\Spi\Doctrine\Exception\ExceptionInterface as ParentExceptionInterface; /** * Interface ExceptionInterface * * @package OldTown\Workflow\Spi\Doctrine\EntityRepository\Exception */ interface ExceptionInterface extends ParentExceptionInterface { }
Java
<form ng-submit="add()" name="contact_form"> <div class="row"> <div class="col s14"> <div class="input-field"> <i ng-if="config.json.help" class="material-icons tooltipped contact-tooltip" data-position="right" data-delay="50" data-tooltip="{{config.json.help}}">help</i> <input name="input" type="text" ng-model="model" class="field" style="line-height: normal" ng-pattern="config.pattern" id="{{config.json.type}}_input" ng-class="{'invalid': !contact_form['input'].$valid}"/> <label for="{{config.json.type}}_input" class="active"> <span class="valign-wrapper"> <i ng-if="config.json.icon" class="material-icons left">{{config.json.icon}}</i> <img ng-if="config.json.img" ng-src="{{config.img}}" class="contact-img"/> {{config.json.title || config.json.type}} </span> </label> </div> </div> <div class="col s10 contact-add"> <a class="btn" ng-if="model.length" ng-click="add()"><i class="material-icons left md-17">add</i> <span class="hide-on-med-and-down">add</span> </a> </div> </div> </form>
Java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: GnssLogTime.cpp * Author: markov */ #include <boost/date_time/posix_time/posix_time.hpp> #include "gnss_functions.hpp" #include "GnssLogTime.hpp" #include "common_functions.hpp" GnssLogTime::GnssLogTime() { week_ = 0; milliseconds_ = 0; } GnssLogTime::GnssLogTime(unsigned short week, unsigned int milliseconds) { week_ = week; milliseconds_ = milliseconds; utcTime_ = getLogTime(week_, milliseconds_); } GnssLogTime::GnssLogTime(const GnssLogTime& gnssLogTime) : stringUtcTime_(gnssLogTime.stringUtcTime_), stringIsoTime_(gnssLogTime.stringIsoTime_) { week_ = gnssLogTime.week_; milliseconds_ = gnssLogTime.milliseconds_; utcTime_ = gnssLogTime.utcTime_; } GnssLogTime::~GnssLogTime() { } GnssLogTime& GnssLogTime::operator=(const GnssLogTime& b) { week_ = b.week_; milliseconds_ = b.milliseconds_; utcTime_ = b.utcTime_; stringUtcTime_ = b.stringUtcTime_; stringIsoTime_ = b.stringIsoTime_; return *this; } bool GnssLogTime::operator==(const GnssLogTime& b) const { return ((week_ == b.week_) && (milliseconds_ == b.milliseconds_)); } bool GnssLogTime::operator!=(const GnssLogTime& b) const { return ((week_ != b.week_) || (milliseconds_ != b.milliseconds_)); } bool GnssLogTime::operator<(const GnssLogTime& b) const { return ((week_ < b.week_) || (milliseconds_ < b.milliseconds_)); } bool GnssLogTime::operator>(const GnssLogTime& b) const { return ((week_ >= b.week_) && (milliseconds_ > b.milliseconds_)); } bool GnssLogTime::operator<=(const GnssLogTime& b) const { return ((*this < b) || (*this == b)); } bool GnssLogTime::operator>=(const GnssLogTime& b) const { return ((*this > b) || (*this == b)); } PTime GnssLogTime::getUtcTime() { //return UTC time in ptime variable return utcTime_; } std::string GnssLogTime::getStringUtcTime() { //return UTC time in string format if (stringUtcTime_.empty()) { stringUtcTime_ = pTimeToSimpleString(utcTime_); } return stringUtcTime_; } std::string GnssLogTime::getStringIsoTime() { //return UTS time in ISO extended string if (stringIsoTime_.empty()) { stringIsoTime_ = pTimeToIsoString(utcTime_); } return stringIsoTime_; } unsigned short GnssLogTime::getWeek() { return week_; } unsigned int GnssLogTime::getMilliseconds() { return milliseconds_; }
Java
#ifndef Func_seq_H #define Func_seq_H #include "Procedure.h" #include <string> namespace RevLanguage { /** * @brief Function that creates a numerical sequence. * * This function is the equivalent to the 'R' function seq(). * The function creates a numerical sequence from the specified value * to the specified value incremented by a specified value: * * a <- seq(from=1,to=10,by=2) * * Which gives: * {1,3,5,7,9} * * This function is very similar to the range function except that * it has a user specified increment (or decrement). * * * * @copyright Copyright 2009- * @author The RevBayes Development Core Team (Sebastian Hoehna) * @since Version 1.0, 2014-06-19 * */ template <typename valType> class Func_seq : public Procedure { public: Func_seq(); // Basic utility functions Func_seq* clone(void) const; //!< Clone the object static const std::string& getClassType(void); //!< Get Rev type static const TypeSpec& getClassTypeSpec(void); //!< Get class type spec std::string getFunctionName(void) const; //!< Get the primary name of the function in Rev const TypeSpec& getTypeSpec(void) const; //!< Get language type of the object // Regular functions const ArgumentRules& getArgumentRules(void) const; //!< Get argument rules const TypeSpec& getReturnType(void) const; //!< Get type of return value RevPtr<RevVariable> execute(void); //!< Execute function protected: }; } #include "ArgumentRule.h" #include "Ellipsis.h" #include "RbUtil.h" #include "TypedDagNode.h" #include "TypeSpec.h" template <typename valType> RevLanguage::Func_seq<valType>::Func_seq() : Procedure() { } /* Clone object */ template <typename valType> RevLanguage::Func_seq<valType>* RevLanguage::Func_seq<valType>::clone( void ) const { return new Func_seq( *this ); } /** Execute function: We rely on getValue and overloaded push_back to provide functionality */ template <typename valType> RevLanguage::RevPtr<RevLanguage::RevVariable> RevLanguage::Func_seq<valType>::execute( void ) { typename valType::valueType from = static_cast<const valType &>( args[0].getVariable()->getRevObject() ).getValue(); typename valType::valueType to = static_cast<const valType &>( args[1].getVariable()->getRevObject() ).getValue(); typename valType::valueType by = static_cast<const valType &>( args[2].getVariable()->getRevObject() ).getValue(); typename valType::valueType val = from; // typename valType::valueType eps = valType::EPSILON; typename valType::valueType eps = std::numeric_limits<typename valType::valueType>::epsilon(); ModelVector<valType> *seq = new ModelVector<valType>(); // while ( (val >= from && val <= to) || (val <= from && val >= to) ) while ( ((val - from) >= -eps && (val - to) <= eps) || ((val - from) <= eps && (val - to) >= -eps) ) { seq->push_back( valType( val ) ); val += by; } return new RevVariable( seq ); } /** Get argument rules */ template <typename valType> const RevLanguage::ArgumentRules& RevLanguage::Func_seq<valType>::getArgumentRules( void ) const { static ArgumentRules argumentRules = ArgumentRules(); static bool rules_set = false; if ( !rules_set ) { argumentRules.push_back( new ArgumentRule( "from", valType::getClassTypeSpec(), "The first value of the sequence.", ArgumentRule::BY_VALUE, ArgumentRule::ANY ) ); argumentRules.push_back( new ArgumentRule( "to" , valType::getClassTypeSpec(), "The last value of the sequence.", ArgumentRule::BY_VALUE, ArgumentRule::ANY ) ); argumentRules.push_back( new ArgumentRule( "by" , valType::getClassTypeSpec(), "The step-size between value.", ArgumentRule::BY_VALUE, ArgumentRule::ANY ) ); rules_set = true; } return argumentRules; } /** Get Rev type of object */ template <typename valType> const std::string& RevLanguage::Func_seq<valType>::getClassType(void) { static std::string rev_type = "Func_seq<" + valType::getClassType() + ">"; return rev_type; } /** Get class type spec describing type of object */ template <typename valType> const RevLanguage::TypeSpec& RevLanguage::Func_seq<valType>::getClassTypeSpec(void) { static TypeSpec rev_type_spec = TypeSpec( getClassType(), new TypeSpec( Function::getClassTypeSpec() ) ); return rev_type_spec; } /** * Get the primary Rev name for this function. */ template <typename valType> std::string RevLanguage::Func_seq<valType>::getFunctionName( void ) const { // create a name variable that is the same for all instance of this class std::string f_name = "seq"; return f_name; } /** Get type spec */ template <typename valType> const RevLanguage::TypeSpec& RevLanguage::Func_seq<valType>::getTypeSpec( void ) const { static TypeSpec type_spec = getClassTypeSpec(); return type_spec; } /** Get return type */ template <typename valType> const RevLanguage::TypeSpec& RevLanguage::Func_seq<valType>::getReturnType( void ) const { return ModelVector<valType>::getClassTypeSpec(); } #endif
Java
package com.kraz.minehr.items; import com.kraz.minehr.MineHr; import com.kraz.minehr.reference.Reference; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemHoe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class HorizonHoe extends ItemHoe { public HorizonHoe() { super(MineHr.HorizonToolMaterial); } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon(Reference.MOD_ID + ":" + this.getUnlocalizedName().substring(5)); } }
Java
from runtests.mpi import MPITest from nbodykit.lab import * from nbodykit import setup_logging from numpy.testing import assert_allclose import tempfile import os @MPITest([1]) def test_hdf(comm): import h5py # fake structured array dset = numpy.empty(1024, dtype=[('Position', ('f8', 3)), ('Mass', 'f8')]) dset['Position'] = numpy.random.random(size=(1024, 3)) dset['Mass'] = numpy.random.random(size=1024) tmpfile = tempfile.mkstemp()[1] with h5py.File(tmpfile , 'w') as ff: ds = ff.create_dataset('X', data=dset) # store structured array as dataset ds.attrs['BoxSize'] = 1.0 grp = ff.create_group('Y') grp.create_dataset('Position', data=dset['Position']) # column as dataset grp.create_dataset('Mass', data=dset['Mass']) # column as dataset cosmo = cosmology.Planck15 source = HDFCatalog(tmpfile, dataset='X', attrs={"Nmesh":32}, comm=comm) assert_allclose(source['Position'], dset['Position']) region = source.query_range(32, 64) assert_allclose(region['Position'], dset['Position'][32:64]) os.unlink(tmpfile) @MPITest([1, 4]) def test_query_range(comm): import h5py # fake structured array dset = numpy.empty(1024, dtype=[('Position', ('f8', 3)), ('Mass', 'f8'), ('Index', 'i8')]) dset['Index'] = numpy.arange(1024) dset['Position'] = numpy.random.random(size=(1024, 3)) dset['Mass'] = numpy.random.random(size=1024) if comm.rank == 0: tmpfile = tempfile.mkstemp()[1] with h5py.File(tmpfile , 'w') as ff: ds = ff.create_dataset('X', data=dset) # store structured array as dataset ds.attrs['BoxSize'] = 1.0 tmpfile = comm.bcast(tmpfile) else: tmpfile = comm.bcast(None) cosmo = cosmology.Planck15 source = HDFCatalog(tmpfile, dataset='X', attrs={"Nmesh":32}, comm=comm) correct_region = source.gslice(32, 64) region = source.query_range(32, 64) assert_allclose( numpy.concatenate(comm.allgather(region['Index'].compute())), numpy.arange(32, 64) ) if comm.rank == 0: os.unlink(tmpfile) @MPITest([1]) def test_csv(comm): with tempfile.NamedTemporaryFile() as ff: # generate data data = numpy.random.random(size=(100,5)) numpy.savetxt(ff, data, fmt='%.7e'); ff.seek(0) # read nrows names =['a', 'b', 'c', 'd', 'e'] f = CSVCatalog(ff.name, names, blocksize=100, comm=comm) # make sure data is the same for i, name in enumerate(names): numpy.testing.assert_almost_equal(data[:,i], f[name].compute(), decimal=7) # make sure all the columns are there assert all(col in f for col in names) @MPITest([1]) def test_stack_glob(comm): tmpfile1 = 'test-glob-1.dat' tmpfile2 = 'test-glob-2.dat' # generate data data = numpy.random.random(size=(100,5)) numpy.savetxt(tmpfile1, data, fmt='%.7e') numpy.savetxt(tmpfile2, data, fmt='%.7e') # read using a glob names =['a', 'b', 'c', 'd', 'e'] f = CSVCatalog('test-glob-*', names, blocksize=100, comm=comm) # make sure print works print(f) # make sure data is the same fulldata = numpy.concatenate([data, data], axis=0) for i, name in enumerate(names): numpy.testing.assert_almost_equal(fulldata[:,i], f[name].compute(), decimal=7) # make sure all the columns are there assert all(col in f for col in names) os.unlink(tmpfile1) os.unlink(tmpfile2) @MPITest([1]) def test_stack_list(comm): tmpfile1 = 'test-list-1.dat' tmpfile2 = 'test-list-2.dat' # generate data data = numpy.random.random(size=(100,5)) numpy.savetxt(tmpfile1, data, fmt='%.7e') numpy.savetxt(tmpfile2, data, fmt='%.7e') # read using a glob names =['a', 'b', 'c', 'd', 'e'] f = CSVCatalog(['test-list-1.dat', 'test-list-2.dat'], names, blocksize=100, comm=comm) # make sure print works print(f) # make sure data is the same fulldata = numpy.concatenate([data, data], axis=0) for i, name in enumerate(names): numpy.testing.assert_almost_equal(fulldata[:,i], f[name].compute(), decimal=7) # make sure all the columns are there assert all(col in f for col in names) os.unlink(tmpfile1) os.unlink(tmpfile2)
Java
package com.taobao.api.response; import com.taobao.api.TaobaoResponse; import com.taobao.api.internal.mapping.ApiField; /** * TOP API: taobao.logistics.consign.order.createandsend response. * * @author auto create * @since 1.0, null */ public class LogisticsConsignOrderCreateandsendResponse extends TaobaoResponse { private static final long serialVersionUID = 2877278252382584596L; /** * 是否成功 */ @ApiField("is_success") private Boolean isSuccess; /** * 订单ID */ @ApiField("order_id") private Long orderId; /** * 结果描述 */ @ApiField("result_desc") private String resultDesc; public Boolean getIsSuccess() { return this.isSuccess; } public Long getOrderId() { return this.orderId; } public String getResultDesc() { return this.resultDesc; } public void setIsSuccess(Boolean isSuccess) { this.isSuccess = isSuccess; } public void setOrderId(Long orderId) { this.orderId = orderId; } public void setResultDesc(String resultDesc) { this.resultDesc = resultDesc; } }
Java
/* * Pixel Dungeon * Copyright (C) 2012-2015 Oleg Dolya * * 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 <http://www.gnu.org/licenses/> */ package com.voicecrystal.pixeldungeonlegends.actors.hero; import com.watabou.utils.Bundle; public enum HeroSubClass { NONE( null, null ), GLADIATOR( "gladiator", "A successful attack with a melee weapon allows the _Gladiator_ to start a combo, " + "in which every next successful hit inflicts more damage." ), BERSERKER( "berserker", "When severely wounded, the _Berserker_ enters a state of wild fury " + "significantly increasing his damage output." ), WARLOCK( "warlock", "After killing an enemy the _Warlock_ consumes its soul. " + "It heals his wounds and satisfies his hunger." ), BATTLEMAGE( "battlemage", "When fighting with a wand in his hands, the _Battlemage_ inflicts additional damage depending " + "on the current number of charges. Every successful hit restores 1 charge to this wand." ), ASSASSIN( "assassin", "When performing a surprise attack, the _Assassin_ inflicts additional damage to his target." ), FREERUNNER( "freerunner", "The _Freerunner_ can move almost twice faster, than most of the monsters. When he " + "is running, the Freerunner is much harder to hit. For that he must be unencumbered and not starving." ), SNIPER( "sniper", "_Snipers_ are able to detect weak points in an enemy's armor, " + "effectively ignoring it when using a missile weapon." ), WARDEN( "warden", "Having a strong connection with forces of nature gives _Wardens_ an ability to gather dewdrops and " + "seeds from plants. Also trampling a high grass grants them a temporary armor buff." ); private String title; private String desc; private HeroSubClass( String title, String desc ) { this.title = title; this.desc = desc; } public String title() { return title; } public String desc() { return desc; } private static final String SUBCLASS = "subClass"; public void storeInBundle( Bundle bundle ) { bundle.put( SUBCLASS, toString() ); } public static HeroSubClass restoreInBundle( Bundle bundle ) { String value = bundle.getString( SUBCLASS ); try { return valueOf( value ); } catch (Exception e) { return NONE; } } }
Java
<?php /** * TrcIMPLAN Índice Básico de Colonias * * Copyright (C) 2016 Guillermo Valdes Lozano * * 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 <http://www.gnu.org/licenses/>. * * @package TrcIMPLAN */ namespace IBCTorreon; /** * Clase VillaJardin */ class VillaJardin extends \IBCBase\PublicacionWeb { /** * Constructor */ public function __construct() { // Título, autor y fecha $this->nombre = 'Villa Jardin'; $this->autor = 'IMPLAN Torreón Staff'; $this->fecha = '2016-09-02 12:55:35'; // El nombre del archivo a crear (obligatorio) y rutas relativas a las imágenes $this->archivo = 'villa-jardin'; $this->imagen = '../imagenes/imagen.jpg'; $this->imagen_previa = '../imagenes/imagen-previa.jpg'; // La descripción y claves dan información a los buscadores y redes sociales $this->descripcion = 'Colonia Villa Jardin de IBC Torreón.'; $this->claves = 'IMPLAN, Torreon, Desagregación'; // El directorio en la raíz donde se guardará el archivo HTML $this->directorio = 'ibc-torreon'; // Opción del menú Navegación a poner como activa cuando vea esta publicación $this->nombre_menu = 'IBC > IBC Torreón'; // Para el Organizador $this->categorias = array(); $this->fuentes = array(); $this->regiones = array(); } // constructor /** * Datos * * @return array Arreglo asociativo */ public function datos() { return array( 'Demografía' => array( 'Población total' => '548', 'Porcentaje de población masculina' => '46.41', 'Porcentaje de población femenina' => '53.59', 'Porcentaje de población de 0 a 14 años' => '11.60', 'Porcentaje de población de 15 a 64 años' => '63.71', 'Porcentaje de población de 65 y más años' => '13.63', 'Porcentaje de población no especificada' => '11.06', 'Fecundidad promedio' => '1.93', 'Porcentaje de población nacida en otro estado' => '24.29', 'Porcentaje de población con discapacidad' => '4.61' ), 'Educación' => array( 'Grado Promedio de Escolaridad' => '14.01', 'Grado Promedio de Escolaridad masculina' => '14.57', 'Grado Promedio de Escolaridad femenina' => '13.51' ), 'Características Económicas' => array( 'Población Económicamente Activa' => '52.20', 'Población Económicamente Activa masculina' => '63.52', 'Población Económicamente Activa femenina' => '36.48', 'Población Ocupada' => '93.39', 'Población Ocupada masculina' => '63.47', 'Población Ocupada femenina' => '36.53', 'Población Desocupada' => '6.61', 'Derechohabiencia' => '72.90' ), 'Viviendas' => array( 'Hogares' => '154', 'Hogares Jefatura masculina' => '80.29', 'Hogares Jefatura femenina' => '19.71', 'Ocupación por Vivienda' => '3.56', 'Viviendas con Electricidad' => '99.72', 'Viviendas con Agua' => '100.00', 'Viviendas con Drenaje' => '99.72', 'Viviendas con Televisión' => '89.25', 'Viviendas con Automóvil' => '84.62', 'Viviendas con Computadora' => '72.81', 'Viviendas con Celular' => '82.00', 'Viviendas con Internet' => '68.86' ), 'Unidades Económicas' => array( 'Total Actividades Económicas' => '52', 'Primer actividad nombre' => 'Otros servicios, excepto Gobierno', 'Primer actividad porcentaje' => '15.38', 'Segunda actividad nombre' => 'Inmobiliarios', 'Segunda actividad porcentaje' => '13.46', 'Tercera actividad nombre' => 'Comercio Menudeo', 'Tercera actividad porcentaje' => '11.54', 'Cuarta actividad nombre' => 'Salud', 'Cuarta actividad porcentaje' => '7.69', 'Quinta actividad nombre' => 'Profesionales, Científicos, Técnicos', 'Quinta actividad porcentaje' => '7.69' ) ); } // datos } // Clase VillaJardin ?>
Java
# Changelog ## Version 0.1 First release, implement fixed 10 by 10 grid with 3 ships of length 5, no adversary.
Java
/**General utility methods collection (not all self developed). */ package de.konradhoeffner.commons;
Java
#ifndef _ASM_X86_UACCESS_64_H #define _ASM_X86_UACCESS_64_H /* * User space memory access functions */ #include <linux/compiler.h> #include <linux/errno.h> #include <linux/lockdep.h> #include <linux/kasan-checks.h> #include <asm/alternative.h> #include <asm/cpufeatures.h> #include <asm/page.h> /* * Copy To/From Userspace */ /* Handles exceptions in both to and from, but doesn't do access_ok */ __must_check unsigned long copy_user_enhanced_fast_string(void *to, const void *from, unsigned len); __must_check unsigned long copy_user_generic_string(void *to, const void *from, unsigned len); __must_check unsigned long copy_user_generic_unrolled(void *to, const void *from, unsigned len); static __always_inline __must_check unsigned long copy_user_generic(void *to, const void *from, unsigned len) { unsigned ret; /* * If CPU has ERMS feature, use copy_user_enhanced_fast_string. * Otherwise, if CPU has rep_good feature, use copy_user_generic_string. * Otherwise, use copy_user_generic_unrolled. */ alternative_call_2(copy_user_generic_unrolled, copy_user_generic_string, X86_FEATURE_REP_GOOD, copy_user_enhanced_fast_string, X86_FEATURE_ERMS, ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from), "=d" (len)), "1" (to), "2" (from), "3" (len) : "memory", "rcx", "r8", "r9", "r10", "r11"); return ret; } __must_check unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len); static __always_inline __must_check int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size) { int ret = 0; check_object_size(dst, size, false); if (!__builtin_constant_p(size)) { return copy_user_generic(dst, (__force void *)src, size); } switch (size) { case 1: __uaccess_begin(); __get_user_asm(*(u8 *)dst, (u8 __user *)src, ret, "b", "b", "=q", 1); __uaccess_end(); return ret; case 2: __uaccess_begin(); __get_user_asm(*(u16 *)dst, (u16 __user *)src, ret, "w", "w", "=r", 2); __uaccess_end(); return ret; case 4: __uaccess_begin(); __get_user_asm(*(u32 *)dst, (u32 __user *)src, ret, "l", "k", "=r", 4); __uaccess_end(); return ret; case 8: __uaccess_begin(); __get_user_asm(*(u64 *)dst, (u64 __user *)src, ret, "q", "", "=r", 8); __uaccess_end(); return ret; case 10: __uaccess_begin(); __get_user_asm(*(u64 *)dst, (u64 __user *)src, ret, "q", "", "=r", 10); if (likely(!ret)) __get_user_asm(*(u16 *)(8 + (char *)dst), (u16 __user *)(8 + (char __user *)src), ret, "w", "w", "=r", 2); __uaccess_end(); return ret; case 16: __uaccess_begin(); __get_user_asm(*(u64 *)dst, (u64 __user *)src, ret, "q", "", "=r", 16); if (likely(!ret)) __get_user_asm(*(u64 *)(8 + (char *)dst), (u64 __user *)(8 + (char __user *)src), ret, "q", "", "=r", 8); __uaccess_end(); return ret; default: return copy_user_generic(dst, (__force void *)src, size); } } static __always_inline __must_check int __copy_from_user(void *dst, const void __user *src, unsigned size) { might_fault(); kasan_check_write(dst, size); return __copy_from_user_nocheck(dst, src, size); } static __always_inline __must_check int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size) { int ret = 0; check_object_size(src, size, true); if (!__builtin_constant_p(size)) { return copy_user_generic((__force void *)dst, src, size); } switch (size) { case 1: __uaccess_begin(); __put_user_asm(*(u8 *)src, (u8 __user *)dst, ret, "b", "b", "iq", 1); __uaccess_end(); return ret; case 2: __uaccess_begin(); __put_user_asm(*(u16 *)src, (u16 __user *)dst, ret, "w", "w", "ir", 2); __uaccess_end(); return ret; case 4: __uaccess_begin(); __put_user_asm(*(u32 *)src, (u32 __user *)dst, ret, "l", "k", "ir", 4); __uaccess_end(); return ret; case 8: __uaccess_begin(); __put_user_asm(*(u64 *)src, (u64 __user *)dst, ret, "q", "", "er", 8); __uaccess_end(); return ret; case 10: __uaccess_begin(); __put_user_asm(*(u64 *)src, (u64 __user *)dst, ret, "q", "", "er", 10); if (likely(!ret)) { asm("":::"memory"); __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst, ret, "w", "w", "ir", 2); } __uaccess_end(); return ret; case 16: __uaccess_begin(); __put_user_asm(*(u64 *)src, (u64 __user *)dst, ret, "q", "", "er", 16); if (likely(!ret)) { asm("":::"memory"); __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst, ret, "q", "", "er", 8); } __uaccess_end(); return ret; default: return copy_user_generic((__force void *)dst, src, size); } } static __always_inline __must_check int __copy_to_user(void __user *dst, const void *src, unsigned size) { might_fault(); kasan_check_read(src, size); return __copy_to_user_nocheck(dst, src, size); } static __always_inline __must_check int __copy_in_user(void __user *dst, const void __user *src, unsigned size) { int ret = 0; might_fault(); if (!__builtin_constant_p(size)) return copy_user_generic((__force void *)dst, (__force void *)src, size); switch (size) { case 1: { u8 tmp; __uaccess_begin(); __get_user_asm(tmp, (u8 __user *)src, ret, "b", "b", "=q", 1); if (likely(!ret)) __put_user_asm(tmp, (u8 __user *)dst, ret, "b", "b", "iq", 1); __uaccess_end(); return ret; } case 2: { u16 tmp; __uaccess_begin(); __get_user_asm(tmp, (u16 __user *)src, ret, "w", "w", "=r", 2); if (likely(!ret)) __put_user_asm(tmp, (u16 __user *)dst, ret, "w", "w", "ir", 2); __uaccess_end(); return ret; } case 4: { u32 tmp; __uaccess_begin(); __get_user_asm(tmp, (u32 __user *)src, ret, "l", "k", "=r", 4); if (likely(!ret)) __put_user_asm(tmp, (u32 __user *)dst, ret, "l", "k", "ir", 4); __uaccess_end(); return ret; } case 8: { u64 tmp; __uaccess_begin(); __get_user_asm(tmp, (u64 __user *)src, ret, "q", "", "=r", 8); if (likely(!ret)) __put_user_asm(tmp, (u64 __user *)dst, ret, "q", "", "er", 8); __uaccess_end(); return ret; } default: return copy_user_generic((__force void *)dst, (__force void *)src, size); } } static __must_check __always_inline int __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size) { kasan_check_write(dst, size); return __copy_from_user_nocheck(dst, src, size); } static __must_check __always_inline int __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) { kasan_check_read(src, size); return __copy_to_user_nocheck(dst, src, size); } extern long __copy_user_nocache(void *dst, const void __user *src, unsigned size, int zerorest); static inline int __copy_from_user_nocache(void *dst, const void __user *src, unsigned size) { might_fault(); kasan_check_write(dst, size); return __copy_user_nocache(dst, src, size, 1); } static inline int __copy_from_user_inatomic_nocache(void *dst, const void __user *src, unsigned size) { kasan_check_write(dst, size); return __copy_user_nocache(dst, src, size, 0); } unsigned long copy_user_handle_tail(char *to, char *from, unsigned len); #endif /* _ASM_X86_UACCESS_64_H */
Java
package listener; /** * Created by pengshu on 2016/11/11. */ public class IndexManager implements EntryListener { /** * 博客文章被创建 * * @param entryevent */ @Override public void entryAdded(EntryEvent entryevent) { System.out.println("IndexManager 处理 博客文章被创建事件。"); } /** * 博客文章被删除 * * @param entryevent */ @Override public void entryDeleted(EntryEvent entryevent) { System.out.println("IndexManager 处理 博客文章被删除事件。"); } /** * 博客文章被修改 * * @param entryevent */ @Override public void entryModified(EntryEvent entryevent) { System.out.println("IndexManager 处理 博客文章被修改事件。"); } }
Java
<?php /** * @package Joomla.Platform * @subpackage Google * * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; use Joomla\Registry\Registry; /** * Google+ data class for the Joomla Platform. * * @since 12.3 */ class JGoogleDataPlus extends JGoogleData { /** * @var JGoogleDataPlusPeople Google+ API object for people. * @since 12.3 */ protected $people; /** * @var JGoogleDataPlusActivities Google+ API object for people. * @since 12.3 */ protected $activities; /** * @var JGoogleDataPlusComments Google+ API object for people. * @since 12.3 */ protected $comments; /** * Constructor. * * @param Registry $options Google options object * @param JGoogleAuth $auth Google data http client object * * @since 12.3 */ public function __construct(Registry $options = null, JGoogleAuth $auth = null) { // Setup the default API url if not already set. $options->def('api.url', 'https://www.googleapis.com/plus/v1/'); parent::__construct($options, $auth); if (isset($this->auth) && !$this->auth->getOption('scope')) { $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me'); } } /** * Magic method to lazily create API objects * * @param string $name Name of property to retrieve * * @return JGoogleDataPlus Google+ API object (people, activities, comments). * * @since 12.3 */ public function __get($name) { switch ($name) { case 'people': if ($this->people == null) { $this->people = new JGoogleDataPlusPeople($this->options, $this->auth); } return $this->people; case 'activities': if ($this->activities == null) { $this->activities = new JGoogleDataPlusActivities($this->options, $this->auth); } return $this->activities; case 'comments': if ($this->comments == null) { $this->comments = new JGoogleDataPlusComments($this->options, $this->auth); } return $this->comments; } } }
Java
<?php namespace Smartling\Jobs; use Smartling\ApiWrapperInterface; use Smartling\Base\ExportedAPI; use Smartling\Helpers\ArrayHelper; use Smartling\Queue\QueueInterface; use Smartling\Settings\SettingsManager; use Smartling\Submissions\SubmissionManager; class DownloadTranslationJob extends JobAbstract { public const JOB_HOOK_NAME = 'smartling-download-task'; private QueueInterface $queue; public function __construct( ApiWrapperInterface $api, SettingsManager $settingsManager, SubmissionManager $submissionManager, string $jobRunInterval, int $workerTTL, QueueInterface $queue ) { parent::__construct($api, $settingsManager, $submissionManager, $jobRunInterval, $workerTTL); $this->queue = $queue; } public function getJobHookName(): string { return self::JOB_HOOK_NAME; } public function run(): void { $this->getLogger()->info('Started Translation Download Job.'); $this->processDownloadQueue(); $this->getLogger()->info('Finished Translation Download Job.'); } private function processDownloadQueue(): void { while (false !== ($submissionId = $this->queue->dequeue(QueueInterface::QUEUE_NAME_DOWNLOAD_QUEUE))) { $submissionId = ArrayHelper::first($submissionId); $result = $this->submissionManager->find(['id' => $submissionId]); if (0 < count($result)) { $entity = ArrayHelper::first($result); } else { $this->getLogger() ->warning(vsprintf('Got submission id=%s that does not exists in database. Skipping.', [$submissionId])); continue; } do_action(ExportedAPI::ACTION_SMARTLING_DOWNLOAD_TRANSLATION, $entity); $this->placeLockFlag(true); } } }
Java
"""1.5 : Migrating work unity Revision ID: 1212f113f03b Revises: 1f07ae132ac8 Create Date: 2013-01-21 11:53:56.598914 """ # revision identifiers, used by Alembic. revision = '1212f113f03b' down_revision = '1f07ae132ac8' from alembic import op import sqlalchemy as sa UNITIES = dict(NONE="", HOUR=u"heure(s)", DAY=u"jour(s)", WEEK=u"semaine(s)", MONTH=u"mois", FEUIL=u"feuillet(s)", PACK=u"forfait") UNITS = (u"heure(s)", u"jour(s)", u"semaine(s)", u"mois", u"forfait", u"feuillet(s)",) def translate_unity(unity): return UNITIES.get(unity, UNITIES["NONE"]) def translate_inverse(unity): for key, value in UNITIES.items(): if unity == value: return key else: return u"NONE" def upgrade(): from autonomie.models.task import WorkUnit from autonomie.models.task.estimation import EstimationLine from autonomie.models.task.invoice import InvoiceLine from autonomie.models.task.invoice import CancelInvoiceLine from autonomie_base.models.base import DBSESSION # Adding some characters to the Lines for table in "estimation_line", "invoice_line", "cancelinvoice_line": op.alter_column(table, "unity", type_=sa.String(100)) for value in UNITS: unit = WorkUnit(label=value) DBSESSION().add(unit) for factory in (EstimationLine, InvoiceLine, CancelInvoiceLine): for line in factory.query(): line.unity = translate_unity(line.unity) DBSESSION().merge(line) def downgrade(): from autonomie.models.task import WorkUnit from autonomie.models.task.estimation import EstimationLine from autonomie.models.task.invoice import InvoiceLine from autonomie.models.task.invoice import CancelInvoiceLine from autonomie_base.models.base import DBSESSION for factory in (EstimationLine, InvoiceLine, CancelInvoiceLine): for line in factory.query(): line.unity = translate_inverse(line.unity) DBSESSION().merge(line) for value in WorkUnit.query(): DBSESSION().delete(value)
Java
package com.actelion.research.orbit.imageAnalysis.components.icons; import java.awt.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.io.*; import java.lang.ref.WeakReference; import java.util.Base64; import java.util.Stack; import javax.imageio.ImageIO; import javax.swing.SwingUtilities; import javax.swing.plaf.UIResource; import org.pushingpixels.neon.api.icon.ResizableIcon; import org.pushingpixels.neon.api.icon.ResizableIconUIResource; /** * This class has been automatically generated using <a * href="https://github.com/kirill-grouchnikov/radiance">Photon SVG transcoder</a>. */ public class toggle_markup implements ResizableIcon { private Shape shape = null; private GeneralPath generalPath = null; private Paint paint = null; private Stroke stroke = null; private Shape clip = null; private Stack<AffineTransform> transformsStack = new Stack<>(); private void _paint0(Graphics2D g,float origAlpha) { transformsStack.push(g.getTransform()); // g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); transformsStack.push(g.getTransform()); g.transform(new AffineTransform(1.0666667222976685f, 0.0f, 0.0f, 1.0666667222976685f, -0.0f, -0.0f)); // _0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); transformsStack.push(g.getTransform()); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, -343.7007751464844f)); // _0_0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); transformsStack.push(g.getTransform()); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_0_0 paint = new Color(255, 0, 255, 255); stroke = new BasicStroke(25.0f,0,0,4.0f,null,0.0f); shape = new Rectangle2D.Double(86.42857360839844, 424.5050964355469, 187.14285278320312, 205.0); g.setPaint(paint); g.setStroke(stroke); g.draw(shape); g.setTransform(transformsStack.pop()); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); transformsStack.push(g.getTransform()); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_0_1 paint = new Color(0, 255, 255, 255); stroke = new BasicStroke(25.0f,0,0,4.0f,null,0.0f); if (generalPath == null) { generalPath = new GeneralPath(); } else { generalPath.reset(); } generalPath.moveTo(450.7143f, 462.36224f); generalPath.lineTo(425.0f, 703.7908f); generalPath.lineTo(236.42857f, 766.6479f); generalPath.lineTo(96.42857f, 826.6479f); generalPath.lineTo(84.28571f, 947.3622f); generalPath.lineTo(412.85715f, 1023.0765f); generalPath.lineTo(482.85715f, 902.3622f); generalPath.lineTo(620.0f, 989.5051f); generalPath.lineTo(637.8571f, 420.93365f); generalPath.closePath(); shape = generalPath; g.setPaint(paint); g.setStroke(stroke); g.draw(shape); g.setTransform(transformsStack.pop()); g.setTransform(transformsStack.pop()); g.setTransform(transformsStack.pop()); g.setTransform(transformsStack.pop()); } @SuppressWarnings("unused") private void innerPaint(Graphics2D g) { float origAlpha = 1.0f; Composite origComposite = g.getComposite(); if (origComposite instanceof AlphaComposite) { AlphaComposite origAlphaComposite = (AlphaComposite)origComposite; if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { origAlpha = origAlphaComposite.getAlpha(); } } _paint0(g, origAlpha); shape = null; generalPath = null; paint = null; stroke = null; clip = null; transformsStack.clear(); } /** * Returns the X of the bounding box of the original SVG image. * * @return The X of the bounding box of the original SVG image. */ public static double getOrigX() { return 75.46253967285156; } /** * Returns the Y of the bounding box of the original SVG image. * * @return The Y of the bounding box of the original SVG image. */ public static double getOrigY() { return 65.65621185302734; } /** * Returns the width of the bounding box of the original SVG image. * * @return The width of the bounding box of the original SVG image. */ public static double getOrigWidth() { return 618.7836303710938; } /** * Returns the height of the bounding box of the original SVG image. * * @return The height of the bounding box of the original SVG image. */ public static double getOrigHeight() { return 674.2141723632812; } /** The current width of this resizable icon. */ private int width; /** The current height of this resizable icon. */ private int height; /** * Creates a new transcoded SVG image. This is marked as private to indicate that app * code should be using the {@link #of(int, int)} method to obtain a pre-configured instance. */ private toggle_markup() { this.width = (int) getOrigWidth(); this.height = (int) getOrigHeight(); } @Override public int getIconHeight() { return height; } @Override public int getIconWidth() { return width; } @Override public synchronized void setDimension(Dimension newDimension) { this.width = newDimension.width; this.height = newDimension.height; } @Override public synchronized void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2d.translate(x, y); double coef1 = (double) this.width / getOrigWidth(); double coef2 = (double) this.height / getOrigHeight(); double coef = Math.min(coef1, coef2); g2d.clipRect(0, 0, this.width, this.height); g2d.scale(coef, coef); g2d.translate(-getOrigX(), -getOrigY()); if (coef1 != coef2) { if (coef1 < coef2) { int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); g2d.translate(0, extraDy); } else { int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); g2d.translate(extraDx, 0); } } Graphics2D g2ForInner = (Graphics2D) g2d.create(); innerPaint(g2ForInner); g2ForInner.dispose(); g2d.dispose(); } /** * Returns a new instance of this icon with specified dimensions. * * @param width Required width of the icon * @param height Required height of the icon * @return A new instance of this icon with specified dimensions. */ public static ResizableIcon of(int width, int height) { toggle_markup base = new toggle_markup(); base.width = width; base.height = height; return base; } /** * Returns a new {@link UIResource} instance of this icon with specified dimensions. * * @param width Required width of the icon * @param height Required height of the icon * @return A new {@link UIResource} instance of this icon with specified dimensions. */ public static ResizableIconUIResource uiResourceOf(int width, int height) { toggle_markup base = new toggle_markup(); base.width = width; base.height = height; return new ResizableIconUIResource(base); } /** * Returns a factory that returns instances of this icon on demand. * * @return Factory that returns instances of this icon on demand. */ public static Factory factory() { return toggle_markup::new; } }
Java
# roadie [![GPLv3](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://www.gnu.org/copyleft/gpl.html) [![Build Status](https://travis-ci.org/jkawamoto/roadie.svg?branch=master)](https://travis-ci.org/jkawamoto/roadie) [![wercker status](https://app.wercker.com/status/6c499024136e7067b86bef4bd07d7f62/s/master "wercker status")](https://app.wercker.com/project/byKey/6c499024136e7067b86bef4bd07d7f62) [![Go Report](https://goreportcard.com/badge/github.com/jkawamoto/roadie)](https://goreportcard.com/report/github.com/jkawamoto/roadie) [![Release](https://img.shields.io/badge/release-0.4.0-brightgreen.svg)](https://github.com/jkawamoto/roadie/releases/tag/v0.4.0) [![Japanese](https://img.shields.io/badge/qiita-%E6%97%A5%E6%9C%AC%E8%AA%9E-brightgreen.svg)](http://qiita.com/jkawamoto/items/751558536a597a33ae2a) [![Logo](https://jkawamoto.github.io/roadie/img/banner.png)](https://jkawamoto.github.io/roadie/) A easy way to run your programs on [Google Cloud Platform](https://cloud.google.com/) and [Microsoft Azure](https://azure.microsoft.com/). See [documents](https://jkawamoto.github.io/roadie/) for more information. ## Description Roadie helps you to upload your source codes to the cloud, create and delete instances, and manage outputs. For example, ```sh $ roadie run --local . --name analyze-wowah script.yml ``` uploads your source codes in current directory, and run them in such a manner that `script.yml` specifies. The `script.yml` is a simple YAML file like ```yaml apt: - unrar data: - http://mmnet.iis.sinica.edu.tw/dl/wowah/wowah.rar run: - unrar x -r wowah.rar - analyze WoWAH ``` The above `script.yml` asks roadie to install apt package `unrar` and download a data file from such URL as the preparation. Then, it directs to run those two commands: unrar the downloaded file, analyze the obtained data files. Roadie uploads results of such commands to a cloud storage after they finish. You can access those results by ```sh $ roadie result get analyze-wowah "*" -o ./res ``` Then, Roadie downloads all result files into `./res` directory. ## Installation Compiled binary files for some platforms are uploaded in [release page](https://github.com/jkawamoto/roadie/releases). If you're a [Homebrew](http://brew.sh/) or [Linuxbrew](http://linuxbrew.sh/) user, you can install Roadie by the following commands: ```sh $ brew tap jkawamoto/roadie $ brew install roadie ``` ## Initialization After installing Roadie, the following initialization is required in order to authorize Roadie to access cloud services. ```sh $ roadie init ``` ## License This software except files in `docker` folder is released under The GNU General Public License Version 3, see [COPYING](COPYING) for more detail.
Java
/* ** ** This file is part of BananaCam. ** ** BananaCam 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. ** ** BananaCam 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 BananaCam. If not, see <http://www.gnu.org/licenses/>. ** */ #include "camera_control.h" void error_func (GPContext *context, const char *format, va_list args, void *data) { context = context; data = data; fprintf(stderr, "*** Contexterror ***\n"); vfprintf(stderr, format, args); fprintf(stderr, "\n"); } void message_func (GPContext *context, const char *format, va_list args, void *data) { context = context; data = data; vprintf(format, args); printf("\n"); } void signal_handler(int sig) { printf("Signal ==> %i\n", sig); } void signal_inib() { struct sigaction act; int i; act.sa_handler = signal_handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; i = 1; while (i < 32) { if (i != 11) sigaction(i, &act, NULL); i++; } } int init(t_cam *c) { c->liveview = 0; c->liveview_fps = 30; c->liveview_fps_time = 1000000 / 30; pthread_mutex_init(&c->liveview_mutex, NULL); pthread_cond_init(&c->liveview_condvar, NULL); c->folder_path = strdup("/tmp/"); c->camera_value_list = NULL; gp_context_set_error_func(c->context, (GPContextErrorFunc)error_func, NULL); gp_context_set_message_func(c->context, (GPContextMessageFunc)message_func, NULL); gp_camera_new(&c->camera); c->context = gp_context_new(); printf("Camera Init\n"); c->ret = gp_camera_init(c->camera, c->context); if (c->ret != GP_OK) { printf("gp_camera_init: %d\n", c->ret); return (GP_ERROR); } /* get_initial_camera_values(t_cam *c); */ return (GP_OK); } void generic_exec(t_cam *c, char *command, char **param) { char *msg = NULL; if (command && strncmp(command, "get_", 4) == 0) { command = &command[4]; get_config(command, c); return; } if (param) { if (param[0]) set_config(command, param[0], c); } else { asprintf(&msg, "bad parameters for %s", command); creat_and_send_message(BAD_PARAMETERS, NULL, NULL, msg, c); } } int exec_command(t_cam *c, char *command, char **param) { t_func *tmp = NULL; int flag = 0; if (strcmp(command, "liveview") != 0 && c->liveview == 1) { printf("enter inside here\n"); c->liveview = 0; flag = 1; sleep(1); } tmp = c->first_func_ptr; while (tmp != NULL) { if (strcmp(command, tmp->name) == 0) { tmp->func_ptr(c, param); break; } tmp = tmp->next; } if (tmp == NULL) generic_exec(c, command, param); if (flag == 1) liveview(c, NULL); return (0); } void add_func_ptr_list(t_cam *c, char *name, int (*func_ptr)(t_cam *c, char **param)) { t_func *tmp; if (c->first_func_ptr == NULL) { c->first_func_ptr = malloc(sizeof(*c->first_func_ptr)); tmp = c->first_func_ptr; tmp->next = NULL; tmp->func_ptr = func_ptr; tmp->name = strdup(name); c->first_func_ptr = tmp; } else { tmp = c->first_func_ptr; while (tmp->next != NULL) tmp = tmp->next; tmp->next = malloc(sizeof(*tmp->next)); tmp = tmp->next; tmp->next = NULL; tmp->func_ptr = func_ptr; tmp->name = strdup(name); } } int main(int ac, char **av) { t_cam *c; ac = ac; av = av; #ifdef __APPLE__ //pthread_t thread; printf("Killing PTPCamera process\n"); system("killall PTPCamera"); //pthread_create(&thread, NULL, initUSBDetect, (void *)c); #endif signal_inib(); c = malloc(sizeof(*c)); c->first_func_ptr = NULL; init(c); get_all_widget_and_choices(c); add_func_ptr_list(c, "capture", trigger_capture); add_func_ptr_list(c, "liveview", liveview); add_func_ptr_list(c, "auto_focus", auto_focus); add_func_ptr_list(c, "liveviewfps", liveviewfps); add_func_ptr_list(c, "get_liveviewfps", get_liveviewfps); add_func_ptr_list(c, "defaultpath", set_default_folder_path); add_func_ptr_list(c, "get_defaultpath", get_default_folder_path); pthread_create(&c->liveview_thread, NULL, liveview_launcher, (void*)c); init_comm(c, UNIX_SOCKET_PATH); gp_camera_exit(c->camera, c->context); return (0); }
Java
<!-- ~ Copyright (C) 2010 Brockmann Consult GmbH (info@brockmann-consult.de) ~ ~ 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 http://www.gnu.org/licenses/ --> <html> <head> <title>Sentinel-2 Toolbox Help - Export Color Legend</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../style.css"> </head> <body> <table class="header"> <tr class="header"> <td class="header">&nbsp; Export Color Legend</td> <td class="header" align="right"><a href="../general/BeamOverview.html"><img src="../images/snap_header.jpg" border="0" ></a></td> </tr> </table> <h4>Exporting a Color Legend Image</h4> <p> For non-RGB images it is possible to export the current colour palette setting as a colour legend image. This function is available from the context menu over non-RGB images. The menu item <i>Export Color Legend</i> brings up a file chooser dialog allowing you to select the file name for the exported legend image. The legend appearance can be modified by opening the <i>Properties...</i> button in the file chooser: </p> <p align="center"> <img src="images/ColorLegendProperties.png" width="370" height="313"> </p> <p>Note that the tranparency mode is only enabled for the image types TIFF and PNG. A preview dialog for the legend image can be opened by clicking the <i>Preview...</i> button. Within the dialog it is also possible to copy the colour legend image the the system clipboard by using the context menu over the image area: </p> <p align="center"> <img src="images/ColorLegendPreview.png" width="492" height="194"> </p> <hr> </body> </html>
Java
/* * This file is part of the demos-linux package. * Copyright (C) 2011-2022 Mark Veltzer <mark.veltzer@gmail.com> * * demos-linux 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. * * demos-linux 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 demos-linux. If not, see <http://www.gnu.org/licenses/>. */ #include <firstinclude.h> #include <stdlib.h> // for malloc(3), free(3), EXIT_SUCCESS #include <iostream> // for std::cout, std::endl /* * This example shows how to use the C++ operator new placement * operator. * * Things we learn: * 1. How to write your own placement function. * 2. Regular constructor gets called after the placement. * 3. Releasing of space could be overridden too. * 4. This could be used for caching and real time considerations for instance. * 5. Even if you allocate an array the delete[] is NOT called so * your regular delete operator needs to know how to do the job * both for arrays and for single elements (if you want arrays * at all that is...). * * TODO: * - show in place construction (calling the constructor on an otherwise * allocated block of ram) */ class A { public: float val; A(void) { val=-7.6; } A(double ival) { val=ival; } void *operator new(size_t size, double val) { std::cout << "in new operator" << std::endl; std::cout << "size is " << size << std::endl; void *pointer=malloc(size); std::cout << "pointer is " << pointer << std::endl; // next two lines have no effect since the constructor // will be called and will override it // A *p=(A *)pointer; // p->val=val; return(pointer); } // this is for allocating arrays, the size that you get // is SizeOfObject*NumOfObjects... void *operator new[] (const size_t size) { std::cout << "in new[] operator" << std::endl; std::cout << "size is " << size << std::endl; void *pointer=malloc(size); std::cout << "pointer is " << pointer << std::endl; return(pointer); } // notice that this does NOT get called... void operator delete[] (void *pointer) { std::cout << "in delete[] operator" << std::endl; std::cout << "pointer is " << pointer << std::endl; free(pointer); } void* operator new(size_t size) { std::cout << "in new operator" << std::endl; std::cout << "size is " << size << std::endl; // void *pointer=new char[size]; void *pointer=malloc(size); std::cout << "pointer is " << pointer << std::endl; return(pointer); } void operator delete(void *pointer) { std::cout << "in delete operator" << std::endl; std::cout << "pointer is " << pointer << std::endl; free(pointer); } }; int main(int argc, char** argv, char** envp) { std::cout << "heap no arguments example" << std::endl; A* a=new A(); std::cout << "a->val is " << a->val << std::endl; #pragma GCC diagnostic ignored "-Wmismatched-new-delete" delete a; std::cout << "heap arguments example" << std::endl; A* b=new(5.5)A(); std::cout << "b->val is " << b->val << std::endl; #pragma GCC diagnostic ignored "-Wmismatched-new-delete" delete b; std::cout << "many heap no arguments example" << std::endl; const unsigned int num_objs=5; A* e=new A[num_objs]; for(unsigned int i=0; i<num_objs; i++) { std::cout << i << " " << "e->val is " << e[i].val << std::endl; } delete[] e; // the next two examples are stack examples in which case neither // the new nor the delete operator will be called (memory is stack // memory). // could you write a C++ object which can be used ONLY on the stack // or conversly ONLY on the heap using this property ?!? std::cout << "stack no arguments example" << std::endl; A c; std::cout << "c.val is " << c.val << std::endl; std::cout << "stack arguments example" << std::endl; A d(6.7); std::cout << "d.val is " << d.val << std::endl; return EXIT_SUCCESS; }
Java