code
stringlengths
3
1.05M
repo_name
stringlengths
4
116
path
stringlengths
3
942
language
stringclasses
30 values
license
stringclasses
15 values
size
int32
3
1.05M
local combat = Combat() combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) local condition = Condition(CONDITION_PARALYZE) condition:setParameter(CONDITION_PARAM_TICKS, 20000) condition:setFormula(-0.65, 0, -0.85, 0) combat:addCondition(condition) local spell = Spell("instant") function spell.onCastSpell(creature, var) return combat:execute(creature, var) end spell:name("elder bonelord paralyze") spell:words("###83") spell:isAggressive(true) spell:blockWalls(true) spell:needTarget(true) spell:needLearn(true) spell:register()
mattyx14/otxserver
data/scripts/spells/monster/elder_bonelord_paralyze.lua
Lua
gpl-2.0
551
/* Copyright (C) 2000-2021 the YAMBO team http://www.yambo-code.org Authors (see AUTHORS file for details): AF This file is distributed under the terms of the GNU General Public License. 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, 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., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA or visit http://www.gnu.org/copyleft/gpl.txt. */ #undef DEV_SUBNAME #undef DEV_SUBNAME_ALT #undef DEV_VARNAME #undef DEV_ATTRIBUTE #undef DEV_PINNED #undef DEV_SUB #undef DEV_SUB_ALT #undef DEV_VAR #undef DEV_ATTR #undef DEV_PIN !#undef YAMBO_CUDA_OR_OMP !#undef YAMBO_CUDA_OR_OMP_END
yambo-code/yambo
include/headers/common/dev_undefs.h
C
gpl-2.0
1,157
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- /* This file is part of the KDE project Copyright (C) 2000 by Carsten Pfeiffer <pfeiffer@kde.org> 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONFIGDIALOG_H #define CONFIGDIALOG_H #include <tqcheckbox.h> #include <tqevent.h> #include <tqgroupbox.h> #include <tqheader.h> #include <tqradiobutton.h> #include <tqvbox.h> #include <kdialogbase.h> #include <keditlistbox.h> #include <kkeydialog.h> #include <tdelistview.h> #include <knuminput.h> class TDEGlobalAccel; class KKeyChooser; class TDEListView; class TQPushButton; class TQDialog; class ConfigDialog; class ConfigDialog : public KDialogBase { Q_OBJECT public: ConfigDialog(TDEGlobalAccel *accel, bool isApplet ); ~ConfigDialog(); virtual void show(); void commitShortcuts(); private: KKeyChooser *keysWidget; }; class ListView : public TDEListView { public: ListView( ConfigDialog* configWidget, TQWidget *parent, const char *name ) : TDEListView( parent, name ), _configWidget( configWidget ), _regExpEditor(0L) {} // TQListView has a weird idea of a sizeHint... virtual TQSize sizeHint () const { int w = minimumSizeHint().width(); int h = header()->height(); h += viewport()->sizeHint().height(); h += horizontalScrollBar()->height(); TQListViewItem *item = firstChild(); while ( item ) { h += item->totalHeight(); item = item->nextSibling(); } return TQSize( w, h ); } protected: virtual void rename( TQListViewItem* item, int c ); private: ConfigDialog* _configWidget; TQDialog* _regExpEditor; }; #endif // CONFIGDIALOG_H
Fat-Zer/tdebase
kcontrol/randr/configdialog.h
C
gpl-2.0
2,368
cmd_sound/pcmcia/pdaudiocf/built-in.o := rm -f sound/pcmcia/pdaudiocf/built-in.o; /opt/arm-2009q3/bin/arm-none-eabi-ar rcs sound/pcmcia/pdaudiocf/built-in.o
sembre/kernel_totoro_update3
common/sound/pcmcia/pdaudiocf/.built-in.o.cmd
Batchfile
gpl-2.0
158
# datepicker-1.py from wax import * from wax.tools.datepicker import DatePicker import datetime import time class MainFrame(VerticalFrame): def Body(self): p1 = HorizontalPanel(self) dp1 = DatePicker(p1) p1.AddComponent(dp1) p1.AddSpace(10) b1 = Button(p1, "Add 1 day", event=self.AddOneDay) p1.AddComponent(b1) p1.Pack() self.AddComponent(p1, expand='h', border=4) p2 = HorizontalPanel(self) dp2 = DatePicker(p2, style='dropdown', show_century=1) p2.AddComponent(dp2) p2.AddSpace(10) b2 = Button(p2, "Yesterday", event=self.SetToYesterday) p2.AddComponent(b2) p2.Pack() self.AddComponent(p2, expand='h', border=4) self.Pack() self.BackgroundColor = p1.BackgroundColor self.dp1 = dp1 self.dp2 = dp2 # restrict dp2's range to current year thisyear = time.localtime(time.time())[0] dp2.SetRange((thisyear, 1, 1), (thisyear, 12, 31)) def AddOneDay(self, event): self.dp1.Inc() print "Date set to:", self.dp1.Value def SetToYesterday(self, event): now = time.localtime(time.time()) self.dp2.Value = now[:3] # tuple: (year, month, day) self.dp2.Dec() app = Application(MainFrame, title='datepicker-1') app.Run()
MSMBA/msmba-workflow
msmba-workflow/srclib/wax/examples/datepicker-1.py
Python
gpl-2.0
1,480
/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * 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 TITANIC_PET_SECTION_H #define TITANIC_PET_SECTION_H #include "titanic/messages/mouse_messages.h" #include "titanic/support/simple_file.h" namespace Titanic { enum PetArea { PET_INVENTORY = 0, PET_CONVERSATION = 1, PET_REMOTE = 2, PET_ROOMS = 3, PET_REAL_LIFE = 4, PET_STARFIELD = 5, PET_MESSAGE = 6 }; class CPetControl; class CPetElement; class CPetText; class CScreenManager; class CRoomItem; struct CPetSectionSubData { int _field0; int _field4; int _field8; int _fieldC; CPetSectionSubData() : _field0(0), _field4(0), _field8(0), _fieldC(0) {} }; class CPetSection { public: CPetControl *_petControl; protected: /** * Called when the current area is changed */ void areaChanged(PetArea area); /** * Returns the name of the currently active NPC, if any */ CString getActiveNPCName() const; /** * Create a color table */ void copyColors(uint tableNum, uint colors[5]); public: CPetSection() : _petControl(nullptr) {} virtual ~CPetSection() {} /** * Sets up the section */ virtual bool setup(CPetControl *petControl) { return false; } /** * Reset the section */ virtual bool reset() { return false; } /** * Draw the section */ virtual void draw(CScreenManager *screenManager) {} /** * Get the bounds for the section */ virtual Rect getBounds() const { return Rect(); } /** * Called when a general change occurs */ virtual void changed(int changeType) {} /** * Following are handlers for the various messages that the PET can * pass onto the currently active section/area */ virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return false; } virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; } virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; } virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; } virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; } virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { return false; } virtual bool KeyCharMsg(CKeyCharMsg *msg) { return false; } virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; } /** * Check whether a drag drop can occur */ virtual bool checkDragEnd(CGameObject *item) { return false; } /** * Returns item a drag-drop operation has dropped on, if any */ virtual CGameObject *dragEnd(const Point &pt) const { return nullptr; } /** * Display a message */ virtual void displayMessage(const CString &msg); /** * Returns true if the object is in a valid state */ virtual bool isValid(CPetControl *petControl) { return false; } /** * Load the data for the class from file */ virtual void load(SimpleFile *file, int param) {} /** * Called after a game has been loaded */ virtual void postLoad() {} /** * Save the data for the class to file */ virtual void save(SimpleFile *file, int indent) {} /** * Called when a section is switched to */ virtual void enter(PetArea oldArea) {} /** * Called when a section is being left, to switch to another area */ virtual void leave() {} virtual void proc23() {} /** * Called when a new room is entered */ virtual void enterRoom(CRoomItem *room) {} /** * Called when a previously set up PET timer expires */ virtual void timerExpired(int val); /** * Get a reference to the tooltip text associated with the section */ virtual CPetText *getText() { return nullptr; } /** * Removes text after a given duration */ virtual void removeText(int duration); /** * Removes text after a given duration */ virtual void removeText(); /** * Stops the text removal timer */ virtual void stopTextTimer(); /** * Get an element from the section by a designated Id */ virtual CPetElement *getElement(uint id) { return nullptr; } /** * Special retrieval of glyph background image */ virtual CGameObject *getBackground(int index) const { return nullptr; } /** * Display a title for an NPC */ virtual void displayNPCName(CGameObject *npc) {} virtual void proc33() {} /** * Sets the NPC to use */ virtual void setNPC(const CString &name) {} /** * Resets the active NPC */ virtual void resetNPC() {} /** * Show the text cursor */ virtual void showCursor() {} /** * Hide the text cursor */ virtual void hideCursor() {} /** * Highlights a glyph item in the section, if applicable */ virtual void highlight(int id) {} /** * Get the PET control */ CPetControl *getPetControl() const { return _petControl; } /** * Get a specified color in the currently active UI color table */ uint getColor(uint index); /** * Get one of the game's three UI color tables. If the default * tableNum of -1 is used, the table is taken from the game state */ const uint *getColorTable(int tableNum = -1); }; } // End of namespace Titanic #endif /* TITANIC_PET_SECTION_H */
blorente/scummvm
engines/titanic/pet_control/pet_section.h
C
gpl-2.0
5,874
## # This file is part of WhatWeb and may be subject to # redistribution and commercial restrictions. Please see the WhatWeb # web site for more information on licensing and terms of use. # https://morningstarsecurity.com/research/whatweb ## Plugin.define do name "Hughes-Satellite-Router" authors [ "Brendan Coles <bcoles@gmail.com>", # 2011-08-14 ] version "0.1" description "Hughes IPoS (IP over Satellite) router" website "http://www.hughes.com/ProductsAndTechnology/BroadbandSatelliteSystems/Pages/default.aspx" # ShodanHQ results as at 2011-08-14 # # 3,874 for HUGHES Terminal # Google results as at 2011-08-14 # # 2 for inurl:sys_info "Print this page. It will be needed if your system fails." # Dorks # dorks [ 'inurl:sys_info "Print this page. It will be needed if your system fails."' ] # Matches # matches [ # Frameset { :text=>'<frame src=/fs/dynaform/dw_logo.html scrolling=no marginheight=0 marginwidth=0 NORESIZE>' }, # Model Detection # Frameset # Title { :model=>/<title>([A-Z]{0,2}[\d]{1,5}[A-Z]?) System Control Center<\/title>/ }, # Model Detection # /fs/dynaform/welcome.html { :url=>"/fs/dynaform/welcome.html", :model=>/<ctrlCenter style="font-size: 14pt; color: #000000; font-weight: bold">([^\s]+) <\/ctrlCenter>/ }, # Version Detection # /sys_info/ { :url=>"/sys_info/", :version=>/<\/td><\/tr><tr><td><div class=text>Software Release:<\/td><td><div class=text>([^<^\s]+)<\/td><\/tr>/ }, # MAC Address Detection # /sys_info/ { :url=>"/sys_info/", :string=>/<\/td><\/tr><tr><td><div class=text>LAN[\d]{1,2} MAC Address:<\/td><td><div class=text>([A-F\d:]{17})<\/td><\/tr>/ }, # WWW-Authenticate Header { :search=>"headers[www-authenticate]", :regexp=>/^Basic realm="HUGHES Terminal"$/ }, ] end
urbanadventurer/WhatWeb
plugins/hughes-satellite-router.rb
Ruby
gpl-2.0
1,736
.jumbotron { position: relative; padding: 40px 0; } .jumbotron h1 { font-size: 52px; letter-spacing: -1px; line-height: 1; margin: 0 0 10px 0; } .jumbotron p { font-size: 19.5px; line-height: 1.275; margin: 0 0 20px 0; } .jumbotron .btn { margin-top: 10px; } .jumbotron .btn-large { margin-top: 20px; font-size: 17px; } .masthead { padding: 80px 0 60px; text-align: center; } .masthead h1 { font-size: 91px; } .masthead p { font-size: 39px; } .masthead .btn-large { font-size: 26px; padding: 13px 26px; } .jumbotron.has-image { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .masthead.has-image { text-align: right; } .thumbnails { margin-bottom: 20px; margin-right: -10px; list-style: none; *zoom: 1; } .thumbnails:before, .thumbnails:after { display: table; content: ""; line-height: 0; } .thumbnails:after { clear: both; } .row-fluid .thumbnails { margin-right: 0; } .thumbnails > li { float: right; position: relative; margin-bottom: 20px; margin-right: 10px; } .thumbnail { border: 1px solid #ddd; display: block; padding: 4px; line-height: 20px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.055); -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.055); box-shadow: 0 1px 3px rgba(0,0,0,0.055); -webkit-transition: all .2s ease-in-out; -moz-transition: all .2s ease-in-out; -o-transition: all .2s ease-in-out; transition: all .2s ease-in-out; } a.thumbnail:hover { border-color: #1ba1e2; -webkit-box-shadow: 0 1px 4px rgba(0,105,214,0.25); -moz-box-shadow: 0 1px 4px rgba(0,105,214,0.25); box-shadow: 0 1px 4px rgba(0,105,214,0.25); } .thumbnail > img { display: block; max-width: 100%; margin-right: auto; margin-left: auto; } .thumbnail .caption { padding: 9px; color: #666; } .thumbnails.paper > li:before, .thumbnails.paper > li:after { content: ''; position: absolute; z-index: -2; bottom: 15px; right: 10px; width: 50%; height: 20%; box-shadow: 0 15px 10px rgba(0,0,0,0.7); -webkit-transform: rotate(-3deg); -moz-transform: rotate(-3deg); -ms-transform: rotate(-3deg); -o-transform: rotate(-3deg); transform: rotate(-3deg); } .thumbnails.paper > li:after { left: 10px; right: auto; -webkit-transform: rotate(3deg); -moz-transform: rotate(3deg); -ms-transform: rotate(3deg); -o-transform: rotate(3deg); transform: rotate(3deg); } .thumbnails.paper .thumbnail { border: none; padding: 0; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .thumbnails.paper a.thumbnail.paper:hover { -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .t3-logo, .t3-logo-small { display: block; text-decoration: none; text-indent: -9999em; text-align: right; background-repeat: no-repeat; background-position: center; } .t3-logo { width: 182px; height: 50px; } .t3-logo-small { width: 60px; height: 30px; } .t3-logo, .t3-logo-color { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-big-color.png"); } .t3-logo-small, .t3-logo-small.t3-logo-color { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-small-color.png"); } .t3-logo-dark { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-big-dark.png"); } .t3-logo-small.t3-logo-dark { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-small-dark.png"); } .t3-logo-light { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-big-light.png"); } .t3-logo-small.t3-logo-light { background-image: url("http://joomlart.s3.amazonaws.com/images/jat3v3-documents/logo-complete/t3logo-small-light.png"); } .wrap { width: auto; clear: both; } .offset-12 { margin-right: -938px; } .offset-11 { margin-right: -859px; } .offset-10 { margin-right: -780px; } .offset-9 { margin-right: -701px; } .offset-8 { margin-right: -622px; } .offset-7 { margin-right: -543px; } .offset-6 { margin-right: -464px; } .offset-5 { margin-right: -385px; } .offset-4 { margin-right: -306px; } .offset-3 { margin-right: -227px; } .offset-2 { margin-right: -148px; } .offset-1 { margin-right: -69px; } .row-fluid .spanfirst { margin-right: 0 !important; } @media (max-width: 767px) { .always-show .mega > .mega-dropdown-menu, .always-show .dropdown-menu { display: block !important; position: static; } } .wrap { width: auto; clear: both; } body { background-color: #F5F5F5; color: #444; font-family: 'open_sansregular', sans-serif; font-size: 13px; line-height: 20px; margin: 0; } a { color: #1ba1e2; text-decoration: none; } a:hover { color: #1ba1e2; } img { max-width: 100% !important; } .img-rounded { -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .img-polaroid { padding: 4px; background-color: #fff; border: 1px solid #ccc; border: 1px solid rgba(0,0,0,0.2); -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1); -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0,0,0,0.1); } .img-circle { -webkit-border-radius: 500px; -moz-border-radius: 500px; border-radius: 500px; } ------------------------------------------------------- table { background-color: transparent; border-collapse: collapse; border-spacing: 0; } th, td { line-height: 20px; padding: 8px 10px; text-align: right; vertical-align: top; } td { border-top: 1px solid #ddd; } th { background: #444; color: #eee; font-weight: bold; } th a { color: #eee; } th a:hover, th a:focus, th a:active { color: #fff; } .cat-list-row0:hover, .cat-list-row1:hover { background: #f5f5f5; } .cat-list-row1, tr.cat-list-row1 td { background: #f9f9f9; } table.contentpane, table.tablelist, table.category, table.admintable, table.blog { width: 100%; } table.contentpaneopen { border: 0; } ------------------------------------------------------- .star { color: #ffc40d; } .red { color: #d21f45; } .element-invisible { position: absolute; padding: 0; margin: 0; border: 0; height: 1px; width: 1px; overflow: hidden; } #ja-maincontent #system-message-container #system-message { margin-bottom: 0px !important; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } #ja-maincontent #system-message-container #system-message > div { padding: 20px 20px 10px 20px; } form { margin: 0 0 20px; } input, textarea { width: 210px; } textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input { -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); -webkit-transition: border linear .2s, box-shadow linear .2s, width 0.7s ease 0s; -moz-transition: border linear .2s, box-shadow linear .2s, width 0.7s ease 0s; -o-transition: border linear .2s, box-shadow linear .2s, width 0.7s ease 0s; transition: border linear .2s, box-shadow linear .2s, width 0.7s ease 0s; } textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus, .uneditable-input:focus { border-color: #999999; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(0,0,0,.25); -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(0,0,0,.25); box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(0,0,0,.25); } input[type="file"], input[type="image"], input[type="submit"], input[type="reset"], input[type="button"], input[type="radio"], input[type="checkbox"] { width: auto; } select, input[type="file"] { height: 30px; line-height: 30px; } select { width: 220px; border: 1px solid #ddd; } select[multiple], select[size] { height: auto; } .radio, .checkbox { padding-right: 18px; } .radio input[type="radio"], .checkbox input[type="checkbox"] { margin-right: -18px; } .controls > .radio:first-child, .controls > .checkbox:first-child { padding-top: 5px; } .radio.inline, .checkbox.inline { padding-top: 5px; margin-bottom: 0; } .radio.inline + .radio.inline, .checkbox.inline + .checkbox.inline { margin-right: 10px; } .input-mini { width: 60px; } .input-small { width: 90px; } .input-medium { width: 150px; } .input-large { width: 210px; } .input-xlarge { width: 270px; } .input-xxlarge { width: 530px; } .form-actions { padding: 19px 20px 20px; margin-top: 20px; margin-bottom: 20px; background-color: #f5f5f5; border-top: 1px solid #ddd; } .help-block, .help-inline { color: #6a6a6a; } .help-block { margin-bottom: 10px; } .input-append, .input-prepend { margin-bottom: 5px; } .form-search input, .form-search textarea, .form-search select, .form-search .help-inline, .form-search .uneditable-input, .form-search .input-prepend, .form-search .input-append, .form-inline input, .form-inline textarea, .form-inline select, .form-inline .help-inline, .form-inline .uneditable-input, .form-inline .input-prepend, .form-inline .input-append, .form-horizontal input, .form-horizontal textarea, .form-horizontal select, .form-horizontal .help-inline, .form-horizontal .uneditable-input, .form-horizontal .input-prepend, .form-horizontal .input-append { margin-bottom: 0; } .form-search .input-append, .form-inline .input-append, .form-search .input-prepend, .form-inline .input-prepend { margin-bottom: 0; } .form-search .radio, .form-search .checkbox, .form-inline .radio, .form-inline .checkbox { padding-right: 0; margin-bottom: 0; } .form-search .radio input[type="radio"], .form-search .checkbox input[type="checkbox"], .form-inline .radio input[type="radio"], .form-inline .checkbox input[type="checkbox"] { margin-left: 3px; margin-right: 0; } .control-group { margin-bottom: 10px; } legend + .control-group { margin-top: 20px; } .form-horizontal .control-group { margin-bottom: 20px; } .form-horizontal .control-label { width: 140px; padding-top: 5px; text-align: left; } .form-horizontal .controls { margin-right: 160px; } .form-horizontal .help-block { margin-top: 10px; margin-bottom: 0; } .form-horizontal .form-actions { padding-right: 160px; } .btn { padding: 4px 14px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.1); -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.1); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.1); color: #444; text-shadow: 0 1px 1px rgba(255,255,255,0.75); background-color: #f8f8f8; background-image: -moz-linear-gradient(top,#ffffff,#eee); background-image: -webkit-gradient(linear,0 0,0 100%,from(#ffffff),to(#eee)); background-image: -webkit-linear-gradient(top,#ffffff,#eee); background-image: -o-linear-gradient(top,#ffffff,#eee); background-image: linear-gradient(to bottom,#ffffff,#eee); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffeeeeee', GradientType=0); border-color: #eee #eee #c8c8c8; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #eee; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn:hover, .btn:focus, .btn:active, .btn.active, .btn.disabled, .btn[disabled] { color: #444; background-color: #eee; *background-color: #e1e1e1; } .btn:active, .btn.active { background-color: #d5d5d5 \9; } .btn:hover, .btn a.btn:hover { text-decoration: none; background-color: #eee; } .btn:focus, .btn a.btn:focus { outline: 0; } .btn.active, .btn:active, .btn a.btn:active { text-decoration: none; outline: 0; -webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05); box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05); } .btn-large { padding: 9px 14px; font-size: 15px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.5); -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.5); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.5); } .btn-small { padding: 3px 9px; font-size: 12px; } .btn-mini { padding: 2px 6px; font-size: 11px; } .btn { border-color: #c5c5c5; border-color: rgba(0,0,0,0.15) rgba(0,0,0,0.15) rgba(0,0,0,0.25); } .btn-primary { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #35ace6; background-image: -moz-linear-gradient(top,#47b4e9,#1ba1e2); background-image: -webkit-gradient(linear,0 0,0 100%,from(#47b4e9),to(#1ba1e2)); background-image: -webkit-linear-gradient(top,#47b4e9,#1ba1e2); background-image: -o-linear-gradient(top,#47b4e9,#1ba1e2); background-image: linear-gradient(to bottom,#47b4e9,#1ba1e2); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff46b4e9', endColorstr='#ff1ba1e2', GradientType=0); border-color: #1ba1e2 #1ba1e2 #13709e; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #1ba1e2; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] { color: #fff; background-color: #1ba1e2; *background-color: #1891cb; } .btn-primary:active, .btn-primary.active { background-color: #1681b4 \9; } .btn-warning { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #de6847; background-image: -moz-linear-gradient(top,#e17658,#d9532d); background-image: -webkit-gradient(linear,0 0,0 100%,from(#e17658),to(#d9532d)); background-image: -webkit-linear-gradient(top,#e17658,#d9532d); background-image: -o-linear-gradient(top,#e17658,#d9532d); background-image: linear-gradient(to bottom,#e17658,#d9532d); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe07658', endColorstr='#ffd9532d', GradientType=0); border-color: #d9532d #d9532d #9d391c; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #d9532d; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-warning:hover, .btn-warning:focus, .btn-warning:active, .btn-warning.active, .btn-warning.disabled, .btn-warning[disabled] { color: #fff; background-color: #d9532d; *background-color: #c84824; } .btn-warning:active, .btn-warning.active { background-color: #b34120 \9; } .btn-danger { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #dc3357; background-image: -moz-linear-gradient(top,#e34163,#d21f45); background-image: -webkit-gradient(linear,0 0,0 100%,from(#e34163),to(#d21f45)); background-image: -webkit-linear-gradient(top,#e34163,#d21f45); background-image: -o-linear-gradient(top,#e34163,#d21f45); background-image: linear-gradient(to bottom,#e34163,#d21f45); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe24163', endColorstr='#ffd21f45', GradientType=0); border-color: #d21f45 #d21f45 #8f152f; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #d21f45; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger.active, .btn-danger.disabled, .btn-danger[disabled] { color: #fff; background-color: #d21f45; *background-color: #bc1c3e; } .btn-danger:active, .btn-danger.active { background-color: #a61836 \9; } .btn-success { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #98c935; background-image: -moz-linear-gradient(top,#a3d53e,#88b828); background-image: -webkit-gradient(linear,0 0,0 100%,from(#a3d53e),to(#88b828)); background-image: -webkit-linear-gradient(top,#a3d53e,#88b828); background-image: -o-linear-gradient(top,#a3d53e,#88b828); background-image: linear-gradient(to bottom,#a3d53e,#88b828); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffa2d53d', endColorstr='#ff88b828', GradientType=0); border-color: #88b828 #88b828 #5a791a; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #88b828; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-success:hover, .btn-success:focus, .btn-success:active, .btn-success.active, .btn-success.disabled, .btn-success[disabled] { color: #fff; background-color: #88b828; *background-color: #79a323; } .btn-success:active, .btn-success.active { background-color: #698e1f \9; } .btn-info { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #35ace6; background-image: -moz-linear-gradient(top,#47b4e9,#1ba1e2); background-image: -webkit-gradient(linear,0 0,0 100%,from(#47b4e9),to(#1ba1e2)); background-image: -webkit-linear-gradient(top,#47b4e9,#1ba1e2); background-image: -o-linear-gradient(top,#47b4e9,#1ba1e2); background-image: linear-gradient(to bottom,#47b4e9,#1ba1e2); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff46b4e9', endColorstr='#ff1ba1e2', GradientType=0); border-color: #1ba1e2 #1ba1e2 #13709e; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #1ba1e2; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-info:hover, .btn-info:focus, .btn-info:active, .btn-info.active, .btn-info.disabled, .btn-info[disabled] { color: #fff; background-color: #1ba1e2; *background-color: #1891cb; } .btn-info:active, .btn-info.active { background-color: #1681b4 \9; } .btn-inverse { color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #535353; background-image: -moz-linear-gradient(top,#5e5e5e,#444); background-image: -webkit-gradient(linear,0 0,0 100%,from(#5e5e5e),to(#444)); background-image: -webkit-linear-gradient(top,#5e5e5e,#444); background-image: -o-linear-gradient(top,#5e5e5e,#444); background-image: linear-gradient(to bottom,#5e5e5e,#444); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5d5d5d', endColorstr='#ff444444', GradientType=0); border-color: #444 #444 #1e1e1e; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #444; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .btn-inverse:hover, .btn-inverse:focus, .btn-inverse:active, .btn-inverse.active, .btn-inverse.disabled, .btn-inverse[disabled] { color: #fff; background-color: #444; *background-color: #373737; } .btn-inverse:active, .btn-inverse.active { background-color: #2b2b2b \9; } .invalid { border-color: #d21f45; } label.invalid { color: #d21f45; } .nav { margin-bottom: 20px; } .nav > li > a:hover { background-color: #eee; color: #222; } .nav .dropdown-toggle .caret { border-top-color: #1ba1e2; border-bottom-color: #1ba1e2; margin-top: 8px; margin-right: 5px; } .nav .dropdown-toggle:hover .caret { border-top-color: #fff; border-bottom-color: #fff; } .nav .active .dropdown-toggle .caret { border-top-color: #fff; border-bottom-color: #fff; } .nav-tabs .active .dropdown-toggle .caret { border-top-color: #666; border-bottom-color: #666; } .caret { border-top: 4px solid #000; } .dropdown .caret { margin-top: 8px; margin-right: 2px; } .dropdown-menu { background-color: #fff; border: 1px solid rgba(0,0,0,0.2); padding: 0; margin: 0; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-box-shadow: 0 5px 10px rgba(0,0,0,0.2); -moz-box-shadow: 0 5px 10px rgba(0,0,0,0.2); box-shadow: 0 5px 10px rgba(0,0,0,0.2); } .dropdown-menu a { font-weight: normal; padding: 3px 20px; color: #444; text-shadow: none; } .nav li.dropdown.open > .dropdown-toggle, .nav li.dropdown.active > .dropdown-toggle, .nav li.dropdown.open.active > .dropdown-toggle, .nav > li.dropdown.open.active > a:hover { background-color: transparent; color: #1ba1e2; } .nav li.dropdown > .dropdown-toggle .caret { border-top-color: #666; border-bottom-color: #666; } .nav li.dropdown > .dropdown-toggle:hover .caret { border-top-color: #fff; border-bottom-color: #fff; } .nav li.dropdown.open > .dropdown-toggle .caret, .nav li.dropdown.active > .dropdown-toggle .caret, .nav li.dropdown.open.active > .dropdown-toggle .caret { border-top-color: #fff; border-bottom-color: #fff; } .dropdown-menu li > a:hover, .dropdown-menu li > a:focus, .dropdown-submenu:hover > a { color: #222; background: #eee; } .dropdown-menu .active > a, .dropdown-menu .active > a:hover { color: #fff; background: #1ba1e2; } .dropdown-menu .disabled > a, .dropdown-menu .disabled > a:hover { color: #999; } .dropdown-menu .disabled > a:hover { background-color: transparent; } .dropdown-submenu > .dropdown-menu { margin: -1px -1px 0; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .dropdown-submenu > a:after { border-width: 4px 4px 4px 0; border-right-color: #cccccc; margin-top: 5px; margin-left: -10px; } .dropdown-submenu:hover > a:after { border-right-color: #222; } .ja-navhelper { background: #2f2f2f; color: #666; } .breadcrumb { padding: 10px 0; margin: 0; background-color: transparent; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .breadcrumb li { text-shadow: none; } .breadcrumb a { color: #666; } .breadcrumb .divider { padding: 0 5px; color: #666; } .breadcrumb .divider img { vertical-align: middle; } .breadcrumb .active { color: #999; } .module_menu .nav { margin-bottom: 20px; } .module_menu .nav > li { border-top: 1px solid #eee; } .module_menu .nav > li > a { color: #444; padding: 5px; } .module_menu .nav > li:first-child { border-top: 0; } .module_menu .nav > li:first-child > a { color: #444; padding-top: 0; border-top: 0; } .module_menu .nav > li > a:hover { background: transparent; color: #1ba1e2; } .module_menu .nav > li.active > a { color: #1ba1e2; } .ja-mainnav { height: 40px; position: relative; z-index: 40; } .ja-mainnav .navbar { color: #666; margin-bottom: 0; margin-top: 0; } .ja-mainnav .navbar-inner { background: transparent; filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); min-height: 40px; padding: 0; border: 0; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .ja-mainnav .navbar .nav { margin: 0; } .ja-mainnav .navbar .nav > li > a { border-top: 0; font-family: 'open_sans_lightregular'; font-size: 18px; padding: 10px 15px; text-shadow: none; } .ja-mainnav .navbar .nav > li:first-child > a { padding-right: 0; } .ja-mainnav .navbar .nav > li > a:focus, .ja-mainnav .navbar .nav > li > a:hover { background: transparent; color: #fff; text-shadow: none; } .ja-mainnav .navbar .nav > .active > a, .ja-mainnav .navbar .nav > .active > a:hover, .ja-mainnav .navbar .nav > .active > a:focus { background-color: transparent; color: #fff; font-family: 'open_sansregular'; text-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .ja-mainnav .navbar .btn-navbar { float: right; padding: 7px 10px; margin: 7px 20px 0; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,0.25); background-color: #e8e8e8; background-image: -moz-linear-gradient(top,#f2f2f2,#d9d9d9); background-image: -webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#d9d9d9)); background-image: -webkit-linear-gradient(top,#f2f2f2,#d9d9d9); background-image: -o-linear-gradient(top,#f2f2f2,#d9d9d9); background-image: linear-gradient(to bottom,#f2f2f2,#d9d9d9); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffd8d8d8', GradientType=0); border-color: #d9d9d9 #d9d9d9 #b3b3b3; border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25); *background-color: #d9d9d9; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075); -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075); } .ja-mainnav .navbar .btn-navbar:hover, .ja-mainnav .navbar .btn-navbar:focus, .ja-mainnav .navbar .btn-navbar:active, .ja-mainnav .navbar .btn-navbar.active, .ja-mainnav .navbar .btn-navbar.disabled, .ja-mainnav .navbar .btn-navbar[disabled] { color: #fff; background-color: #d9d9d9; *background-color: #cccccc; } .ja-mainnav .navbar .btn-navbar:active, .ja-mainnav .navbar .btn-navbar.active { background-color: #bfbfbf \9; } .ja-mainnav .navbar .btn-navbar .icon-bar { width: 18px; height: 2px; background-color: #f5f5f5; -webkit-border-radius: 1px; -moz-border-radius: 1px; border-radius: 1px; -webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.25); -moz-box-shadow: 0 1px 0 rgba(0,0,0,0.25); box-shadow: 0 1px 0 rgba(0,0,0,0.25); } .ja-mainnav .btn-navbar .icon-bar + .icon-bar { margin-top: 3px; } .ja-mainnav .dropdown .caret { margin-right: 5px; } .ja-mainnav .dropdown-menu { -webkit-box-shadow: 0 5px 10px rgba(0,0,0,0.2); -moz-box-shadow: 0 5px 10px rgba(0,0,0,0.2); box-shadow: 0 5px 10px rgba(0,0,0,0.2); } .ja-mainnav .dropdown-menu a { border-top: 1px solid #eee; padding: 5px 20px; text-shadow: none; } .ja-mainnav .dropdown-menu li:first-child > a { border-top: 0; } .ja-mainnav .dropdown-menu a { display: block; } .ja-mainnav .navbar .nav > li > .dropdown-menu:before { display: none; } .ja-mainnav .navbar .nav > li > .dropdown-menu:after { display: none; } .ja-mainnav .nav li.dropdown.open > .dropdown-toggle { background-color: transparent; } .ja-mainnav .nav li.dropdown.active > .dropdown-toggle, .ja-mainnav .nav li.dropdown.open.active > .dropdown-toggle { background-color: transparent; } .ja-mainnav .dropdown-menu li > a:hover, .ja-mainnav .dropdown-menu li > a:focus, .ja-mainnav .dropdown-submenu:hover > a { background: #666; color: #fff; } .ja-mainnav .dropdown-menu .active > a, .ja-mainnav .dropdown-menu .active > a:hover { color: #1ba1e2; background: none; filter: background(none); } .ja-mainnav .dropdown-menu .disabled > a, .ja-mainnav .dropdown-menu .disabled > a:hover { color: #999; } .ja-mainnav .dropdown-menu .disabled > a:hover { background-color: transparent; } .dropdown-menu li > a:hover, .dropdown-menu li > a:focus, .dropdown-submenu:hover > a { background-color: #666666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#666666',endColorstr='#666666',GradientType=0); } .t3-module { background: #fff; color: #666; min-height: 240px; margin-bottom: 10px; position: relative; } .t3-module .module-inner { padding: 20px; } .module-title { background: inherit; color: #444; font-weight: normal; font-size: 30px; line-height: 1; margin: 0; padding: 0; } .module-ct { background: inherit; color: inherit; padding: 10px 0 0; } .t3-module ul, .t3-module ol { margin-right: 20px; } .t3-module ul.unstyled, .t3-module ol.unstyled, .t3-module ul.nav, .t3-module ol.nav { margin-right: 0; } .module.no-padding .module-inner { padding: 0; } .module.no-padding .module-ct { padding: 0; } .module.no-bg { background-color: transparent; } .module.height-auto { min-height: 1px; } .module.mod-hilite1 { background: #1ba1e2; color: #fff; } .module.mod-hilite1 .module-title { color: #fff; } .module.mod-hilite1 a { color: #fff; } .module.mod-hilite2 { background: #d21f45; color: #fff; } .module.mod-hilite2 .module-title { color: #fff; } .module.mod-hilite3 { background: #3b5998; color: #fff; } .module.mod-hilite3 .module-title { color: #fff; } .module.mod-hilite4 { background: #88b828; color: #fff; } .module.mod-hilite4 .module-title { color: #fff; } .module.mod-hilite4 a { color: #dff0bc; } .module.mod-hilite4 a:hover { text-decoration: underline; } .module.mod-hilite5 { background: #d9532d; color: #fff; } .module.mod-hilite5 .module-title { color: #fff; } .module.mod-hilite6 { background: #c22b7c; color: #fff; } .module.mod-hilite6 .module-title { color: #fff; } .module.mod-hilite7 { background: #472b6b; color: #fff; } .module.mod-hilite7 .module-title { color: #fff; } .module.mod-hilite8 { background: #e842a4; color: #fff; } .module.mod-hilite8 .module-title { color: #fff; } #form-login-username #modlgn-username, #form-login-password #modlgn-passwd { width: 80%; } .banneritem { padding: 10px 0; border-top: 1px solid #ddd; } .banneritem:first-child { margin-top: 10px; } .banneritem a { font-weight: bold; } .bannerfooter { border-top: 1px solid #ddd; font-size: 11px; padding-top: 10px; text-align: left; } .categories-module h4, ul.categories-module h4, .category-module h4, ul.category-module h4 { font-size: 13px; font-weight: normal; margin: 0; } .feed h4 { font-weight: bold; } .feed .newsfeed, .feed ul.newsfeed { border-top: 1px solid #eee; } .feed .newsfeed .feed-link, .feed .newsfeed h5.feed-link, .feed ul.newsfeed .feed-link, .feed ul.newsfeed h5.feed-link { font-size: 13px; font-weight: normal; margin: 0; } ul.newsfeed { border: 0 !important; margin: 0; padding: 0; list-style: none; } ul.newsfeed .newsfeed-item { border-bottom: 1px solid #e5e5e5; margin-bottom: 10px; padding: 0 0 10px 0; } ul.newsfeed .newsfeed-item:last-child { border: 0; margin-bottom: 0; padding-bottom: 0; } .latestusers, ul.latestusers { margin-right: 0; } .latestusers li, ul.latestusers li { background: #eee; display: inline-block; padding: 5px 10px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .stats-module dt, .stats-module dd { display: inline-block; margin: 0; } .stats-module dt { font-weight: bold; width: 35%; } .stats-module dd { width: 60%; } div.tagspopular ul { display: block; margin: 0; padding: 0; list-style: none; overflow: hidden; } div.tagspopular ul li { color: #666; display: inline-block; margin: 0 0 5px 5px; } div.tagspopular ul li a { background: #eee; border-radius: 3px; color: #666; display: block; padding: 2px 5px; } div.tagspopular ul li a:hover, div.tagspopular ul li a:focus, div.tagspopular ul li a:active { background: #1ba1e2; color: #fff; text-decoration: none; } div.tagssimilar ul { margin: 0; padding: 0; list-style: none; } div.tagssimilar ul li { border-bottom: 1px solid #eee; padding: 8px 0; } div.tagssimilar ul li a { color: #666; } div.tagssimilar ul li a:hover, div.tagssimilar ul li a:focus, div.tagssimilar ul li a:active { color: #1ba1e2; } .mod-languages { float: left; } div.mod-languages ul.lang-inline li { margin-right: 0; } .mod-preview-info { z-index: 1; } .blog-featured { background: #fff; padding: 20px; } .blog-featured hr { display: none; } .items-leading .leading { margin-bottom: 30px; } .items-row { background: #fff; min-height: 240px; } .items-row .item { padding: 20px; } .divider-vertical { margin: 0 0 10px; border: 0; } .item-page { background: #fff; padding: 20px; } .article-aside { border-top: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; color: #999; font-size: 12px; margin-bottom: 20px; padding: 10px 0; } .article-info { margin: 0; width: 90%; } .article-info .article-info-term { display: none; } .article-info dd { float: right; margin: 3px 0 3px 10px; white-space: nowrap; } .article-info dd span a { color: #444; } .article-info dd span a:hover, .article-info dd span a:focus, .article-info dd span a:active { color: #1ba1e2; } .article-info dd.createdby { background: url(../../../images/icon-user.png) no-repeat right center; padding-right: 25px; } .article-info dd.published { background: url(../../../images/icon-date.png) no-repeat right center; padding-right: 25px; } .article-info dd.category-name { background: url(../../../images/icon-category.png) no-repeat right center; padding-right: 25px; } .article-footer { color: #999; font-size: 12px; margin-bottom: 20px; } article img[align=left], .img_caption.left { margin: 0 0 20px 10px; } article img[align=right], .img_caption.right { margin: 0 10px 20px 0; } .img-intro-none, .img-intro-left, .img-intro-right, .img-fulltext-none, .img-fulltext-left, .img-fulltext-right, .img_caption { position: relative; } .img-intro-none, .img-intro-left, .img-intro-right, .img-fulltext-none, .img-fulltext-left, .img-fulltext-right, .img_caption { margin-bottom: 20px; max-width: 100%; } .img-fulltext-left { float: right; margin-left: 10px; } .img-fulltext-right { float: left; margin-right: 10px; } .img-intro-none img, .img-intro-left img, .img-intro-right img, .img-fulltext-none img, .img-fulltext-left img, .img-fulltext-right img { margin: 0; } .article-content img[align="left"], .article-content .img_caption.right, .article-intro img[align="left"], .article-intro .img_caption.right { margin-top: 5px; } .img_caption img { margin-bottom: 1px !important; } .img_caption p.img_caption { background: #eee; color: #666; font-size: 11px; width: 100%; margin: 0; padding: 5px; text-align: center; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; clear: both; } .pull-none { margin-bottom: 30px; } article aside .btn-group > .dropdown-toggle { background: transparent; border: 0; padding: 0; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .login_form fieldset, .login fieldset { padding: 15px 0 0; } .login_form fieldset p, .login fieldset p { margin: 0 0 5px; } .login_form label, .login label { display: block; font-weight: bold; } .login-fields { margin: 0 0 10px; } .login_form .inputbox, .login-fields .required { margin-right: 10px; width: 150px; } .login_form .remember .inputbox { width: 20px; } .form-register fieldset { padding: 0 0 10px; } .form-register p { margin: 0 0 5px; } .form-register p.form-des { margin: 15px 0; } .form-register label { display: block; float: right; font-weight: bold; text-align: left; width: 130px; } .form-register .inputbox { margin-right: 10px; width: 200px; } .form-register .button { margin-right: 140px; } .registration fieldset dt { margin-left: 5px; } .admintable textarea { max-width: 90% !important; resize: none; } #mailto-window { background: #fff; margin: 10px 0 20px; padding: 0; position: relative; } #mailto-window h2 { font-size: 150%; margin-top: 0; margin-bottom: 20px; } #mailto-window .mailto-close { background: #FFF; background: -moz-linear-gradient(bottom,#ccc,#f0f0f0); background: -webkit-linear-gradient(bottom,#ccc,#f0f0f0); border: 1px solid #CCC; border-radius: 3px; color: #666; font-size: 92%; padding: 2px 5px; position: absolute; top: -10px; left: 0px; text-shadow: 1px 1px 0 #f0f0f0; } #mailto-window .mailto-close a { color: #666; } #mailto-window .mailto-close:hover { border-color: #999; box-shadow: 0 0 3px rgba(0,0,0,0.2); } #mailtoForm .formelm { padding: 5px 0; vertical-align: middle; overflow: hidden; } #mailtoForm .formelm label { display: block; float: right; font-weight: bold; vertical-align: middle; width: 100px; } #mailtoForm p { margin-top: 20px; } #mailtoForm .inputbox { width: 70%; } #mailtoForm .button { margin-left: 5px; } #adminForm .controls .editor { *zoom: 1; } #adminForm .controls .editor:before, #adminForm .controls .editor:after { display: table; content: ""; line-height: 0; } #adminForm .controls .editor:after { clear: both; } .user-details { padding: 10px 0; } .user-details p { margin: 0 0 5px; } .user-details label { display: block; float: right; font-weight: bold; text-align: left; width: 130px; } .user-details .inputbox { margin-right: 10px; width: 200px; } .user-details .button { margin-right: 140px; } .user-details .paramlist .paramlist_key { padding: 0 0 5px; width: 130px; } .user-details .paramlist .paramlist_value { padding: 0 0 5px; } .user-details .user_name span { font-weight: bold; padding-right: 10px; } .reset .form-validate p, .remind .form-validate p { background: #eee; border: 1px solid #ddd; margin-bottom: 20px; padding: 10px 20px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .reset .form-validate fieldset dl, .remind .form-validate fieldset dl { margin: 0; } .reset .form-validate fieldset dt, .remind .form-validate fieldset dt { margin: 4px 0 0 0; } .profile { background: #fff; padding: 20px; } .profile #users-profile-core { width: 100%; } .profile .dl-horizontal dd { border-bottom: 1px solid #e5e5e5; padding: 10px 20px 10px 0; margin-right: 120px; } .profile .dl-horizontal dt { border-bottom: 1px solid #e5e5e5; padding: 10px 0; } #ja-mainbody .search { background: #fff; padding: 20px; } #searchForm { padding: 10px 20px; border: 1px solid #ddd; background: #eee; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; *zoom: 1; } #searchForm:before, #searchForm:after { display: table; content: ""; line-height: 0; } #searchForm:after { clear: both; } #searchForm fieldset { margin: 20px 0; } #searchForm legend { margin-bottom: 10px; } #searchForm .phrases-box .radio { padding-top: 0; } #searchForm .phrases-box .radio input[type="radio"] { margin-top: 3px; } .phrases-box input, .phrases-box label, .form-limit input, .form-limit label, .only label { display: inline-block; margin-left: 10px; } .search .only legend { display: block; margin-bottom: 20px; overflow: hidden; } .search .only label { display: block; float: right; } .phrases-box input { margin: 0; } .search-results { margin-top: 20px; } .search-results .result-title { font-size: 15px; margin-top: 20px; } .search-results .result-category { font-size: 11px; color: #999; } .search-results .result-text { margin-top: 5px; margin-bottom: 5px; } .search-results .result-created { font-size: 11px; color: #999; } .contact .accordion-heading .accordion-toggle { font-weight: bold; } .contact-form input[type^="checkbox"] { vertical-align: top; } .contact-form input[type^="checkbox"] + label { display: inline-block; } #archive-items > li { line-height: normal; margin: 0; overflow: visible; padding: 0; } #archive-items div.intro { clear: both; overflow: hidden; } .categories-list .category-desc { background: #1ba1e2; color: #fff; margin-bottom: 10px; min-height: 240px; padding: 0; } .categories-list .category-desc a { text-decoration: underline; } .categories-list .category-desc h2 { color: #fff; margin: 0 0 -10px; padding: 10px 20px 0; } .categories-list .category-desc p { padding: 20px; } .categories-list .category-item { background: #fff; margin-bottom: 10px; min-height: 240px; } .categories-list .category-item .item-title { border: 0; margin-bottom: 0; padding: 10px 20px; } .categories-list .category-item .category-desc { background: #fff; color: #444; min-height: 1px; padding: 0 20px 20px; } .categories-list .category-item .category-desc p { padding: 0; } .category-list { background: #fff; padding: 20px; } .newsfeed { background: #fff; padding: 20px; } .newsfeed > h2 { border-bottom: 1px solid #ddd; padding-bottom: 20px; margin-bottom: 20px; } .newsfeed-category form { overflow: hidden; } .feed-description { margin-bottom: 40px; } .edit { background: #fff; padding: 20px; } .edit .nav-tabs > .active > a { background: transparent; } .edit .nav-tabs > li > a:hover { background: #f0f0f0; border: 1px solid #ddd; color: #444; } .edit textarea { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .button2-left, .button2-left div { float: right; } .button2-right, .button2-right div { float: left; } .button2-left { margin: 5px 0 0 5px; } .button2-right { margin: 5px 5px 0 0; } .button2-left a, .button2-right a, .button2-left span, .button2-right span { background: #eee; border: 1px solid #e1e1e1; color: #999; cursor: pointer; display: block; float: right; padding: 2px 10px; border-radius: 0px; } .button2-left span, .button2-right span { color: #999; cursor: default; } .button2-left .page a, .button2-right .page a, .button2-left .page span, .button2-right .page span { padding: 0 6px; } .button2-left a:hover, .button2-right a:hover { background: #e1e1e1; color: #444; text-decoration: none; } .controls img.calendar { cursor: pointer; margin-right: 5px; } div.weblink-category table.category td > p { padding-left: 30px; } div.weblink-category table.category ul.actions { float: left; margin: -30px 0 0 0; padding: 0; list-style: none; } .weblink-category table.category ul.actions li a { background: none; padding-right: 0; } .weblink-category ul li a.category { background: none !important; padding-right: 0 !important; } .weblink-category ul.category li { padding: 5px; } .weblink-category ul.category li a { background: none; padding-right: 0; } .article-content .pagination ul { border-right: 1px solid #ddd; } .article-content .pagination ul li { float: right; padding: 10px 20px; line-height: normal; border: 1px solid #ddd; border-right: 0; } .article-content .pagination ul a { border: 0; text-decoration: none; background-color: transparent; line-height: normal; padding: 0; } .pagenavcounter { margin: 0 0 20px; font-weight: bold; } #article-index { float: left; margin: 0 20px 20px 0; padding: 10px; width: 30%; border: 1px solid #ddd; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } #article-index ul { margin: 0 20px 0 0; } .pagenav { margin: 0; padding: 0; list-style: none; } .pagenav li { margin: 0; padding: 0; float: right; } .pagenav li.pagenav-prev, .pagenav li.previous { margin-left: 10px; } .pagenav li a { background: #666; border: 1px solid #666; color: #fff; padding: 8px 10px; line-height: normal; -webkit-transition: 0.5s; -moz-transition: 0.5s; -o-transition: 0.5s; transition: 0.5s; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .pagenav li a:hover { background-color: #1ba1e2; border-color: #1ba1e2; color: #fff; } .counter { display: none; float: left; line-height: 1; margin: 10px 0; text-align: left; } div.pagination { background: #222222; margin: -12px 0 20px; line-height: 1; text-align: center; } div.pagination ul.pagination-list { margin: 0; padding: 0; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .pagination ul > li:first-child > a, .pagination ul > li:first-child > span { background: transparent; border: 0; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .pagination ul > li > a, .pagination ul > li > span { background: transparent; border: 0; color: #999; padding: 10px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .pagination ul > li > a:hover { background: #1ba1e2; color: #fff; } .pagination ul > li:last-child > a, .pagination ul > li:last-child > span { background: transparent; border: 0; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .pagination ul > li:last-child > a:hover { background: #1ba1e2; color: #fff; } .items-more h3 { margin: 0 0 5px; } .back_button a, .back_button a:hover, .back_button a:active { display: block; margin: 10px 0; } .filters { margin: 10px 0 5px; } .display-limit { margin: 10px 0 5px; } .filters .filter-search, .filters .display-limit { float: right; width: 50%; } .filters .display-limit { float: left; text-align: left; } #system-message dt { font-weight: bold; } #system-message dd { font-weight: bold; } #system-message dd.message ul, #system-message dd.error ul, #system-message dd.notice ul { margin: 0; padding: 0; } #system-message dd.message ul li, #system-message dd.error ul li, #system-message dd.notice ul li { background: none; margin: 0; padding: 5px; } .tip-wrap { background: #fff6df; border: 1px solid #fb3; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 0 3px rgba(0,0,0,0.4); -moz-box-shadow: 0 0 3px rgba(0,0,0,0.4); box-shadow: 0 0 3px rgba(0,0,0,0.4); max-width: 300px; z-index: 999; } .tip-title { border-bottom: 1px solid #fb3; font-weight: bold; padding: 5px 10px; } .tip-text { font-size: 13px; margin: 0; padding: 5px 10px; } .hasTip img { border: none; margin: 0 0 0 5px; } .readmore .btn { background: url(../../../images/readmore-bg-rtl.png) no-repeat right top transparent; border: 0; height: 20px; margin: 0; padding: 0; width: 20px; text-indent: -999em; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; -webkit-transition: none; -moz-transition: none; -o-transition: none; transition: none; } .readmore .btn:hover { background-position: right bottom; } .blog .tags { background: #fff; border-bottom: solid 1px #e5e5e5; padding: 10px 20px; } .tags span { margin-bottom: 3px; } .tags .label-info[href] { background: #1ba1e2; font-weight: normal; text-shadow: none; } .tags .label-info[href]:hover, .tags .label-info[href]:focus, .tags .label-info[href]:active { background: #1891cb; } .item-page .tags { margin-bottom: 15px; } .tag-category { background: #fff; padding: 20px; } .tag-category h2 { line-height: normal; margin-top: 0; } .tag-category ul.category { margin: 10px 0 0; } .tag-category ul.category li { list-style: none; padding: 10px 20px; border-bottom: solid 1px #e5e5e5; } .tag-category ul.category li h3 { line-height: normal; } .tag-category ul li.pagination-list { border-bottom: none; padding: 0s; } .tag-category ul li img { margin-bottom: 10px; } #page-site a.modal.btn { position: relative; top: 0; right: auto; left: 0; z-index: 10; width: auto; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; box-shadow: none; } .mod-preview-info { z-index: 1000; } #recaptcha_area { max-width: 198px; } p { margin: 0 0 10px; } p small, p .small { font-size: 11px; color: #999; } .lead { margin-bottom: 20px; font-size: 20px; font-weight: 200; line-height: 30px; } small { font-size: 85%; } strong { font-weight: bold; } em { font-style: italic; } cite { font-style: normal; } .muted { color: #999; } .highlight { background-color: #FFC; font-weight: bold; padding: 1px 4px; } h1, h2, h3, h4, h5, h6 { margin: 10px 0; font-family: 'open_sans_lightregular', sans-serif; font-weight: normal; line-height: 1; color: #444; text-rendering: optimizelegibility; } h1 small, h2 small, h3 small, h4 small, h5 small, h6 small { font-weight: normal; line-height: 1; color: #999; } h1 { font-size: 20px; line-height: 40px; } h1 small { font-size: 18px; } h2 { font-size: 19px; line-height: 30px; } h2 small { font-size: 17.5px; } h3 { font-size: 17.5px; line-height: 30px; } h3 small { font-size: 15px; } h4 { font-size: 15px; line-height: 20px; } h4 small { font-size: 13px; } h5 { font-size: 14px; line-height: 20px; } h5 small { font-size: 11px; } h6 { font-size: 13px; line-height: 20px; } .page-header { border-bottom: 1px solid #ddd; padding-bottom: 10px; margin: 0 0 20px; } .page-title, .page-header h1 { line-height: 1; margin: 0; } .page-subheader { border-bottom: 1px solid #ddd; margin: 0 0 20px; *zoom: 1; } .page-subheader:before, .page-subheader:after { display: table; content: ""; line-height: 0; } .page-subheader:after { clear: both; } .page-subtitle, .page-subheader h2 { line-height: 1; margin: 0; } .page-header + .page-subheader { margin-top: -20px; } .article-title, .article-header h1 { margin: 0 0 10px 0; line-height: 1; } .item-title { font-weight: bold; } ul, ol { padding: 0; margin: 0 25px 10px 0; } ul ul, ul ol, ol ol, ol ul { margin-bottom: 0; } ul { list-style: disc; } ol { list-style: decimal; } li { line-height: 20px; } ul.unstyled, ol.unstyled { margin-right: 0; list-style: none; } dl { margin-bottom: 20px; } dt, dd { line-height: 20px; } dt { font-weight: bold; } dd { margin-right: 10px; } .dl-horizontal dt { float: right; width: 120px; clear: right; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dl-horizontal dd { margin-right: 130px; } hr { margin: 20px 0; border: 0; border-top: 1px solid #eee; border-bottom: 1px solid #fff; } abbr[title] { cursor: help; border-bottom: 1px dotted #999; } abbr.initialism { font-size: 90%; text-transform: uppercase; } blockquote { padding: 0 15px 0 0; margin: 0 0 20px; border-right: 5px solid #eee; } blockquote p { margin-bottom: 0; font-size: 16px; font-weight: 300; line-height: 25px; } blockquote small { display: block; line-height: 20px; color: #999; } blockquote small:before { content: '\2014 \00A0'; } blockquote.pull-right { float: left; padding-left: 15px; padding-right: 0; border-left: 5px solid #eee; border-right: 0; } blockquote.pull-right p, blockquote.pull-right small { text-align: left; } blockquote.pull-right small:before { content: ''; } blockquote.pull-right small:after { content: '\00A0 \2014'; } q:before, q:after, blockquote:before, blockquote:after { content: ""; } address { display: block; margin-bottom: 20px; font-style: normal; line-height: 20px; } .btn-icon { display: block; } .btn-big { background-position: center center; background-repeat: no-repeat; height: 240px; position: relative; width: 219px; text-align: right; vertical-align: bottom; } .btn-icon span { color: #fff; display: block; font-family: 'open_sans_semiboldregular'; padding: 20px; position: absolute; bottom: 0; right: 0; } .icon-contact { background-image: url(../../../images/ico/mail-big.png); } .icon-photo { background-image: url(../../../images/ico/photo-big.png); } .social-wrap .btn-small { background-color: #fff; background-position: top right; background-repeat: no-repeat; float: right; height: 114px; padding: 0; text-indent: -999em; width: 114px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-transition: 0.5s; -moz-transition: 0.5s; -o-transition: 0.5s; transition: 0.5s; } .social-wrap .icon-facebook { background-image: url(../../../images/ico/facebook.png); margin: 0 0 10px 10px; } .social-wrap .icon-facebook:hover, .social-wrap .icon-facebook:focus, .social-wrap .icon-facebook:active { background-color: #3b5998; background-position: right bottom; } .social-wrap .icon-google-plus { background-image: url(../../../images/ico/google-plus.png); margin: 0 0 10px 0; } .social-wrap .icon-google-plus:hover, .social-wrap .icon-google-plus:focus, .social-wrap .icon-google-plus:active { background-color: #da5834; background-position: right bottom; } .social-wrap .icon-twitter { background-image: url(../../../images/ico/twitter.png); margin: 0 0 0 10px; } .social-wrap .icon-twitter:hover, .social-wrap .icon-twitter:focus, .social-wrap .icon-twitter:active { background-color: #02b3eb; background-position: right bottom; } .social-wrap .icon-flicker { background-image: url(../../../images/ico/flicker.png); margin: 0; } .social-wrap .icon-flicker:hover, .social-wrap .icon-flicker:focus, .social-wrap .icon-flicker:active { background-color: #e842a4; background-position: right bottom; } .accordion-style { height: 240px; position: relative; } .accordion-style .content { height: 56px; position: absolute; right: 0; bottom: 0; padding: 0 20px; overflow: hidden; -webkit-transition: 0.5s; -moz-transition: 0.5s; -o-transition: 0.5s; transition: 0.5s; } .accordion-style .content h3 { font-family: 'open_sans_semiboldregular'; font-size: 14px; margin: 0; padding: 20px 0; line-height: 1; } .accordion-style .content p { margin-bottom: 20px; } .accordion-style .content p.readmore { margin-bottom: 0; *zoom: 1; } .accordion-style .content p.readmore:before, .accordion-style .content p.readmore:after { display: table; content: ""; line-height: 0; } .accordion-style .content p.readmore:after { clear: both; } .accordion-style .content p.readmore a { background: url(../../../images/readon-w-bg.png) no-repeat right top; display: block; height: 20px; width: 20px; text-indent: -999em; overflow: hidden; } .accordion-style .content p.readmore a:hover { background-position: right bottom; } .accordion-style:hover .content { height: 240px; } .accordion-style.mod-hilite1 .content { background-color: #1ba1e2; color: #fff; } .accordion-style.mod-hilite2 .content { background-color: #d21f45; color: #fff; } .accordion-style.mod-hilite3 .content { background-color: #3b5998; color: #fff; } .accordion-style.mod-hilite4 .content { background-color: #88b828; color: #fff; } .accordion-style.mod-hilite5 .content { background-color: #d9532d; color: #fff; } .accordion-style.mod-hilite6 .content { background-color: #c22b7c; color: #fff; } .accordion-style.mod-hilite7 .content { background-color: #472b6b; color: #fff; } .accordion-style.mod-hilite8 .content { background-color: #e842a4; color: #fff; } .accordion-style.mod-hilite1 .content h3, .accordion-style.mod-hilite2 .content h3, .accordion-style.mod-hilite3 .content h3, .accordion-style.mod-hilite4 .content h3, .accordion-style.mod-hilite5 .content h3, .accordion-style.mod-hilite6 .content h3, .accordion-style.mod-hilite7 .content h3, .accordion-style.mod-hilite8 .content h3 { color: #fff; } .banner-text h2 { color: #222; margin: 0 0 10px; padding: 0; } .banner-text p { font-family: 'open_sans_semiboldregular'; color: #1ba1e2; margin: 0; } .module.badge-hot .module-inner { position: relative; } .module .badge { background-image: url(../../../images/badge-bg.gif); background-repeat: no-repeat; display: block; color: #fff; height: 20px; position: absolute; padding: 0; line-height: 1; left: 0; top: 0; width: 35px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; } .module.badge-hot .badge { background-position: 100% 0; } .module.badge-new .badge { background-position: 100% -20px; } .module.badge-pick .badge { background-position: 100% -40px; } .module.badge-top .badge { background-position: 100% -60px; } .ja-header { padding-top: 20px; padding-bottom: 20px; } .logo { float: right; } .logo h1, .logo h1 a { display: inline-block; line-height: 1; margin: 0; } .logo-image { overflow: hidden; } .logo-image a { background-image: url("../../../images/themes/light/logo.png"); background-repeat: no-repeat; width: 610px; height: 100px; } .logo-image span, .logo-image small { display: none; } .logo-text h1 { color: #444; } .logo-text h1 a { color: #444; text-decoration: none; } .logo-text:hover h1 a, .logo-text h1 a:hover, .logo-text h1 a:active, .logo-text h1 a:focus { text-decoration: none; } .logo-text .site-slogan { display: block; font-size: 13px; margin-top: 5px; } .head-search { float: left; } .head-search form { margin: 0; } .head-search label { display: none; } .head-search .input { background: url(../../../images/icon-search.png) no-repeat 210px 8px #111; border: 1px solid #222; padding-top: 7px; padding-bottom: 7px; width: 226px; } .head-search .input:focus { background-color: #fff; border-color: #fff; color: #444; } .ja-slideshow { margin-bottom: 10px; } .ja-sl { padding-bottom: 60px; padding-top: 60px; } .ja-sl-1 { margin: 0; padding: 0; } .ja-sl-2 { margin: 0; padding: 10px 0 0 0; } .ja-sl-2 .t3-module { margin-bottom: 0; } .ja-sl-3 { padding: 30px 0 40px; } .ja-sl-3 .t3-module { margin-bottom: 0; } .ja-mainbody { padding: 10px 0; position: relative; z-index: 20; } .one-row, .double-row, .triple-row { min-height: 240px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } .double-rows { min-height: 490px; } .triple-rows { min-height: 740px; } ul.double-rows { height: auto; } .ja-footer { color: #666; *zoom: 1; } .ja-footer:before, .ja-footer:after { display: table; content: ""; line-height: 0; } .ja-footer:after { clear: both; } .ja-footer small { display: block; font-size: 100%; } .ja-fotoer a, .ja-footer .nav > li > a { color: #666; } .ja-footer a:hover, .ja-footer .nav > li > a:hover { color: #1ba1e2; } .ja-fn { border-top: 1px solid #ffffff; padding: 40px 0; } .ja-footnav { padding: 0; *zoom: 1; } .ja-footnav:before, .ja-footnav:after { display: table; content: ""; line-height: 0; } .ja-footnav:after { clear: both; } .ja-fn .module { background: transparent; color: #666; margin-bottom: 0; min-height: 1px; } .ja-fn .module .module-inner { padding: 0; } .ja-fn .module .module-title { color: #222; font-family: 'open_sans_semiboldregular'; font-size: 13px; margin-bottom: 5px; } .ja-fn .module .module-ct { font-size: 12px; } .ja-footnav ul { list-style: none; margin-right: 0; margin-bottom: 0; } .ja-footnav li { padding: 5px 0; } .ja-footnav li a { -webkit-transition: 0.5s; -moz-transition: 0.5s; -o-transition: 0.5s; transition: 0.5s; } .ja-footnav li a:hover { background: transparent; } .ja-footnav .module-title { font-size: 17px; color: #222; } .ja-copyright { font-size: 11px; padding: 0; *zoom: 1; } .ja-copyright:before, .ja-copyright:after { display: table; content: ""; line-height: 0; } .ja-copyright:after { clear: both; } .ja-copyright .container { border-top: 1px solid #ffffff; padding: 40px 0 80px; } .copyright { background: url(../../../images/footer-logo.png) no-repeat right center; } .copyright small { font-size: 11px; padding-right: 100px; padding-top: 10px; } .poweredby { text-align: left; } .contact { background: #fff; padding: 20px; } #slide-contact { border-bottom: solid 1px #e5e5e5; } .contact .accordion-group { -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; border-bottom: none; margin-bottom: 0; } .contact .accordion-heading { color: #666; } .contact .accordion-heading a { color: #666; outline: none; } .accordion-inner .contact-form fieldset { border: none !important; padding: 0; } .contact .nav-tabs > .active > a, .contact .nav-tabs > .active > a:hover, .contact .nav-tabs > .active > a:focus { -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; background: #1ba1e2; color: #fff; } .contact h3 { margin-bottom: 0; } .contact .dl-horizontal dd { margin-right: 0; } .contact .contact-form fieldset { border: 1px solid #ddd; padding: 20px; } .contact .contact-form legend { border: 0; display: inline-block; font-size: 13px; margin: 0; padding: 0 10px; width: auto; } .contact .contact-form .form-actions { margin: 0 -20px -20px; padding: 10px 20px; } div.login-wrap { background: #fff; margin: 0 auto; padding: 20px; width: 490px; } div.login-wrap fieldset.well { border: 0; background: transparent; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } div.login-wrap .other-links ul { font-size: 12px; margin: 0; padding: 0; list-style: none; text-align: center; } div.login-wrap .other-links ul li { display: inline-block; } div.login-wrap .other-links ul li a { background: url(../../../images/bullet.gif) no-repeat right center; color: #444; padding-right: 10px; padding-left: 10px; } div.login-wrap .other-links ul li a:hover, div.login-wrap .other-links ul li a:focus, div.login-wrap .other-links ul li a:active { background-image: url(../../../images/bullet-hover.gif); color: #1ba1e2; } .logout { background: #fff; padding: 20px; } .logout .controls { margin-right: 0; } .reset, .remind { background: #fff; padding: 20px; } .reset .form-actions, .remind .form-actions { background: transparent; border: 0; margin-right: 0; padding-top: 0; padding-bottom: 0; } .reset .form-horizontal .control-group, .remind .form-horizontal .control-group { margin-bottom: 0; } .finder { background: #fff; padding: 20px; } .finder #search-form { padding: 0; } #search-form { background: #fff; padding: 20px; } #search-form .word .inputbox { margin-bottom: 10px; vertical-align: top; } #search-form .word .button { background: #444; border: 1px solid #444; color: #fff; padding: 5px 10px; } #search-form .word .button:hover { background: #1ba1e2; border-color: #1ba1e2; } #finder-filter-window ul { margin: 0; padding: 0; list-style: none; } #finder-filter-window ul li label { color: #999; font-weight: bold; } .weblink-category { background: #fff; padding: 20px; } .weblink-category ul { margin: 0; padding: 5px 0; list-style: none; } .weblink-category ul ul { margin-right: 20px; } .weblink-category ul li a { background: url(../../../images/bullet.gif) no-repeat right center; color: #444; font-weight: normal; padding-right: 15px; } .weblink-category ul li a:hover, .weblink-category ul li a:focus, .weblink-category ul li a:active { background-image: url(../../../images/bullet-hover.gif); color: #1ba1e2; } .newsfeed-category { background: #fff; padding: 20px; } .quick-contact p { color: #fff; } .quick-contact a { color: #1ba1e2; } .quick-contact p strong { color: #666; } .acymailing_module_form .acymailing_introtext { margin-bottom: 10px; } .acymailing_module div.acymailing_form { overflow: hidden; } .acymailing_module div.acymailing_form p { margin-bottom: 0; } div.acymailing_form p.onefield { float: right; margin-left: 10px; } div.acymailing_form p.onefield .inputbox { background: #F5F5F5; border: 1px solid #ffffff; height: 35px; margin-bottom: 0; width: 60%; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } div.acymailing_form p.onefield .inputbox:focus { background: #fff; border-color: #fff; } .com_acymailing div.acymailing_form p.onefield .inputbox:focus { border-color: #ffffff; background: #F5F5F5; color: #fff; } div.acymailing_form p.acysubbuttons { float: right; } div.acymailing_form p.acysubbuttons .button { background: url(../../../images/arrow-2.png) no-repeat right top; border: 0; height: 35px; width: 35px; text-indent: -999em; -webkit-transition: none; -moz-transition: none; -o-transition: none; transition: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } div.acymailing_form p.acysubbuttons .button:hover { background-position: right bottom; } div.acymailing_module a.modal, div.acymailing_module a.acymailing_togglemodule { background: #222; border: 0; color: #999; display: block; top: auto; right: 0; margin: 0; padding: 10px 20px; position: relative; width: auto; text-align: center; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } div.acymailing_module a.modal:hover, div.acymailing_module a.acymailing_togglemodule:hover { background: #1ba1e2; color: #fff; } .manager.thumbnails > li { display: inline-block; margin-right: 10px; text-align: center; } ul.social-list { margin: 0 !important; } ul.social-list li { display: block; margin: 0; padding: 5px 0 !important; overflow: hidden; } ul.social-list li a { display: block; } ul.social-list li span { background: url(../../../images/icons-social.png); background-repeat: no-repeat; display: inline-block; height: 20px; margin-left: 10px; width: 20px; } ul.social-list li.twitter a span { background-position: 0px 0px; } ul.social-list li.twitter a:hover { color: #1ba1e2; } ul.social-list li.twitter a:hover span { background-position: -20px 0px; } ul.social-list li.facebook a span { background-position: 0px -20px; } ul.social-list li.facebook a:hover { color: #3b5998; } ul.social-list li.facebook a:hover span { background-position: -20px -20px; } ul.social-list li.flickr a span { background-position: 0px -40px; } ul.social-list li.flickr a:hover { color: #472b6b; } ul.social-list li.flickr a:hover span { background-position: -20px -40px; } ul.social-list li.google a span { background-position: 0px -60px; } ul.social-list li.google a:hover { color: #d9532d; } ul.social-list li.google a:hover span { background-position: -20px -60px; } .edit .tab-content #images .modal { box-shadow: none; right: auto; margin-right: 0; position: inherit; top: auto; width: auto; } body { background: #F5F5F5; } .page-header { border-bottom: 1px solid #e5e5e5; } .page-subheader { border-bottom: 1px solid #444; } .divider-vertical { border-top: 1px solid #ddd; } .logo-text h1 { color: #444; } .logo-text h1 a { color: #444; } .logo-text .site-slogan { display: block; font-size: 13px; margin-top: 5px; } .head-search .input { background: url(../../../images/themes/light/search-bg.png) no-repeat 210px 8px #fff; border-color: #dcdcdc; color: #444; } .head-search .input:focus { background-image: url(../../../images/icon-search.png); color: #444; } .ja-mainnav .navbar-inner { filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); } .ja-mainnav .navbar .nav > li > a { color: #666; } .ja-mainnav .navbar .nav > .active > a, .ja-mainnav .navbar .nav > .active > a:hover, .ja-mainnav .navbar .nav > .active > a:focus { color: #1ba1e2 !important; } .ja-mainnav .navbar .nav li.dropdown.open > .dropdown-toggle .caret, .ja-mainnav .navbar .nav li.dropdown.active > .dropdown-toggle .caret, .ja-mainnav .navbar .nav li.dropdown.open.active > .dropdown-toggle .caret { border-bottom-color: #1ba1e2; border-top-color: #1ba1e2; } .ja-mainnav .navbar .nav > li > a:hover, .ja-mainnav .navbar .nav > li > a:focus, .navbar .nav li.dropdown.open > .dropdown-toggle, .navbar .nav li.dropdown.active > .dropdown-toggle, .navbar .nav li.dropdown.open.active > .dropdown-toggle { color: #1ba1e2; } .input-append .add-on, .input-prepend .add-on { background: #eee; } .nav-tabs.nav-stacked > li > a, .pagination a, .pagination span { border-color: #444; } .pagination a:hover, .pagination .active a, .pagination .active span, .pagination a, .pagination span { background: #444; } .btn { text-shadow: none; } #ja-footer { color: #666; } #ja-footer .t3-module { color: #666; } .ja-fn { border-top: 1px solid #dcdcdc; } .ja-copyright .container { border-top: 1px solid #dcdcdc; } .ja-footnav li a { color: #666; } .ja-footnav li a:hover { color: #1ba1e2; } .copyright { background: url(../../../images/themes/light/footer-logo.png) no-repeat right center; } .copyright a, .poweredby a { color: #808080; } .quick-contact p { color: #222; } div.acymailing_form p.onefield .inputbox { background: #ffffff; border: 1px solid #e8e8e8; color: #666; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } div.acymailing_form p.onefield .inputbox:focus { color: #444; } div.acymailing_form p.acysubbuttons .button { background-image: url(../../../images/themes/light/arrow-2.png); } .quick-contact p strong { color: #666; } ul.social-list li span { background: url(../../../images/themes/light/icons-social.png); } .head-search .input { background-position: 15px 8px; } .itemListCategory { zoom: 1; overflow: hidden; } div.itemToolbar ul li { display: inline-block; } .t3-megamenu .mega-nav .dropdown-submenu > a:after { margin-left: 0; } article img[align=left], .img_caption.left { margin: 0 10px 20px 0; } article img[align=right], .img_caption.right { margin: 0 0 20px 10px; } .ja-mainnav .navbar .nav > li > a { letter-spacing: -1px; } div.acymailing_form p.acysubbuttons .button { background-image: url(../../../images/arrow-2-rtl.png); } div.catItemReadMore a, div.tagItemReadMore a, div.userItemReadMore a { background-image: url(../../../images/readmore-bg-rtl.png); }
hscomp2002/edmansport
templates/ja_mero/css/rtl/light/template.css
CSS
gpl-2.0
69,900
#include <iostream> #include <map> #include <vector> #include <string> #include <algorithm> #include <fstream> using namespace std; vector<string> dict; map<string, int> map_dict; void reformat(string &line) { int sz = line.size(); int j = 1; for(int i = 1; i < sz; ++i) { if(isalpha(line[i])) line[j++] = line[i]; } line.resize(j); } int main() { freopen("./critical.txt", "r", stdin); string word; while(cin>>word) { if(word[0]=='#') break; if(word.size() <= 7) { dict.push_back(word); map_dict[word]++; } } sort(dict.begin(), dict.end()); cin.ignore(); string line; while(getline(cin, line)) { if(line[0] == '#') break; reformat(line); sort(line.begin(), line.end()); map<string,int> key; do { int sz = line.size(); for(int i = 0; i < sz; ++i) { string s = line.substr(i, sz); if(!key[s]) key[s]++; } }while(next_permutation(line.begin(),line.end())); int cnt = 0; map<string, int>::iterator it; for(it = key.begin(); it != key.end(); ++it) { if(binary_search(dict.begin(), dict.end(), it->first)) { if(map_dict[it->first] > 1) cnt += map_dict[it->first]; else cnt++; } } cout << cnt << endl; key.clear(); line.clear(); } return 0; }
rahulroot/Uva
895/program.cpp
C++
gpl-2.0
1,399
export default (sequelize, dataTypes) => { return sequelize.define( 'Community', { id: sequelize.idType, subdomain: { type: dataTypes.TEXT, unique: true, allowNull: false, validate: { isLowercase: true, len: [1, 280], is: /^[a-zA-Z0-9-]+$/, // Must contain at least one letter, alphanumeric and hyphens }, }, domain: { type: dataTypes.TEXT, unique: true, }, title: { type: dataTypes.TEXT, allowNull: false }, citeAs: { type: dataTypes.TEXT }, publishAs: { type: dataTypes.TEXT }, description: { type: dataTypes.TEXT, validate: { len: [0, 280], }, }, avatar: { type: dataTypes.TEXT }, favicon: { type: dataTypes.TEXT }, accentColorLight: { type: dataTypes.STRING }, accentColorDark: { type: dataTypes.STRING }, hideCreatePubButton: { type: dataTypes.BOOLEAN }, headerLogo: { type: dataTypes.TEXT }, headerLinks: { type: dataTypes.JSONB }, headerColorType: { type: dataTypes.ENUM, values: ['light', 'dark', 'custom'], defaultValue: 'dark', }, useHeaderTextAccent: { type: dataTypes.BOOLEAN }, hideHero: { type: dataTypes.BOOLEAN }, hideHeaderLogo: { type: dataTypes.BOOLEAN }, heroLogo: { type: dataTypes.TEXT }, heroBackgroundImage: { type: dataTypes.TEXT }, heroBackgroundColor: { type: dataTypes.TEXT }, heroTextColor: { type: dataTypes.TEXT }, useHeaderGradient: { type: dataTypes.BOOLEAN }, heroImage: { type: dataTypes.TEXT }, heroTitle: { type: dataTypes.TEXT }, heroText: { type: dataTypes.TEXT }, heroPrimaryButton: { type: dataTypes.JSONB }, heroSecondaryButton: { type: dataTypes.JSONB }, heroAlign: { type: dataTypes.TEXT }, navigation: { type: dataTypes.JSONB }, hideNav: { type: dataTypes.BOOLEAN }, navLinks: { type: dataTypes.JSONB }, footerLinks: { type: dataTypes.JSONB }, footerLogoLink: { type: dataTypes.TEXT }, footerTitle: { type: dataTypes.TEXT }, footerImage: { type: dataTypes.TEXT }, website: { type: dataTypes.TEXT }, facebook: { type: dataTypes.TEXT }, twitter: { type: dataTypes.TEXT }, email: { type: dataTypes.TEXT }, issn: { type: dataTypes.TEXT }, isFeatured: { type: dataTypes.BOOLEAN }, viewHash: { type: dataTypes.STRING }, editHash: { type: dataTypes.STRING }, premiumLicenseFlag: { type: dataTypes.BOOLEAN, defaultValue: false }, defaultPubCollections: { type: dataTypes.JSONB }, /* Set by Associations */ organizationId: { type: dataTypes.UUID }, }, { classMethods: { associate: (models) => { const { Community, Organization, Collection, Page, Pub, ScopeSummary } = models; Community.belongsTo(Organization, { onDelete: 'CASCADE', as: 'organization', foreignKey: 'organizationId', }); Community.hasMany(Collection, { onDelete: 'CASCADE', as: 'collections', foreignKey: 'communityId', }); Community.hasMany(Pub, { onDelete: 'CASCADE', as: 'pubs', foreignKey: 'communityId', }); Community.hasMany(Page, { onDelete: 'CASCADE', as: 'pages', foreignKey: 'communityId', }); Community.belongsTo(ScopeSummary, { as: 'scopeSummary', foreignKey: 'scopeSummaryId', }); }, }, }, ); };
pubpub/pubpub
server/community/model.ts
TypeScript
gpl-2.0
3,307
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # # 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.
Sophist-UK/Sophist_picard
picard/browser/__init__.py
Python
gpl-2.0
823
/* * EntityManager.cpp * * Created on: 29 Nov 2015 * Author: osboxes */ #include "EntityManager.h" #include "../syscalls/SysCalls.h" using namespace std; EntityManager::EntityManager(std::string fileName) :m_index("entity.idx"){ m_fname = fileName; m_fdReader = syscalls::open ( m_fname.c_str(),O_CREAT|O_RDONLY,0777 ); m_fdWriter = syscalls::open ( m_fname.c_str(),O_CREAT|O_WRONLY,0777 ); syscalls::lseek(m_fdWriter,0,SEEK_END); struct stat buf; fstat(m_fdWriter, &buf); m_offset = buf.st_size; } EntityManager::~EntityManager() { syscalls::close(m_fdReader); syscalls::close(m_fdWriter); } void EntityManager::persist(Entity entity){ char buffer[sizeof(Entity)]; memcpy(buffer, &entity, sizeof(Entity)); syscalls::write(m_fdWriter,buffer,sizeof(Entity)); m_index.addIndex(entity.nombre, m_offset); m_offset += sizeof(Entity); } void EntityManager::findAll(const char* name,std::list<Entity>& results){ std::list<long> offsets; m_index.getOffsets(name, offsets); for (std::list<long>::iterator it = offsets.begin(); it != offsets.end(); it++){ long offset = *it; Entity entity; syscalls::lseek(m_fdReader, offset,SEEK_SET); syscalls::read(m_fdReader, &entity, sizeof(Entity)); results.push_back(entity); } }
gguzelj/7559-TP2
DbLib/persistence/EntityManager.cpp
C++
gpl-2.0
1,262
/* * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <mach/rpm-regulator.h> #include <mach/msm_bus_board.h> #include <mach/msm_bus.h> #include "mach/socinfo.h" #include "acpuclock.h" #include "acpuclock-krait.h" static struct hfpll_data hfpll_data __initdata = { .mode_offset = 0x00, .l_offset = 0x08, .m_offset = 0x0C, .n_offset = 0x10, .config_offset = 0x04, .config_val = 0x7845C665, .has_droop_ctl = true, .droop_offset = 0x14, .droop_val = 0x0108C000, .low_vdd_l_max = 22, .nom_vdd_l_max = 42, .vdd[HFPLL_VDD_NONE] = 0, .vdd[HFPLL_VDD_LOW] = 945000, .vdd[HFPLL_VDD_NOM] = 1050000, .vdd[HFPLL_VDD_HIGH] = 1150000, }; static struct scalable scalable[] __initdata = { [CPU0] = { .hfpll_phys_base = 0x00903200, .aux_clk_sel_phys = 0x02088014, .aux_clk_sel = 3, .sec_clk_sel = 2, .l2cpmr_iaddr = 0x4501, #ifdef CONFIG_CPU_OVERCLOCK .vreg[VREG_CORE] = { "krait0", 1450000 }, #else .vreg[VREG_CORE] = { "krait0", 1300000 }, #endif .vreg[VREG_MEM] = { "krait0_mem", 1150000 }, .vreg[VREG_DIG] = { "krait0_dig", 1150000 }, .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 }, }, [CPU1] = { .hfpll_phys_base = 0x00903240, .aux_clk_sel_phys = 0x02098014, .aux_clk_sel = 3, .sec_clk_sel = 2, .l2cpmr_iaddr = 0x5501, #ifdef CONFIG_CPU_OVERCLOCK .vreg[VREG_CORE] = { "krait1", 1450000 }, #else .vreg[VREG_CORE] = { "krait1", 1300000 }, #endif .vreg[VREG_MEM] = { "krait1_mem", 1150000 }, .vreg[VREG_DIG] = { "krait1_dig", 1150000 }, .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 }, }, [CPU2] = { .hfpll_phys_base = 0x00903280, .aux_clk_sel_phys = 0x020A8014, .aux_clk_sel = 3, .sec_clk_sel = 2, .l2cpmr_iaddr = 0x6501, #ifdef CONFIG_CPU_OVERCLOCK .vreg[VREG_CORE] = { "krait2", 1450000 }, #else .vreg[VREG_CORE] = { "krait2", 1300000 }, #endif .vreg[VREG_MEM] = { "krait2_mem", 1150000 }, .vreg[VREG_DIG] = { "krait2_dig", 1150000 }, .vreg[VREG_HFPLL_A] = { "krait2_hfpll", 1800000 }, }, [CPU3] = { .hfpll_phys_base = 0x009032C0, .aux_clk_sel_phys = 0x020B8014, .aux_clk_sel = 3, .sec_clk_sel = 2, .l2cpmr_iaddr = 0x7501, #ifdef CONFIG_CPU_OVERCLOCK .vreg[VREG_CORE] = { "krait3", 1450000 }, #else .vreg[VREG_CORE] = { "krait3", 1300000 }, #endif .vreg[VREG_MEM] = { "krait3_mem", 1150000 }, .vreg[VREG_DIG] = { "krait3_dig", 1150000 }, .vreg[VREG_HFPLL_A] = { "krait3_hfpll", 1800000 }, }, [L2] = { .hfpll_phys_base = 0x00903300, .aux_clk_sel_phys = 0x02011028, .aux_clk_sel = 3, .sec_clk_sel = 2, .l2cpmr_iaddr = 0x0500, .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 }, }, }; /* * The correct maximum rate for 8064ab in 600 MHZ. * We rely on the RPM rounding requests up here. */ static struct msm_bus_paths bw_level_tbl[] __initdata = { [0] = BW_MBPS(640), /* At least 80 MHz on bus. */ [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */ [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */ [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */ [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */ [5] = BW_MBPS(4264), /* At least 533 MHz on bus. */ }; static struct msm_bus_scale_pdata bus_scale_data __initdata = { .usecase = bw_level_tbl, .num_usecases = ARRAY_SIZE(bw_level_tbl), .active_only = 1, .name = "acpuclk-8064", }; static struct l2_level l2_freq_tbl[] __initdata = { [0] = { { 378000, PLL_8, 0, 0x00 }, 950000, 1050000, 1 }, [1] = { { 432000, HFPLL, 2, 0x20 }, 1050000, 1050000, 2 }, [2] = { { 486000, HFPLL, 2, 0x24 }, 1050000, 1050000, 2 }, [3] = { { 540000, HFPLL, 2, 0x28 }, 1050000, 1050000, 2 }, [4] = { { 594000, HFPLL, 1, 0x16 }, 1050000, 1050000, 2 }, [5] = { { 648000, HFPLL, 1, 0x18 }, 1050000, 1050000, 4 }, [6] = { { 702000, HFPLL, 1, 0x1A }, 1150000, 1150000, 4 }, [7] = { { 756000, HFPLL, 1, 0x1C }, 1150000, 1150000, 4 }, [8] = { { 810000, HFPLL, 1, 0x1E }, 1150000, 1150000, 4 }, [9] = { { 864000, HFPLL, 1, 0x20 }, 1150000, 1150000, 4 }, [10] = { { 918000, HFPLL, 1, 0x22 }, 1150000, 1150000, 5 }, [11] = { { 972000, HFPLL, 1, 0x24 }, 1150000, 1150000, 5 }, [12] = { { 1026000, HFPLL, 1, 0x26 }, 1150000, 1150000, 5 }, [13] = { { 1080000, HFPLL, 1, 0x28 }, 1150000, 1150000, 5 }, [14] = { { 1134000, HFPLL, 1, 0x2A }, 1150000, 1150000, 5 }, { } }; static struct acpu_level tbl_slow[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 0, { 432000, HFPLL, 2, 0x20 }, L2(5), 975000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 975000 }, { 0, { 540000, HFPLL, 2, 0x28 }, L2(5), 1000000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 1000000 }, { 0, { 648000, HFPLL, 1, 0x18 }, L2(5), 1025000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 1025000 }, { 0, { 756000, HFPLL, 1, 0x1C }, L2(5), 1075000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 1075000 }, { 0, { 864000, HFPLL, 1, 0x20 }, L2(5), 1100000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1100000 }, { 0, { 972000, HFPLL, 1, 0x24 }, L2(5), 1125000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1125000 }, { 0, { 1080000, HFPLL, 1, 0x28 }, L2(14), 1175000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1175000 }, { 0, { 1188000, HFPLL, 1, 0x2C }, L2(14), 1200000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1200000 }, { 0, { 1296000, HFPLL, 1, 0x30 }, L2(14), 1225000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1225000 }, { 0, { 1404000, HFPLL, 1, 0x34 }, L2(14), 1237500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1237500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1250000 }, { 0, { 0 } } }; static struct acpu_level tbl_nom[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000 }, { 0, { 432000, HFPLL, 2, 0x20 }, L2(5), 925000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 925000 }, { 0, { 540000, HFPLL, 2, 0x28 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 0, { 648000, HFPLL, 1, 0x18 }, L2(5), 975000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 975000 }, { 0, { 756000, HFPLL, 1, 0x1C }, L2(5), 1025000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 1025000 }, { 0, { 864000, HFPLL, 1, 0x20 }, L2(5), 1050000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1050000 }, { 0, { 972000, HFPLL, 1, 0x24 }, L2(5), 1075000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1075000 }, { 0, { 1080000, HFPLL, 1, 0x28 }, L2(14), 1125000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1125000 }, { 0, { 1188000, HFPLL, 1, 0x2C }, L2(14), 1150000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1150000 }, { 0, { 1296000, HFPLL, 1, 0x30 }, L2(14), 1175000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1175000 }, { 0, { 1404000, HFPLL, 1, 0x34 }, L2(14), 1187500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1187500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1200000 }, { 0, { 0 } } }; static struct acpu_level tbl_fast[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 850000 }, { 0, { 432000, HFPLL, 2, 0x20 }, L2(5), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 0, { 540000, HFPLL, 2, 0x28 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 0, { 648000, HFPLL, 1, 0x18 }, L2(5), 925000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 925000 }, { 0, { 756000, HFPLL, 1, 0x1C }, L2(5), 975000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 975000 }, { 0, { 864000, HFPLL, 1, 0x20 }, L2(5), 1000000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1000000 }, { 0, { 972000, HFPLL, 1, 0x24 }, L2(5), 1025000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1025000 }, { 0, { 1080000, HFPLL, 1, 0x28 }, L2(14), 1075000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1075000 }, { 0, { 1188000, HFPLL, 1, 0x2C }, L2(14), 1100000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1100000 }, { 0, { 1296000, HFPLL, 1, 0x30 }, L2(14), 1125000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1125000 }, { 0, { 1404000, HFPLL, 1, 0x34 }, L2(14), 1137500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1137500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1150000 }, { 0, { 0 } } }; static struct acpu_level tbl_faster[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 850000 }, { 0, { 432000, HFPLL, 2, 0x20 }, L2(5), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 0, { 540000, HFPLL, 2, 0x28 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 0, { 648000, HFPLL, 1, 0x18 }, L2(5), 925000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 925000 }, { 0, { 756000, HFPLL, 1, 0x1C }, L2(5), 962500 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 962500 }, { 0, { 864000, HFPLL, 1, 0x20 }, L2(5), 975000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 975000 }, { 0, { 972000, HFPLL, 1, 0x24 }, L2(5), 1000000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1000000 }, { 0, { 1080000, HFPLL, 1, 0x28 }, L2(14), 1050000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1050000 }, { 0, { 1188000, HFPLL, 1, 0x2C }, L2(14), 1075000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1075000 }, { 0, { 1296000, HFPLL, 1, 0x30 }, L2(14), 1100000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1100000 }, { 0, { 1404000, HFPLL, 1, 0x34 }, L2(14), 1112500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1112500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1125000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS0_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 962500 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 1000000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1025000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1037500 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1075000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1087500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1125000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1150000 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1162500 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS1_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 962500 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 975000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1000000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1012500 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1037500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1050000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1087500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1112500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1125000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS2_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 925000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 925000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 925000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 925000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 937500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 950000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 975000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1000000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1012500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1037500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1075000 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1087500 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS3_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 900000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 900000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 925000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 950000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 975000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 987500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1000000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1037500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1050000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS4_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 950000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 962500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 975000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1000000 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1012500 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS5_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 987500 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 1000000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS6_1512MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 975000 }, { 1, { 1512000, HFPLL, 1, 0x38 }, L2(14), 987500 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS0_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 962500 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 1000000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1025000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1037500 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1075000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1087500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1125000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1150000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1175000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1225000 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1250000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS1_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 962500 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 975000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 1000000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1012500 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1037500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1050000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1087500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1112500 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1150000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1187500 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1200000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS2_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 925000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 925000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 925000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 925000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 937500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 950000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 975000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1000000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1012500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1037500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1075000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1100000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1137500 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1162500 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS3_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 900000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 900000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 925000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 950000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 975000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 987500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1000000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1037500 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1062500 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1100000 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1125000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS4_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 950000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 962500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 975000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1000000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1037500 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1075000 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1100000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS5_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 987500 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1012500 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1050000 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1075000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS6_1700MHz[] __initdata = { { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 975000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1000000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1025000 }, { 1, { 1728000, HFPLL, 1, 0x40 }, L2(14), 1050000 }, { 0, { 0 } } }; static struct acpu_level tbl_PVS0_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 950000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 950000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 950000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 950000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 950000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 962500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 975000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 1000000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1025000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1037500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1062500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1100000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1125000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1175000 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1225000 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1287500 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1337500 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1387500 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS1_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 925000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 925000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 925000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 925000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 925000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 937500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 950000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 975000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 1000000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 1012500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1037500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1075000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1100000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1137500 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1187500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1250000 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1300000 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1350000 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS2_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 900000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 900000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 900000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 912500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 925000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 950000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 975000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 987500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1012500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1050000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1075000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1112500 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1162500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1212500 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1262500 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1312500 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS3_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 900000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 900000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 900000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 900000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 900000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 900000 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 912500 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 937500 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 962500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 975000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 1000000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1025000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1050000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1087500 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1137500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1175000 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1225000 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1275000 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS4_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 875000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 950000 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 962500 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 975000 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 1000000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1037500 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1075000 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1112500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1150000 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1200000 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1250000 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS5_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 875000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 987500 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1012500 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1050000 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1087500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1125000 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1175000 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1225000 }, #endif { 0, { 0 } } }; static struct acpu_level tbl_PVS6_2000MHz[] __initdata = { #ifdef CONFIG_LOW_CPUCLOCKS { 1, { 270000, HFPLL, 2, 0x16 }, L2(0), 875000 }, #endif { 1, { 378000, PLL_8, 0, 0x00 }, L2(0), 875000 }, { 1, { 486000, HFPLL, 2, 0x24 }, L2(5), 875000 }, { 1, { 594000, HFPLL, 1, 0x16 }, L2(5), 875000 }, { 1, { 702000, HFPLL, 1, 0x1A }, L2(5), 875000 }, { 1, { 810000, HFPLL, 1, 0x1E }, L2(5), 887500 }, { 1, { 918000, HFPLL, 1, 0x22 }, L2(5), 900000 }, { 1, { 1026000, HFPLL, 1, 0x26 }, L2(5), 925000 }, { 1, { 1134000, HFPLL, 1, 0x2A }, L2(14), 937500 }, { 1, { 1242000, HFPLL, 1, 0x2E }, L2(14), 950000 }, { 1, { 1350000, HFPLL, 1, 0x32 }, L2(14), 962500 }, { 1, { 1458000, HFPLL, 1, 0x36 }, L2(14), 975000 }, { 1, { 1566000, HFPLL, 1, 0x3A }, L2(14), 1000000 }, { 1, { 1674000, HFPLL, 1, 0x3E }, L2(14), 1025000 }, { 1, { 1782000, HFPLL, 1, 0x42 }, L2(14), 1062500 }, { 1, { 1890000, HFPLL, 1, 0x46 }, L2(14), 1100000 }, #ifdef CONFIG_CPU_OVERCLOCK { 1, { 1998000, HFPLL, 1, 0x4A }, L2(14), 1150000 }, { 1, { 2106000, HFPLL, 1, 0x4E }, L2(14), 1200000 }, #endif { 0, { 0 } } }; static struct pvs_table pvs_tables[NUM_SPEED_BINS][NUM_PVS] __initdata = { [0][PVS_SLOW] = {tbl_slow, sizeof(tbl_slow), 0 }, [0][PVS_NOMINAL] = {tbl_nom, sizeof(tbl_nom), 25000 }, [0][PVS_FAST] = {tbl_fast, sizeof(tbl_fast), 25000 }, [0][PVS_FASTER] = {tbl_faster, sizeof(tbl_faster), 25000 }, [1][0] = { tbl_PVS0_1700MHz, sizeof(tbl_PVS0_1700MHz), 0 }, [1][1] = { tbl_PVS1_1700MHz, sizeof(tbl_PVS1_1700MHz), 25000 }, [1][2] = { tbl_PVS2_1700MHz, sizeof(tbl_PVS2_1700MHz), 25000 }, [1][3] = { tbl_PVS3_1700MHz, sizeof(tbl_PVS3_1700MHz), 25000 }, [1][4] = { tbl_PVS4_1700MHz, sizeof(tbl_PVS4_1700MHz), 25000 }, [1][5] = { tbl_PVS5_1700MHz, sizeof(tbl_PVS5_1700MHz), 25000 }, [1][6] = { tbl_PVS6_1700MHz, sizeof(tbl_PVS6_1700MHz), 25000 }, [2][0] = { tbl_PVS0_2000MHz, sizeof(tbl_PVS0_2000MHz), 0 }, #ifdef CONFIG_CPU_OVERCLOCK [2][1] = { tbl_PVS1_2000MHz, sizeof(tbl_PVS1_2000MHz), 26000 }, [2][2] = { tbl_PVS2_2000MHz, sizeof(tbl_PVS2_2000MHz), 26000 }, [2][3] = { tbl_PVS3_2000MHz, sizeof(tbl_PVS3_2000MHz), 26000 }, [2][4] = { tbl_PVS4_2000MHz, sizeof(tbl_PVS4_2000MHz), 26000 }, [2][5] = { tbl_PVS5_2000MHz, sizeof(tbl_PVS5_2000MHz), 26000 }, [2][6] = { tbl_PVS6_2000MHz, sizeof(tbl_PVS6_2000MHz), 26000 }, #else [2][1] = { tbl_PVS1_2000MHz, sizeof(tbl_PVS1_2000MHz), 25000 }, [2][2] = { tbl_PVS2_2000MHz, sizeof(tbl_PVS2_2000MHz), 25000 }, [2][3] = { tbl_PVS3_2000MHz, sizeof(tbl_PVS3_2000MHz), 25000 }, [2][4] = { tbl_PVS4_2000MHz, sizeof(tbl_PVS4_2000MHz), 25000 }, [2][5] = { tbl_PVS5_2000MHz, sizeof(tbl_PVS5_2000MHz), 25000 }, [2][6] = { tbl_PVS6_2000MHz, sizeof(tbl_PVS6_2000MHz), 25000 }, #endif [14][0] = { tbl_PVS0_1512MHz, sizeof(tbl_PVS0_1512MHz), 0 }, [14][1] = { tbl_PVS1_1512MHz, sizeof(tbl_PVS1_1512MHz), 25000 }, [14][2] = { tbl_PVS2_1512MHz, sizeof(tbl_PVS2_1512MHz), 25000 }, [14][3] = { tbl_PVS3_1512MHz, sizeof(tbl_PVS3_1512MHz), 25000 }, [14][4] = { tbl_PVS4_1512MHz, sizeof(tbl_PVS4_1512MHz), 25000 }, [14][5] = { tbl_PVS5_1512MHz, sizeof(tbl_PVS5_1512MHz), 25000 }, [14][6] = { tbl_PVS6_1512MHz, sizeof(tbl_PVS6_1512MHz), 25000 }, }; static struct acpuclk_krait_params acpuclk_8064_params __initdata = { .scalable = scalable, .scalable_size = sizeof(scalable), .hfpll_data = &hfpll_data, .pvs_tables = pvs_tables, .l2_freq_tbl = l2_freq_tbl, .l2_freq_tbl_size = sizeof(l2_freq_tbl), .bus_scale = &bus_scale_data, .pte_efuse_phys = 0x007000C0, .get_bin_info = get_krait_bin_format_a, .stby_khz = 378000, }; static int __init acpuclk_8064_probe(struct platform_device *pdev) { if (cpu_is_apq8064ab() || SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) { acpuclk_8064_params.hfpll_data->low_vdd_l_max = 37; acpuclk_8064_params.hfpll_data->nom_vdd_l_max = 74; } return acpuclk_krait_init(&pdev->dev, &acpuclk_8064_params); } static struct platform_driver acpuclk_8064_driver = { .driver = { .name = "acpuclk-8064", .owner = THIS_MODULE, }, }; static int __init acpuclk_8064_init(void) { return platform_driver_probe(&acpuclk_8064_driver, acpuclk_8064_probe); } device_initcall(acpuclk_8064_init);
fideoman/Alucard-Kernel-jfltexx
arch/arm/mach-msm/acpuclock-8064.c
C
gpl-2.0
32,224
<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PyQt4.QtGui.QGraphicsView.OptimizationFlag</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Tree link --> <th>&nbsp;&nbsp;&nbsp;<a href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th> <!-- Index link --> <th>&nbsp;&nbsp;&nbsp;<a href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th> <!-- Help link --> <th>&nbsp;&nbsp;&nbsp;<a href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" >2015-2Schrodinger Python API</th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> PyQt4 :: QtGui :: QGraphicsView :: OptimizationFlag :: Class&nbsp;OptimizationFlag </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >]&nbsp;|&nbsp;<a href="PyQt4.QtGui.QGraphicsView.OptimizationFlag-class.html" target="_top">no&nbsp;frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== CLASS DESCRIPTION ==================== --> <h1 class="epydoc">Class OptimizationFlag</h1><p class="nomargin-top"></p> <pre class="base-tree"> <a href="object-class.html">object</a> --+ | <a href="int-class.html">int</a> --+ | <strong class="uidshort">QGraphicsView.OptimizationFlag</strong> </pre> <hr /> <!-- ==================== INSTANCE METHODS ==================== --> <a name="section-InstanceMethods"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Instance Methods</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-InstanceMethods" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type">&nbsp;</span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="PyQt4.QtGui.QGraphicsView.OptimizationFlag-class.html#__or__" class="summary-sig-name">__or__</a>(<span class="summary-sig-arg">x</span>, <span class="summary-sig-arg">y</span>)</span><br /> x|y</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type">&nbsp;</span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="PyQt4.QtGui.QGraphicsView.OptimizationFlag-class.html#__reduce__" class="summary-sig-name">__reduce__</a>(<span class="summary-sig-arg">...</span>)</span><br /> helper for pickle</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type">&nbsp;</span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="PyQt4.QtGui.QGraphicsView.OptimizationFlag-class.html#__ror__" class="summary-sig-name">__ror__</a>(<span class="summary-sig-arg">x</span>, <span class="summary-sig-arg">y</span>)</span><br /> y|x</td> <td align="right" valign="top"> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="int-class.html">int</a></code></b>: <code><a href="int-class.html#__abs__">__abs__</a></code>, <code><a href="int-class.html#__add__">__add__</a></code>, <code><a href="int-class.html#__and__">__and__</a></code>, <code><a href="int-class.html#__cmp__">__cmp__</a></code>, <code><a href="int-class.html#__coerce__">__coerce__</a></code>, <code><a href="int-class.html#__div__">__div__</a></code>, <code><a href="int-class.html#__divmod__">__divmod__</a></code>, <code><a href="int-class.html#__float__">__float__</a></code>, <code><a href="int-class.html#__floordiv__">__floordiv__</a></code>, <code><a href="int-class.html#__format__">__format__</a></code>, <code><a href="int-class.html#__getattribute__">__getattribute__</a></code>, <code><a href="int-class.html#__getnewargs__">__getnewargs__</a></code>, <code><a href="int-class.html#__hash__">__hash__</a></code>, <code><a href="int-class.html#__hex__">__hex__</a></code>, <code><a href="int-class.html#__index__">__index__</a></code>, <code><a href="int-class.html#__int__">__int__</a></code>, <code><a href="int-class.html#__invert__">__invert__</a></code>, <code><a href="int-class.html#__long__">__long__</a></code>, <code><a href="int-class.html#__lshift__">__lshift__</a></code>, <code><a href="int-class.html#__mod__">__mod__</a></code>, <code><a href="int-class.html#__mul__">__mul__</a></code>, <code><a href="int-class.html#__neg__">__neg__</a></code>, <code><a href="int-class.html#__new__">__new__</a></code>, <code><a href="int-class.html#__nonzero__">__nonzero__</a></code>, <code><a href="int-class.html#__oct__">__oct__</a></code>, <code><a href="int-class.html#__pos__">__pos__</a></code>, <code><a href="int-class.html#__pow__">__pow__</a></code>, <code><a href="int-class.html#__radd__">__radd__</a></code>, <code><a href="int-class.html#__rand__">__rand__</a></code>, <code><a href="int-class.html#__rdiv__">__rdiv__</a></code>, <code><a href="int-class.html#__rdivmod__">__rdivmod__</a></code>, <code><a href="int-class.html#__repr__">__repr__</a></code>, <code><a href="int-class.html#__rfloordiv__">__rfloordiv__</a></code>, <code><a href="int-class.html#__rlshift__">__rlshift__</a></code>, <code><a href="int-class.html#__rmod__">__rmod__</a></code>, <code><a href="int-class.html#__rmul__">__rmul__</a></code>, <code><a href="int-class.html#__rpow__">__rpow__</a></code>, <code><a href="int-class.html#__rrshift__">__rrshift__</a></code>, <code><a href="int-class.html#__rshift__">__rshift__</a></code>, <code><a href="int-class.html#__rsub__">__rsub__</a></code>, <code><a href="int-class.html#__rtruediv__">__rtruediv__</a></code>, <code><a href="int-class.html#__rxor__">__rxor__</a></code>, <code><a href="int-class.html#__str__">__str__</a></code>, <code><a href="int-class.html#__sub__">__sub__</a></code>, <code><a href="int-class.html#__truediv__">__truediv__</a></code>, <code><a href="int-class.html#__trunc__">__trunc__</a></code>, <code><a href="int-class.html#__xor__">__xor__</a></code>, <code><a href="int-class.html#bit_length">bit_length</a></code>, <code><a href="int-class.html#conjugate">conjugate</a></code> </p> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="object-class.html">object</a></code></b>: <code><a href="object-class.html#__delattr__">__delattr__</a></code>, <code><a href="object-class.html#__init__">__init__</a></code>, <code><a href="object-class.html#__reduce_ex__">__reduce_ex__</a></code>, <code><a href="object-class.html#__setattr__">__setattr__</a></code>, <code><a href="object-class.html#__sizeof__">__sizeof__</a></code>, <code><a href="object-class.html#__subclasshook__">__subclasshook__</a></code> </p> </td> </tr> </table> <!-- ==================== PROPERTIES ==================== --> <a name="section-Properties"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Properties</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-Properties" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="int-class.html">int</a></code></b>: <code><a href="int-class.html#denominator">denominator</a></code>, <code><a href="int-class.html#imag">imag</a></code>, <code><a href="int-class.html#numerator">numerator</a></code>, <code><a href="int-class.html#real">real</a></code> </p> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="object-class.html">object</a></code></b>: <code><a href="object-class.html#__class__">__class__</a></code> </p> </td> </tr> </table> <!-- ==================== METHOD DETAILS ==================== --> <a name="section-MethodDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Method Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-MethodDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="__or__"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">__or__</span>(<span class="sig-arg">x</span>, <span class="sig-arg">y</span>)</span> <br /><em class="fname">(Or operator)</em> </h3> </td><td align="right" valign="top" >&nbsp; </td> </tr></table> <p>x|y</p> <dl class="fields"> <dt>Overrides: int.__or__ </dt> </dl> </td></tr></table> </div> <a name="__reduce__"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">__reduce__</span>(<span class="sig-arg">...</span>)</span> </h3> </td><td align="right" valign="top" >&nbsp; </td> </tr></table> <p>helper for pickle</p> <dl class="fields"> <dt>Overrides: object.__reduce__ <dd><em class="note">(inherited documentation)</em></dd> </dt> </dl> </td></tr></table> </div> <a name="__ror__"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">__ror__</span>(<span class="sig-arg">x</span>, <span class="sig-arg">y</span>)</span> </h3> </td><td align="right" valign="top" >&nbsp; </td> </tr></table> <p>y|x</p> <dl class="fields"> <dt>Overrides: int.__ror__ </dt> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Tree link --> <th>&nbsp;&nbsp;&nbsp;<a href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th> <!-- Index link --> <th>&nbsp;&nbsp;&nbsp;<a href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th> <!-- Help link --> <th>&nbsp;&nbsp;&nbsp;<a href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" >2015-2Schrodinger Python API</th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Sat May 9 06:30:56 2015 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>
platinhom/ManualHom
Schrodinger/Schrodinger_2015-2_docs/python_api/api/PyQt4.QtGui.QGraphicsView.OptimizationFlag-class.html
HTML
gpl-2.0
14,688
#include "configio.h" #include <limits.h> static mystring default_bulletin_dir("bulletins"); static const mystring filename_bulletin_dir = "bulletin-dir"; mystring configuration::bulletin_dir() const { return read_dir(filename_bulletin_dir, default_bulletin_dir, (config_cache<mystring>&)bulletin_dir_cache); }
hetznerZApackages/vmailmgr
lib/config/_bulletin_dir.cc
C++
gpl-2.0
340
public class Star { int x; int y; int owner; int colony; public Star(int x,int y,int owner,int colony){ this.x = x; this.y = y; this.owner = owner; this.colony = colony; } }
TravisRidge/Gigaquadrant
Gigaquadrant/src/Star.java
Java
gpl-2.0
191
/* QUYNH NGA NGUYEN - ID: 700110099 Project FSE Chatroom - 18-652 Server-side file handles requests from clien-side. */ var app = require('express')(); var server = require('http').createServer(app); var io = require('socket.io')(server); var fs = require('fs'); var dbfile = "database.db"; var existed = fs.existsSync(dbfile); var sqlite3 = require('sqlite3').verbose(); var db = new sqlite3.Database(dbfile); app.get("/", function(req, res) { res.sendFile(__dirname + "/index.html"); }); app.get("/chatroom", function(req, res) { res.sendFile(__dirname + "/chatroom.html"); }); app.get("/style.css", function(req, res) { res.sendFile(__dirname + "/style.css"); }); app.get("/FSEChatroomLogo.png", function(req, res) { res.sendFile(__dirname + "/FSEChatroomLogo.png"); }); db.serialize(function() { if (!existed) { db.run("CREATE TABLE chatHistory (name TEXT, message TEXT, time TEXT)"); } }); io.on("connection", function(socket) { socket.on("join", function(name) { // if name already taken, emits an error event back to chatroom var socketList = io.sockets.sockets; var nameTaken = false; for (var i = 0; i < socketList.length; i++) { if (socketList[i].nickname === name) { nameTaken = true; break; } } if (nameTaken) { socket.emit("nameTaken", name); return; } // accepts new user. Sets the name associated with this user socket.nickname = name; // announces new user socket.broadcast.emit("newUser", name); socket.emit("newUser", name); // loads chat history db.serialize(function() { if (existed) { db.each("SELECT * FROM chatHistory", function(err, row) { socket.emit("message", row.name, row.message, row.time); }); } }); }); socket.on("newMessage", function(message) { var time = getTimeString(); socket.broadcast.emit("message", socket.nickname, message, time); socket.emit("message", socket.nickname, message, time); // saves message into database db.serialize(function() { db.run("INSERT into chatHistory (name, message, time)" + " VALUES (?, ?, ?)", socket.nickname, message, time); }); }); socket.on("disconnect", function() { socket.broadcast.emit("exit", socket.nickname); }); }); function getTimeString() { var date = new Date(); var ret = date.getMonth() + "." + date.getDate() + "." + date.getFullYear() + " "; var time = date.getHours(); if (time < 12) { ret += time + ":" + date.getMinutes() + "AM"; } else { if (time > 12) { time -= 12; } ret += time + ":" + date.getMinutes() + "PM"; } return ret; } server.listen(8080); //db.close();
quynhnga-nguyen/FSEChatRoom
server.js
JavaScript
gpl-2.0
2,600
/****************************************************************************** °æÈ¨ËùÓÐ (C), 2001-2012, »ªÎª¼¼ÊõÓÐÏÞ¹«Ë¾ ****************************************************************************** ÎÄ ¼þ Ãû : ScApSec.h °æ ±¾ ºÅ : ³õ¸å Éú³ÉÈÕÆÚ : 2012Äê8ÔÂ27ÈÕ ×î½üÐÞ¸Ä : ¹¦ÄÜÃèÊö : SCÄ£¿é º¯ÊýÁбí : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö ******************************************************************************/ #ifndef __SCAPSEC_H__ #define __SCAPSEC_H__ #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif #pragma pack(4) /***************************************************************************** 1 ÆäËûÍ·Îļþ°üº¬ *****************************************************************************/ #include "vos.h" #include "ScInterface.h" #include "ScComm.h" /***************************************************************************** 2 ºê¶¨Òå *****************************************************************************/ #define SC_SECURITY_ITEM_NUM (16) /* °²È«´æ´¢Ïî¸öÊý */ #define SC_SECURITY_ITEM_LENGTH_SIZE (4) /* °²È«´æ´¢Ï¶È×ֶδóС */ #define SC_SECURITY_ITEM_CONTENT_SIZE (256) /* °²È«´æ´¢ÏîÄÚÈÝ×ֶδóС */ #define SC_SECURITY_ITEM_HASH_SIZE (32) /* °²È«´æ´¢ÏîHASH×ֶδóС */ #define SC_SECURITY_ITEM_PADDING_SIZE (12) /* °²È«´æ´¢¹Ì¶¨Ìî³ä×ֶδóС */ #define SC_SECURITY_ITEM_TOTAL_SIZE (SC_SECURITY_ITEM_LENGTH_SIZE\ + SC_SECURITY_ITEM_CONTENT_SIZE\ + SC_SECURITY_ITEM_HASH_SIZE\ + SC_SECURITY_ITEM_PADDING_SIZE) /* °²È«´æ´¢Ïî×Ü´óС */ #define SC_SECURITY_ITEM_PADDING_VALUE (0xC) /* °²È«´æ´¢¹Ì¶¨Ìî³äÄÚÈÝ */ #define SC_SEC_AT_KEY_LEN (16) /* °²È«AT keyµÄ³¤¶È */ #define SC_APSEC_SP_MAX_DATA_LEN (266) /* °²È«·â°üÊý¾Ý¶Î×î´ó³¤¶È */ #define SC_AES_TEXT_MIN_LEN (16) /* AES¼Ó½âÃÜËã·¨Îı¾×îС×Ö½ÚÊý */ #define SC_APSEC_SP_MAJOR_VERSION (1) /* °²È«·â°üÖ÷ÃüÁî°æ±¾ */ #define SC_APSEC_SP_MAJOR_SECSTORE (1) /* °²È«·â°üÖ÷ÃüÁîÀàÐͰ²È«´æ´¢ */ #define SC_APSEC_SP_MAJOR_AT_KEY (0xD0) /* °²È«·â°üÖ÷ÃüÉèÖð²È«AT key */ #define SC_APSEC_SP_MINOR_VERSION (1) /* °²È«·â°ü´ÎÃüÁî°æ±¾ */ #define SC_APSEC_SP_MINOR_AT_KEY (0x90) /* °²È«·â°ü´ÎÃüÉèÖð²È«AT key */ #define SC_APSEC_SP_MINOR_READ (1) /* °²È«·â°ü´ÎÃü¶Á°²È«Êý¾ÝÏî */ #define SC_APSEC_SP_MINOR_WRITE (2) /* °²È«·â°ü´ÎÃüд°²È«Êý¾ÝÏî */ #define SC_APSEC_SP_FLAG_REQ (1) /* APÏ·¢ÇëÇó°²È«·â°üÖеıê־λ */ #define SC_APSEC_SP_FLAG_CNF (2) /* Modem»Ø¸´°²È«·â°üÖеıê־λ */ #define SC_APSEC_SP_FLAG_AT_KEY (0x40) /* APÉèÖð²È«AT key°²È«·â°üÖеıê־λ */ #define SC_APSEC_SP_FLAG_ATSEC_REQ_AT_KEY (1) /* °²È«·â°ü±ê־λÇëÇó°²È«AT key */ #define SC_APSEC_SP_FLAG_ATSEC_SEQID_ERR (4) /* °²È«·â°ü±ê־λÇëÇó°²È«AT key */ #define SC_APSEC_SP_FLAG_ATSEC_PARA_ERR (5) /* °²È«·â°ü±ê־λÇëÇó°²È«AT key */ #define SC_APSEC_SP_FLAG_RLT_SUCCESS (0) /* °²È«·â°ü±ê־λ·µ»Ø´¦Àí³É¹¦ */ #define SC_APSEC_SP_FLAG_RLT_PARAERR (5) /* °²È«·â°ü±ê־λ·µ»Ø²ÎÊý´íÎó */ #define SC_APSEC_SP_FLAG_RLT_DUALBACK_FAILED (6) /* °²È«·â°ü±ê־λ·µ»ØË«±¸·Ýʧ°Ü */ #define SC_APSEC_SP_SEQID_MIN_VALUE (0x01) /* °²È«·â°üÖÐSeqIDµÄ×îСֵ */ #define SC_APSEC_SP_SEQID_MAX_VALUE (0xFF) /* °²È«·â°üÖÐSeqIDµÄ×î´óÖµ */ #define SC_APSEC_SP_SEQID_AT_KEY (0x00) /* ÉèÖð²È«AT keyʱ°²È«·â°üÖÐSeqIDµÄÖµ */ #define SC_APSEC_SP_RANDOM_LEN (16) /* APÏ·¢µÄËæ»úÊý³¤¶È */ /***************************************************************************** 3 ö¾Ù¶¨Òå *****************************************************************************/ /***************************************************************************** ö¾ÙÃû : SC_APSEC_ITME_ENUM ö¾Ù˵Ã÷ : Ö¸¶¨°²È«Êý¾ÝÏîµÄÀàÐÍ 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ enum SC_APSEC_ITME_ENUM { SC_APSEC_ITME_UE_IMEI_I = 0, /* IMEI */ SC_APSEC_ITME_MMB_KL_TEMP = 1, /* Temporary license key */ SC_APSEC_ITME_MMB_KL_REAL = 2, /* Usually license key */ SC_APSEC_ITME_MMB_CASID = 3, /* CA system ID */ SC_APSEC_ITME_MMB_ME_PUBKEY = 4, /* Public key */ SC_APSEC_ITME_MMB_ME_PRIVKEY = 5, /* Private key */ SC_APSEC_ITME_MMB_ME_SIGNATURE = 6, /* signature */ SC_APSEC_ITME_MMB_SEC_SRV_STAT = 7, /* secure clock state */ SC_APSEC_ITME_MMB_SEC_NITZ = 8, /* Broadcast clock */ SC_APSEC_ITME_MMB_SEC_RTC = 9, /* RTC */ SC_APSEC_ITME_MMB_NUM = 10, /* ±£Áô1 */ SC_APSEC_ITME_MMB_RESERVED2 = 11, /* ±£Áô2 */ SC_APSEC_ITME_MMB_RESERVED3 = 12, /* ±£Áô3 */ SC_APSEC_ITME_MMB_RESERVED4 = 13, /* ±£Áô4 */ SC_APSEC_ITME_MMB_RESERVED5 = 14, /* ±£Áô5 */ SC_APSEC_ITME_MMB_RESERVED6 = 15, /* ±£Áô6 */ SC_APSEC_ITEM_MMB_BUTT, }; typedef VOS_UINT32 SC_APSEC_ITME_ENUM_UINT32; /***************************************************************************** ö¾ÙÃû : SC_APSEC_FILE_STATE_INIT_ENUM ö¾Ù˵Ã÷ : °²È«´æ´¢Îļþ³õʼ»¯×´Ì¬ 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ enum SC_APSEC_FILE_STATE_INIT_ENUM { SC_SECURITY_FILE_STATE_INIT = 0x5A5A5A5A, /* °²È«´æ´¢Îļþ³õʼ»¯Íê³É */ SC_SECURITY_FILE_STATE_IDEL = 0x5A5A55AA, /* °²È«´æ´¢Îļþ³õʼ»¯Î´Íê³É */ SC_SECURITY_FILE_STATE_BUTT, }; typedef VOS_UINT32 SC_APSEC_FILE_STATE_INIT_ENUM_UINT32; enum SC_APSEC_SP_RESULT_ENUM { SC_APSEC_SP_OK = 0, /* °²È«·â°üOK */ SC_APSEC_SP_NO_SATK = 1, /* °²È«·â°üÎÞ°²È«AT key */ SC_APSEC_SP_PADDING_ERR = 2, /* °²È«·â°üPADDINGλ´íÎó */ SC_APSEC_SP_SEQID_ERR = 3, /* °²È«·â°üSeqIDУÑéʧ°Ü */ SC_APSEC_SP_PARA_ERR = 4, /* °²È«·â°ü×ֶβÎÊý´íÎó */ SC_APSEC_SP_ERROR, /* °²È«·â°ü´æÔÚÆäËûÒì³£ */ }; typedef VOS_UINT32 SC_APSEC_SP_RESULT_ENUM_UINT32; /***************************************************************************** 4 È«¾Ö±äÁ¿ÉùÃ÷ *****************************************************************************/ /***************************************************************************** 5 ÏûϢͷ¶¨Òå *****************************************************************************/ /***************************************************************************** 6 ÏûÏ¢¶¨Òå *****************************************************************************/ /***************************************************************************** 7 STRUCT¶¨Òå *****************************************************************************/ /***************************************************************************** ½á¹¹Ãû : SC_APSEC_SECTURE_ITEM_STRU ö¾Ù˵Ã÷ : °²È«´æ´¢Ïî¶ÁȡдÈëÏî½á¹¹ 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ typedef struct { SC_APSEC_ITME_ENUM_UINT32 enItemId; VOS_UINT32 ulItemLen; VOS_UINT8 *pucContent; }SC_APSEC_SECTURE_ITEM_STRU; /***************************************************************************** ½á¹¹Ãû : SC_APSEC_SECTURE_ITEM_STRU ö¾Ù˵Ã÷ : °²È«´æ´¢Ïî¶ÁȡдÈëÏî½á¹¹ 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ typedef struct { VOS_UINT8 aucEncryptContent[SC_SECURITY_ITEM_TOTAL_SIZE]; }SC_APSEC_ENCRYPT_STRU; /***************************************************************************** ½á¹¹Ãû : SC_APSEC_DEFAULT_ITEM_STRU ö¾Ù˵Ã÷ : °²È«´æ´¢ÏîĬÈϽṹ 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ typedef struct { VOS_UINT32 ulItemLen; VOS_UINT8 aucContent[SC_SECURITY_ITEM_CONTENT_SIZE]; VOS_UINT8 aucHash[SC_SECURITY_ITEM_HASH_SIZE]; }SC_APSEC_DEFAULT_ITEM_STRU; typedef struct { VOS_UINT8 ucSeqID; VOS_UINT8 ucMajorCMD; VOS_UINT8 ucMinorCMD; VOS_UINT8 ucFlag; } SC_APSEC_SP_HEADER_STRU; typedef struct { VOS_UINT8 ucReserved :4; VOS_UINT8 ucVer :2; VOS_UINT8 ucType :2; } SC_APSEC_SP_MAJOR_CMD_STRU; typedef struct { VOS_UINT8 ucSecItem :4; VOS_UINT8 ucVer :2; VOS_UINT8 ucType :2; } SC_APSEC_SP_MINOR_CMD_STRU; typedef struct { VOS_UINT8 ucResult :3; VOS_UINT8 ucAtSec :3; VOS_UINT8 ucType :2; } SC_APSEC_SP_FLAG_STRU; typedef struct { SC_APSEC_SP_HEADER_STRU stHeader; VOS_UINT16 usDataLen; VOS_UINT8 aucData[SC_APSEC_SP_MAX_DATA_LEN]; } SC_APSEC_SECURE_PACKET_STRU; /***************************************************************************** 8 UNION¶¨Òå *****************************************************************************/ /***************************************************************************** 9 OTHERS¶¨Òå *****************************************************************************/ /***************************************************************************** 10 º¯ÊýÉùÃ÷ *****************************************************************************/ /***************************************************************************** º¯ Êý Ãû : SC_APSEC_GetFileInitState ¹¦ÄÜÃèÊö : »ñȡ˫±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ30ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_GetFileInitState(VOS_VOID); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_SetFileInitState ¹¦ÄÜÃèÊö : ÉèÖÃË«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÊäÈë²ÎÊý : ulState:Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ30ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_VOID SC_APSEC_SetFileInitState(SC_APSEC_FILE_STATE_INIT_ENUM_UINT32 ulState); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_EncryptItem ¹¦ÄÜÃèÊö : °²È«´æ´¢Ïî¸üÐÂ½Ó¿Ú ÊäÈë²ÎÊý : pucSrc: δ¼ÓÃÜÊý¾Ý ulItemLen: itemµÄ³¤¶È Êä³ö²ÎÊý : pucDest:¼ÓÃܺóÃÜÎÄ ·µ »Ø Öµ : VOS_UINT32 ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_EncryptItem( VOS_UINT32 ulItemLen, const VOS_CHAR *pucSrc, VOS_CHAR *pucDest); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_UpdateSecItem ¹¦ÄÜÃèÊö : °²È«´æ´¢Ïî¸üÐÂ½Ó¿Ú ÊäÈë²ÎÊý : pstSecItem: ÐèÒª¸üÐµİ²È«´æ´¢ÏîÄÚÈÝ enSecItemId:°²È«´æ´¢ÏîID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ27ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_UpdateSecItem( SC_APSEC_ITME_ENUM_UINT32 enSecItemId, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItem); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_ReadEncryptFile ¹¦ÄÜÃèÊö : ±¸·Ý¼ÓÃÜÎļþ¶ÁÈ¡µ½ÄÚ´æÖÐ ÊäÈë²ÎÊý : pucFile:Îļþ·¾¶ Êä³ö²ÎÊý : ppstEncryptFile:ÎļþÄÚÈÝÔÚÄÚ´æÖб£´æµÄµØÖ· ·µ »Ø Öµ : ¼ÓÃÜÎļþÔÚÄÚ´æÖеĵØÖ· ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ31ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern SC_APSEC_ENCRYPT_STRU* SC_APSEC_ReadEncryptFile(VOS_CHAR *pucFile); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_ReadEncryptItem ¹¦ÄÜÃèÊö : Ë«±¸·ÝÎļþ¼ÓÃÜ´æ´¢Ïî¶ÁÈ¡£¬Íê³ÉHASH¼ìÑé²¢½âÃÜ ÊäÈë²ÎÊý : enSecItemId:°²È«´æ´¢ÏîID pstFileContent:°²È«´æ´¢ÎļþԭʼÊý¾Ý Êä³ö²ÎÊý : pstSecItem:½âÃܺóµÄ°²È«´æ´¢Ïî ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ30ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_ReadEncryptItem( SC_APSEC_ITME_ENUM_UINT32 enSecItemId, SC_APSEC_ENCRYPT_STRU *pstFileContent, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItem); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_InitDualBackFile ¹¦ÄÜÃèÊö : Ë«±¸·ÝÎļþ½âÃܺóµÄÊý¾Ý³õʼ»¯µ½ÄÚ´æÖÐ ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ30ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_InitDualBackFile(VOS_VOID); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_GetFileSyncFlg ¹¦ÄÜÃèÊö : Ë«±¸·ÝÎļþÖØÍ¬²½±ê¼Ç»ñÈ¡º¯Êý ÊäÈë²ÎÊý : enSecItemId:°²È«´æ´¢Ïî pstEncryptFileA:Ö¸Ïò¼ÓÃÜÎļþAÖа²È«´æ´¢ÏîµÄÖ¸Õë pstEncryptFileC:Ö¸Ïò¼ÓÃÜÎļþCÖа²È«´æ´¢ÏîµÄÖ¸Õë Êä³ö²ÎÊý : pstSecItemA:¼ÓÃÜÎļþA½âÃܺóµÃµ½µÄ°²È«´æ´¢Ïî pstSecItemC:¼ÓÃÜÎļþC½âÃܺóµÃµ½µÄ°²È«´æ´¢Ïî pulFileSyncFlgA:ÎļþAÐèÒªÖØÍ¬²½µÄ±ê¼Ç pulFileSyncFlgC:ÎļþCÐèÒªÖØÍ¬²½µÄ±ê¼Ç ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ3ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_VOID SC_APSEC_GetFileSyncFlg( SC_APSEC_ITME_ENUM_UINT32 enSecItemId, SC_APSEC_ENCRYPT_STRU *pstEncryptFileA, SC_APSEC_ENCRYPT_STRU *pstEncryptFileC, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItemA, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItemC, VOS_UINT32 *pulFileSyncFlgA, VOS_UINT32 *pulFileSyncFlgC); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_ResyncFile ¹¦ÄÜÃèÊö : Ë«±¸·ÝÎļþÖØÍ¬²½´¦Àíº¯Êý ÊäÈë²ÎÊý : ulSyncFileFlg:Ë«±¸·ÝÎļþÖØÍ¬²½±ê¼Ç Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ3ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_ResyncFile(VOS_UINT32 ulSyncFileFlg); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_ReadSecItem ¹¦ÄÜÃèÊö : °²È«´æ´¢¼ö¶ÁÈ¡ ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ30ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_ReadSecItem( SC_APSEC_ITME_ENUM_UINT32 enSecItemId, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItem); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_FreshDualBackFile ¹¦ÄÜÃèÊö : °²È«´æ´¢Ë«±¸·ÝÎļþˢРÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : Ë«±¸·ÝÎļþ³õʼ»¯×´Ì¬ ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ31ÈÕ ÐÞ¸ÄÄÚÈÝ : V7R1C50 ISDB°²È«´æ´¢ÏîÄ¿ÐÂÔö *****************************************************************************/ extern VOS_UINT32 SC_APSEC_FreshDualBackFile(VOS_VOID); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_IncrementSeqID ¹¦ÄÜÃèÊö : ±¾µØÈ«¾Ö±äÁ¿ÖеÄSeqID×ÔÔö1 ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_VOID µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ2ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ extern VOS_VOID SC_APSEC_IncrementSeqID( VOS_VOID ); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_RegressSeqID ¹¦ÄÜÃèÊö : ¸´Ô­±¾µØÈ«¾Ö±äÁ¿ÖеÄSeqID ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_VOID µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ2ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ extern VOS_VOID SC_APSEC_RegressSeqID( VOS_VOID ); extern VOS_UINT32 SC_APSEC_GenerateSecATkey( VOS_UINT32 *pulSPLen, VOS_UINT8 *pucSecPacket ); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_DecryptSecPacket ¹¦ÄÜÃèÊö : ʹÓÃAES-ECBËã·¨½âÃܰ²È«·â°ü ÊäÈë²ÎÊý : VOS_UINT8 *pucCipherSP -- °²È«·â°üÃÜÎÄ VOS_UINT32 ulCipherSPLen -- °²È«·â°üÃÜÎij¤¶È Êä³ö²ÎÊý : SC_APSEC_SECURE_PACKET_STRU *pstSecPacket -- ½âÃܺóµÄ°²È«·â°ü ·µ »Ø Öµ : SC_APSEC_DECRYPT_RESULT_ENUM_UINT32 µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ2ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ SC_APSEC_SP_RESULT_ENUM_UINT32 SC_APSEC_DecryptSecPacket( VOS_UINT8 *pucCipherSP, VOS_UINT32 ulCipherSPLen, SC_APSEC_SECURE_PACKET_STRU *pstSecPacket ); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_CheckSecPacket ¹¦ÄÜÃèÊö : ¼ì²é°²È«·â°üУÑéλ ÊäÈë²ÎÊý : pstSecPacket -- ´ýУÑéµÄ°²È«·â°ü Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : SC_APSEC_SP_RESULT_ENUM_UINT32 µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ2ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ SC_APSEC_SP_RESULT_ENUM_UINT32 SC_APSEC_CheckSecPacket( SC_APSEC_SECURE_PACKET_STRU *pstSecPacket ); extern VOS_UINT32 SC_APSEC_EncryptSecPacket( SC_APSEC_SECURE_PACKET_STRU *pstSecPacket, VOS_UINT8 *pucCipherSP, VOS_UINT32 *pulCipherSPLen); extern VOS_UINT32 SC_APSEC_CreateSecPacket( SC_APSEC_SP_RESULT_ENUM_UINT32 enResult, SC_APSEC_SECURE_PACKET_STRU *pstSecPacket, VOS_UINT8 *pucSecPacket, VOS_UINT32 *pulSPLen ); /***************************************************************************** º¯ Êý Ãû : SC_APSEC_DealSecureStorage ¹¦ÄÜÃèÊö : ´¦Àí°²È«´æ´¢ÃüÁî ÊäÈë²ÎÊý : SC_APSEC_SECURE_PACKET_STRU *pstSecPacket -- ´ý´¦ÀíµÄ°²È«·â°ü Êä³ö²ÎÊý : SC_APSEC_SECURE_PACKET_STRU *pstSecPacket -- ´¦ÀíÍê³ÉµÄ°²È«·â°ü ·µ »Ø Öµ : VOS_VOID µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê9ÔÂ2ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ extern VOS_VOID SC_APSEC_DealSecureStorage( SC_APSEC_SECURE_PACKET_STRU *pstSecPacket ); extern VOS_UINT32 SC_APSEC_GetDefaultSecItem( SC_APSEC_ITME_ENUM_UINT32 enSecItemId, SC_APSEC_DEFAULT_ITEM_STRU *pstSecItem); extern SC_APSEC_SECTURE_ITEM_STRU* SC_APSEC_GetSecItemDefaultTbl(VOS_VOID); #if ((VOS_OS_VER == VOS_WIN32) || (VOS_OS_VER == VOS_NUCLEUS)) #pragma pack() #else #pragma pack(0) #endif #ifdef __cplusplus #if __cplusplus } #endif #endif #endif
araca/Zen-Kernel-Huawei-P7
drivers/hisi/modem/oam/inc/gu/ccore/sc/ScApSec.h
C
gpl-2.0
22,528
/* from Henry Spencer's stringlib */ /* Bugfix by Guido: Handle empty strings correctly. */ #include <string.h> #undef strstr /* * strstr - find first occurrence of wanted in s */ char * /* found string, or NULL if none */ strstr(s, wanted) const char *s; const char *wanted; { register const char *scan; register size_t len; register char firstc; if (!*s) { if (*wanted) return NULL; else return (char*) s; } else if (!*wanted) { return (char*) s; } /* * The odd placement of the two tests is so "" is findable. * Also, we inline the first char for speed. * The ++ on scan has been moved down for optimization. */ firstc = *wanted; len = strlen(wanted); for (scan = s; *scan != firstc || strncmp(scan, wanted, len) != 0; ) if (*scan++ == '\0') return(NULL); return((char *)scan); }
ArmstrongJ/MiNTLib
string/strstr.c
C
gpl-2.0
831
<?php /** * Tools for creating thumbnails. * * @package Image * @author C. Erdmann * @link http://www.cerdmann.de/thumb * @author Robert Wetzlmayr * * Refactored from function.thumb.php by C. Erdmann, which contained * the following credit and licensing terms: * * Smarty plugin "Thumb" * Purpose: creates cached thumbnails * Home: http://www.cerdmann.com/thumb/ * Copyright (C) 2005 Christoph Erdmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * * @author Christoph Erdmann (CE) <smarty@cerdmann.com> * @link http://www.cerdmann.com * * @author Benjamin Fleckenstein (BF) * @link http://www.benjaminfleckenstein.de * * @author Marcus Gueldenmeister (MG) * @link http://www.gueldenmeister.de/marcus/ * * @author Andreas Bösch (AB) */ /** * Output debug log. * * @global bool $verbose */ $verbose = false; /** * Creates thumbnails for larger images. * * @package Image */ class wet_thumb { /** * The width of your thumbnail. The height (if not set) will be * automatically calculated. * * @var int */ public $width; /** * The height of your thumbnail. The width (if not set) will be * automatically calculated. * * @var int */ public $height; /** * Set the longest side of the image if width, height and shortside is * not set. */ public $longside; /** * Set the shortest side of the image if width, height and longside is * not set. */ public $shortside; /** * Set to 'false' if your source image is smaller than the calculated * thumb and you do not want the image to get extrapolated. */ public $extrapolate; /** * Crops the image. * * If set to TRUE, image will be cropped in the center to destination width * and height params, while keeping aspect ratio. Otherwise the image will * get resized. * * @var bool */ public $crop; /** * Applies unsharpen mask. * * Set to FALSE if you don't want to use the Unsharp-Mask. * Thumbnail creation will be faster, but quality is reduced. * * @var bool */ public $sharpen; /** * If set to FALSE the image will not have a lens icon. * * @var bool */ public $hint; /** * Set to FALSE to get no lightgrey bottom bar. * * @var bool */ public $addgreytohint; /** * JPEG image quality (0...100, defaults to 80). * * @var int */ public $quality; /** * Set to your target URL (a href="linkurl"). * * @var string */ public $linkurl; /** * Will be inserted in the image-tag. * * @var string */ public $html; /** * An array of accepted image formats. * * @var array */ public $types = array('', '.gif', '.jpg', '.png'); /** * Source. * * @var array */ public $_SRC; /** * Destination. * * @var array */ public $_DST; /** * Constructor. */ public function __construct() { $this->extrapolate = false; $this->crop = true; $this->sharpen = true; $this->hint = true; $this->addgreytohint = true; $this->quality = 80; $this->html = ' alt="" title="" '; $this->link = true; } /** * Writes a thumbnail file. * * @param string $infile Image file name. * @param array $outfile Array of thumb file names (1...n) * @return bool TRUE on success */ public function write($infile, $outfile) { global $verbose; if ($verbose) { echo "writing thumb nail..."; } // Get source image info. if (!($temp = txpimagesize($infile, true)) || empty($temp['image'])) { return false; } $this->_SRC['file'] = $infile; $this->_SRC['width'] = $temp[0]; $this->_SRC['height'] = $temp[1]; $this->_SRC['type'] = $temp[2]; // 1=GIF, 2=JPEG, 3=PNG, 18=WebP, 19=AVIF. $this->_SRC['string'] = $temp[3]; $this->_SRC['image'] = $temp['image']; $this->_SRC['filename'] = basename($infile); //$this->_SRC['modified'] = filemtime($infile); /* // Make sure we have enough memory if the image is large. if (max($this->_SRC['width'], $this->_SRC['height']) > 1024) { $shorthand = array('K', 'M', 'G'); $tens = array('000', '000000', '000000000'); // A good enough decimal approximation of K, M, and G. // Do not *decrease* memory_limit. list($ml, $extra) = str_ireplace($shorthand, $tens, array(ini_get('memory_limit'), EXTRA_MEMORY)); if ($ml < $extra) { ini_set('memory_limit', EXTRA_MEMORY); } } // Read source image. if ($this->_SRC['type'] == 1) { $this->_SRC['image'] = imagecreatefromgif($this->_SRC['file']); } elseif ($this->_SRC['type'] == 2) { $this->_SRC['image'] = imagecreatefromjpeg($this->_SRC['file']); } elseif ($this->_SRC['type'] == 3) { $this->_SRC['image'] = imagecreatefrompng($this->_SRC['file']); } elseif ($this->_SRC['type'] == 18) { $this->_SRC['image'] = imagecreatefromwebp($this->_SRC['file']); } elseif ($this->_SRC['type'] == 19) { $this->_SRC['image'] = imagecreatefromavif($this->_SRC['file']); } */ // Ensure non-zero height/width. if (!$this->_SRC['height']) { $this->_SRC['height'] = 100; } if (!$this->_SRC['width']) { $this->_SRC['width'] = 100; } // Check image orientation. if ($this->_SRC['width'] >= $this->_SRC['height']) { $this->_SRC['format'] = 'landscape'; } else { $this->_SRC['format'] = 'portrait'; } // Get destination image info. if (is_numeric($this->width) and empty($this->height)) { $this->_DST['width'] = $this->width; $this->_DST['height'] = round($this->width/($this->_SRC['width']/$this->_SRC['height'])); } elseif (is_numeric($this->height) and empty($this->width)) { $this->_DST['height'] = $this->height; $this->_DST['width'] = round($this->height/($this->_SRC['height']/$this->_SRC['width'])); } elseif (is_numeric($this->width) and is_numeric($this->height)) { $this->_DST['width'] = $this->width; $this->_DST['height'] = $this->height; } elseif (is_numeric($this->longside) and empty($this->shortside)) { // Preserve aspect ratio based on provided height. if ($this->_SRC['format'] == 'portrait') { $this->_DST['height'] = $this->longside; $this->_DST['width'] = round($this->longside/($this->_SRC['height']/$this->_SRC['width'])); } else { $this->_DST['width'] = $this->longside; $this->_DST['height'] = round($this->longside/($this->_SRC['width']/$this->_SRC['height'])); } } elseif (is_numeric($this->shortside)) { // Preserve aspect ratio based on provided width. if ($this->_SRC['format'] == 'portrait') { $this->_DST['width'] = $this->shortside; $this->_DST['height'] = round($this->shortside/($this->_SRC['width']/$this->_SRC['height'])); } else { $this->_DST['height'] = $this->shortside; $this->_DST['width'] = round($this->shortside/($this->_SRC['height']/$this->_SRC['width'])); } } else { // Default dimensions. $this->width = 100; $this->_DST['width'] = $this->width; $this->_DST['height'] = round($this->width/($this->_SRC['width']/$this->_SRC['height'])); } // Don't make the new image larger than the original image. if ( $this->extrapolate === false && $this->_DST['height'] > $this->_SRC['height'] && $this->_DST['width'] > $this->_SRC['width'] ) { $this->_DST['width'] = $this->_SRC['width']; $this->_DST['height'] = $this->_SRC['height']; } $this->_DST['type'] = $this->_SRC['type']; $this->_DST['file'] = $outfile; // Crop image. $off_w = 0; $off_h = 0; if ($this->crop != false) { if ($this->_SRC['height'] < $this->_SRC['width']) { $ratio = (double) ($this->_SRC['height'] / $this->_DST['height']); $cpyWidth = round($this->_DST['width'] * $ratio); if ($cpyWidth > $this->_SRC['width']) { $ratio = (double) ($this->_SRC['width'] / $this->_DST['width']); $cpyWidth = $this->_SRC['width']; $cpyHeight = round($this->_DST['height'] * $ratio); $off_w = 0; $off_h = round(($this->_SRC['height'] - $cpyHeight) / 2); $this->_SRC['height'] = $cpyHeight; } else { $cpyHeight = $this->_SRC['height']; $off_w = round(($this->_SRC['width'] - $cpyWidth) / 2); $off_h = 0; $this->_SRC['width'] = $cpyWidth; } } else { $ratio = (double) ($this->_SRC['width'] / $this->_DST['width']); $cpyHeight = round($this->_DST['height'] * $ratio); if ($cpyHeight > $this->_SRC['height']) { $ratio = (double) ($this->_SRC['height'] / $this->_DST['height']); $cpyHeight = $this->_SRC['height']; $cpyWidth = round($this->_DST['width'] * $ratio); $off_w = round(($this->_SRC['width'] - $cpyWidth) / 2); $off_h = 0; $this->_SRC['width'] = $cpyWidth; } else { $cpyWidth = $this->_SRC['width']; $off_w = 0; $off_h = round(($this->_SRC['height'] - $cpyHeight) / 2); $this->_SRC['height'] = $cpyHeight; } } } // Create DST. $this->_DST['image'] = imagecreatetruecolor($this->_DST['width'], $this->_DST['height']); // GIF or PNG destination, set the transparency up. if ($this->_DST['type'] == 1 || $this->_DST['type'] == 3 || $this->_DST['type'] == 18) { $trans_idx = imagecolortransparent($this->_SRC['image']); $pallet_size = imagecolorstotal($this->_SRC['image']); // Is there a specific transparent colour? if ($trans_idx >= 0 && ($trans_idx < $pallet_size)) { $trans_color = imagecolorsforindex($this->_SRC['image'], $trans_idx); $trans_idx = imagecolorallocate( $this->_DST['image'], $trans_color['red'], $trans_color['green'], $trans_color['blue'] ); imagefill($this->_DST['image'], 0, 0, $trans_idx); imagecolortransparent($this->_DST['image'], $trans_idx); } elseif ($this->_DST['type'] == 3 || $this->_DST['type'] == 18 || $this->_DST['type'] == 19) { imagealphablending($this->_DST['image'], false); $transparent = imagecolorallocatealpha($this->_DST['image'], 0, 0, 0, 127); imagefill($this->_DST['image'], 0, 0, $transparent); imagesavealpha($this->_DST['image'], true); } } imagecopyresampled( $this->_DST['image'], $this->_SRC['image'], 0, 0, $off_w, $off_h, $this->_DST['width'], $this->_DST['height'], $this->_SRC['width'], $this->_SRC['height'] ); // avif weirdness if ($this->_DST['type'] == 19) { imageflip($this->_DST['image'], IMG_FLIP_HORIZONTAL); } if ($this->sharpen === true) { $this->_DST['image'] = UnsharpMask($this->_DST['image'], 80, .5, 3); } // Finally, the real dimensions. $this->height = $this->_DST['height']; $this->width = $this->_DST['width']; // Add magnifying glass. if ($this->hint === true) { // Should we really add white bars? if ($this->addgreytohint === true) { $trans = imagecolorallocatealpha($this->_DST['image'], 255, 255, 255, 25); imagefilledrectangle( $this->_DST['image'], 0, $this->_DST['height'] - 9, $this->_DST['width'], $this->_DST['height'], $trans ); } $magnifier = imagecreatefromstring(gzuncompress(base64_decode("eJzrDPBz5+WS4mJgYOD19HAJAtLcIMzBBiRXrilXA1IsxU6eIRxAUMOR0gHkcxZ4RBYD1QiBMOOlu3V/gIISJa4RJc5FqYklmfl5CiGZuakMBoZ6hkZ6RgYGJs77ex2BalRBaoLz00rKE4tSGXwTk4vyc1NTMhMV3DKLUsvzi7KLFXwjFEAa2svWnGdgYPTydHEMqZhTOsE++1CAyNHzm2NZjgau+dAmXlAwoatQmOld3t/NPxlLMvY7sovPzXHf7re05BPzjpQTMkZTPjm1HlHkv6clYWK43Zt16rcDjdZ/3j2cd7qD4/HHH3GaprFrw0QZDHicORXl2JsPsveVTDz//L3N+WpxJ5Hff+10Tjdd2/Vi17vea79Om5w9zzyne9GLnWGrN8atby/ayXPOsu2w4quvVtxNCVVz5nAf3nDpZckBCedpqSc28WTOWnT7rZNXZSlPvFybie9EFc6y3bIMCn3JAoJ+kyyfn9qWq+LZ9Las26Jv482cDRE6Ci0B6gVbo2oj9KabzD8vyMK4ZMqMs2kSvW4chz88SXNzmeGjtj1QZK9M3HHL8L7HITX3t19//VVY8CYDg9Kvy2vDXu+6mGGxNOiltMPsjn/t9eJr0ja/FOdi5TyQ9Lz3fOqstOr99/dnro2vZ1jy76D/vYivPsBoYPB09XNZ55TQBAAJjs5s</body>"))); imagealphablending($this->_DST['image'], true); imagecopy($this->_DST['image'], $magnifier, $this->_DST['width'] - 15, $this->_DST['height'] - 14, 0, 0, 11, 11); imagedestroy($magnifier); } if ($verbose) { echo "... saving image ..."; } $result = false; if ($this->_DST['type'] == 1) { imagetruecolortopalette($this->_DST['image'], false, 256); $imagefn = 'imagegif'; } elseif ($this->_DST['type'] == 2) { $imagefn = 'imagejpeg'; } elseif ($this->_DST['type'] == 3) { $imagefn = 'imagepng'; } elseif ($this->_DST['type'] == 18) { $imagefn = 'imagewebp'; } elseif ($this->_DST['type'] == 19) { $imagefn = 'imageavif'; } if (isset($imagefn) && function_exists($imagefn)) { $result = $imagefn == 'imagejpeg' ? imagejpeg($this->_DST['image'], $this->_DST['file'], $this->quality) : $imagefn($this->_DST['image'], $this->_DST['file']); } imagedestroy($this->_DST['image']); imagedestroy($this->_SRC['image']); if ($verbose) { echo $result ? "... image successfully saved ..." : "... failed to save image ..."; } return $result; } /** * Return a reference to the the thumbnail image as a HTML a or img tag. * * @param bool $aslink Return an anchor tag to the source image * @param bool $aspopup Open the link in new window * @return string HTML markup */ public function asTag($aslink = true, $aspopup = false) { $imgtag = '<img src="'.$this->_DST['file'].'" '.$this->html.' width="'.$this->width.'" height="'.$this->height.'" />'; if ($aslink === true) { return '<a href="'.((empty($this->linkurl)) ? $this->_SRC['file'] : $this->linkurl).'" '. (($aspopup === true) ? ' target="_blank"' : '').'>'.$imgtag.'</a>'; } return $imgtag; } } /** * Wrapper for wet_thumb interfacing Textpattern. * * @package Image */ class txp_thumb extends wet_thumb { /** * File extension. * * @var string */ public $m_ext; /** * Image ID. * * @var int */ public $m_id; /** * Constructor. * * @param int $id The Image id. */ public function __construct($id) { $id = assert_int($id); $rs = safe_row("*", 'txp_image', "id = $id LIMIT 1"); if ($rs) { extract($rs); $this->m_ext = $ext; $this->m_id = $id; } parent::__construct(); } /** * Creates a thumbnail image from a source image. * * @param string $dummy1 Isn't used. * @param string $dummy2 Isn't used. * @return bool TRUE on success */ public function write($dummy1 = '', $dummy2 = '') { if (!isset($this->m_ext)) { return false; } if (parent::write( IMPATH.$this->m_id.$this->m_ext, IMPATH.$this->m_id.'t'.$this->m_ext )) { safe_update( 'txp_image', "thumbnail = 1, thumb_w = $this->width, thumb_h = $this->height, date = NOW()", "id = ".$this->m_id ); chmod(IMPATH.$this->m_id.'t'.$this->m_ext, 0644); return true; } return false; } /** * Removes a thumbnail. * * @return bool TRUE on success */ public function delete() { if (!isset($this->m_ext)) { return false; } if (unlink(IMPATH.$this->m_id.'t'.$this->m_ext)) { safe_update('txp_image', "thumbnail = 0", "id = ".$this->m_id); return true; } return false; } } /** * Unsharp mask. * * Unsharp mask algorithm by Torstein Hønsi 2003 (thoensi_at_netcom_dot_no) * Christoph Erdmann: changed it a little, because I could not reproduce the * darker blurred image, now it is up to 15% faster with same results * * @author Torstein Hønsi * @author Christoph Erdmann * @param resource $img Image as a resource * @param int $amount Filter parameter * @param int $radius Filter parameter * @param int $threshold Filter parameter * @return resource Sharpened image as a resource. * * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. */ function UnsharpMask($img, $amount, $radius, $threshold) { // Attempt to calibrate the parameters to Photoshop: if ($amount > 500) { $amount = 500; } $amount = (int)($amount * 0.016); if ($radius > 50) { $radius = 50; } $radius = $radius * 2; if ($threshold > 255) { $threshold = 255; } $radius = abs(round($radius)); // Only integers make sense. if ($radius == 0) { return $img; } $w = imagesx($img); $h = imagesy($img); $imgCanvas = $img; $imgCanvas2 = $img; $imgBlur = imagecreatetruecolor($w, $h); // Gaussian blur matrix: // 1 2 1 // 2 4 2 // 1 2 1 // Move copies of the image around one pixel at the time and merge them // with weight according to the matrix. The same matrix is simply // repeated for higher radii. for ($i = 0; $i < $radius; $i++) { imagecopy($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left imagecopymerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right imagecopymerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33); // down left imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right imagecopymerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33); // left imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20); // up imagecopymerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 17); // down imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center } $imgCanvas = $imgBlur; // Calculate the difference between the blurred pixels and the original // and set the pixels. for ($x = 0; $x < $w; $x++) { // Each row. for ($y = 0; $y < $h; $y++) { // Each pixel. $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); $rOrig = (($rgbOrig >> 16) & 0xFF); $gOrig = (($rgbOrig >> 8) & 0xFF); $bOrig = ($rgbOrig & 0xFF); $rgbBlur = ImageColorAt($imgCanvas, $x, $y); $rBlur = (($rgbBlur >> 16) & 0xFF); $gBlur = (($rgbBlur >> 8) & 0xFF); $bBlur = ($rgbBlur & 0xFF); // When the masked pixels differ less from the original than the // threshold specifies, they are set to their original value. $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); ImageSetPixel($img, $x, $y, $pixCol); } } } return $img; }
textpattern/textpattern
textpattern/lib/class.thumb.php
PHP
gpl-2.0
22,703
#!/usr/bin/php -q <?php /** * pbxassist.php * This file is part of the YATE Project http://YATE.null.ro * * Yet Another Telephony Engine - a fully featured software PBX and IVR * Copyright (C) 2007-2013 Null Team * * This software is distributed under multiple licenses; * see the COPYING file in the main directory for licensing * information for this specific distribution. * * This use of this software may be subject to additional restrictions. * See the LEGAL file in the main directory for details. * * 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. */ /* Sample PBX assistant for the Yate PHP interface To use add in regexroute.conf ^NNN$=external/nochan/pbxassist.php;real_callto=real/resource/to/call You will also need a priority= in extmodule.conf [general] in range 50-85 */ require_once("libyate.php"); $ourcallid = true; function onStartup(&$ev) { global $ourcallid; Yate::Output("Channel $ourcallid is being assisted"); } function onHangup($ev) { global $ourcallid; Yate::Output("Channel $ourcallid has hung up"); } function onDisconnect(&$ev,$reason) { global $ourcallid; Yate::Output("Channel $ourcallid was disconnected, reason: '$reason'"); // Sample action: redirect to info tone if user is busy if ($reason == "busy") { $m = new Yate("call.execute"); $m->id = $ev->id; $m->SetParam("id",$ourcallid); $m->SetParam("callto","tone/info"); $m->Dispatch(); // Also send progressing so the tone goes through in early media $m = new Yate("call.progress"); $m->SetParam("targetid",$ourcallid); $m->Dispatch(); return true; } return false; } /* Always the first action to do */ Yate::Init(); /* The main loop. We pick events and handle them */ while ($ourcallid) { $ev=Yate::GetEvent(); /* If Yate disconnected us then exit cleanly */ if ($ev === false) break; /* No need to handle empty events in this application */ if ($ev === true) continue; /* If we reached here we should have a valid object */ switch ($ev->type) { case "incoming": // Yate::Debug("PHP Message: " . $ev->name . " id: " . $ev->id); switch ($ev->name) { case "call.execute": $ourcallid = $ev->GetValue("id"); $callto = $ev->GetValue("real_callto"); if ($ourcallid && $callto) { // Put back the real callto and let the message flow $ev->SetParam("callto",$callto); Yate::Install("chan.hangup",75,"id",$ourcallid); Yate::Install("chan.disconnected",75,"id",$ourcallid); onStartup($ev); } else { Yate::Output("Invalid assist: '$ourcallid' -> '$callto'"); $ourcallid = false; } break; case "chan.hangup": // We were hung up. Do any cleanup and exit. onHangup($ev); $ourcallid = false; break; case "chan.disconnected": // Our party disconnected and we're ready to hang up. // We should reconnect before this message is acknowledged if (onDisconnect($ev,$ev->GetValue("reason"))) $ev->handled = true; break; } /* This is extremely important. We MUST let messages return, handled or not */ if ($ev !== false) $ev->Acknowledge(); break; case "answer": // Yate::Debug("PHP Answered: " . $ev->name . " id: " . $ev->id); break; case "installed": // Yate::Debug("PHP Installed: " . $ev->name); break; case "uninstalled": // Yate::Debug("PHP Uninstalled: " . $ev->name); break; default: // Yate::Output("PHP Event: " . $ev->type); } } Yate::Output("PHP: bye!"); /* vi: set ts=8 sw=4 sts=4 noet: */ ?>
shimaore/yate
share/scripts/pbxassist.php
PHP
gpl-2.0
3,723
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" #include <signal.h> #include "sys_vars.h" #include "my_stacktrace.h" #include "global_threads.h" #ifdef __WIN__ #include <crtdbg.h> #define SIGNAL_FMT "exception 0x%x" #else #define SIGNAL_FMT "signal %d" #endif /* We are handling signals in this file. Any global variables we read should be 'volatile sig_atomic_t' to guarantee that we read some consistent value. */ static volatile sig_atomic_t segfaulted= 0; extern ulong max_used_connections; extern volatile sig_atomic_t calling_initgroups; extern my_bool opt_core_file; /** * Handler for fatal signals * * Fatal events (seg.fault, bus error etc.) will trigger * this signal handler. The handler will try to dump relevant * debugging information to stderr and dump a core image. * * Signal handlers can only use a set of 'safe' system calls * and library functions. A list of safe calls in POSIX systems * are available at: * http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html * For MS Windows, guidelines are available at: * http://msdn.microsoft.com/en-us/library/xdkz3x12(v=vs.71).aspx * * @param sig Signal number */ extern "C" sig_handler handle_fatal_signal(int sig) { if (segfaulted) { my_safe_printf_stderr("Fatal " SIGNAL_FMT " while backtracing\n", sig); _exit(1); /* Quit without running destructors */ } segfaulted = 1; #ifdef __WIN__ SYSTEMTIME utc_time; GetSystemTime(&utc_time); const long hrs= utc_time.wHour; const long mins= utc_time.wMinute; const long secs= utc_time.wSecond; #else /* Using time() instead of my_time() to avoid looping */ const time_t curr_time= time(NULL); /* Calculate time of day */ const long tmins = curr_time / 60; const long thrs = tmins / 60; const long hrs = thrs % 24; const long mins = tmins % 60; const long secs = curr_time % 60; #endif char hrs_buf[3]= "00"; char mins_buf[3]= "00"; char secs_buf[3]= "00"; my_safe_itoa(10, hrs, &hrs_buf[2]); my_safe_itoa(10, mins, &mins_buf[2]); my_safe_itoa(10, secs, &secs_buf[2]); my_safe_printf_stderr("%s:%s:%s UTC - mysqld got " SIGNAL_FMT " ;\n", hrs_buf, mins_buf, secs_buf, sig); my_safe_printf_stderr("%s", "This could be because you hit a bug. It is also possible that this binary\n" "or one of the libraries it was linked against is corrupt, improperly built,\n" "or misconfigured. This error can also be caused by malfunctioning hardware.\n"); my_safe_printf_stderr("%s", "We will try our best to scrape up some info that will hopefully help\n" "diagnose the problem, but since we have already crashed, \n" "something is definitely wrong and this may fail.\n\n"); my_safe_printf_stderr("key_buffer_size=%lu\n", (ulong) dflt_key_cache->key_cache_mem_size); my_safe_printf_stderr("read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); my_safe_printf_stderr("max_used_connections=%lu\n", (ulong) max_used_connections); my_safe_printf_stderr("max_threads=%u\n", (uint) thread_scheduler->max_threads); my_safe_printf_stderr("thread_count=%u\n", get_thread_count()); my_safe_printf_stderr("connection_count=%u\n", (uint) connection_count); my_safe_printf_stderr("It is possible that mysqld could use up to \n" "key_buffer_size + " "(read_buffer_size + sort_buffer_size)*max_threads = " "%lu K bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * thread_scheduler->max_threads + max_connections * sizeof(THD)) / 1024); my_safe_printf_stderr("%s", "Hope that's ok; if not, decrease some variables in the equation.\n\n"); #if defined(HAVE_LINUXTHREADS) #define UNSAFE_DEFAULT_LINUX_THREADS 200 if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS) { my_safe_printf_stderr( "You seem to be running 32-bit Linux and have " "%d concurrent connections.\n" "If you have not changed STACK_SIZE in LinuxThreads " "and built the binary \n" "yourself, LinuxThreads is quite likely to steal " "a part of the global heap for\n" "the thread stack. Please read " "http://dev.mysql.com/doc/mysql/en/linux-installation.html\n\n" thread_count); } #endif /* HAVE_LINUXTHREADS */ #ifdef HAVE_STACKTRACE THD *thd=current_thd; if (!(test_flags & TEST_NO_STACKTRACE)) { my_safe_printf_stderr("Thread pointer: 0x%p\n", thd); my_safe_printf_stderr("%s", "Attempting backtrace. You can use the following " "information to find out\n" "where mysqld died. If you see no messages after this, something went\n" "terribly wrong...\n"); my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL, my_thread_stack_size); } if (thd) { const char *kreason= "UNKNOWN"; switch (thd->killed.load()) { case THD::NOT_KILLED: kreason= "NOT_KILLED"; break; case THD::KILL_BAD_DATA: kreason= "KILL_BAD_DATA"; break; case THD::KILL_CONNECTION: kreason= "KILL_CONNECTION"; break; case THD::KILL_QUERY: kreason= "KILL_QUERY"; break; case THD::KILL_TIMEOUT: kreason= "KILL_TIMEOUT"; break; case THD::KILLED_NO_VALUE: kreason= "KILLED_NO_VALUE"; break; case THD::ABORT_QUERY: kreason= "ABORT_QUERY"; break; } my_safe_printf_stderr("%s", "\n" "Trying to get some variables.\n" "Some pointers may be invalid and cause the dump to abort.\n"); thd->raw_query_buffer[thd->RAW_QUERY_BUFFER_LENGTH] = '\0'; my_safe_printf_stderr("Last run query buffer: %s\n", thd->raw_query_buffer); my_safe_printf_stderr("Query (%p): ", thd->query()); my_safe_print_str(thd->query(), MY_MIN(1024U, thd->query_length())); my_safe_printf_stderr("Connection ID (thread ID): %u\n", thd->thread_id()); my_safe_printf_stderr("Status: %s\n\n", kreason); } my_safe_printf_stderr("%s", "The manual page at " "http://dev.mysql.com/doc/mysql/en/crashing.html contains\n" "information that should help you find out what is causing the crash.\n"); #endif /* HAVE_STACKTRACE */ #ifdef HAVE_INITGROUPS if (calling_initgroups) { my_safe_printf_stderr("%s", "\n" "This crash occured while the server was calling initgroups(). This is\n" "often due to the use of a mysqld that is statically linked against \n" "glibc and configured to use LDAP in /etc/nsswitch.conf.\n" "You will need to either upgrade to a version of glibc that does not\n" "have this problem (2.3.4 or later when used with nscd),\n" "disable LDAP in your nsswitch.conf, or use a " "mysqld that is not statically linked.\n"); } #endif if (locked_in_memory) { my_safe_printf_stderr("%s", "\n" "The \"--memlock\" argument, which was enabled, " "uses system calls that are\n" "unreliable and unstable on some operating systems and " "operating-system versions (notably, some versions of Linux).\n" "This crash could be due to use of those buggy OS calls.\n" "You should consider whether you really need the " "\"--memlock\" parameter and/or consult the OS distributer about " "\"mlockall\" bugs.\n"); } #ifdef HAVE_WRITE_CORE if (opt_core_file) { my_safe_printf_stderr("%s", "Writing a core file\n"); my_write_core(sig); } #endif #ifndef __WIN__ /* Quit, without running destructors (etc.) On Windows, do not terminate, but pass control to exception filter. */ _exit(1); // Using _exit(), since exit() is not async signal safe #endif } /** * Extended handler for fatal signals. * * @param sig Signal number * @param info Detailed signal information * @param ctx Signal context including registers in uc_mcontext */ extern "C" sig_handler handle_fatal_signal_ex(int sig, siginfo_t *info, void *ctx) { /* Save detailed information on stack in volatile variables to make sure they are not optimized out. For reference on Intel, ucontext->uc_mcontext.gregs is an array of registers: R8 - R15 0 - 7 RAX 13 RDI 8 RCX 14 RSI 9 RSP 15 RBP 10 RIP 16 RBX 11 EFL 17 RDX 12 */ siginfo_t * volatile MY_ATTRIBUTE((unused)) siginfo = info; ucontext_t * volatile MY_ATTRIBUTE((unused)) ucontext = reinterpret_cast<ucontext_t *>(ctx); return handle_fatal_signal(sig); }
facebook/mysql-5.6
sql/signal_handler.cc
C++
gpl-2.0
9,684
/* * ClPreconditionerHandler_test.cpp * * Created on: 4 de abr. de 2016 * Author: juan */ #include "ClPreconditionerHandler.h"
Thejuampi/PFC
cpp/icoFoamOCL/ClPreconditionerHandler_test.cpp
C++
gpl-2.0
140
/** * @file * @brief Monsters doing stuff (monsters acting). **/ #include "AppHdr.h" #include "mon-act.h" #include "areas.h" #include "arena.h" #include "artefact.h" #include "attitude-change.h" #include "beam.h" #include "cloud.h" #include "coordit.h" #include "dbg-scan.h" #include "delay.h" #include "dungeon.h" #include "effects.h" #include "env.h" #include "food.h" #include "fight.h" #include "fineff.h" #include "godpassive.h" #include "godprayer.h" #include "itemname.h" #include "itemprop.h" #include "items.h" #include "item_use.h" #include "libutil.h" #include "map_knowledge.h" #include "mapmark.h" #include "message.h" #include "misc.h" #include "mon-abil.h" #include "mon-behv.h" #include "mon-cast.h" #include "mon-death.h" #include "mon-iter.h" #include "mon-place.h" #include "mon-project.h" #include "mgen_data.h" #include "mon-stuff.h" #include "mon-util.h" #include "notes.h" #include "player.h" #include "random.h" #include "religion.h" #include "shopping.h" // for item values #include "spl-book.h" #include "spl-damage.h" #include "spl-summoning.h" #include "spl-util.h" #include "state.h" #include "stuff.h" #include "target.h" #include "teleport.h" #include "terrain.h" #include "throw.h" #include "traps.h" #include "hints.h" #include "view.h" #include "shout.h" static bool _handle_pickup(monster* mons); static void _mons_in_cloud(monster* mons); static void _heated_area(monster* mons); static bool _is_trap_safe(const monster* mons, const coord_def& where, bool just_check = false); static bool _monster_move(monster* mons); static spell_type _map_wand_to_mspell(wand_type kind); static void _shedu_movement_clamp(monster* mons); // [dshaligram] Doesn't need to be extern. static coord_def mmov; static const coord_def mon_compass[8] = { coord_def(-1,-1), coord_def(0,-1), coord_def(1,-1), coord_def(1,0), coord_def(1, 1), coord_def(0, 1), coord_def(-1,1), coord_def(-1,0) }; static int _compass_idx(const coord_def& mov) { for (int i = 0; i < 8; i++) if (mon_compass[i] == mov) return i; return -1; } static inline bool _mons_natural_regen_roll(monster* mons) { const int regen_rate = mons_natural_regen_rate(mons); return x_chance_in_y(regen_rate, 25); } // Do natural regeneration for monster. static void _monster_regenerate(monster* mons) { if (crawl_state.disables[DIS_MON_REGEN]) return; if (mons->has_ench(ENCH_SICK) || mons->has_ench(ENCH_DEATHS_DOOR) || (!mons_can_regenerate(mons) && !(mons->has_ench(ENCH_REGENERATION)))) { return; } // Non-land creatures out of their element cannot regenerate. if (mons_primary_habitat(mons) != HT_LAND && !monster_habitable_grid(mons, grd(mons->pos()))) { return; } if (monster_descriptor(mons->type, MDSC_REGENERATES) || (mons->type == MONS_FIRE_ELEMENTAL && (grd(mons->pos()) == DNGN_LAVA || cloud_type_at(mons->pos()) == CLOUD_FIRE)) || (mons->type == MONS_WATER_ELEMENTAL && feat_is_watery(grd(mons->pos()))) || (mons->type == MONS_AIR_ELEMENTAL && env.cgrid(mons->pos()) == EMPTY_CLOUD && one_chance_in(3)) || mons->has_ench(ENCH_REGENERATION) || mons->has_ench(ENCH_WITHDRAWN) || _mons_natural_regen_roll(mons)) { mons->heal(1); } } static void _escape_water_hold(monster* mons) { if (mons->has_ench(ENCH_WATER_HOLD)) { if (mons_habitat(mons) != HT_AMPHIBIOUS && mons_habitat(mons) != HT_WATER) { mons->speed_increment -= 5; } simple_monster_message(mons, " pulls free of the water."); mons->del_ench(ENCH_WATER_HOLD); } } static bool _swap_monsters(monster* mover, monster* moved) { // Can't swap with a stationary monster. // Although nominally stationary kraken tentacles can be swapped // with the main body. if (moved->is_stationary() && !moved->is_child_tentacle()) return false; // If the target monster is constricted it is stuck // and not eligible to be swapped with if (moved->is_constricted()) { dprf("%s fails to swap with %s, constricted.", mover->name(DESC_THE).c_str(), moved->name(DESC_THE).c_str()); return false; } // Swapping is a purposeful action. if (mover->confused()) return false; // Right now just happens in sanctuary. if (!is_sanctuary(mover->pos()) || !is_sanctuary(moved->pos())) return false; // A friendly or good-neutral monster moving past a fleeing hostile // or neutral monster, or vice versa. if (mover->wont_attack() == moved->wont_attack() || mons_is_retreating(mover) == mons_is_retreating(moved)) { return false; } // Don't swap places if the player explicitly ordered their pet to // attack monsters. if ((mover->friendly() || moved->friendly()) && you.pet_target != MHITYOU && you.pet_target != MHITNOT) { return false; } if (!mover->can_pass_through(moved->pos()) || !moved->can_pass_through(mover->pos())) { return false; } if (!monster_habitable_grid(mover, grd(moved->pos())) && !mover->can_cling_to(moved->pos()) || !monster_habitable_grid(moved, grd(mover->pos())) && !moved->can_cling_to(mover->pos())) { return false; } // Okay, we can do the swap. const coord_def mover_pos = mover->pos(); const coord_def moved_pos = moved->pos(); mover->set_position(moved_pos); moved->set_position(mover_pos); mover->clear_far_constrictions(); moved->clear_far_constrictions(); mover->check_clinging(true); moved->check_clinging(true); mgrd(mover->pos()) = mover->mindex(); mgrd(moved->pos()) = moved->mindex(); if (you.can_see(mover) && you.can_see(moved)) { mprf("%s and %s swap places.", mover->name(DESC_THE).c_str(), moved->name(DESC_THE).c_str()); } _escape_water_hold(mover); return true; } static bool _do_mon_spell(monster* mons, bolt &beem) { // Shapeshifters don't get spells. if (!mons->is_shapeshifter() || !mons->is_actual_spellcaster()) { if (handle_mon_spell(mons, beem)) { // If a Pan lord/pghost is known to be a spellcaster, it's safer // to assume it has ranged spells too. For others, it'd just // lead to unnecessary false positives. if (mons_is_ghost_demon(mons->type)) mons->flags |= MF_SEEN_RANGED; mmov.reset(); return true; } } return false; } static void _swim_or_move_energy(monster* mon, bool diag = false) { const dungeon_feature_type feat = grd(mon->pos()); // FIXME: Replace check with mons_is_swimming()? mon->lose_energy((feat >= DNGN_LAVA && feat <= DNGN_SHALLOW_WATER && mon->ground_level()) ? EUT_SWIM : EUT_MOVE, diag ? 10 : 1, diag ? 14 : 1); } static bool _unfriendly_or_insane(const monster* mon) { return !mon->wont_attack() || mon->has_ench(ENCH_INSANE); } // Check up to eight grids in the given direction for whether there's a // monster of the same alignment as the given monster that happens to // have a ranged attack. If this is true for the first monster encountered, // returns true. Otherwise returns false. static bool _ranged_allied_monster_in_dir(monster* mon, coord_def p) { coord_def pos = mon->pos(); for (int i = 1; i <= LOS_RADIUS; i++) { pos += p; if (!in_bounds(pos)) break; const monster* ally = monster_at(pos); if (ally == NULL) continue; if (mons_aligned(mon, ally)) { // Hostile monsters of normal intelligence only move aside for // monsters of the same type. if (mons_intel(mon) <= I_NORMAL && _unfriendly_or_insane(mon) && mons_genus(mon->type) != mons_genus(ally->type)) { return false; } if (mons_has_ranged_attack(ally)) return true; } break; } return false; } // Check whether there's a monster of the same type and alignment adjacent // to the given monster in at least one of three given directions (relative to // the monster position). static bool _allied_monster_at(monster* mon, coord_def a, coord_def b, coord_def c) { vector<coord_def> pos; pos.push_back(mon->pos() + a); pos.push_back(mon->pos() + b); pos.push_back(mon->pos() + c); for (unsigned int i = 0; i < pos.size(); i++) { if (!in_bounds(pos[i])) continue; const monster* ally = monster_at(pos[i]); if (ally == NULL) continue; if (ally->is_stationary() || ally->reach_range() > REACH_NONE) continue; // Hostile monsters of normal intelligence only move aside for // monsters of the same genus. if (mons_intel(mon) <= I_NORMAL && _unfriendly_or_insane(mon) && mons_genus(mon->type) != mons_genus(ally->type)) { continue; } if (mons_aligned(mon, ally)) return true; } return false; } // Altars as well as branch entrances are considered interesting for // some monster types. static bool _mon_on_interesting_grid(monster* mon) { // Patrolling shouldn't happen all the time. if (one_chance_in(4)) return false; const dungeon_feature_type feat = grd(mon->pos()); switch (feat) { // Holy beings will tend to patrol around altars to the good gods. case DNGN_ALTAR_ELYVILON: if (!one_chance_in(3)) return false; // else fall through case DNGN_ALTAR_ZIN: case DNGN_ALTAR_SHINING_ONE: return mon->is_holy(); // Orcs will tend to patrol around altars to Beogh, and guard the // stairway from and to the Orcish Mines. case DNGN_ALTAR_BEOGH: case DNGN_ENTER_ORCISH_MINES: case DNGN_RETURN_FROM_ORCISH_MINES: return mons_is_native_in_branch(mon, BRANCH_ORCISH_MINES); // Same for elves and the Elven Halls. case DNGN_ENTER_ELVEN_HALLS: case DNGN_RETURN_FROM_ELVEN_HALLS: return mons_is_native_in_branch(mon, BRANCH_ELVEN_HALLS); // Spiders... case DNGN_ENTER_SPIDER_NEST: return mons_is_native_in_branch(mon, BRANCH_SPIDER_NEST); // And the forest natives. case DNGN_ENTER_FOREST: return mons_is_native_in_branch(mon, BRANCH_FOREST); default: return false; } } // If a hostile monster finds itself on a grid of an "interesting" feature, // while unoccupied, it will remain in that area, and try to return to it // if it left it for fighting, seeking etc. static void _maybe_set_patrol_route(monster* mons) { if (mons_is_wandering(mons) && !mons->friendly() && !mons->is_patrolling() && _mon_on_interesting_grid(mons)) { mons->patrol_point = mons->pos(); } } static bool _mons_can_cast_dig(const monster* mons, bool random) { return (mons->foe != MHITNOT && mons->can_use_spells() && mons->has_spell(SPELL_DIG) && !mons->confused() && !(silenced(mons->pos()) || mons->has_ench(ENCH_MUTE)) && (!mons->has_ench(ENCH_ANTIMAGIC) || (random && x_chance_in_y(4 * BASELINE_DELAY, 4 * BASELINE_DELAY + mons->get_ench(ENCH_ANTIMAGIC).duration) || (!random && 4 * BASELINE_DELAY >= mons->get_ench(ENCH_ANTIMAGIC).duration)))); } static bool _mons_can_zap_dig(const monster* mons) { return (mons->foe != MHITNOT && !mons->asleep() && !mons->confused() // they don't get here anyway && !mons->submerged() && mons_itemuse(mons) >= MONUSE_STARTING_EQUIPMENT && mons->inv[MSLOT_WAND] != NON_ITEM && mitm[mons->inv[MSLOT_WAND]].base_type == OBJ_WANDS && mitm[mons->inv[MSLOT_WAND]].sub_type == WAND_DIGGING && mitm[mons->inv[MSLOT_WAND]].plus > 0); } static void _set_mons_move_dir(const monster* mons, coord_def* dir, coord_def* delta) { ASSERT(dir); ASSERT(delta); // Some calculations. if ((mons_class_flag(mons->type, M_BURROWS) || _mons_can_cast_dig(mons, false)) && mons->foe == MHITYOU) { // Boring beetles always move in a straight line in your // direction. *delta = you.pos() - mons->pos(); } else { *delta = (mons->firing_pos.zero() ? mons->target : mons->firing_pos) - mons->pos(); } // Move the monster. *dir = delta->sgn(); if (mons_is_retreating(mons) && mons->travel_target != MTRAV_WALL && (!mons->friendly() || mons->target != you.pos())) { *dir *= -1; } } static void _tweak_wall_mmov(const monster* mons, bool move_trees = false) { // The rock worm will try to move along through rock for as long as // possible. If the player is walking through a corridor, for example, // moving along in the wall beside him is much preferable to actually // leaving the wall. // This might cause the rock worm to take detours but it still // comes off as smarter than otherwise. // If we're already moving into a shielded spot, don't adjust move // (this leads to zig-zagging) if (feat_is_solid(grd(mons->pos() + mmov))) return; int dir = _compass_idx(mmov); ASSERT(dir != -1); // If we're already adjacent to our target and shielded, don't shift position. // If we're adjacent and unshielded, widen our search angle to include any // spot adjacent to both us and our target int range = 1; if (mons->target == mons->pos() + mmov) { if (feat_is_solid(grd(mons->pos()))) return; else { if (dir % 2 == 1) range = 2; } } int count = 0; int choice = dir; // stick with mmov if none are good for (int i = -range; i <= range; ++i) { const int altdir = (dir + i + 8) % 8; const coord_def t = mons->pos() + mon_compass[altdir]; const bool good = in_bounds(t) && (move_trees ? feat_is_tree(grd(t)) : feat_is_rock(grd(t)) && !feat_is_permarock(grd(t))); if (good && one_chance_in(++count)) choice = altdir; } mmov = mon_compass[choice]; } typedef FixedArray< bool, 3, 3 > move_array; static void _fill_good_move(const monster* mons, move_array* good_move) { for (int count_x = 0; count_x < 3; count_x++) for (int count_y = 0; count_y < 3; count_y++) { const int targ_x = mons->pos().x + count_x - 1; const int targ_y = mons->pos().y + count_y - 1; // Bounds check: don't consider moving out of grid! if (!in_bounds(targ_x, targ_y)) { (*good_move)[count_x][count_y] = false; continue; } (*good_move)[count_x][count_y] = mon_can_move_to_pos(mons, coord_def(count_x-1, count_y-1)); } } // This only tracks movement, not whether hitting an // adjacent monster is a possible move. bool mons_can_move_towards_target(const monster* mon) { coord_def mov, delta; _set_mons_move_dir(mon, &mov, &delta); move_array good_move; _fill_good_move(mon, &good_move); int dir = _compass_idx(mov); for (int i = -1; i <= 1; ++i) { const int altdir = (dir + i + 8) % 8; const coord_def p = mon_compass[altdir] + coord_def(1, 1); if (good_move(p)) return true; } return false; } //--------------------------------------------------------------- // // handle_movement // // Move the monster closer to its target square. // //--------------------------------------------------------------- static void _handle_movement(monster* mons) { _maybe_set_patrol_route(mons); // Monsters will try to flee out of a sanctuary. if (is_sanctuary(mons->pos()) && mons_is_influenced_by_sanctuary(mons) && !mons_is_fleeing_sanctuary(mons)) { mons_start_fleeing_from_sanctuary(mons); } else if (mons_is_fleeing_sanctuary(mons) && !is_sanctuary(mons->pos())) { // Once outside there's a chance they'll regain their courage. // Nonliving and berserking monsters always stop immediately, // since they're only being forced out rather than actually // scared. if (mons->holiness() == MH_NONLIVING || mons->berserk() || mons->has_ench(ENCH_INSANE) || x_chance_in_y(2, 5)) { mons_stop_fleeing_from_sanctuary(mons); } } coord_def delta; _set_mons_move_dir(mons, &mmov, &delta); // Don't allow monsters to enter a sanctuary or attack you inside a // sanctuary, even if you're right next to them. if (is_sanctuary(mons->pos() + mmov) && (!is_sanctuary(mons->pos()) || mons->pos() + mmov == you.pos())) { mmov.reset(); } // Bounds check: don't let fleeing monsters try to run off the grid. const coord_def s = mons->pos() + mmov; if (!in_bounds_x(s.x)) mmov.x = 0; if (!in_bounds_y(s.y)) mmov.y = 0; if (delta.rdist() > 3) { // Reproduced here is some semi-legacy code that makes monsters // move somewhat randomly along oblique paths. It is an // exceedingly good idea, given crawl's unique line of sight // properties. // // Added a check so that oblique movement paths aren't used when // close to the target square. -- bwr // Sometimes we'll just move parallel the x axis. if (abs(delta.x) > abs(delta.y) && coinflip()) mmov.y = 0; // Sometimes we'll just move parallel the y axis. if (abs(delta.y) > abs(delta.x) && coinflip()) mmov.x = 0; } // Now quit if we can't move. if (mmov.origin()) return; const coord_def newpos(mons->pos() + mmov); move_array good_move; _fill_good_move(mons, &good_move); // Make rock worms and dryads prefer shielded terrain. if (mons_wall_shielded(mons)) _tweak_wall_mmov(mons, mons->type == MONS_DRYAD); // If the monster is moving in your direction, whether to attack or // protect you, or towards a monster it intends to attack, check // whether we first need to take a step to the side to make sure the // reinforcement can follow through. Only do this with 50% chance, // though, so it's not completely predictable. // First, check whether the monster is smart enough to even consider // this. if ((newpos == you.pos() || monster_at(newpos) && mons->foe == mgrd(newpos)) && mons_intel(mons) >= I_ANIMAL && coinflip() && !mons_is_confused(mons) && !mons->caught() && !mons->berserk_or_insane()) { // If the monster is moving parallel to the x or y axis, check // whether // // a) the neighbouring grids are blocked // b) there are other unblocked grids adjacent to the target // c) there's at least one allied monster waiting behind us. // // (For really smart monsters, also check whether there's a // monster farther back in the corridor that has some kind of // ranged attack.) if (mmov.y == 0) { if (!good_move[1][0] && !good_move[1][2] && (good_move[mmov.x+1][0] || good_move[mmov.x+1][2]) && (_allied_monster_at(mons, coord_def(-mmov.x, -1), coord_def(-mmov.x, 0), coord_def(-mmov.x, 1)) || mons_intel(mons) >= I_NORMAL && _unfriendly_or_insane(mons) && _ranged_allied_monster_in_dir(mons, coord_def(-mmov.x, 0)))) { if (good_move[mmov.x+1][0]) mmov.y = -1; if (good_move[mmov.x+1][2] && (mmov.y == 0 || coinflip())) mmov.y = 1; } } else if (mmov.x == 0) { if (!good_move[0][1] && !good_move[2][1] && (good_move[0][mmov.y+1] || good_move[2][mmov.y+1]) && (_allied_monster_at(mons, coord_def(-1, -mmov.y), coord_def(0, -mmov.y), coord_def(1, -mmov.y)) || mons_intel(mons) >= I_NORMAL && _unfriendly_or_insane(mons) && _ranged_allied_monster_in_dir(mons, coord_def(0, -mmov.y)))) { if (good_move[0][mmov.y+1]) mmov.x = -1; if (good_move[2][mmov.y+1] && (mmov.x == 0 || coinflip())) mmov.x = 1; } } else // We're moving diagonally. { if (good_move[mmov.x+1][1]) { if (!good_move[1][mmov.y+1] && (_allied_monster_at(mons, coord_def(-mmov.x, -1), coord_def(-mmov.x, 0), coord_def(-mmov.x, 1)) || mons_intel(mons) >= I_NORMAL && _unfriendly_or_insane(mons) && _ranged_allied_monster_in_dir(mons, coord_def(-mmov.x, -mmov.y)))) { mmov.y = 0; } } else if (good_move[1][mmov.y+1] && (_allied_monster_at(mons, coord_def(-1, -mmov.y), coord_def(0, -mmov.y), coord_def(1, -mmov.y)) || mons_intel(mons) >= I_NORMAL && _unfriendly_or_insane(mons) && _ranged_allied_monster_in_dir(mons, coord_def(-mmov.x, -mmov.y)))) { mmov.x = 0; } } } // Now quit if we can't move. if (mmov.origin()) return; // Try to stay in sight of the player if we're moving towards // him/her, in order to avoid the monster coming into view, // shouting, and then taking a step in a path to the player which // temporarily takes it out of view, which can lead to the player // getting "comes into view" and shout messages with no monster in // view. // Doesn't matter for arena mode. if (crawl_state.game_is_arena()) return; // Did we just come into view? // TODO: This doesn't seem to work right. Fix, or remove? if (mons->seen_context != SC_JUST_SEEN) return; if (testbits(mons->flags, MF_WAS_IN_VIEW)) return; const coord_def old_pos = mons->pos(); const int old_dist = grid_distance(you.pos(), old_pos); // We're already staying in the player's LOS. if (you.see_cell(old_pos + mmov)) return; // We're not moving towards the player. if (grid_distance(you.pos(), old_pos + mmov) >= old_dist) { // Instead of moving out of view, we stay put. if (you.see_cell(old_pos)) mmov.reset(); return; } // Try to find a move that brings us closer to the player while // keeping us in view. int matches = 0; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { if (i == 0 && j == 0) continue; if (!good_move[i][j]) continue; coord_def d(i - 1, j - 1); coord_def tmp = old_pos + d; if (grid_distance(you.pos(), tmp) < old_dist && you.see_cell(tmp)) { if (one_chance_in(++matches)) mmov = d; break; } } // We haven't been able to find a visible cell to move to. If previous // position was visible, we stay put. if (you.see_cell(old_pos) && !you.see_cell(old_pos + mmov)) mmov.reset(); } //--------------------------------------------------------------- // // _handle_potion // // Give the monster a chance to quaff a potion. Returns true if // the monster imbibed. // //--------------------------------------------------------------- static bool _handle_potion(monster* mons, bolt & beem) { if (mons->asleep() || mons->inv[MSLOT_POTION] == NON_ITEM || !one_chance_in(3)) { return false; } if (mons_itemuse(mons) < MONUSE_STARTING_EQUIPMENT) return false; // Make sure the item actually is a potion. if (mitm[mons->inv[MSLOT_POTION]].base_type != OBJ_POTIONS) return false; bool rc = false; const int potion_idx = mons->inv[MSLOT_POTION]; item_def& potion = mitm[potion_idx]; const potion_type ptype = static_cast<potion_type>(potion.sub_type); if (mons->can_drink_potion(ptype) && mons->should_drink_potion(ptype)) { const bool was_visible = you.can_see(mons); // Drink the potion. const item_type_id_state_type id = mons->drink_potion_effect(ptype); // Give ID if necessary. if (was_visible && id != ID_UNKNOWN_TYPE) set_ident_type(OBJ_POTIONS, ptype, id); // Remove it from inventory. if (dec_mitm_item_quantity(potion_idx, 1)) mons->inv[MSLOT_POTION] = NON_ITEM; else if (is_blood_potion(potion)) remove_oldest_blood_potion(potion); mons->lose_energy(EUT_ITEM); rc = true; } return rc; } static bool _handle_evoke_equipment(monster* mons, bolt & beem) { // TODO: check non-ring, non-amulet equipment if (mons->asleep() || mons->inv[MSLOT_JEWELLERY] == NON_ITEM || !one_chance_in(3)) { return false; } if (mons_itemuse(mons) < MONUSE_STARTING_EQUIPMENT) return false; // Make sure the item actually is a ring or amulet. if (mitm[mons->inv[MSLOT_JEWELLERY]].base_type != OBJ_JEWELLERY) return false; bool rc = false; const int jewellery_idx = mons->inv[MSLOT_JEWELLERY]; item_def& jewellery = mitm[jewellery_idx]; const jewellery_type jtype = static_cast<jewellery_type>(jewellery.sub_type); if (mons->can_evoke_jewellery(jtype) && mons->should_evoke_jewellery(jtype)) { const bool was_visible = you.can_see(mons); // Drink the potion. const item_type_id_state_type id = mons->evoke_jewellery_effect(jtype); // Give ID if necessary. if (was_visible && id != ID_UNKNOWN_TYPE) set_ident_type(OBJ_JEWELLERY, jtype, id); mons->lose_energy(EUT_ITEM); rc = true; } return rc; } static bool _handle_reaching(monster* mons) { bool ret = false; const reach_type range = mons->reach_range(); actor *foe = mons->get_foe(); if (!foe || range <= REACH_NONE) return false; if (is_sanctuary(mons->pos()) || is_sanctuary(foe->pos())) return false; if (mons->submerged()) return false; if (mons_aligned(mons, foe) && !mons->has_ench(ENCH_INSANE)) return false; // Greatly lowered chances if the monster is fleeing or pacified and // leaving the level. if ((mons_is_fleeing(mons) || mons->pacified()) && !one_chance_in(8)) return false; const coord_def foepos(foe->pos()); const coord_def delta(foepos - mons->pos()); const int grid_distance(delta.rdist()); const coord_def first_middle(mons->pos() + delta / 2); const coord_def second_middle(foepos - delta / 2); if (grid_distance == 2 // The monster has to be attacking the correct position. && mons->target == foepos // With a reaching attack with a large enough range: && delta.abs() <= range // And with no dungeon furniture in the way of the reaching // attack; && (feat_is_reachable_past(grd(first_middle)) || feat_is_reachable_past(grd(second_middle))) // The foe should be on the map (not stepped from time). && in_bounds(foepos)) { ret = true; ASSERT(foe->is_player() || foe->is_monster()); fight_melee(mons, foe); if (mons->alive()) { // Player saw the item reach. item_def *wpn = mons->weapon(0); if (wpn && !is_artefact(*wpn) && you.can_see(mons) // Don't auto-identify polearm brands && get_weapon_brand(*wpn) == SPWPN_REACHING) { set_ident_flags(*wpn, ISFLAG_KNOW_TYPE); } } } return ret; } //--------------------------------------------------------------- // // handle_scroll // // Give the monster a chance to read a scroll. Returns true if // the monster read something. // //--------------------------------------------------------------- static bool _handle_scroll(monster* mons) { // Yes, there is a logic to this ordering {dlb}: if (mons->asleep() || mons_is_confused(mons) || mons->submerged() || mons->inv[MSLOT_SCROLL] == NON_ITEM || mons->has_ench(ENCH_BLIND) || !one_chance_in(3)) { return false; } if (mons_itemuse(mons) < MONUSE_STARTING_EQUIPMENT) return false; if (silenced(mons->pos())) return false; // Make sure the item actually is a scroll. if (mitm[mons->inv[MSLOT_SCROLL]].base_type != OBJ_SCROLLS) return false; bool read = false; item_type_id_state_type ident = ID_UNKNOWN_TYPE; bool was_visible = you.can_see(mons); // Notice how few cases are actually accounted for here {dlb}: const int scroll_type = mitm[mons->inv[MSLOT_SCROLL]].sub_type; switch (scroll_type) { case SCR_TELEPORTATION: if (!mons->has_ench(ENCH_TP) && !mons->no_tele(true, false)) { if (mons->caught() || mons_is_fleeing(mons) || mons->pacified()) { simple_monster_message(mons, " reads a scroll."); read = true; ident = ID_KNOWN_TYPE; monster_teleport(mons, false); } } break; case SCR_BLINKING: if ((mons->caught() || mons_is_fleeing(mons) || mons->pacified()) && mons_near(mons) && !mons->no_tele(true, false)) { simple_monster_message(mons, " reads a scroll."); read = true; if (mons->caught()) { ident = ID_KNOWN_TYPE; monster_blink(mons); } else if (blink_away(mons)) ident = ID_KNOWN_TYPE; } break; case SCR_SUMMONING: if (mons_near(mons)) { simple_monster_message(mons, " reads a scroll."); mprf("Wisps of shadow swirl around %s.", mons->name(DESC_THE).c_str()); read = true; int count = roll_dice(2, 2); for (int i = 0; i < count; ++i) { create_monster( mgen_data(RANDOM_MOBILE_MONSTER, SAME_ATTITUDE(mons), mons, 3, SPELL_SHADOW_CREATURES, mons->pos(), mons->foe, 0, GOD_NO_GOD)); } ident = ID_KNOWN_TYPE; } break; } if (read) { if (dec_mitm_item_quantity(mons->inv[MSLOT_SCROLL], 1)) mons->inv[MSLOT_SCROLL] = NON_ITEM; if (ident != ID_UNKNOWN_TYPE && was_visible) set_ident_type(OBJ_SCROLLS, scroll_type, ident); mons->lose_energy(EUT_ITEM); } return read; } static int _generate_rod_power(monster *mons, int overriding_power = 0) { // power is actually 5 + Evocations + 2d(Evocations) // modified by shield and shield skill int shield_num = 1; int shield_den = 1; int shield_base = 1; if (mons->inv[MSLOT_SHIELD] != NON_ITEM) { item_def *shield = mons->mslot_item(MSLOT_SHIELD); switch (shield->sub_type) { case ARM_BUCKLER: shield_base += 4; break; case ARM_SHIELD: shield_base += 2; break; case ARM_LARGE_SHIELD: shield_base++; break; default: break; } } const int power_base = mons->skill(SK_EVOCATIONS); int power = 5 + power_base + (2 * random2(power_base)); if (shield_base > 1) { const int shield_mod = ((power / shield_base) * shield_num) / shield_den; power -= shield_mod; } if (overriding_power > 0) power = overriding_power; return power; } static bolt& _generate_item_beem(bolt &beem, bolt& from, monster* mons) { beem.name = from.name; beem.beam_source = mons->mindex(); beem.source = mons->pos(); beem.colour = from.colour; beem.range = from.range; beem.damage = from.damage; beem.ench_power = from.ench_power; beem.hit = from.hit; beem.glyph = from.glyph; beem.flavour = from.flavour; beem.thrower = from.thrower; beem.is_beam = from.is_beam; beem.is_explosion = from.is_explosion; return beem; } static bool _setup_wand_beam(bolt& beem, monster* mons) { item_def &wand(mitm[mons->inv[MSLOT_WAND]]); // map wand type to monster spell type const spell_type mzap = _map_wand_to_mspell((wand_type)wand.sub_type); if (mzap == SPELL_NO_SPELL) return false; // set up the beam int power = 30 + mons->hit_dice; bolt theBeam = mons_spell_beam(mons, mzap, power); beem = _generate_item_beem(beem, theBeam, mons); beem.aux_source = wand.name(DESC_QUALNAME, false, true, false, false); return true; } static void _mons_fire_wand(monster* mons, item_def &wand, bolt &beem, bool was_visible, bool niceWand) { if (!simple_monster_message(mons, " zaps a wand.")) { if (!silenced(you.pos())) mpr("You hear a zap.", MSGCH_SOUND); } // charge expenditure {dlb} wand.plus--; beem.is_tracer = false; beem.fire(); if (was_visible) { const int wand_type = wand.sub_type; if (niceWand || !beem.is_enchantment() || beem.obvious_effect) { set_ident_type(OBJ_WANDS, wand_type, ID_KNOWN_TYPE); mons->props["wand_known"] = true; } else { set_ident_type(OBJ_WANDS, wand_type, ID_MON_TRIED_TYPE); mons->props["wand_known"] = false; } // Increment zap count. if (wand.plus2 >= 0) wand.plus2++; mons->flags |= MF_SEEN_RANGED; } mons->lose_energy(EUT_ITEM); } static void _rod_fired_pre(monster* mons) { make_mons_stop_fleeing(mons); if (!simple_monster_message(mons, " zaps a rod.") && !silenced(you.pos())) { mpr("You hear a zap.", MSGCH_SOUND); } } static bool _rod_fired_post(monster* mons, item_def &rod, int idx, bolt &beem, int rate, bool was_visible) { rod.plus -= rate; dprf("rod charge: %d, %d", rod.plus, rod.plus2); if (was_visible) { if (!beem.is_enchantment() || beem.obvious_effect) set_ident_flags(rod, ISFLAG_KNOW_TYPE); } mons->lose_energy(EUT_ITEM); return true; } static bool _get_rod_spell_and_cost(const item_def& rod, spell_type& spell, int& cost) { bool success = false; for (int i = 0; i < SPELLBOOK_SIZE; ++i) { spell_type s = which_spell_in_book(rod, i); int c = spell_difficulty(spell) * ROD_CHARGE_MULT; if (s == SPELL_NO_SPELL || rod.plus < c) continue; success = true; spell = s; cost = c; if (one_chance_in(SPELLBOOK_SIZE - i + 1)) break; } return success; } static bool _thunderbolt_tracer(monster *caster, int pow, coord_def aim) { coord_def prev; if (caster->props.exists("thunderbolt_last") && caster->props["thunderbolt_last"].get_int() + 1 == you.num_turns) { prev = caster->props["thunderbolt_aim"].get_coord(); } targetter_thunderbolt hitfunc(caster, spell_range(SPELL_THUNDERBOLT, pow), prev); hitfunc.set_aim(aim); mon_attitude_type castatt = caster->temp_attitude(); int friendly = 0, enemy = 0; for (map<coord_def, aff_type>::const_iterator p = hitfunc.zapped.begin(); p != hitfunc.zapped.end(); ++p) { if (p->second <= 0) continue; const actor *victim = actor_at(p->first); if (!victim) continue; int dam = 4 >> victim->res_elec(); if (mons_atts_aligned(castatt, victim->temp_attitude())) friendly += dam; else enemy += dam; } return enemy > friendly; return false; } // handle_rod // -- implemented as a dependent to handle_wand currently // (no wand + rod turns this way) // notes: // shamelessly repurposing handle_wand code // not one word about the name of this function! static bool _handle_rod(monster *mons, bolt &beem) { const int weapon = mons->inv[MSLOT_WEAPON]; item_def &rod(mitm[weapon]); // Make sure the item actually is a rod. ASSERT(rod.base_type == OBJ_RODS); // was the player visible when we started? bool was_visible = you.can_see(mons); bool check_validity = true; bool is_direct_effect = false; spell_type mzap = SPELL_NO_SPELL; int rate = 0; if (!_get_rod_spell_and_cost(rod, mzap, rate)) return false; // XXX: There should be a better way to do this than hardcoding // monster-castable rod spells! switch (mzap) { case SPELL_BOLT_OF_FIRE: case SPELL_BOLT_OF_INACCURACY: case SPELL_IRON_SHOT: case SPELL_LIGHTNING_BOLT: case SPELL_POISON_ARROW: case SPELL_THROW_FLAME: case SPELL_THROW_FROST: break; case SPELL_FIREBALL: if (mons->foe_distance() < 2) return false; break; case SPELL_FREEZING_CLOUD: case SPELL_POISONOUS_CLOUD: if (mons->foe_distance() <= 2) return false; break; case SPELL_THUNDERBOLT: if (mons->props.exists("thunderbolt_last") && mons->props["thunderbolt_last"].get_int() + 1 == you.num_turns) { rate = min(5 * ROD_CHARGE_MULT, (int)rod.plus); mons->props["thunderbolt_mana"].get_int() = rate; } break; case SPELL_CALL_IMP: case SPELL_CAUSE_FEAR: case SPELL_SUMMON_DEMON: case SPELL_SUMMON_SWARM: case SPELL_OLGREBS_TOXIC_RADIANCE: _rod_fired_pre(mons); mons_cast(mons, beem, mzap, false); _rod_fired_post(mons, rod, weapon, beem, rate, was_visible); return true; default: return false; } bool zap = false; // set up the beam const int power = max(_generate_rod_power(mons), 1); dprf("using rod with power %d", power); bolt theBeam = mons_spell_beam(mons, mzap, power, check_validity); beem = _generate_item_beem(beem, theBeam, mons); beem.aux_source = rod.name(DESC_QUALNAME, false, true, false, false); if (mons->confused()) { beem.target = dgn_random_point_from(mons->pos(), LOS_RADIUS); if (beem.target.origin()) return false; zap = true; } else if (mzap == SPELL_THUNDERBOLT) zap = _thunderbolt_tracer(mons, power, beem.target); else { fire_tracer(mons, beem); zap = mons_should_fire(beem); } if (is_direct_effect) { actor* foe = mons->get_foe(); if (!foe) return false; _rod_fired_pre(mons); direct_effect(mons, mzap, beem, foe); return _rod_fired_post(mons, rod, weapon, beem, rate, was_visible); } else if (mzap == SPELL_THUNDERBOLT) { _rod_fired_pre(mons); cast_thunderbolt(mons, power, beem.target); return _rod_fired_post(mons, rod, weapon, beem, rate, was_visible); } else if (zap) { _rod_fired_pre(mons); beem.is_tracer = false; beem.fire(); return _rod_fired_post(mons, rod, weapon, beem, rate, was_visible); } return false; } //--------------------------------------------------------------- // // handle_wand // // Give the monster a chance to zap a wand or rod. Returns true // if the monster zapped. // //--------------------------------------------------------------- static bool _handle_wand(monster* mons, bolt &beem) { // Yes, there is a logic to this ordering {dlb}: // FIXME: monsters should be able to use wands or rods // out of sight of the player [rob] if (!mons_near(mons) || mons->asleep() || mons->has_ench(ENCH_SUBMERGED) || coinflip()) { return false; } if (mons_itemuse(mons) < MONUSE_STARTING_EQUIPMENT) return false; if (mons->inv[MSLOT_WEAPON] != NON_ITEM && mitm[mons->inv[MSLOT_WEAPON]].base_type == OBJ_RODS) { return _handle_rod(mons, beem); } if (mons->inv[MSLOT_WAND] == NON_ITEM || mitm[mons->inv[MSLOT_WAND]].plus <= 0) { return false; } // Make sure the item actually is a wand. if (mitm[mons->inv[MSLOT_WAND]].base_type != OBJ_WANDS) return false; bool niceWand = false; bool zap = false; bool was_visible = you.can_see(mons); if (!_setup_wand_beam(beem, mons)) return false; item_def &wand = mitm[mons->inv[MSLOT_WAND]]; const wand_type kind = (wand_type)wand.sub_type; switch (kind) { case WAND_DISINTEGRATION: // Dial down damage from wands of disintegration, since // disintegration beams can do large amounts of damage. beem.damage.size = beem.damage.size * 2 / 3; break; case WAND_ENSLAVEMENT: case WAND_RANDOM_EFFECTS: // These have been deemed "too tricky" at this time {dlb}: return false; case WAND_DIGGING: // This is handled elsewhere. return false; // These are wands that monsters will aim at themselves {dlb}: case WAND_HASTING: if (!mons->has_ench(ENCH_HASTE)) { beem.target = mons->pos(); niceWand = true; break; } return false; case WAND_HEAL_WOUNDS: if (mons->hit_points <= mons->max_hit_points / 2) { beem.target = mons->pos(); niceWand = true; break; } return false; case WAND_INVISIBILITY: if (!mons->has_ench(ENCH_INVIS) && !mons->has_ench(ENCH_SUBMERGED) && !mons->glows_naturally() && (!mons->friendly() || you.can_see_invisible(false))) { beem.target = mons->pos(); niceWand = true; break; } return false; case WAND_TELEPORTATION: if (mons->hit_points <= mons->max_hit_points / 2 || mons->caught()) { if (!mons->has_ench(ENCH_TP) && !one_chance_in(20)) { beem.target = mons->pos(); niceWand = true; break; } // This break causes the wand to be tried on the player. break; } return false; default: break; } if (mons->confused()) { beem.target = dgn_random_point_from(mons->pos(), LOS_RADIUS); if (beem.target.origin()) return false; zap = true; } else if (!niceWand) { // Fire tracer, if necessary. fire_tracer(mons, beem); // Good idea? zap = mons_should_fire(beem); } if (niceWand || zap) { if (!niceWand) make_mons_stop_fleeing(mons); _mons_fire_wand(mons, wand, beem, was_visible, niceWand); return true; } return false; } static bool _mons_has_launcher(const monster* mons) { for (int i = MSLOT_WEAPON; i <= MSLOT_ALT_WEAPON; ++i) { if (item_def *item = mons->mslot_item(static_cast<mon_inv_type>(i))) { if (is_range_weapon(*item)) return true; } } return false; } //--------------------------------------------------------------- // // handle_throw // // Give the monster a chance to throw something. Returns true if // the monster hurled. // //--------------------------------------------------------------- static bool _handle_throw(monster* mons, bolt & beem) { // Yes, there is a logic to this ordering {dlb}: if (mons->incapacitated() || mons->submerged()) { return false; } if (mons_itemuse(mons) < MONUSE_STARTING_EQUIPMENT && mons->type != MONS_SPECTRAL_THING) { return false; } bool archer = mons->is_archer(); const bool liquefied = mons->liquefied_ground(); // Highly-specialised archers are more likely to shoot than talk. (?) // If we're standing on liquefied ground, try to stand and fire! // (Particularly archers.) if ((liquefied && !archer && one_chance_in(9)) || (!liquefied && one_chance_in(archer ? 9 : 5))) return false; if (mons_class_flag(mons->type, M_STABBER) && mons->get_foe() != NULL) { // Stabbers going in for the kill don't use ranged attacks. if (mons->get_foe()->incapacitated()) return false; // But assassins WILL use their blowguns in melee range, if their foe is // not already incapacitated and they have useful ammo left. else if (mons_has_incapacitating_ranged_attack(mons, mons->get_foe())) archer = true; } // Don't allow offscreen throwing for now. if (mons->foe == MHITYOU && !mons_near(mons)) return false; // Monsters won't shoot in melee range, largely for balance reasons. // Specialist archers are an exception to this rule. if (!archer && adjacent(beem.target, mons->pos())) return false; // If the monster is a spellcaster, don't bother throwing stuff. // Exception: Spellcasters that already start out with some kind // ranged weapon. Seeing how monsters are disallowed from picking // up launchers if they have ranged spells, this will only apply // to very few monsters. if (mons_has_ranged_spell(mons, true, false) && !_mons_has_launcher(mons)) { return false; } // Greatly lowered chances if the monster is fleeing or pacified and // leaving the level. if ((mons_is_fleeing(mons) || mons->pacified()) && !one_chance_in(8)) { return false; } item_def *launcher = NULL; const item_def *weapon = NULL; const int mon_item = mons_pick_best_missile(mons, &launcher); if (mon_item == NON_ITEM || !mitm[mon_item].defined()) return false; if (player_or_mon_in_sanct(mons)) return false; item_def *missile = &mitm[mon_item]; const actor *act = actor_at(beem.target); if (missile->base_type == OBJ_MISSILES && missile->sub_type == MI_THROWING_NET && act) { // Throwing a net at a target that is already caught would be // completely useless, so bail out. if (act->caught()) return false; // Netting targets that are already permanently stuck in place // is similarly useless. if (mons_class_is_stationary(act->type)) return false; } // If the attack needs a launcher that we can't wield, bail out. if (launcher) { weapon = mons->mslot_item(MSLOT_WEAPON); if (weapon && weapon != launcher && weapon->cursed()) return false; } // Ok, we'll try it. setup_monster_throw_beam(mons, beem); // Set fake damage for the tracer. beem.damage = dice_def(10, 10); // Set item for tracer, even though it probably won't be used beem.item = missile; // Fire tracer. fire_tracer(mons, beem); // Clear fake damage (will be set correctly in mons_throw). beem.damage = 0; // Good idea? if (mons_should_fire(beem)) { // Monsters shouldn't shoot if fleeing, so let them "turn to attack". make_mons_stop_fleeing(mons); if (launcher && launcher != weapon) mons->swap_weapons(); beem.name.clear(); return mons_throw(mons, beem, mon_item); } return false; } // Give the monster its action energy (aka speed_increment). static void _monster_add_energy(monster* mons) { if (mons->speed > 0) { // Randomise to make counting off monster moves harder: const int energy_gained = max(1, div_rand_round(mons->speed * you.time_taken, 10)); mons->speed_increment += energy_gained; } } #ifdef DEBUG # define DEBUG_ENERGY_USE(problem) \ if (mons->speed_increment == old_energy && mons->alive()) \ mprf(MSGCH_DIAGNOSTICS, \ problem " for monster '%s' consumed no energy", \ mons->name(DESC_PLAIN).c_str()); #else # define DEBUG_ENERGY_USE(problem) ((void) 0) #endif static void _confused_move_dir(monster *mons) { mmov.reset(); int pfound = 0; for (adjacent_iterator ai(mons->pos(), false); ai; ++ai) if (mons->can_pass_through(*ai)) { // Highly intelligent monsters don't move if they might drown. if (mons_intel(mons) == I_HIGH && !mons->is_habitable(*ai)) { // Players without a spoiler sheet have no way to know which // monsters are I_HIGH, and this behaviour is obscure. // Thus, give a message. const string where = make_stringf("%s@%d,%d", level_id::current().describe().c_str(), mons->pos().x, mons->pos().y); if (!mons->props.exists("no_conf_move") || mons->props["no_conf_move"].get_string() != where) { // But don't spam. mons->props["no_conf_move"] = where; simple_monster_message(mons, make_stringf(" stays still, afraid of the %s.", feat_type_name(grd(*ai))).c_str()); } mmov.reset(); break; } else if (one_chance_in(++pfound)) mmov = *ai - mons->pos(); } } static int _tentacle_move_speed(monster_type type) { if (type == MONS_KRAKEN) return 10; else if (type == MONS_TENTACLED_STARSPAWN) return 18; else return 0; } static void _pre_monster_move(monster* mons) { mons->hit_points = min(mons->max_hit_points, mons->hit_points); if (mons->type == MONS_SPATIAL_MAELSTROM && !player_in_branch(BRANCH_ABYSS) && !player_in_branch(BRANCH_ZIGGURAT)) { for (int i = 0; i < you.time_taken; ++i) { if (one_chance_in(100)) { mons->banish(mons); return; } } } if (mons->type == MONS_SNAPLASHER_VINE && mons->props.exists("vine_awakener")) { monster* awakener = monster_by_mid(mons->props["vine_awakener"].get_int()); if (awakener && !awakener->can_see(mons)) { simple_monster_message(mons, " falls limply to the ground."); monster_die(mons, KILL_RESET, NON_MONSTER); return; } } if (mons_stores_tracking_data(mons)) { actor* foe = mons->get_foe(); if (foe) { if (!mons->props.exists("foe_pos")) mons->props["foe_pos"].get_coord() = foe->pos(); else { if (mons->props["foe_pos"].get_coord().distance_from(mons->pos()) > foe->pos().distance_from(mons->pos())) mons->props["foe_approaching"].get_bool() = true; else mons->props["foe_approaching"].get_bool() = false; mons->props["foe_pos"].get_coord() = foe->pos(); } } else mons->props.erase("foe_pos"); } reset_battlesphere(mons); reset_spectral_weapon(mons); // This seems to need to go here to actually get monsters to slow down. // XXX: Replace with a new ENCH_LIQUEFIED_GROUND or something. if (mons->liquefied_ground()) { mon_enchant me = mon_enchant(ENCH_SLOW, 0, 0, 20); if (mons->has_ench(ENCH_SLOW)) mons->update_ench(me); else mons->add_ench(me); mons->calc_speed(); } fedhas_neutralise(mons); // Monster just summoned (or just took stairs), skip this action. if (!mons_is_mimic(mons->type) && testbits(mons->flags, MF_JUST_SUMMONED)) { mons->flags &= ~MF_JUST_SUMMONED; return; } mon_acting mact(mons); // Mimics get enough energy to act immediately when revealed. if (mons_is_mimic(mons->type) && testbits(mons->flags, MF_JUST_SUMMONED)) { mons->speed_increment = 80; mons->flags &= ~MF_JUST_SUMMONED; } else _monster_add_energy(mons); // Handle clouds on nonmoving monsters. if (mons->speed == 0) { _mons_in_cloud(mons); // Update constriction durations mons->accum_has_constricted(); _heated_area(mons); if (mons->type == MONS_NO_MONSTER) return; } // Apply monster enchantments once for every normal-speed // player turn. mons->ench_countdown -= you.time_taken; while (mons->ench_countdown < 0) { mons->ench_countdown += 10; mons->apply_enchantments(); // If the monster *merely* died just break from the loop // rather than quit altogether, since we have to deal with // giant spores and ball lightning exploding at the end of the // function, but do return if the monster's data has been // reset, since then the monster type is invalid. if (mons->type == MONS_NO_MONSTER) return; else if (mons->hit_points < 1) break; } // Memory is decremented here for a reason -- we only want it // decrementing once per monster "move". if (mons->foe_memory > 0 && !you.penance[GOD_ASHENZARI] && !mons_class_flag(mons->type, M_VIGILANT)) { mons->foe_memory -= you.time_taken; } // Otherwise there are potential problems with summonings. if (mons->type == MONS_GLOWING_SHAPESHIFTER) mons->add_ench(ENCH_GLOWING_SHAPESHIFTER); if (mons->type == MONS_SHAPESHIFTER) mons->add_ench(ENCH_SHAPESHIFTER); // We reset batty monsters from wander to seek here, instead // of in handle_behaviour() since that will be called with // every single movement, and we want these monsters to // hit and run. -- bwr if (mons->foe != MHITNOT && mons_is_wandering(mons) && mons_is_batty(mons)) { mons->behaviour = BEH_SEEK; } mons->check_speed(); } void handle_monster_move(monster* mons) { const monsterentry* entry = get_monster_data(mons->type); if (!entry) return; int old_energy = mons->speed_increment; int non_move_energy = min(entry->energy_usage.move, entry->energy_usage.swim); #ifdef DEBUG_MONS_SCAN bool monster_was_floating = mgrd(mons->pos()) != mons->mindex(); #endif coord_def old_pos = mons->pos(); coord_def kraken_last_update = mons->pos(); if (!mons->has_action_energy()) return; move_solo_tentacle(mons); if (!mons->alive()) return; if (old_pos != mons->pos() && mons_is_tentacle_head(mons_base_type(mons))) { move_child_tentacles(mons); kraken_last_update = mons->pos(); } old_pos = mons->pos(); #ifdef DEBUG_MONS_SCAN if (!monster_was_floating && mgrd(mons->pos()) != mons->mindex()) { mprf(MSGCH_ERROR, "Monster %s became detached from mgrd " "in handle_monster_move() loop", mons->name(DESC_PLAIN, true).c_str()); mpr("[[[[[[[[[[[[[[[[[[", MSGCH_WARN); debug_mons_scan(); mpr("]]]]]]]]]]]]]]]]]]", MSGCH_WARN); monster_was_floating = true; } else if (monster_was_floating && mgrd(mons->pos()) == mons->mindex()) { mprf(MSGCH_DIAGNOSTICS, "Monster %s re-attached itself to mgrd " "in handle_monster_move() loop", mons->name(DESC_PLAIN, true).c_str()); monster_was_floating = false; } #endif if (mons->is_projectile()) { if (iood_act(*mons)) return; mons->lose_energy(EUT_MOVE); return; } if (mons->type == MONS_BATTLESPHERE) { if (fire_battlesphere(mons)) mons->lose_energy(EUT_SPECIAL); } if (mons->type == MONS_FULMINANT_PRISM) { ++mons->number; if (mons->number == 2) mons->suicide(); else { if (player_can_hear(mons->pos())) { if (you.can_see(mons)) { simple_monster_message(mons, " crackles loudly.", MSGCH_WARN); } else mpr("You hear a loud crackle.", MSGCH_SOUND); } // Done this way to keep the detonation timer predictable mons->speed_increment -= 10; } return; } mons->shield_blocks = 0; const int cloud_num = env.cgrid(mons->pos()); const bool avoid_cloud = mons_avoids_cloud(mons, cloud_num); _mons_in_cloud(mons); _heated_area(mons); if (!mons->alive()) return; slime_wall_damage(mons, speed_to_duration(mons->speed)); if (!mons->alive()) return; if (mons->type == MONS_TIAMAT && one_chance_in(3)) draconian_change_colour(mons); _monster_regenerate(mons); if (mons->cannot_act() || mons->type == MONS_SIXFIRHY // these move only 8 of 24 turns && ++mons->number / 8 % 3 != 2 // but are not helpless || mons->type == MONS_JIANGSHI // similarly, but more irregular (48 of 90) && (++mons->number / 6 % 3 == 1 || mons->number / 3 % 5 == 1)) { mons->speed_increment -= non_move_energy; return; } if (mons->has_ench(ENCH_DAZED) && one_chance_in(5)) { simple_monster_message(mons, " is lost in a daze."); mons->speed_increment -= non_move_energy; return; } if (crawl_state.disables[DIS_MON_ACT] && _unfriendly_or_insane(mons)) { mons->speed_increment -= non_move_energy; return; } handle_behaviour(mons); // handle_behaviour() could make the monster leave the level. if (!mons->alive()) return; ASSERT(!crawl_state.game_is_arena() || mons->foe != MHITYOU); ASSERT_IN_BOUNDS_OR_ORIGIN(mons->target); // Submerging monsters will hide from clouds. if (avoid_cloud && monster_can_submerge(mons, grd(mons->pos())) && !mons->caught() && !mons->submerged()) { mons->add_ench(ENCH_SUBMERGED); mons->speed_increment -= ENERGY_SUBMERGE(entry); return; } if (mons->speed >= 100) { mons->speed_increment -= non_move_energy; return; } if (igrd(mons->pos()) != NON_ITEM && (mons_itemuse(mons) >= MONUSE_WEAPONS_ARMOUR || mons_itemeat(mons) != MONEAT_NOTHING)) { // Keep neutral, charmed, summoned monsters from picking up stuff. // Same for friendlies if friendly_pickup is set to "none". if ((!mons->neutral() && !mons->has_ench(ENCH_CHARM) || (you_worship(GOD_JIYVA) && mons_is_slime(mons))) && !mons->is_summoned() && !mons->is_perm_summoned() && (!mons->friendly() || you.friendly_pickup != FRIENDLY_PICKUP_NONE)) { if (_handle_pickup(mons)) { DEBUG_ENERGY_USE("handle_pickup()"); return; } } } // Lurking monsters only stop lurking if their target is right // next to them, otherwise they just sit there. // However, if the monster is involuntarily submerged but // still alive (e.g., nonbreathing which had water poured // on top of it), this doesn't apply. if (mons_is_lurking(mons) || mons->has_ench(ENCH_SUBMERGED)) { if (mons->foe != MHITNOT && grid_distance(mons->target, mons->pos()) <= 1) { if (mons->submerged()) { // Don't unsubmerge if the monster is avoiding the // cloud on top of the water. if (avoid_cloud) { mons->speed_increment -= non_move_energy; return; } if (!mons->del_ench(ENCH_SUBMERGED)) { // Couldn't unsubmerge. mons->speed_increment -= non_move_energy; return; } } mons->behaviour = BEH_SEEK; } else { mons->speed_increment -= non_move_energy; return; } } if (mons->caught()) { // Struggling against the net takes time. _swim_or_move_energy(mons); } else if (!mons->petrified()) { // Calculates mmov based on monster target. _handle_movement(mons); _shedu_movement_clamp(mons); if (mons_is_confused(mons) || mons->type == MONS_AIR_ELEMENTAL && mons->submerged()) { _confused_move_dir(mons); // OK, mmov determined. const coord_def newcell = mmov + mons->pos(); monster* enemy = monster_at(newcell); if (enemy && newcell != mons->pos() && !is_sanctuary(mons->pos())) { if (fight_melee(mons, enemy)) { mmov.reset(); DEBUG_ENERGY_USE("fight_melee()"); return; } else { // FIXME: None of these work! // Instead run away! if (mons->add_ench(mon_enchant(ENCH_FEAR))) behaviour_event(mons, ME_SCARE, 0, newcell); return; } } } } mon_nearby_ability(mons); if (!mons->alive()) return; // XXX: A bit hacky, but stores where we WILL move, if we don't take // another action instead (used for decision-making) if (mons_stores_tracking_data(mons)) mons->props["mmov"].get_coord() = mmov; if (!mons->asleep() && !mons_is_wandering(mons) && !mons->withdrawn() // Berserking monsters are limited to running up and // hitting their foes. && !mons->berserk_or_insane() // Slime creatures can split while wandering or resting. || mons->type == MONS_SLIME_CREATURE) { bolt beem; beem.source = mons->pos(); beem.target = mons->target; beem.beam_source = mons->mindex(); // XXX: Otherwise perma-confused monsters can almost never properly // aim spells, since their target is constantly randomized. // This does make them automatically aware of the player in several // situations they otherwise would not, however. if (mons_class_flag(mons->type, M_CONFUSED)) { actor* foe = mons->get_foe(); if (foe && mons->can_see(foe)) beem.target = foe->pos(); } // Prevents unfriendlies from nuking you from offscreen. // How nice! const bool friendly_or_near = mons->friendly() && mons->foe == MHITYOU || mons->near_foe(); if (friendly_or_near || mons->type == MONS_TEST_SPAWNER // Slime creatures can split when offscreen. || mons->type == MONS_SLIME_CREATURE // Lost souls can flicker away at any time they're isolated || mons->type == MONS_LOST_SOUL // Let monsters who have Dig use it off-screen. || mons->has_spell(SPELL_DIG)) { // [ds] Special abilities shouldn't overwhelm // spellcasting in monsters that have both. This aims // to give them both roughly the same weight. if (coinflip() ? mon_special_ability(mons, beem) || _do_mon_spell(mons, beem) : _do_mon_spell(mons, beem) || mon_special_ability(mons, beem)) { DEBUG_ENERGY_USE("spell or special"); mmov.reset(); return; } } if (friendly_or_near) { if (_handle_potion(mons, beem)) { DEBUG_ENERGY_USE("_handle_potion()"); return; } if (_handle_scroll(mons)) { DEBUG_ENERGY_USE("_handle_scroll()"); return; } if (_handle_evoke_equipment(mons, beem)) { DEBUG_ENERGY_USE("_handle_evoke_equipment()"); return; } if (_handle_wand(mons, beem)) { DEBUG_ENERGY_USE("_handle_wand()"); return; } if (_handle_reaching(mons)) { DEBUG_ENERGY_USE("_handle_reaching()"); return; } } if (_handle_throw(mons, beem)) { DEBUG_ENERGY_USE("_handle_throw()"); return; } } if (!mons->caught()) { if (mons->pos() + mmov == you.pos()) { ASSERT(!crawl_state.game_is_arena()); if (_unfriendly_or_insane(mons) && !mons->has_ench(ENCH_CHARM) && !mons->withdrawn()) { if (!mons->wont_attack()) { // If it steps into you, cancel other targets. mons->foe = MHITYOU; mons->target = you.pos(); } fight_melee(mons, &you); if (mons_is_batty(mons)) { mons->behaviour = BEH_WANDER; set_random_target(mons); } DEBUG_ENERGY_USE("fight_melee()"); mmov.reset(); return; } } // See if we move into (and fight) an unfriendly monster. monster* targ = monster_at(mons->pos() + mmov); //If a tentacle owner is attempting to move into an adjacent //segment, kill the segment and adjust connectivity data. if (targ && mons_tentacle_adjacent(mons, targ)) { bool basis = targ->props.exists("outwards"); int out_idx = basis ? targ->props["outwards"].get_int() : -1; if (out_idx != -1) menv[out_idx].props["inwards"].get_int() = mons->mindex(); monster_die(targ, KILL_MISC, NON_MONSTER, true); targ = NULL; } if (targ && targ != mons && mons->behaviour != BEH_WITHDRAW && (!mons_aligned(mons, targ) || mons->has_ench(ENCH_INSANE)) && monster_can_hit_monster(mons, targ)) { // Maybe they can swap places? if (_swap_monsters(mons, targ)) { _swim_or_move_energy(mons); return; } // Figure out if they fight. else if ((!mons_is_firewood(targ) || mons->is_child_tentacle()) && fight_melee(mons, targ)) { if (mons_is_batty(mons)) { mons->behaviour = BEH_WANDER; set_random_target(mons); // mons->speed_increment -= mons->speed; } mmov.reset(); DEBUG_ENERGY_USE("fight_melee()"); return; } } else if (mons->behaviour == BEH_WITHDRAW && ((targ && targ != mons && targ->friendly()) || (you.pos() == mons->pos() + mmov))) { // Don't count turns spent blocked by friendly creatures // (or the player) as an indication that we're stuck mons->props.erase("blocked_deadline"); } if (invalid_monster(mons) || mons->is_stationary()) { if (mons->speed_increment == old_energy) mons->speed_increment -= non_move_energy; return; } if (mons->cannot_move() || !_monster_move(mons)) { mons->speed_increment -= non_move_energy; mons->check_clinging(false); } } you.update_beholder(mons); you.update_fearmonger(mons); // Reevaluate behaviour, since the monster's surroundings have // changed (it may have moved, or died for that matter). Don't // bother for dead monsters. :) if (mons->alive()) { handle_behaviour(mons); ASSERT_IN_BOUNDS_OR_ORIGIN(mons->target); } if (mons_is_tentacle_head(mons_base_type(mons))) { if (mons->pos() != kraken_last_update) move_child_tentacles(mons); mons->number += (old_energy - mons->speed_increment) * _tentacle_move_speed(mons_base_type(mons)); while (mons->number >= 100) { move_child_tentacles(mons); mons->number -= 100; } } } static void _post_monster_move(monster* mons) { if (invalid_monster(mons)) return; mons->handle_constriction(); if (mons->type == MONS_ANCIENT_ZYME) ancient_zyme_sicken(mons); if (mons->type == MONS_ASMODEUS || mons->type == MONS_CHAOS_BUTTERFLY) { cloud_type ctype; switch (mons->type) { case MONS_ASMODEUS: ctype = CLOUD_FIRE; break; case MONS_CHAOS_BUTTERFLY: ctype = CLOUD_RAIN; break; default: ctype = CLOUD_NONE; break; } for (adjacent_iterator ai(mons->pos()); ai; ++ai) if (!feat_is_solid(grd(*ai)) && (env.cgrid(*ai) == EMPTY_CLOUD || env.cloud[env.cgrid(*ai)].type == ctype)) { place_cloud(ctype, *ai, 2 + random2(6), mons); } } if (mons->type != MONS_NO_MONSTER && mons->hit_points < 1) monster_die(mons, KILL_MISC, NON_MONSTER); } priority_queue<pair<monster *, int>, vector<pair<monster *, int> >, MonsterActionQueueCompare> monster_queue; // Inserts a monster into the monster queue (needed to ensure that any monsters // given energy or an action by a effect can actually make use of that energy // this round) void queue_monster_for_action(monster* mons) { monster_queue.push(pair<monster *, int>(mons, mons->speed_increment)); } //--------------------------------------------------------------- // // handle_monsters // // This is the routine that controls monster AI. // //--------------------------------------------------------------- void handle_monsters(bool with_noise) { for (monster_iterator mi; mi; ++mi) { _pre_monster_move(*mi); if (!invalid_monster(*mi) && mi->alive() && mi->has_action_energy()) monster_queue.push(pair<monster *, int>(*mi, mi->speed_increment)); } int tries = 0; // infinite loop protection, shouldn't be ever needed while (!monster_queue.empty()) { if (tries++ > 32767) { die("infinite handle_monsters() loop, mons[0 of %d] is %s", (int)monster_queue.size(), monster_queue.top().first->name(DESC_PLAIN, true).c_str()); } monster *mon = monster_queue.top().first; const int oldspeed = monster_queue.top().second; monster_queue.pop(); if (invalid_monster(mon) || !mon->alive() || !mon->has_action_energy()) continue; // Only move the monster if nothing else has played with its energy // during their turn. // This can happen with, e.g., headbutt stuns, cold attacks on cold- // -blooded monsters, etc. // If something's played with the energy, they get added back to // the queue just after this. if (oldspeed == mon->speed_increment) { handle_monster_move(mon); _post_monster_move(mon); fire_final_effects(); } if (mon->has_action_energy()) { monster_queue.push( pair<monster *, int>(mon, mon->speed_increment)); } // If the player got banished, discard pending monster actions. if (you.banished) { // Clear list of mesmerising monsters. you.clear_beholders(); you.clear_fearmongers(); you.stop_constricting_all(); you.stop_being_constricted(); break; } } // Process noises now (before clearing the sleep flag). if (with_noise) apply_noises(); // Clear one-turn deep sleep flag. // XXX: With the current handling, it would be cleaner to // not treat this as an enchantment. // XXX: ENCH_SLEEPY only really works for player-cast // hibernation. for (monster_iterator mi; mi; ++mi) mi->del_ench(ENCH_SLEEPY); // Clear any summoning flags so that lower indiced // monsters get their actions in the next round. for (int i = 0; i < MAX_MONSTERS; i++) menv[i].flags &= ~MF_JUST_SUMMONED; } static bool _jelly_divide(monster* parent) { if (!mons_class_flag(parent->type, M_SPLITS)) return false; const int reqd = max(parent->hit_dice * 8, 50); if (parent->hit_points < reqd) return false; monster* child = NULL; coord_def child_spot; int num_spots = 0; // First, find a suitable spot for the child {dlb}: for (adjacent_iterator ai(parent->pos()); ai; ++ai) if (actor_at(*ai) == NULL && parent->can_pass_through(*ai) && one_chance_in(++num_spots)) { child_spot = *ai; } if (num_spots == 0) return false; // Now that we have a spot, find a monster slot {dlb}: child = get_free_monster(); if (!child) return false; // Handle impact of split on parent {dlb}: parent->max_hit_points /= 2; if (parent->hit_points > parent->max_hit_points) parent->hit_points = parent->max_hit_points; parent->init_experience(); parent->experience = parent->experience * 3 / 5 + 1; // Create child {dlb}: // This is terribly partial and really requires // more thought as to generation ... {dlb} *child = *parent; child->max_hit_points = child->hit_points; child->speed_increment = 70 + random2(5); child->moveto(child_spot); child->set_new_monster_id(); mgrd(child->pos()) = child->mindex(); if (!simple_monster_message(parent, " splits in two!") && (player_can_hear(parent->pos()) || player_can_hear(child->pos()))) { mpr("You hear a squelching noise.", MSGCH_SOUND); } if (crawl_state.game_is_arena()) arena_placed_monster(child); return true; } // XXX: This function assumes that only jellies eat items. static bool _monster_eat_item(monster* mons, bool nearby) { if (!mons_eats_items(mons)) return false; // Friendly jellies won't eat (unless worshipping Jiyva). if (mons->friendly() && !you_worship(GOD_JIYVA)) return false; // Off-limit squares are off-limit. if (testbits(env.pgrid(mons->pos()), FPROP_NO_JIYVA)) return false; int hps_changed = 0; // Zotdef jellies are toned down slightly int max_eat = roll_dice(1, (crawl_state.game_is_zotdef() ? 8 : 10)); int eaten = 0; bool eaten_net = false; bool death_ooze_ate_good = false; bool death_ooze_ate_corpse = false; bool shown_msg = false; piety_gain_t gain = PIETY_NONE; int js = JS_NONE; // Jellies can swim, so don't check water for (stack_iterator si(mons->pos()); si && eaten < max_eat && hps_changed < 50; ++si) { if (!is_item_jelly_edible(*si)) continue; #if defined(DEBUG_DIAGNOSTICS) || defined(DEBUG_EATERS) mprf(MSGCH_DIAGNOSTICS, "%s eating %s", mons->name(DESC_PLAIN, true).c_str(), si->name(DESC_PLAIN).c_str()); #endif int quant = si->quantity; death_ooze_ate_good = (mons->type == MONS_DEATH_OOZE && (get_weapon_brand(*si) == SPWPN_HOLY_WRATH || get_ammo_brand(*si) == SPMSL_SILVER)); death_ooze_ate_corpse = (mons->type == MONS_DEATH_OOZE && ((si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY) || si->base_type == OBJ_FOOD && si->sub_type == FOOD_CHUNK)); if (si->base_type != OBJ_GOLD) { quant = min(quant, max_eat - eaten); hps_changed += (quant * item_mass(*si)) / (crawl_state.game_is_zotdef() ? 30 : 20) + quant; eaten += quant; if (mons->caught() && si->base_type == OBJ_MISSILES && si->sub_type == MI_THROWING_NET && item_is_stationary(*si)) { mons->del_ench(ENCH_HELD, true); eaten_net = true; } } else { // Shouldn't be much trouble to digest a huge pile of gold! if (quant > 500) quant = 500 + roll_dice(2, (quant - 500) / 2); hps_changed += quant / 10 + 1; eaten++; } if (eaten && !shown_msg && player_can_hear(mons->pos())) { mprf(MSGCH_SOUND, "You hear a%s slurping noise.", nearby ? "" : " distant"); shown_msg = true; } if (you_worship(GOD_JIYVA)) { gain = sacrifice_item_stack(*si, &js, quant); if (gain > PIETY_NONE) simple_god_message(" appreciates your sacrifice."); jiyva_slurp_message(js); } if (quant >= si->quantity) item_was_destroyed(*si, mons->mindex()); if (is_blood_potion(*si)) { for (int i = 0; i < quant; ++i) remove_oldest_blood_potion(*si); } dec_mitm_item_quantity(si.link(), quant); } if (eaten > 0) { hps_changed = max(hps_changed, 1); hps_changed = min(hps_changed, 50); if (death_ooze_ate_good) mons->hurt(NULL, hps_changed, BEAM_NONE, false); else { // This is done manually instead of using heal_monster(), // because that function doesn't work quite this way. - bwr const int base_max = mons_avg_hp(mons->type); mons->hit_points += hps_changed; mons->hit_points = min(MAX_MONSTER_HP, min(base_max * 2, mons->hit_points)); mons->max_hit_points = max(mons->hit_points, mons->max_hit_points); } if (death_ooze_ate_corpse) place_cloud(CLOUD_MIASMA, mons->pos(), 4 + random2(5), mons); if (death_ooze_ate_good) simple_monster_message(mons, " twists violently!"); else if (eaten_net) simple_monster_message(mons, " devours the net!"); else _jelly_divide(mons); } return (eaten > 0); } static bool _monster_eat_single_corpse(monster* mons, item_def& item, bool do_heal, bool nearby) { if (item.base_type != OBJ_CORPSES || item.sub_type != CORPSE_BODY) return false; const monster_type mt = item.mon_type; if (do_heal) { const int base_max = mons_avg_hp(mons->type); mons->hit_points += 1 + random2(mons_weight(mt)) / 100; mons->hit_points = min(MAX_MONSTER_HP, min(base_max * 2, mons->hit_points)); mons->max_hit_points = max(mons->hit_points, mons->max_hit_points); } if (nearby) { mprf("%s eats %s.", mons->name(DESC_THE).c_str(), item.name(DESC_THE).c_str()); } // Butcher the corpse without leaving chunks. butcher_corpse(item, MB_MAYBE, false); return true; } static bool _monster_eat_corpse(monster* mons, bool do_heal, bool nearby) { if (!mons_eats_corpses(mons)) return false; int eaten = 0; for (stack_iterator si(mons->pos()); si; ++si) { if (_monster_eat_single_corpse(mons, *si, do_heal, nearby)) { eaten++; break; } } return (eaten > 0); } static bool _monster_eat_food(monster* mons, bool nearby) { if (!mons_eats_food(mons)) return false; if (mons_is_fleeing(mons)) return false; int eaten = 0; for (stack_iterator si(mons->pos()); si; ++si) { const bool is_food = (si->base_type == OBJ_FOOD); const bool is_corpse = (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY); const bool free_to_eat = (mons->wont_attack() || grid_distance(mons->pos(), you.pos()) > 1); if (!is_food && !is_corpse) continue; if (free_to_eat && coinflip()) { if (is_food) { if (nearby) { mprf("%s eats %s.", mons->name(DESC_THE).c_str(), quant_name(*si, 1, DESC_THE).c_str()); } dec_mitm_item_quantity(si.link(), 1); eaten++; break; } else { // Assume that only undead can heal from eating corpses. if (_monster_eat_single_corpse(mons, *si, mons->holiness() == MH_UNDEAD, nearby)) { eaten++; break; } } } } return (eaten > 0); } //--------------------------------------------------------------- // // handle_pickup // // Returns false if monster doesn't spend any time picking something up. // //--------------------------------------------------------------- static bool _handle_pickup(monster* mons) { if (mons->asleep() || mons->submerged()) return false; // Flying over water doesn't let you pick up stuff. This is inexact, as // a merfolk could be flying, but that's currently impossible except for // being tornadoed, and with *that* low life expectancy let's not care. dungeon_feature_type feat = grd(mons->pos()); if ((feat == DNGN_LAVA || feat == DNGN_DEEP_WATER) && mons->flight_mode()) return false; const bool nearby = mons_near(mons); int count_pickup = 0; if (mons_itemeat(mons) != MONEAT_NOTHING) { if (mons_eats_items(mons)) { if (_monster_eat_item(mons, nearby)) return false; } else if (mons_eats_corpses(mons)) { // Assume that only undead can heal from eating corpses. if (_monster_eat_corpse(mons, mons->holiness() == MH_UNDEAD, nearby)) { return false; } } else if (mons_eats_food(mons)) { if (_monster_eat_food(mons, nearby)) return false; } } if (mons_itemuse(mons) >= MONUSE_WEAPONS_ARMOUR) { // Note: Monsters only look at stuff near the top of stacks. // // XXX: Need to put in something so that monster picks up // multiple items (e.g. ammunition) identical to those it's // carrying. // // Monsters may now pick up up to two items in the same turn. // (jpeg) for (stack_iterator si(mons->pos()); si; ++si) { if (si->flags & ISFLAG_NO_PICKUP) continue; if (mons->pickup_item(*si, nearby)) count_pickup++; if (count_pickup > 1 || coinflip()) break; } } return (count_pickup > 0); } // Randomise potential damage. static int _estimated_trap_damage(trap_type trap) { switch (trap) { case TRAP_BLADE: return (10 + random2(30)); case TRAP_DART: return random2(4); case TRAP_ARROW: return random2(7); case TRAP_SPEAR: return random2(10); case TRAP_BOLT: return random2(13); default: return 0; } } // Check whether a given trap (described by trap position) can be // regarded as safe. Takes into account monster intelligence and // allegiance. // (just_check is used for intelligent monsters trying to avoid traps.) static bool _is_trap_safe(const monster* mons, const coord_def& where, bool just_check) { const int intel = mons_intel(mons); const trap_def *ptrap = find_trap(where); if (!ptrap) return true; const trap_def& trap = *ptrap; const bool player_knows_trap = (trap.is_known(&you)); // No friendly monsters will ever enter a Zot trap you know. if (player_knows_trap && mons->friendly() && trap.type == TRAP_ZOT) return false; // Dumb monsters don't care at all. if (intel == I_PLANT) return true; // Known shafts are safe. Unknown ones are unknown. if (trap.type == TRAP_SHAFT) return true; // Hostile monsters are not afraid of non-mechanical traps. // Allies will try to avoid teleportation and zot traps. const bool mechanical = (trap.category() == DNGN_TRAP_MECHANICAL); if (trap.is_known(mons)) { if (just_check) return false; // Square is blocked. else { // Test for corridor-like environment. const int x = where.x - mons->pos().x; const int y = where.y - mons->pos().y; // The question is whether the monster (m) can easily reach its // presumable destination (x) without stepping on the trap. Traps // in corridors do not allow this. See e.g // #x# ## // #^# or m^x // m ## // // The same problem occurs if paths are blocked by monsters, // hostile terrain or other traps rather than walls. // What we do is check whether the squares with the relative // positions (-1,0)/(+1,0) or (0,-1)/(0,+1) form a "corridor" // (relative to the _trap_ position rather than the monster one). // If they don't, the trap square is marked as "unsafe" (because // there's a good alternative move for the monster to take), // otherwise the decision will be made according to later tests // (monster hp, trap type, ...) // If a monster still gets stuck in a corridor it will usually be // because it has less than half its maximum hp. if ((mon_can_move_to_pos(mons, coord_def(x-1, y), true) || mon_can_move_to_pos(mons, coord_def(x+1,y), true)) && (mon_can_move_to_pos(mons, coord_def(x,y-1), true) || mon_can_move_to_pos(mons, coord_def(x,y+1), true))) { return false; } } } // Friendlies will try not to be parted from you. if (intelligent_ally(mons) && trap.type == TRAP_TELEPORT && player_knows_trap && mons_near(mons)) { return false; } // Healthy monsters don't mind a little pain. if (mechanical && mons->hit_points >= mons->max_hit_points / 2 && (intel == I_ANIMAL || mons->hit_points > _estimated_trap_damage(trap.type))) { return true; } // In Zotdef critters will risk death to get to the Orb if (crawl_state.game_is_zotdef() && mechanical) return true; // Friendly and good neutral monsters don't enjoy Zot trap perks; // handle accordingly. In the arena Zot traps affect all monsters. if (mons->wont_attack() || crawl_state.game_is_arena()) { return (mechanical ? mons_flies(mons) : !trap.is_known(mons) || trap.type != TRAP_ZOT); } else return (!mechanical || mons_flies(mons) || !trap.is_known(mons)); } static void _mons_open_door(monster* mons, const coord_def &pos) { const char *adj = "", *noun = "door"; bool was_seen = false; set<coord_def> all_door = connected_doors(pos); get_door_description(all_door.size(), &adj, &noun); for (set<coord_def>::iterator i = all_door.begin(); i != all_door.end(); ++i) { const coord_def& dc = *i; if (you.see_cell(dc)) was_seen = true; grd(dc) = DNGN_OPEN_DOOR; set_terrain_changed(dc); } if (was_seen) { viewwindow(); string open_str = "opens the "; open_str += adj; open_str += noun; open_str += "."; // Should this be conditionalized on you.can_see(mons?) mons->seen_context = (all_door.size() <= 2) ? SC_DOOR : SC_GATE; if (!you.can_see(mons)) { mprf("Something unseen %s", open_str.c_str()); interrupt_activity(AI_FORCE_INTERRUPT); } else if (!you_are_delayed()) { mprf("%s %s", mons->name(DESC_A).c_str(), open_str.c_str()); } } mons->lose_energy(EUT_MOVE); dungeon_events.fire_position_event(DET_DOOR_OPENED, pos); } static bool _no_habitable_adjacent_grids(const monster* mon) { for (adjacent_iterator ai(mon->pos()); ai; ++ai) if (monster_habitable_grid(mon, grd(*ai))) return false; return true; } static bool _same_tentacle_parts(const monster* mpusher, const monster* mpushee) { if (!mons_is_tentacle_head(mons_base_type(mpusher))) return false; if (mpushee->is_child_tentacle_of(mpusher)) return true; if (mons_tentacle_adjacent(mpusher, mpushee)) return true; return false; } static bool _mons_can_displace(const monster* mpusher, const monster* mpushee) { if (invalid_monster(mpusher) || invalid_monster(mpushee)) return false; const int ipushee = mpushee->mindex(); if (invalid_monster_index(ipushee)) return false; if (!mpushee->has_action_energy() && !_same_tentacle_parts(mpusher, mpushee)) { return false; } // Confused monsters can't be pushed past, sleeping monsters // can't push. Note that sleeping monsters can't be pushed // past, either, but they may be woken up by a crowd trying to // elbow past them, and the wake-up check happens downstream. // Monsters caught in a net also can't be pushed past. if (mons_is_confused(mpusher) || mons_is_confused(mpushee) || mpusher->cannot_move() || mpusher->is_stationary() || mpusher->is_constricted() || mpushee->is_constricted() || (!_same_tentacle_parts(mpusher, mpushee) && (mpushee->cannot_move() || mpushee->is_stationary())) || mpusher->asleep() || mpushee->caught()) { return false; } // Batty monsters are unpushable. if (mons_is_batty(mpusher) || mons_is_batty(mpushee)) return false; // Anyone can displace a submerged monster (otherwise monsters can // get stuck behind a trapdoor spider, giving away its presence). if (mpushee->submerged()) return true; if (!monster_shover(mpusher)) return false; // Fleeing monsters of the same type may push past higher ranking ones. if (!monster_senior(mpusher, mpushee, mons_is_retreating(mpusher))) return false; return true; } static int _count_adjacent_slime_walls(const coord_def &pos) { int count = 0; for (adjacent_iterator ai(pos); ai; ++ai) if (env.grid(*ai) == DNGN_SLIMY_WALL) count++; return count; } // Returns true if the monster should try to avoid that position // because of taking damage from slime walls. static bool _check_slime_walls(const monster *mon, const coord_def &targ) { if (!player_in_branch(BRANCH_SLIME_PITS) || mons_is_slime(mon) || actor_slime_wall_immune(mon) || mons_intel(mon) <= I_REPTILE) { return false; } const int target_count = _count_adjacent_slime_walls(targ); // Entirely safe. if (!target_count) return false; const int current_count = _count_adjacent_slime_walls(mon->pos()); if (target_count <= current_count) return false; // The monster needs to have a purpose to risk taking damage. if (!mons_is_seeking(mon)) return true; // With enough hit points monsters will consider moving // onto more dangerous squares. return (mon->hit_points < mon->max_hit_points / 2); } // Check whether a monster can move to given square (described by its relative // coordinates to the current monster position). just_check is true only for // calls from is_trap_safe when checking the surrounding squares of a trap. bool mon_can_move_to_pos(const monster* mons, const coord_def& delta, bool just_check) { const coord_def targ = mons->pos() + delta; // Bounds check: don't consider moving out of grid! if (!in_bounds(targ)) return false; // No monster may enter the open sea. if (grd(targ) == DNGN_OPEN_SEA || grd(targ) == DNGN_LAVA_SEA) return false; // Non-friendly and non-good neutral monsters won't enter // sanctuaries. if (!mons->wont_attack() && is_sanctuary(targ) && !is_sanctuary(mons->pos())) { return false; } // Inside a sanctuary don't attack anything! if (is_sanctuary(mons->pos()) && actor_at(targ)) return false; const dungeon_feature_type target_grid = grd(targ); const habitat_type habitat = mons_primary_habitat(mons); // The kraken is so large it cannot enter shallow water. // Its tentacles can, and will, though. if (mons_base_type(mons) == MONS_KRAKEN && target_grid == DNGN_SHALLOW_WATER) { return false; } bool no_water = false; const int targ_cloud_num = env.cgrid(targ); if (mons_avoids_cloud(mons, targ_cloud_num)) return false; if (_check_slime_walls(mons, targ)) return false; const bool burrows = mons_class_flag(mons->type, M_BURROWS); const bool digs = _mons_can_cast_dig(mons, false) || _mons_can_zap_dig(mons); const bool flattens_trees = mons_flattens_trees(mons); if (((burrows || digs) && (target_grid == DNGN_ROCK_WALL || target_grid == DNGN_CLEAR_ROCK_WALL)) || (flattens_trees && feat_is_tree(target_grid))) { // Don't burrow out of bounds. if (!in_bounds(targ)) return false; } else if (no_water && feat_is_water(target_grid)) return false; else if (!mons_can_traverse(mons, targ, false) && !monster_habitable_grid(mons, target_grid)) { // If the monster somehow ended up in this habitat (and is // not dead by now), give it a chance to get out again. if (grd(mons->pos()) == target_grid && mons->ground_level() && _no_habitable_adjacent_grids(mons)) { return true; } return false; } // Wandering mushrooms usually don't move while you are looking. if (mons->type == MONS_WANDERING_MUSHROOM || mons->type == MONS_DEATHCAP || mons->type == MONS_CURSE_SKULL || (mons->type == MONS_LURKING_HORROR && mons->foe_distance() > random2(LOS_RADIUS + 1))) { if (!mons->wont_attack() && is_sanctuary(mons->pos())) { return true; } if (!mons->friendly() && you.see_cell(targ) || mon_enemies_around(mons)) { return false; } } // Fire elementals avoid water and cold. if (mons->type == MONS_FIRE_ELEMENTAL && feat_is_watery(target_grid)) return false; // Submerged water creatures avoid the shallows where // they would be forced to surface. -- bwr // [dshaligram] Monsters now prefer to head for deep water only if // they're low on hitpoints. No point in hiding if they want a // fight. if (habitat == HT_WATER && targ != you.pos() && target_grid != DNGN_DEEP_WATER && grd(mons->pos()) == DNGN_DEEP_WATER && mons->hit_points < (mons->max_hit_points * 3) / 4) { return false; } // Smacking the player is always a good move if we're // hostile (even if we're heading somewhere else). // Also friendlies want to keep close to the player // so it's okay as well. // Smacking another monster is good, if the monsters // are aligned differently. if (monster* targmonster = monster_at(targ)) { if (just_check) { if (targ == mons->pos()) return true; return false; // blocks square } if (!summon_can_attack(mons, targ)) return false; // Cut down plants only when no alternative, or they're // our target. if (mons_is_firewood(targmonster) && mons->target != targ) return false; if (mons_aligned(mons, targmonster) && !mons->has_ench(ENCH_INSANE) && !_mons_can_displace(mons, targmonster)) { // In Zotdef hostiles will whack other hostiles if immobile // - prevents plugging gaps with hostile oklobs if (crawl_state.game_is_zotdef()) { if (!targmonster->is_stationary() || targmonster->attitude != ATT_HOSTILE) { return false; } } else return false; } // Prefer to move past enemies instead of hit them, if we're retreating else if ((!mons_aligned(mons, targmonster) || mons->has_ench(ENCH_INSANE)) && mons->behaviour == BEH_WITHDRAW) { return false; } } // Friendlies shouldn't try to move onto the player's // location, if they are aiming for some other target. if (!_unfriendly_or_insane(mons) && mons->foe != MHITYOU && (mons->foe != MHITNOT || mons->is_patrolling()) && targ == you.pos()) { return false; } // Wandering through a trap is OK if we're pretty healthy, // really stupid, or immune to the trap. if (!_is_trap_safe(mons, targ, just_check)) return false; // If we end up here the monster can safely move. return true; } // Uses, and updates the global variable mmov. static void _find_good_alternate_move(monster* mons, const move_array& good_move) { const coord_def target = mons->firing_pos.zero() ? mons->target : mons->firing_pos; const int current_distance = distance2(mons->pos(), target); int dir = _compass_idx(mmov); // Only handle if the original move is to an adjacent square. if (dir == -1) return; int dist[2]; // First 1 away, then 2 (3 is silly). for (int j = 1; j <= 2; j++) { const int FAR_AWAY = 1000000; // Try both directions (but randomise which one is first). const int sdir = coinflip() ? j : -j; const int inc = -2 * sdir; for (int mod = sdir, i = 0; i < 2; mod += inc, i++) { const int newdir = (dir + 8 + mod) % 8; if (good_move[mon_compass[newdir].x+1][mon_compass[newdir].y+1]) dist[i] = distance2(mons->pos()+mon_compass[newdir], target); else dist[i] = mons_is_retreating(mons) ? (-FAR_AWAY) : FAR_AWAY; } const int dir0 = ((dir + 8 + sdir) % 8); const int dir1 = ((dir + 8 - sdir) % 8); // Now choose. if (dist[0] == dist[1] && abs(dist[0]) == FAR_AWAY) continue; // Which one was better? -- depends on FLEEING or not. if (mons_is_retreating(mons)) { if (dist[0] >= dist[1] && dist[0] >= current_distance) { mmov = mon_compass[dir0]; break; } if (dist[1] >= dist[0] && dist[1] >= current_distance) { mmov = mon_compass[dir1]; break; } } else { if (dist[0] <= dist[1] && dist[0] <= current_distance) { mmov = mon_compass[dir0]; break; } if (dist[1] <= dist[0] && dist[1] <= current_distance) { mmov = mon_compass[dir1]; break; } } } } static void _jelly_grows(monster* mons) { if (player_can_hear(mons->pos())) { mprf(MSGCH_SOUND, "You hear a%s slurping noise.", mons_near(mons) ? "" : " distant"); } mons->hit_points += 5; // possible with ridiculous farming on a full level mons->hit_points = min(mons->hit_points, MAX_MONSTER_HP); // note here, that this makes jellies "grow" {dlb}: if (mons->hit_points > mons->max_hit_points) mons->max_hit_points = mons->hit_points; _jelly_divide(mons); } static bool _monster_swaps_places(monster* mon, const coord_def& delta) { if (delta.origin()) return false; monster* const m2 = monster_at(mon->pos() + delta); if (!m2) return false; if (!_mons_can_displace(mon, m2)) return false; if (m2->asleep()) { if (coinflip()) { dprf("Alerting monster %s at (%d,%d)", m2->name(DESC_PLAIN).c_str(), m2->pos().x, m2->pos().y); behaviour_event(m2, ME_ALERT); } return false; } // Check that both monsters will be happy at their proposed new locations. const coord_def c = mon->pos(); const coord_def n = mon->pos() + delta; if (!monster_habitable_grid(mon, grd(n)) && !mon->can_cling_to(n) || !monster_habitable_grid(m2, grd(c)) && !m2->can_cling_to(c)) { return false; } // Okay, do the swap! #ifdef EUCLIDEAN _swim_or_move_energy(mon, delta.abs() == 2); #else _swim_or_move_energy(mon); #endif mon->set_position(n); mgrd(n) = mon->mindex(); m2->set_position(c); mon->clear_far_constrictions(); m2->clear_far_constrictions(); const int m2i = m2->mindex(); ASSERT_RANGE(m2i, 0, MAX_MONSTERS); mgrd(c) = m2i; _swim_or_move_energy(m2); mon->check_redraw(c, false); if (mon->is_wall_clinging()) mon->check_clinging(true); else mon->apply_location_effects(c); m2->check_redraw(n, false); if (m2->is_wall_clinging()) m2->check_clinging(true); else m2->apply_location_effects(n); // The seen context no longer applies if the monster is moving normally. mon->seen_context = SC_NONE; m2->seen_context = SC_NONE; return false; } static bool _do_move_monster(monster* mons, const coord_def& delta) { const coord_def f = mons->pos() + delta; if (!in_bounds(f)) return false; if (f == you.pos()) { fight_melee(mons, &you); return true; } // This includes the case where the monster attacks itself. if (monster* def = monster_at(f)) { fight_melee(mons, def); return true; } if (mons->is_constricted()) { if (mons->attempt_escape()) simple_monster_message(mons, " escapes!"); else { simple_monster_message(mons, " struggles to escape constriction."); _swim_or_move_energy(mons); return true; } } if (grd(f) == DNGN_CLOSED_DOOR || grd(f) == DNGN_SEALED_DOOR) { if (mons_can_open_door(mons, f)) { _mons_open_door(mons, f); return true; } else if (mons_can_eat_door(mons, f)) { grd(f) = DNGN_FLOOR; set_terrain_changed(f); _jelly_grows(mons); if (you.see_cell(f)) { viewwindow(); if (!you.can_see(mons)) { mpr("The door mysteriously vanishes."); interrupt_activity(AI_FORCE_INTERRUPT); } else simple_monster_message(mons, " eats the door!"); } } // done door-eating jellies } // The monster gave a "comes into view" message and then immediately // moved back out of view, leaing the player nothing to see, so give // this message to avoid confusion. if (mons->seen_context == SC_JUST_SEEN && !you.see_cell(f)) simple_monster_message(mons, " moves out of view."); else if (crawl_state.game_is_hints() && (mons->flags & MF_WAS_IN_VIEW) && !you.see_cell(f)) { learned_something_new(HINT_MONSTER_LEFT_LOS, mons->pos()); } // The seen context no longer applies if the monster is moving normally. mons->seen_context = SC_NONE; // This appears to be the real one, ie where the movement occurs: #ifdef EUCLIDEAN _swim_or_move_energy(mons, delta.abs() == 2); #else _swim_or_move_energy(mons); #endif _escape_water_hold(mons); if (grd(mons->pos()) == DNGN_DEEP_WATER && grd(f) != DNGN_DEEP_WATER && !monster_habitable_grid(mons, DNGN_DEEP_WATER)) { // er, what? Seems impossible. mons->seen_context = SC_NONSWIMMER_SURFACES_FROM_DEEP; } mgrd(mons->pos()) = NON_MONSTER; coord_def old_pos = mons->pos(); mons->set_position(f); mgrd(mons->pos()) = mons->mindex(); mons->check_clinging(true); ballisto_on_move(mons, old_pos); // Let go of all constrictees; only stop *being* constricted if we are now // too far away. mons->stop_constricting_all(true); mons->clear_far_constrictions(); mons->check_redraw(mons->pos() - delta); mons->apply_location_effects(mons->pos() - delta); return true; } // May mons attack targ if it's in its way, despite // possibly aligned attitudes? // The aim of this is to have monsters cut down plants // to get to the player if necessary. static bool _may_cutdown(monster* mons, monster* targ) { // Save friendly plants from allies. // [ds] I'm deliberately making the alignment checks symmetric here. // The previous check involved good-neutrals never attacking friendlies // and friendlies never attacking anything other than hostiles. if ((mons->friendly() || mons->good_neutral()) && (targ->friendly() || targ->good_neutral())) { return false; } // Outside of that case, can always cut mundane plants. if (mons_is_firewood(targ)) { // Don't try to attack briars unless their damage will be insignificant if (targ->type == MONS_BRIAR_PATCH && mons->type != MONS_THORN_HUNTER && (mons->armour_class() * mons->hit_points) < 400) return false; else return true; } // In normal games, that's it. Gotta keep those butterflies alive... if (!crawl_state.game_is_zotdef()) return false; return targ->is_stationary() || mons_class_flag(mons_base_type(targ), M_NO_EXP_GAIN) && !mons_is_tentacle_or_tentacle_segment(targ->type); } static bool _monster_move(monster* mons) { move_array good_move; const habitat_type habitat = mons_primary_habitat(mons); bool deep_water_available = false; if (mons->type == MONS_TRAPDOOR_SPIDER) { if (mons->submerged()) return false; // Trapdoor spiders sometime hide if they can't see their foe. // (Note that friendly trapdoor spiders will thus hide even // if they can see you.) const actor *foe = mons->get_foe(); const bool can_see = foe && mons->can_see(foe); if (monster_can_submerge(mons, grd(mons->pos())) && !can_see && !mons_is_confused(mons) && !mons->caught() && !mons->berserk_or_insane() && one_chance_in(5)) { mons->add_ench(ENCH_SUBMERGED); mons->behaviour = BEH_LURK; return false; } } // Berserking monsters make a lot of racket. if (mons->berserk_or_insane()) { int noise_level = get_shout_noise_level(mons_shouts(mons->type)); if (noise_level > 0) { if (you.can_see(mons) && mons->berserk()) { if (one_chance_in(10)) { mprf(MSGCH_TALK_VISUAL, "%s rages.", mons->name(DESC_THE).c_str()); } noisy(noise_level, mons->pos(), mons->mindex()); } else if (one_chance_in(5)) handle_monster_shouts(mons, true); else { // Just be noisy without messaging the player. noisy(noise_level, mons->pos(), mons->mindex()); } } } if (mons->confused()) { if (!mmov.origin() || one_chance_in(15)) { const coord_def newpos = mons->pos() + mmov; if (in_bounds(newpos) && (habitat == HT_LAND || monster_habitable_grid(mons, grd(newpos)))) { return _do_move_monster(mons, mmov); } } return false; } // If a water monster is currently flopping around on land, it cannot // really control where it wants to move, though there's a 50% chance // of flopping into an adjacent water grid. if (mons->has_ench(ENCH_AQUATIC_LAND)) { vector<coord_def> adj_water; vector<coord_def> adj_move; for (adjacent_iterator ai(mons->pos()); ai; ++ai) { if (!cell_is_solid(*ai)) { adj_move.push_back(*ai); if (feat_is_watery(grd(*ai))) adj_water.push_back(*ai); } } if (adj_move.empty()) { simple_monster_message(mons, " flops around on dry land!"); return false; } vector<coord_def> moves = adj_water; if (adj_water.empty() || coinflip()) moves = adj_move; coord_def newpos = mons->pos(); int count = 0; for (unsigned int i = 0; i < moves.size(); ++i) if (one_chance_in(++count)) newpos = moves[i]; const monster* mon2 = monster_at(newpos); if (!mons->has_ench(ENCH_INSANE) && (newpos == you.pos() && mons->wont_attack() || (mon2 && mons->wont_attack() == mon2->wont_attack()))) { simple_monster_message(mons, " flops around on dry land!"); return false; } return _do_move_monster(mons, newpos - mons->pos()); } // Let's not even bother with this if mmov is zero. if (mmov.origin()) return false; for (int count_x = 0; count_x < 3; count_x++) for (int count_y = 0; count_y < 3; count_y++) { const int targ_x = mons->pos().x + count_x - 1; const int targ_y = mons->pos().y + count_y - 1; // Bounds check: don't consider moving out of grid! if (!in_bounds(targ_x, targ_y)) { good_move[count_x][count_y] = false; continue; } dungeon_feature_type target_grid = grd[targ_x][targ_y]; if (target_grid == DNGN_DEEP_WATER) deep_water_available = true; good_move[count_x][count_y] = mon_can_move_to_pos(mons, coord_def(count_x-1, count_y-1)); } // Now we know where we _can_ move. const coord_def newpos = mons->pos() + mmov; // Water creatures have a preference for water they can hide in -- bwr // [ds] Weakened the powerful attraction to deep water if the monster // is in good health. if (habitat == HT_WATER && deep_water_available && grd(mons->pos()) != DNGN_DEEP_WATER && grd(newpos) != DNGN_DEEP_WATER && newpos != you.pos() && (one_chance_in(3) || mons->hit_points <= (mons->max_hit_points * 3) / 4)) { int count = 0; for (int cx = 0; cx < 3; cx++) for (int cy = 0; cy < 3; cy++) { if (good_move[cx][cy] && grd[mons->pos().x + cx - 1][mons->pos().y + cy - 1] == DNGN_DEEP_WATER) { if (one_chance_in(++count)) { mmov.x = cx - 1; mmov.y = cy - 1; } } } } // Now, if a monster can't move in its intended direction, try // either side. If they're both good, move in whichever dir // gets it closer (farther for fleeing monsters) to its target. // If neither does, do nothing. if (good_move[mmov.x + 1][mmov.y + 1] == false) _find_good_alternate_move(mons, good_move); // ------------------------------------------------------------------ // If we haven't found a good move by this point, we're not going to. // ------------------------------------------------------------------ if (mons->type == MONS_SPATIAL_MAELSTROM) { const dungeon_feature_type feat = grd(mons->pos() + mmov); if (!feat_is_permarock(feat) && feat_is_solid(feat)) { const coord_def target(mons->pos() + mmov); create_monster( mgen_data(MONS_SPATIAL_VORTEX, SAME_ATTITUDE(mons), mons, 2, MON_SUMM_ANIMATE, target, MHITNOT, 0, GOD_LUGONU)); nuke_wall(target); } } const bool burrows = mons_class_flag(mons->type, M_BURROWS); const bool flattens_trees = mons_flattens_trees(mons); const bool digs = _mons_can_cast_dig(mons, false) || _mons_can_zap_dig(mons); // Take care of beetle burrowing. if (burrows || flattens_trees || digs) { const dungeon_feature_type feat = grd(mons->pos() + mmov); if ((feat == DNGN_ROCK_WALL || feat == DNGN_CLEAR_ROCK_WALL) && !burrows && digs) { bolt beem; if (_mons_can_cast_dig(mons, true)) { setup_mons_cast(mons, beem, SPELL_DIG); beem.target = mons->pos() + mmov; mons_cast(mons, beem, SPELL_DIG, true, true); } else if (_mons_can_zap_dig(mons)) { ASSERT(mons->inv[MSLOT_WAND] != NON_ITEM); item_def &wand = mitm[mons->inv[MSLOT_WAND]]; beem.target = mons->pos() + mmov; _setup_wand_beam(beem, mons); _mons_fire_wand(mons, wand, beem, you.can_see(mons), false); } else simple_monster_message(mons, " falters for a moment."); mons->lose_energy(EUT_SPELL); return true; } else if ((((feat == DNGN_ROCK_WALL || feat == DNGN_CLEAR_ROCK_WALL) && burrows) || (flattens_trees && feat_is_tree(feat))) && good_move[mmov.x + 1][mmov.y + 1] == true) { const coord_def target(mons->pos() + mmov); nuke_wall(target); if (flattens_trees) { // Flattening trees has a movement cost to the monster // - 100% over and above its normal move cost. _swim_or_move_energy(mons); if (you.see_cell(target)) { const bool actor_visible = you.can_see(mons); mprf("%s knocks down a tree!", actor_visible? mons->name(DESC_THE).c_str() : "Something"); noisy(25, target); } else noisy(25, target, "You hear a crashing sound."); } else if (player_can_hear(mons->pos() + mmov)) { // Message depends on whether caused by boring beetle or // acid (Dissolution). mpr((mons->type == MONS_BORING_BEETLE) ? "You hear a grinding noise." : "You hear a sizzling sound.", MSGCH_SOUND); } } } bool ret = false; if (good_move[mmov.x + 1][mmov.y + 1] && !mmov.origin()) { // Check for attacking player. if (mons->pos() + mmov == you.pos()) { ret = fight_melee(mons, &you); mmov.reset(); } // If we're following the player through stairs, the only valid // movement is towards the player. -- bwr if (testbits(mons->flags, MF_TAKING_STAIRS)) { const delay_type delay = current_delay_action(); if (delay != DELAY_ASCENDING_STAIRS && delay != DELAY_DESCENDING_STAIRS) { mons->flags &= ~MF_TAKING_STAIRS; dprf("BUG: %s was marked as follower when not following!", mons->name(DESC_PLAIN).c_str()); } else { ret = true; mmov.reset(); dprf("%s is skipping movement in order to follow.", mons->name(DESC_THE).c_str()); } } // Check for attacking another monster. if (monster* targ = monster_at(mons->pos() + mmov)) { if (mons_aligned(mons, targ) && !mons->has_ench(ENCH_INSANE) && (!crawl_state.game_is_zotdef() || !_may_cutdown(mons, targ))) { // Zotdef: monsters will cut down firewood ret = _monster_swaps_places(mons, mmov); } else { fight_melee(mons, targ); ret = true; } // If the monster swapped places, the work's already done. mmov.reset(); } // The monster could die after a melee attack due to a mummy // death curse or something. if (!mons->alive()) return true; if (mons_genus(mons->type) == MONS_EFREET || mons->type == MONS_FIRE_ELEMENTAL) { place_cloud(CLOUD_FIRE, mons->pos(), 2 + random2(4), mons); } if (mons->type == MONS_ROTTING_DEVIL || mons->type == MONS_CURSE_TOE) place_cloud(CLOUD_MIASMA, mons->pos(), 2 + random2(3), mons); } else { monster* targ = monster_at(mons->pos() + mmov); if (!mmov.origin() && targ && _may_cutdown(mons, targ)) { fight_melee(mons, targ); ret = true; } mmov.reset(); // zotdef: sometimes seem to get gridlock. Reset travel path // if we can't move, occasionally if (crawl_state.game_is_zotdef() && one_chance_in(20)) { mons->travel_path.clear(); mons->travel_target = MTRAV_NONE; } // Fleeing monsters that can't move will panic and possibly // turn to face their attacker. make_mons_stop_fleeing(mons); } if (mmov.x || mmov.y || (mons->confused() && one_chance_in(6))) return _do_move_monster(mons, mmov); // Battlespheres need to preserve their tracking targets after each move if (mons_is_wandering(mons) && mons->type != MONS_BATTLESPHERE) { // trigger a re-evaluation of our wander target on our next move -cao mons->target = mons->pos(); if (!mons->is_patrolling()) { mons->travel_target = MTRAV_NONE; mons->travel_path.clear(); } mons->firing_pos.reset(); } return ret; } static void _mons_in_cloud(monster* mons) { // Submerging in water or lava saves from clouds. if (mons->submerged() && env.grid(mons->pos()) != DNGN_FLOOR) return; actor_apply_cloud(mons); } static void _heated_area(monster* mons) { if (!heated(mons->pos())) return; if (mons->is_fiery()) return; // HACK: Currently this prevents even auras not caused by lava orcs... if (you_worship(GOD_BEOGH) && mons->friendly() && mons->god == GOD_BEOGH) return; const int base_damage = random2(11); // Timescale, like with clouds: const int speed = mons->speed > 0 ? mons->speed : 10; const int timescaled = max(0, base_damage) * 10 / speed; // rF protects: const int resist = mons->res_fire(); const int adjusted_damage = resist_adjust_damage(mons, BEAM_FIRE, resist, timescaled, true); // So does AC: const int final_damage = max(0, adjusted_damage - random2(mons->armour_class())); if (final_damage > 0) { if (mons->observable()) mprf("%s is %s by your radiant heat.", mons->name(DESC_THE).c_str(), (final_damage) > 10 ? "blasted" : "burned"); behaviour_event(mons, ME_DISTURB, 0, mons->pos()); #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "%s %s %d damage from heat.", mons->name(DESC_THE).c_str(), mons->conj_verb("take").c_str(), final_damage); #endif mons->hurt(&you, final_damage, BEAM_MISSILE); if (mons->alive() && mons->observable()) print_wounds(mons); } } static spell_type _map_wand_to_mspell(wand_type kind) { switch (kind) { case WAND_FLAME: return SPELL_THROW_FLAME; case WAND_FROST: return SPELL_THROW_FROST; case WAND_SLOWING: return SPELL_SLOW; case WAND_HASTING: return SPELL_HASTE; case WAND_MAGIC_DARTS: return SPELL_MAGIC_DART; case WAND_HEAL_WOUNDS: return SPELL_MINOR_HEALING; case WAND_PARALYSIS: return SPELL_PARALYSE; case WAND_FIRE: return SPELL_BOLT_OF_FIRE; case WAND_COLD: return SPELL_BOLT_OF_COLD; case WAND_CONFUSION: return SPELL_CONFUSE; case WAND_INVISIBILITY: return SPELL_INVISIBILITY; case WAND_TELEPORTATION: return SPELL_TELEPORT_OTHER; case WAND_LIGHTNING: return SPELL_LIGHTNING_BOLT; case WAND_DRAINING: return SPELL_BOLT_OF_DRAINING; case WAND_DISINTEGRATION: return SPELL_DISINTEGRATE; case WAND_POLYMORPH: return SPELL_POLYMORPH; case WAND_DIGGING: return SPELL_DIG; default: return SPELL_NO_SPELL; } } // Keep kraken tentacles from wandering too far away from the boss monster. static void _shedu_movement_clamp(monster *shedu) { if (!mons_is_shedu(shedu)) return; monster *my_pair = get_shedu_pair(shedu); if (!my_pair) return; if (grid_distance(shedu->pos(), my_pair->pos()) >= 10) mmov = (my_pair->pos() - shedu->pos()).sgn(); }
xFleury/crawl-0.13.0-fairplay
source/mon-act.cc
C++
gpl-2.0
126,596
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>SyntheticEvent - YUI 3</title> <link rel="stylesheet" href="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.7.0&#x2F;build&#x2F;cssgrids&#x2F;cssgrids-min.css"> <link rel="stylesheet" href="..&#x2F;assets/vendor/prettify/prettify-min.css"> <link rel="stylesheet" href="..&#x2F;assets/css/main.css" id="site_styles"> <link rel="shortcut icon" type="image/png" href="..&#x2F;assets/favicon.png"> <script src="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;combo?3.7.0&#x2F;build&#x2F;yui&#x2F;yui-min.js"></script> </head> <body class="yui3-skin-sam"> <div id="doc"> <div id="hd" class="yui3-g header"> <div class="yui3-u-3-4"> <h1><img src="..&#x2F;assets/css/logo.png" title="YUI 3"></h1> </div> <div class="yui3-u-1-4 version"> <em>API Docs for: 3.7.3</em> </div> </div> <div id="bd" class="yui3-g"> <div class="yui3-u-1-4"> <div id="docs-sidebar" class="sidebar apidocs"> <div id="api-list"> <h2 class="off-left">APIs</h2> <div id="api-tabview" class="tabview"> <ul class="tabs"> <li><a href="#api-classes">Classes</a></li> <li><a href="#api-modules">Modules</a></li> </ul> <div id="api-tabview-filter"> <input type="search" id="api-filter" placeholder="Type to filter APIs"> </div> <div id="api-tabview-panel"> <ul id="api-classes" class="apis classes"> <li><a href="..&#x2F;classes/Anim.html">Anim</a></li> <li><a href="..&#x2F;classes/App.html">App</a></li> <li><a href="..&#x2F;classes/App.Base.html">App.Base</a></li> <li><a href="..&#x2F;classes/App.Content.html">App.Content</a></li> <li><a href="..&#x2F;classes/App.Transitions.html">App.Transitions</a></li> <li><a href="..&#x2F;classes/App.TransitionsNative.html">App.TransitionsNative</a></li> <li><a href="..&#x2F;classes/AreaSeries.html">AreaSeries</a></li> <li><a href="..&#x2F;classes/AreaSplineSeries.html">AreaSplineSeries</a></li> <li><a href="..&#x2F;classes/Array.html">Array</a></li> <li><a href="..&#x2F;classes/ArrayList.html">ArrayList</a></li> <li><a href="..&#x2F;classes/ArraySort.html">ArraySort</a></li> <li><a href="..&#x2F;classes/AsyncQueue.html">AsyncQueue</a></li> <li><a href="..&#x2F;classes/Attribute.html">Attribute</a></li> <li><a href="..&#x2F;classes/AttributeCore.html">AttributeCore</a></li> <li><a href="..&#x2F;classes/AttributeEvents.html">AttributeEvents</a></li> <li><a href="..&#x2F;classes/AttributeExtras.html">AttributeExtras</a></li> <li><a href="..&#x2F;classes/AttributeLite.html">AttributeLite</a></li> <li><a href="..&#x2F;classes/AutoComplete.html">AutoComplete</a></li> <li><a href="..&#x2F;classes/AutoCompleteBase.html">AutoCompleteBase</a></li> <li><a href="..&#x2F;classes/AutoCompleteFilters.html">AutoCompleteFilters</a></li> <li><a href="..&#x2F;classes/AutoCompleteHighlighters.html">AutoCompleteHighlighters</a></li> <li><a href="..&#x2F;classes/AutoCompleteList.html">AutoCompleteList</a></li> <li><a href="..&#x2F;classes/Axis.html">Axis</a></li> <li><a href="..&#x2F;classes/AxisType.html">AxisType</a></li> <li><a href="..&#x2F;classes/BarSeries.html">BarSeries</a></li> <li><a href="..&#x2F;classes/Base.html">Base</a></li> <li><a href="..&#x2F;classes/BaseCore.html">BaseCore</a></li> <li><a href="..&#x2F;classes/BottomAxisLayout.html">BottomAxisLayout</a></li> <li><a href="..&#x2F;classes/Button.html">Button</a></li> <li><a href="..&#x2F;classes/ButtonCore.html">ButtonCore</a></li> <li><a href="..&#x2F;classes/ButtonGroup.html">ButtonGroup</a></li> <li><a href="..&#x2F;classes/ButtonPlugin.html">ButtonPlugin</a></li> <li><a href="..&#x2F;classes/Cache.html">Cache</a></li> <li><a href="..&#x2F;classes/CacheOffline.html">CacheOffline</a></li> <li><a href="..&#x2F;classes/Calendar.html">Calendar</a></li> <li><a href="..&#x2F;classes/CalendarBase.html">CalendarBase</a></li> <li><a href="..&#x2F;classes/CanvasCircle.html">CanvasCircle</a></li> <li><a href="..&#x2F;classes/CanvasDrawing.html">CanvasDrawing</a></li> <li><a href="..&#x2F;classes/CanvasEllipse.html">CanvasEllipse</a></li> <li><a href="..&#x2F;classes/CanvasGraphic.html">CanvasGraphic</a></li> <li><a href="..&#x2F;classes/CanvasPath.html">CanvasPath</a></li> <li><a href="..&#x2F;classes/CanvasPieSlice.html">CanvasPieSlice</a></li> <li><a href="..&#x2F;classes/CanvasRect.html">CanvasRect</a></li> <li><a href="..&#x2F;classes/CanvasShape.html">CanvasShape</a></li> <li><a href="..&#x2F;classes/CartesianChart.html">CartesianChart</a></li> <li><a href="..&#x2F;classes/CartesianSeries.html">CartesianSeries</a></li> <li><a href="..&#x2F;classes/CategoryAxis.html">CategoryAxis</a></li> <li><a href="..&#x2F;classes/Chart.html">Chart</a></li> <li><a href="..&#x2F;classes/ChartBase.html">ChartBase</a></li> <li><a href="..&#x2F;classes/ChartLegend.html">ChartLegend</a></li> <li><a href="..&#x2F;classes/Circle.html">Circle</a></li> <li><a href="..&#x2F;classes/CircleGroup.html">CircleGroup</a></li> <li><a href="..&#x2F;classes/ClassNameManager.html">ClassNameManager</a></li> <li><a href="..&#x2F;classes/ClickableRail.html">ClickableRail</a></li> <li><a href="..&#x2F;classes/ColumnSeries.html">ColumnSeries</a></li> <li><a href="..&#x2F;classes/ComboSeries.html">ComboSeries</a></li> <li><a href="..&#x2F;classes/ComboSplineSeries.html">ComboSplineSeries</a></li> <li><a href="..&#x2F;classes/config.html">config</a></li> <li><a href="..&#x2F;classes/Console.html">Console</a></li> <li><a href="..&#x2F;classes/Controller.html">Controller</a></li> <li><a href="..&#x2F;classes/Cookie.html">Cookie</a></li> <li><a href="..&#x2F;classes/CurveUtil.html">CurveUtil</a></li> <li><a href="..&#x2F;classes/CustomEvent.html">CustomEvent</a></li> <li><a href="..&#x2F;classes/DataSchema.Array.html">DataSchema.Array</a></li> <li><a href="..&#x2F;classes/DataSchema.Base.html">DataSchema.Base</a></li> <li><a href="..&#x2F;classes/DataSchema.JSON.html">DataSchema.JSON</a></li> <li><a href="..&#x2F;classes/DataSchema.Text.html">DataSchema.Text</a></li> <li><a href="..&#x2F;classes/DataSchema.XML.html">DataSchema.XML</a></li> <li><a href="..&#x2F;classes/DataSource.Function.html">DataSource.Function</a></li> <li><a href="..&#x2F;classes/DataSource.Get.html">DataSource.Get</a></li> <li><a href="..&#x2F;classes/DataSource.IO.html">DataSource.IO</a></li> <li><a href="..&#x2F;classes/DataSource.Local.html">DataSource.Local</a></li> <li><a href="..&#x2F;classes/DataSourceArraySchema.html">DataSourceArraySchema</a></li> <li><a href="..&#x2F;classes/DataSourceCache.html">DataSourceCache</a></li> <li><a href="..&#x2F;classes/DataSourceCacheExtension.html">DataSourceCacheExtension</a></li> <li><a href="..&#x2F;classes/DataSourceJSONSchema.html">DataSourceJSONSchema</a></li> <li><a href="..&#x2F;classes/DataSourceTextSchema.html">DataSourceTextSchema</a></li> <li><a href="..&#x2F;classes/DataSourceXMLSchema.html">DataSourceXMLSchema</a></li> <li><a href="..&#x2F;classes/DataTable.html">DataTable</a></li> <li><a href="..&#x2F;classes/DataTable.Base.html">DataTable.Base</a></li> <li><a href="..&#x2F;classes/DataTable.BodyView.html">DataTable.BodyView</a></li> <li><a href="..&#x2F;classes/DataTable.ColumnWidths.html">DataTable.ColumnWidths</a></li> <li><a href="..&#x2F;classes/DataTable.Core.html">DataTable.Core</a></li> <li><a href="..&#x2F;classes/DataTable.HeaderView.html">DataTable.HeaderView</a></li> <li><a href="..&#x2F;classes/DataTable.Message.html">DataTable.Message</a></li> <li><a href="..&#x2F;classes/DataTable.Mutable.html">DataTable.Mutable</a></li> <li><a href="..&#x2F;classes/DataTable.Scrollable.html">DataTable.Scrollable</a></li> <li><a href="..&#x2F;classes/DataTable.Sortable.html">DataTable.Sortable</a></li> <li><a href="..&#x2F;classes/DataTable.TableView.html">DataTable.TableView</a></li> <li><a href="..&#x2F;classes/Date.html">Date</a></li> <li><a href="..&#x2F;classes/DD.DDM.html">DD.DDM</a></li> <li><a href="..&#x2F;classes/DD.Delegate.html">DD.Delegate</a></li> <li><a href="..&#x2F;classes/DD.Drag.html">DD.Drag</a></li> <li><a href="..&#x2F;classes/DD.Drop.html">DD.Drop</a></li> <li><a href="..&#x2F;classes/DD.Scroll.html">DD.Scroll</a></li> <li><a href="..&#x2F;classes/Dial.html">Dial</a></li> <li><a href="..&#x2F;classes/Do.html">Do</a></li> <li><a href="..&#x2F;classes/Do.AlterArgs.html">Do.AlterArgs</a></li> <li><a href="..&#x2F;classes/Do.AlterReturn.html">Do.AlterReturn</a></li> <li><a href="..&#x2F;classes/Do.Error.html">Do.Error</a></li> <li><a href="..&#x2F;classes/Do.Halt.html">Do.Halt</a></li> <li><a href="..&#x2F;classes/Do.Method.html">Do.Method</a></li> <li><a href="..&#x2F;classes/Do.Prevent.html">Do.Prevent</a></li> <li><a href="..&#x2F;classes/DOM.html">DOM</a></li> <li><a href="..&#x2F;classes/DOMEventFacade.html">DOMEventFacade</a></li> <li><a href="..&#x2F;classes/Drawing.html">Drawing</a></li> <li><a href="..&#x2F;classes/Easing.html">Easing</a></li> <li><a href="..&#x2F;classes/EditorBase.html">EditorBase</a></li> <li><a href="..&#x2F;classes/EditorSelection.html">EditorSelection</a></li> <li><a href="..&#x2F;classes/Ellipse.html">Ellipse</a></li> <li><a href="..&#x2F;classes/EllipseGroup.html">EllipseGroup</a></li> <li><a href="..&#x2F;classes/Escape.html">Escape</a></li> <li><a href="..&#x2F;classes/Event.html">Event</a></li> <li><a href="..&#x2F;classes/EventFacade.html">EventFacade</a></li> <li><a href="..&#x2F;classes/EventHandle.html">EventHandle</a></li> <li><a href="..&#x2F;classes/EventTarget.html">EventTarget</a></li> <li><a href="..&#x2F;classes/ExecCommand.html">ExecCommand</a></li> <li><a href="..&#x2F;classes/Features.html">Features</a></li> <li><a href="..&#x2F;classes/File.html">File</a></li> <li><a href="..&#x2F;classes/FileFlash.html">FileFlash</a></li> <li><a href="..&#x2F;classes/FileHTML5.html">FileHTML5</a></li> <li><a href="..&#x2F;classes/Fills.html">Fills</a></li> <li><a href="..&#x2F;classes/Frame.html">Frame</a></li> <li><a href="..&#x2F;classes/Get.html">Get</a></li> <li><a href="..&#x2F;classes/Get.Transaction.html">Get.Transaction</a></li> <li><a href="..&#x2F;classes/GetNodeJS.html">GetNodeJS</a></li> <li><a href="..&#x2F;classes/Graph.html">Graph</a></li> <li><a href="..&#x2F;classes/Graphic.html">Graphic</a></li> <li><a href="..&#x2F;classes/GraphicBase.html">GraphicBase</a></li> <li><a href="..&#x2F;classes/Gridlines.html">Gridlines</a></li> <li><a href="..&#x2F;classes/GroupDiamond.html">GroupDiamond</a></li> <li><a href="..&#x2F;classes/GroupRect.html">GroupRect</a></li> <li><a href="..&#x2F;classes/Handlebars.html">Handlebars</a></li> <li><a href="..&#x2F;classes/Highlight.html">Highlight</a></li> <li><a href="..&#x2F;classes/Histogram.html">Histogram</a></li> <li><a href="..&#x2F;classes/HistoryBase.html">HistoryBase</a></li> <li><a href="..&#x2F;classes/HistoryHash.html">HistoryHash</a></li> <li><a href="..&#x2F;classes/HistoryHTML5.html">HistoryHTML5</a></li> <li><a href="..&#x2F;classes/HorizontalLegendLayout.html">HorizontalLegendLayout</a></li> <li><a href="..&#x2F;classes/ImgLoadGroup.html">ImgLoadGroup</a></li> <li><a href="..&#x2F;classes/ImgLoadImgObj.html">ImgLoadImgObj</a></li> <li><a href="..&#x2F;classes/Intl.html">Intl</a></li> <li><a href="..&#x2F;classes/IO.html">IO</a></li> <li><a href="..&#x2F;classes/JSON.html">JSON</a></li> <li><a href="..&#x2F;classes/JSONPRequest.html">JSONPRequest</a></li> <li><a href="..&#x2F;classes/Lang.html">Lang</a></li> <li><a href="..&#x2F;classes/LazyModelList.html">LazyModelList</a></li> <li><a href="..&#x2F;classes/LeftAxisLayout.html">LeftAxisLayout</a></li> <li><a href="..&#x2F;classes/Lines.html">Lines</a></li> <li><a href="..&#x2F;classes/LineSeries.html">LineSeries</a></li> <li><a href="..&#x2F;classes/Loader.html">Loader</a></li> <li><a href="..&#x2F;classes/MarkerSeries.html">MarkerSeries</a></li> <li><a href="..&#x2F;classes/Matrix.html">Matrix</a></li> <li><a href="..&#x2F;classes/MatrixUtil.html">MatrixUtil</a></li> <li><a href="..&#x2F;classes/Model.html">Model</a></li> <li><a href="..&#x2F;classes/ModelList.html">ModelList</a></li> <li><a href="..&#x2F;classes/ModelSync.REST.html">ModelSync.REST</a></li> <li><a href="..&#x2F;classes/Node.html">Node</a></li> <li><a href="..&#x2F;classes/NodeList.html">NodeList</a></li> <li><a href="..&#x2F;classes/Number.html">Number</a></li> <li><a href="..&#x2F;classes/NumericAxis.html">NumericAxis</a></li> <li><a href="..&#x2F;classes/Object.html">Object</a></li> <li><a href="..&#x2F;classes/Overlay.html">Overlay</a></li> <li><a href="..&#x2F;classes/Panel.html">Panel</a></li> <li><a href="..&#x2F;classes/Parallel.html">Parallel</a></li> <li><a href="..&#x2F;classes/Path.html">Path</a></li> <li><a href="..&#x2F;classes/PieChart.html">PieChart</a></li> <li><a href="..&#x2F;classes/PieSeries.html">PieSeries</a></li> <li><a href="..&#x2F;classes/Pjax.html">Pjax</a></li> <li><a href="..&#x2F;classes/PjaxBase.html">PjaxBase</a></li> <li><a href="..&#x2F;classes/PjaxContent.html">PjaxContent</a></li> <li><a href="..&#x2F;classes/Plots.html">Plots</a></li> <li><a href="..&#x2F;classes/Plugin.Align.html">Plugin.Align</a></li> <li><a href="..&#x2F;classes/Plugin.AutoComplete.html">Plugin.AutoComplete</a></li> <li><a href="..&#x2F;classes/Plugin.Base.html">Plugin.Base</a></li> <li><a href="..&#x2F;classes/Plugin.Cache.html">Plugin.Cache</a></li> <li><a href="..&#x2F;classes/Plugin.CalendarNavigator.html">Plugin.CalendarNavigator</a></li> <li><a href="..&#x2F;classes/Plugin.ConsoleFilters.html">Plugin.ConsoleFilters</a></li> <li><a href="..&#x2F;classes/Plugin.CreateLinkBase.html">Plugin.CreateLinkBase</a></li> <li><a href="..&#x2F;classes/Plugin.DataTableDataSource.html">Plugin.DataTableDataSource</a></li> <li><a href="..&#x2F;classes/Plugin.DDConstrained.html">Plugin.DDConstrained</a></li> <li><a href="..&#x2F;classes/Plugin.DDNodeScroll.html">Plugin.DDNodeScroll</a></li> <li><a href="..&#x2F;classes/Plugin.DDProxy.html">Plugin.DDProxy</a></li> <li><a href="..&#x2F;classes/Plugin.DDWindowScroll.html">Plugin.DDWindowScroll</a></li> <li><a href="..&#x2F;classes/Plugin.Drag.html">Plugin.Drag</a></li> <li><a href="..&#x2F;classes/Plugin.Drop.html">Plugin.Drop</a></li> <li><a href="..&#x2F;classes/Plugin.EditorBidi.html">Plugin.EditorBidi</a></li> <li><a href="..&#x2F;classes/Plugin.EditorBR.html">Plugin.EditorBR</a></li> <li><a href="..&#x2F;classes/Plugin.EditorLists.html">Plugin.EditorLists</a></li> <li><a href="..&#x2F;classes/Plugin.EditorPara.html">Plugin.EditorPara</a></li> <li><a href="..&#x2F;classes/Plugin.EditorParaBase.html">Plugin.EditorParaBase</a></li> <li><a href="..&#x2F;classes/Plugin.EditorParaIE.html">Plugin.EditorParaIE</a></li> <li><a href="..&#x2F;classes/Plugin.EditorTab.html">Plugin.EditorTab</a></li> <li><a href="..&#x2F;classes/Plugin.ExecCommand.html">Plugin.ExecCommand</a></li> <li><a href="..&#x2F;classes/Plugin.Flick.html">Plugin.Flick</a></li> <li><a href="..&#x2F;classes/Plugin.Host.html">Plugin.Host</a></li> <li><a href="..&#x2F;classes/plugin.NodeFocusManager.html">plugin.NodeFocusManager</a></li> <li><a href="..&#x2F;classes/Plugin.NodeFX.html">Plugin.NodeFX</a></li> <li><a href="..&#x2F;classes/plugin.NodeMenuNav.html">plugin.NodeMenuNav</a></li> <li><a href="..&#x2F;classes/Plugin.Pjax.html">Plugin.Pjax</a></li> <li><a href="..&#x2F;classes/Plugin.Resize.html">Plugin.Resize</a></li> <li><a href="..&#x2F;classes/Plugin.ResizeConstrained.html">Plugin.ResizeConstrained</a></li> <li><a href="..&#x2F;classes/Plugin.ResizeProxy.html">Plugin.ResizeProxy</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollInfo.html">Plugin.ScrollInfo</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewList.html">Plugin.ScrollViewList</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewPaginator.html">Plugin.ScrollViewPaginator</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewScrollbars.html">Plugin.ScrollViewScrollbars</a></li> <li><a href="..&#x2F;classes/Plugin.Shim.html">Plugin.Shim</a></li> <li><a href="..&#x2F;classes/Plugin.SortScroll.html">Plugin.SortScroll</a></li> <li><a href="..&#x2F;classes/Plugin.WidgetAnim.html">Plugin.WidgetAnim</a></li> <li><a href="..&#x2F;classes/Pollable.html">Pollable</a></li> <li><a href="..&#x2F;classes/Profiler.html">Profiler</a></li> <li><a href="..&#x2F;classes/QueryString.html">QueryString</a></li> <li><a href="..&#x2F;classes/Queue.html">Queue</a></li> <li><a href="..&#x2F;classes/Record.html">Record</a></li> <li><a href="..&#x2F;classes/Recordset.html">Recordset</a></li> <li><a href="..&#x2F;classes/RecordsetFilter.html">RecordsetFilter</a></li> <li><a href="..&#x2F;classes/RecordsetIndexer.html">RecordsetIndexer</a></li> <li><a href="..&#x2F;classes/RecordsetSort.html">RecordsetSort</a></li> <li><a href="..&#x2F;classes/Rect.html">Rect</a></li> <li><a href="..&#x2F;classes/Renderer.html">Renderer</a></li> <li><a href="..&#x2F;classes/Resize.html">Resize</a></li> <li><a href="..&#x2F;classes/RightAxisLayout.html">RightAxisLayout</a></li> <li><a href="..&#x2F;classes/Router.html">Router</a></li> <li><a href="..&#x2F;classes/ScrollView.html">ScrollView</a></li> <li><a href="..&#x2F;classes/Selector.html">Selector</a></li> <li><a href="..&#x2F;classes/Shape.html">Shape</a></li> <li><a href="..&#x2F;classes/ShapeGroup.html">ShapeGroup</a></li> <li><a href="..&#x2F;classes/Slider.html">Slider</a></li> <li><a href="..&#x2F;classes/SliderBase.html">SliderBase</a></li> <li><a href="..&#x2F;classes/SliderValueRange.html">SliderValueRange</a></li> <li><a href="..&#x2F;classes/Sortable.html">Sortable</a></li> <li><a href="..&#x2F;classes/SplineSeries.html">SplineSeries</a></li> <li><a href="..&#x2F;classes/StackedAreaSeries.html">StackedAreaSeries</a></li> <li><a href="..&#x2F;classes/StackedAreaSplineSeries.html">StackedAreaSplineSeries</a></li> <li><a href="..&#x2F;classes/StackedAxis.html">StackedAxis</a></li> <li><a href="..&#x2F;classes/StackedBarSeries.html">StackedBarSeries</a></li> <li><a href="..&#x2F;classes/StackedColumnSeries.html">StackedColumnSeries</a></li> <li><a href="..&#x2F;classes/StackedComboSeries.html">StackedComboSeries</a></li> <li><a href="..&#x2F;classes/StackedComboSplineSeries.html">StackedComboSplineSeries</a></li> <li><a href="..&#x2F;classes/StackedLineSeries.html">StackedLineSeries</a></li> <li><a href="..&#x2F;classes/StackedMarkerSeries.html">StackedMarkerSeries</a></li> <li><a href="..&#x2F;classes/StackedSplineSeries.html">StackedSplineSeries</a></li> <li><a href="..&#x2F;classes/StackingUtil.html">StackingUtil</a></li> <li><a href="..&#x2F;classes/State.html">State</a></li> <li><a href="..&#x2F;classes/StyleSheet.html">StyleSheet</a></li> <li><a href="..&#x2F;classes/Subscriber.html">Subscriber</a></li> <li><a href="..&#x2F;classes/SVGCircle.html">SVGCircle</a></li> <li><a href="..&#x2F;classes/SVGDrawing.html">SVGDrawing</a></li> <li><a href="..&#x2F;classes/SVGEllipse.html">SVGEllipse</a></li> <li><a href="..&#x2F;classes/SVGGraphic.html">SVGGraphic</a></li> <li><a href="..&#x2F;classes/SVGPath.html">SVGPath</a></li> <li><a href="..&#x2F;classes/SVGPieSlice.html">SVGPieSlice</a></li> <li><a href="..&#x2F;classes/SVGRect.html">SVGRect</a></li> <li><a href="..&#x2F;classes/SVGShape.html">SVGShape</a></li> <li><a href="..&#x2F;classes/SWF.html">SWF</a></li> <li><a href="..&#x2F;classes/SWFDetect.html">SWFDetect</a></li> <li><a href="..&#x2F;classes/SyntheticEvent.html">SyntheticEvent</a></li> <li><a href="..&#x2F;classes/SyntheticEvent.Notifier.html">SyntheticEvent.Notifier</a></li> <li><a href="..&#x2F;classes/SynthRegistry.html">SynthRegistry</a></li> <li><a href="..&#x2F;classes/Tab.html">Tab</a></li> <li><a href="..&#x2F;classes/TabView.html">TabView</a></li> <li><a href="..&#x2F;classes/Test.ArrayAssert.html">Test.ArrayAssert</a></li> <li><a href="..&#x2F;classes/Test.Assert.html">Test.Assert</a></li> <li><a href="..&#x2F;classes/Test.AssertionError.html">Test.AssertionError</a></li> <li><a href="..&#x2F;classes/Test.ComparisonFailure.html">Test.ComparisonFailure</a></li> <li><a href="..&#x2F;classes/Test.Console.html">Test.Console</a></li> <li><a href="..&#x2F;classes/Test.CoverageFormat.html">Test.CoverageFormat</a></li> <li><a href="..&#x2F;classes/Test.DateAssert.html">Test.DateAssert</a></li> <li><a href="..&#x2F;classes/Test.EventTarget.html">Test.EventTarget</a></li> <li><a href="..&#x2F;classes/Test.Mock.html">Test.Mock</a></li> <li><a href="..&#x2F;classes/Test.Mock.Value.html">Test.Mock.Value</a></li> <li><a href="..&#x2F;classes/Test.ObjectAssert.html">Test.ObjectAssert</a></li> <li><a href="..&#x2F;classes/Test.Reporter.html">Test.Reporter</a></li> <li><a href="..&#x2F;classes/Test.Results.html">Test.Results</a></li> <li><a href="..&#x2F;classes/Test.Runner.html">Test.Runner</a></li> <li><a href="..&#x2F;classes/Test.ShouldError.html">Test.ShouldError</a></li> <li><a href="..&#x2F;classes/Test.ShouldFail.html">Test.ShouldFail</a></li> <li><a href="..&#x2F;classes/Test.TestCase.html">Test.TestCase</a></li> <li><a href="..&#x2F;classes/Test.TestFormat.html">Test.TestFormat</a></li> <li><a href="..&#x2F;classes/Test.TestNode.html">Test.TestNode</a></li> <li><a href="..&#x2F;classes/Test.TestRunner.html">Test.TestRunner</a></li> <li><a href="..&#x2F;classes/Test.TestSuite.html">Test.TestSuite</a></li> <li><a href="..&#x2F;classes/Test.UnexpectedError.html">Test.UnexpectedError</a></li> <li><a href="..&#x2F;classes/Test.UnexpectedValue.html">Test.UnexpectedValue</a></li> <li><a href="..&#x2F;classes/Test.Wait.html">Test.Wait</a></li> <li><a href="..&#x2F;classes/Text.AccentFold.html">Text.AccentFold</a></li> <li><a href="..&#x2F;classes/Text.WordBreak.html">Text.WordBreak</a></li> <li><a href="..&#x2F;classes/TimeAxis.html">TimeAxis</a></li> <li><a href="..&#x2F;classes/ToggleButton.html">ToggleButton</a></li> <li><a href="..&#x2F;classes/TopAxisLayout.html">TopAxisLayout</a></li> <li><a href="..&#x2F;classes/Transition.html">Transition</a></li> <li><a href="..&#x2F;classes/UA.html">UA</a></li> <li><a href="..&#x2F;classes/Uploader.html">Uploader</a></li> <li><a href="..&#x2F;classes/Uploader.Queue.html">Uploader.Queue</a></li> <li><a href="..&#x2F;classes/UploaderFlash.html">UploaderFlash</a></li> <li><a href="..&#x2F;classes/UploaderHTML5.html">UploaderHTML5</a></li> <li><a href="..&#x2F;classes/ValueChange.html">ValueChange</a></li> <li><a href="..&#x2F;classes/VerticalLegendLayout.html">VerticalLegendLayout</a></li> <li><a href="..&#x2F;classes/View.html">View</a></li> <li><a href="..&#x2F;classes/View.NodeMap.html">View.NodeMap</a></li> <li><a href="..&#x2F;classes/VMLCircle.html">VMLCircle</a></li> <li><a href="..&#x2F;classes/VMLDrawing.html">VMLDrawing</a></li> <li><a href="..&#x2F;classes/VMLEllipse.html">VMLEllipse</a></li> <li><a href="..&#x2F;classes/VMLGraphic.html">VMLGraphic</a></li> <li><a href="..&#x2F;classes/VMLPath.html">VMLPath</a></li> <li><a href="..&#x2F;classes/VMLPieSlice.html">VMLPieSlice</a></li> <li><a href="..&#x2F;classes/VMLRect.html">VMLRect</a></li> <li><a href="..&#x2F;classes/VMLShape.html">VMLShape</a></li> <li><a href="..&#x2F;classes/Widget.html">Widget</a></li> <li><a href="..&#x2F;classes/WidgetAutohide.html">WidgetAutohide</a></li> <li><a href="..&#x2F;classes/WidgetButtons.html">WidgetButtons</a></li> <li><a href="..&#x2F;classes/WidgetChild.html">WidgetChild</a></li> <li><a href="..&#x2F;classes/WidgetModality.html">WidgetModality</a></li> <li><a href="..&#x2F;classes/WidgetParent.html">WidgetParent</a></li> <li><a href="..&#x2F;classes/WidgetPosition.html">WidgetPosition</a></li> <li><a href="..&#x2F;classes/WidgetPositionAlign.html">WidgetPositionAlign</a></li> <li><a href="..&#x2F;classes/WidgetPositionConstrain.html">WidgetPositionConstrain</a></li> <li><a href="..&#x2F;classes/WidgetStack.html">WidgetStack</a></li> <li><a href="..&#x2F;classes/WidgetStdMod.html">WidgetStdMod</a></li> <li><a href="..&#x2F;classes/XML.html">XML</a></li> <li><a href="..&#x2F;classes/YQL.html">YQL</a></li> <li><a href="..&#x2F;classes/YQLRequest.html">YQLRequest</a></li> <li><a href="..&#x2F;classes/YUI.html">YUI</a></li> <li><a href="..&#x2F;classes/YUI~substitute.html">YUI~substitute</a></li> </ul> <ul id="api-modules" class="apis modules"> <li><a href="..&#x2F;modules/align-plugin.html">align-plugin</a></li> <li><a href="..&#x2F;modules/anim.html">anim</a></li> <li><a href="..&#x2F;modules/anim-base.html">anim-base</a></li> <li><a href="..&#x2F;modules/anim-color.html">anim-color</a></li> <li><a href="..&#x2F;modules/anim-curve.html">anim-curve</a></li> <li><a href="..&#x2F;modules/anim-easing.html">anim-easing</a></li> <li><a href="..&#x2F;modules/anim-node-plugin.html">anim-node-plugin</a></li> <li><a href="..&#x2F;modules/anim-scroll.html">anim-scroll</a></li> <li><a href="..&#x2F;modules/anim-shape.html">anim-shape</a></li> <li><a href="..&#x2F;modules/anim-shape-transform.html">anim-shape-transform</a></li> <li><a href="..&#x2F;modules/anim-xy.html">anim-xy</a></li> <li><a href="..&#x2F;modules/app.html">app</a></li> <li><a href="..&#x2F;modules/app-base.html">app-base</a></li> <li><a href="..&#x2F;modules/app-content.html">app-content</a></li> <li><a href="..&#x2F;modules/app-transitions.html">app-transitions</a></li> <li><a href="..&#x2F;modules/app-transitions-native.html">app-transitions-native</a></li> <li><a href="..&#x2F;modules/array-extras.html">array-extras</a></li> <li><a href="..&#x2F;modules/array-invoke.html">array-invoke</a></li> <li><a href="..&#x2F;modules/arraylist.html">arraylist</a></li> <li><a href="..&#x2F;modules/arraylist-add.html">arraylist-add</a></li> <li><a href="..&#x2F;modules/arraylist-filter.html">arraylist-filter</a></li> <li><a href="..&#x2F;modules/arraysort.html">arraysort</a></li> <li><a href="..&#x2F;modules/async-queue.html">async-queue</a></li> <li><a href="..&#x2F;modules/attribute.html">attribute</a></li> <li><a href="..&#x2F;modules/attribute-base.html">attribute-base</a></li> <li><a href="..&#x2F;modules/attribute-complex.html">attribute-complex</a></li> <li><a href="..&#x2F;modules/attribute-core.html">attribute-core</a></li> <li><a href="..&#x2F;modules/attribute-events.html">attribute-events</a></li> <li><a href="..&#x2F;modules/attribute-extras.html">attribute-extras</a></li> <li><a href="..&#x2F;modules/autocomplete.html">autocomplete</a></li> <li><a href="..&#x2F;modules/autocomplete-base.html">autocomplete-base</a></li> <li><a href="..&#x2F;modules/autocomplete-filters.html">autocomplete-filters</a></li> <li><a href="..&#x2F;modules/autocomplete-filters-accentfold.html">autocomplete-filters-accentfold</a></li> <li><a href="..&#x2F;modules/autocomplete-highlighters.html">autocomplete-highlighters</a></li> <li><a href="..&#x2F;modules/autocomplete-highlighters-accentfold.html">autocomplete-highlighters-accentfold</a></li> <li><a href="..&#x2F;modules/autocomplete-list.html">autocomplete-list</a></li> <li><a href="..&#x2F;modules/autocomplete-list-keys.html">autocomplete-list-keys</a></li> <li><a href="..&#x2F;modules/autocomplete-plugin.html">autocomplete-plugin</a></li> <li><a href="..&#x2F;modules/autocomplete-sources.html">autocomplete-sources</a></li> <li><a href="..&#x2F;modules/base.html">base</a></li> <li><a href="..&#x2F;modules/base-base.html">base-base</a></li> <li><a href="..&#x2F;modules/base-build.html">base-build</a></li> <li><a href="..&#x2F;modules/base-core.html">base-core</a></li> <li><a href="..&#x2F;modules/base-pluginhost.html">base-pluginhost</a></li> <li><a href="..&#x2F;modules/button.html">button</a></li> <li><a href="..&#x2F;modules/button-core.html">button-core</a></li> <li><a href="..&#x2F;modules/button-group.html">button-group</a></li> <li><a href="..&#x2F;modules/button-plugin.html">button-plugin</a></li> <li><a href="..&#x2F;modules/cache.html">cache</a></li> <li><a href="..&#x2F;modules/cache-base.html">cache-base</a></li> <li><a href="..&#x2F;modules/cache-offline.html">cache-offline</a></li> <li><a href="..&#x2F;modules/cache-plugin.html">cache-plugin</a></li> <li><a href="..&#x2F;modules/calendar.html">calendar</a></li> <li><a href="..&#x2F;modules/calendar-base.html">calendar-base</a></li> <li><a href="..&#x2F;modules/calendarnavigator.html">calendarnavigator</a></li> <li><a href="..&#x2F;modules/charts.html">charts</a></li> <li><a href="..&#x2F;modules/charts-base.html">charts-base</a></li> <li><a href="..&#x2F;modules/charts-legend.html">charts-legend</a></li> <li><a href="..&#x2F;modules/classnamemanager.html">classnamemanager</a></li> <li><a href="..&#x2F;modules/clickable-rail.html">clickable-rail</a></li> <li><a href="..&#x2F;modules/collection.html">collection</a></li> <li><a href="..&#x2F;modules/console.html">console</a></li> <li><a href="..&#x2F;modules/console-filters.html">console-filters</a></li> <li><a href="..&#x2F;modules/cookie.html">cookie</a></li> <li><a href="..&#x2F;modules/createlink-base.html">createlink-base</a></li> <li><a href="..&#x2F;modules/dataschema.html">dataschema</a></li> <li><a href="..&#x2F;modules/dataschema-array.html">dataschema-array</a></li> <li><a href="..&#x2F;modules/dataschema-base.html">dataschema-base</a></li> <li><a href="..&#x2F;modules/dataschema-json.html">dataschema-json</a></li> <li><a href="..&#x2F;modules/dataschema-text.html">dataschema-text</a></li> <li><a href="..&#x2F;modules/dataschema-xml.html">dataschema-xml</a></li> <li><a href="..&#x2F;modules/datasource.html">datasource</a></li> <li><a href="..&#x2F;modules/datasource-arrayschema.html">datasource-arrayschema</a></li> <li><a href="..&#x2F;modules/datasource-cache.html">datasource-cache</a></li> <li><a href="..&#x2F;modules/datasource-function.html">datasource-function</a></li> <li><a href="..&#x2F;modules/datasource-get.html">datasource-get</a></li> <li><a href="..&#x2F;modules/datasource-io.html">datasource-io</a></li> <li><a href="..&#x2F;modules/datasource-jsonschema.html">datasource-jsonschema</a></li> <li><a href="..&#x2F;modules/datasource-local.html">datasource-local</a></li> <li><a href="..&#x2F;modules/datasource-polling.html">datasource-polling</a></li> <li><a href="..&#x2F;modules/datasource-textschema.html">datasource-textschema</a></li> <li><a href="..&#x2F;modules/datasource-xmlschema.html">datasource-xmlschema</a></li> <li><a href="..&#x2F;modules/datatable.html">datatable</a></li> <li><a href="..&#x2F;modules/datatable-base.html">datatable-base</a></li> <li><a href="..&#x2F;modules/datatable-base-deprecated.html">datatable-base-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-body.html">datatable-body</a></li> <li><a href="..&#x2F;modules/datatable-column-widths.html">datatable-column-widths</a></li> <li><a href="..&#x2F;modules/datatable-core.html">datatable-core</a></li> <li><a href="..&#x2F;modules/datatable-datasource.html">datatable-datasource</a></li> <li><a href="..&#x2F;modules/datatable-datasource-deprecated.html">datatable-datasource-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-deprecated.html">datatable-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-head.html">datatable-head</a></li> <li><a href="..&#x2F;modules/datatable-message.html">datatable-message</a></li> <li><a href="..&#x2F;modules/datatable-mutable.html">datatable-mutable</a></li> <li><a href="..&#x2F;modules/datatable-scroll.html">datatable-scroll</a></li> <li><a href="..&#x2F;modules/datatable-scroll-deprecated.html">datatable-scroll-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-sort.html">datatable-sort</a></li> <li><a href="..&#x2F;modules/datatable-sort-deprecated.html">datatable-sort-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-table.html">datatable-table</a></li> <li><a href="..&#x2F;modules/datatype.html">datatype</a></li> <li><a href="..&#x2F;modules/datatype-date.html">datatype-date</a></li> <li><a href="..&#x2F;modules/datatype-date-format.html">datatype-date-format</a></li> <li><a href="..&#x2F;modules/datatype-date-math.html">datatype-date-math</a></li> <li><a href="..&#x2F;modules/datatype-date-parse.html">datatype-date-parse</a></li> <li><a href="..&#x2F;modules/datatype-number.html">datatype-number</a></li> <li><a href="..&#x2F;modules/datatype-number-format.html">datatype-number-format</a></li> <li><a href="..&#x2F;modules/datatype-number-parse.html">datatype-number-parse</a></li> <li><a href="..&#x2F;modules/datatype-xml.html">datatype-xml</a></li> <li><a href="..&#x2F;modules/datatype-xml-format.html">datatype-xml-format</a></li> <li><a href="..&#x2F;modules/datatype-xml-parse.html">datatype-xml-parse</a></li> <li><a href="..&#x2F;modules/dd.html">dd</a></li> <li><a href="..&#x2F;modules/dd-constrain.html">dd-constrain</a></li> <li><a href="..&#x2F;modules/dd-ddm.html">dd-ddm</a></li> <li><a href="..&#x2F;modules/dd-ddm-base.html">dd-ddm-base</a></li> <li><a href="..&#x2F;modules/dd-ddm-drop.html">dd-ddm-drop</a></li> <li><a href="..&#x2F;modules/dd-delegate.html">dd-delegate</a></li> <li><a href="..&#x2F;modules/dd-drag.html">dd-drag</a></li> <li><a href="..&#x2F;modules/dd-drop.html">dd-drop</a></li> <li><a href="..&#x2F;modules/dd-drop-plugin.html">dd-drop-plugin</a></li> <li><a href="..&#x2F;modules/dd-gestures.html">dd-gestures</a></li> <li><a href="..&#x2F;modules/dd-plugin.html">dd-plugin</a></li> <li><a href="..&#x2F;modules/dd-proxy.html">dd-proxy</a></li> <li><a href="..&#x2F;modules/dd-scroll.html">dd-scroll</a></li> <li><a href="..&#x2F;modules/dial.html">dial</a></li> <li><a href="..&#x2F;modules/dom.html">dom</a></li> <li><a href="..&#x2F;modules/dom-base.html">dom-base</a></li> <li><a href="..&#x2F;modules/dom-screen.html">dom-screen</a></li> <li><a href="..&#x2F;modules/dom-style.html">dom-style</a></li> <li><a href="..&#x2F;modules/dump.html">dump</a></li> <li><a href="..&#x2F;modules/editor.html">editor</a></li> <li><a href="..&#x2F;modules/editor-base.html">editor-base</a></li> <li><a href="..&#x2F;modules/editor-bidi.html">editor-bidi</a></li> <li><a href="..&#x2F;modules/editor-br.html">editor-br</a></li> <li><a href="..&#x2F;modules/editor-lists.html">editor-lists</a></li> <li><a href="..&#x2F;modules/editor-para.html">editor-para</a></li> <li><a href="..&#x2F;modules/editor-para-base.html">editor-para-base</a></li> <li><a href="..&#x2F;modules/editor-para-ie.html">editor-para-ie</a></li> <li><a href="..&#x2F;modules/editor-tab.html">editor-tab</a></li> <li><a href="..&#x2F;modules/escape.html">escape</a></li> <li><a href="..&#x2F;modules/event.html">event</a></li> <li><a href="..&#x2F;modules/event-base.html">event-base</a></li> <li><a href="..&#x2F;modules/event-contextmenu.html">event-contextmenu</a></li> <li><a href="..&#x2F;modules/event-custom.html">event-custom</a></li> <li><a href="..&#x2F;modules/event-custom-base.html">event-custom-base</a></li> <li><a href="..&#x2F;modules/event-custom-complex.html">event-custom-complex</a></li> <li><a href="..&#x2F;modules/event-delegate.html">event-delegate</a></li> <li><a href="..&#x2F;modules/event-flick.html">event-flick</a></li> <li><a href="..&#x2F;modules/event-focus.html">event-focus</a></li> <li><a href="..&#x2F;modules/event-gestures.html">event-gestures</a></li> <li><a href="..&#x2F;modules/event-hover.html">event-hover</a></li> <li><a href="..&#x2F;modules/event-key.html">event-key</a></li> <li><a href="..&#x2F;modules/event-mouseenter.html">event-mouseenter</a></li> <li><a href="..&#x2F;modules/event-mousewheel.html">event-mousewheel</a></li> <li><a href="..&#x2F;modules/event-move.html">event-move</a></li> <li><a href="..&#x2F;modules/event-outside.html">event-outside</a></li> <li><a href="..&#x2F;modules/event-resize.html">event-resize</a></li> <li><a href="..&#x2F;modules/event-simulate.html">event-simulate</a></li> <li><a href="..&#x2F;modules/event-synthetic.html">event-synthetic</a></li> <li><a href="..&#x2F;modules/event-tap.html">event-tap</a></li> <li><a href="..&#x2F;modules/event-touch.html">event-touch</a></li> <li><a href="..&#x2F;modules/event-valuechange.html">event-valuechange</a></li> <li><a href="..&#x2F;modules/exec-command.html">exec-command</a></li> <li><a href="..&#x2F;modules/features.html">features</a></li> <li><a href="..&#x2F;modules/file.html">file</a></li> <li><a href="..&#x2F;modules/file-flash.html">file-flash</a></li> <li><a href="..&#x2F;modules/file-html5.html">file-html5</a></li> <li><a href="..&#x2F;modules/frame.html">frame</a></li> <li><a href="..&#x2F;modules/gesture-simulate.html">gesture-simulate</a></li> <li><a href="..&#x2F;modules/get.html">get</a></li> <li><a href="..&#x2F;modules/get-nodejs.html">get-nodejs</a></li> <li><a href="..&#x2F;modules/graphics.html">graphics</a></li> <li><a href="..&#x2F;modules/handlebars.html">handlebars</a></li> <li><a href="..&#x2F;modules/handlebars-base.html">handlebars-base</a></li> <li><a href="..&#x2F;modules/handlebars-compiler.html">handlebars-compiler</a></li> <li><a href="..&#x2F;modules/highlight.html">highlight</a></li> <li><a href="..&#x2F;modules/highlight-accentfold.html">highlight-accentfold</a></li> <li><a href="..&#x2F;modules/highlight-base.html">highlight-base</a></li> <li><a href="..&#x2F;modules/history.html">history</a></li> <li><a href="..&#x2F;modules/history-base.html">history-base</a></li> <li><a href="..&#x2F;modules/history-hash.html">history-hash</a></li> <li><a href="..&#x2F;modules/history-hash-ie.html">history-hash-ie</a></li> <li><a href="..&#x2F;modules/history-html5.html">history-html5</a></li> <li><a href="..&#x2F;modules/imageloader.html">imageloader</a></li> <li><a href="..&#x2F;modules/intl.html">intl</a></li> <li><a href="..&#x2F;modules/io.html">io</a></li> <li><a href="..&#x2F;modules/io-base.html">io-base</a></li> <li><a href="..&#x2F;modules/io-form.html">io-form</a></li> <li><a href="..&#x2F;modules/io-nodejs.html">io-nodejs</a></li> <li><a href="..&#x2F;modules/io-queue.html">io-queue</a></li> <li><a href="..&#x2F;modules/io-upload-iframe.html">io-upload-iframe</a></li> <li><a href="..&#x2F;modules/io-xdr.html">io-xdr</a></li> <li><a href="..&#x2F;modules/json.html">json</a></li> <li><a href="..&#x2F;modules/json-parse.html">json-parse</a></li> <li><a href="..&#x2F;modules/json-stringify.html">json-stringify</a></li> <li><a href="..&#x2F;modules/jsonp.html">jsonp</a></li> <li><a href="..&#x2F;modules/jsonp-url.html">jsonp-url</a></li> <li><a href="..&#x2F;modules/lazy-model-list.html">lazy-model-list</a></li> <li><a href="..&#x2F;modules/loader.html">loader</a></li> <li><a href="..&#x2F;modules/loader-base.html">loader-base</a></li> <li><a href="..&#x2F;modules/matrix.html">matrix</a></li> <li><a href="..&#x2F;modules/model.html">model</a></li> <li><a href="..&#x2F;modules/model-list.html">model-list</a></li> <li><a href="..&#x2F;modules/model-sync-rest.html">model-sync-rest</a></li> <li><a href="..&#x2F;modules/node.html">node</a></li> <li><a href="..&#x2F;modules/node-base.html">node-base</a></li> <li><a href="..&#x2F;modules/node-core.html">node-core</a></li> <li><a href="..&#x2F;modules/node-data.html">node-data</a></li> <li><a href="..&#x2F;modules/node-deprecated.html">node-deprecated</a></li> <li><a href="..&#x2F;modules/node-event-delegate.html">node-event-delegate</a></li> <li><a href="..&#x2F;modules/node-event-html5.html">node-event-html5</a></li> <li><a href="..&#x2F;modules/node-event-simulate.html">node-event-simulate</a></li> <li><a href="..&#x2F;modules/node-flick.html">node-flick</a></li> <li><a href="..&#x2F;modules/node-focusmanager.html">node-focusmanager</a></li> <li><a href="..&#x2F;modules/node-load.html">node-load</a></li> <li><a href="..&#x2F;modules/node-menunav.html">node-menunav</a></li> <li><a href="..&#x2F;modules/node-pluginhost.html">node-pluginhost</a></li> <li><a href="..&#x2F;modules/node-screen.html">node-screen</a></li> <li><a href="..&#x2F;modules/node-scroll-info.html">node-scroll-info</a></li> <li><a href="..&#x2F;modules/node-style.html">node-style</a></li> <li><a href="..&#x2F;modules/oop.html">oop</a></li> <li><a href="..&#x2F;modules/overlay.html">overlay</a></li> <li><a href="..&#x2F;modules/panel.html">panel</a></li> <li><a href="..&#x2F;modules/parallel.html">parallel</a></li> <li><a href="..&#x2F;modules/pjax.html">pjax</a></li> <li><a href="..&#x2F;modules/pjax-base.html">pjax-base</a></li> <li><a href="..&#x2F;modules/pjax-content.html">pjax-content</a></li> <li><a href="..&#x2F;modules/pjax-plugin.html">pjax-plugin</a></li> <li><a href="..&#x2F;modules/plugin.html">plugin</a></li> <li><a href="..&#x2F;modules/pluginhost.html">pluginhost</a></li> <li><a href="..&#x2F;modules/pluginhost-base.html">pluginhost-base</a></li> <li><a href="..&#x2F;modules/pluginhost-config.html">pluginhost-config</a></li> <li><a href="..&#x2F;modules/profiler.html">profiler</a></li> <li><a href="..&#x2F;modules/querystring.html">querystring</a></li> <li><a href="..&#x2F;modules/querystring-parse.html">querystring-parse</a></li> <li><a href="..&#x2F;modules/querystring-parse-simple.html">querystring-parse-simple</a></li> <li><a href="..&#x2F;modules/querystring-stringify.html">querystring-stringify</a></li> <li><a href="..&#x2F;modules/querystring-stringify-simple.html">querystring-stringify-simple</a></li> <li><a href="..&#x2F;modules/queue-promote.html">queue-promote</a></li> <li><a href="..&#x2F;modules/range-slider.html">range-slider</a></li> <li><a href="..&#x2F;modules/recordset.html">recordset</a></li> <li><a href="..&#x2F;modules/recordset-base.html">recordset-base</a></li> <li><a href="..&#x2F;modules/recordset-filter.html">recordset-filter</a></li> <li><a href="..&#x2F;modules/recordset-indexer.html">recordset-indexer</a></li> <li><a href="..&#x2F;modules/recordset-sort.html">recordset-sort</a></li> <li><a href="..&#x2F;modules/resize.html">resize</a></li> <li><a href="..&#x2F;modules/resize-contrain.html">resize-contrain</a></li> <li><a href="..&#x2F;modules/resize-plugin.html">resize-plugin</a></li> <li><a href="..&#x2F;modules/resize-proxy.html">resize-proxy</a></li> <li><a href="..&#x2F;modules/rollup.html">rollup</a></li> <li><a href="..&#x2F;modules/router.html">router</a></li> <li><a href="..&#x2F;modules/scrollview.html">scrollview</a></li> <li><a href="..&#x2F;modules/scrollview-base.html">scrollview-base</a></li> <li><a href="..&#x2F;modules/scrollview-base-ie.html">scrollview-base-ie</a></li> <li><a href="..&#x2F;modules/scrollview-list.html">scrollview-list</a></li> <li><a href="..&#x2F;modules/scrollview-paginator.html">scrollview-paginator</a></li> <li><a href="..&#x2F;modules/scrollview-scrollbars.html">scrollview-scrollbars</a></li> <li><a href="..&#x2F;modules/selection.html">selection</a></li> <li><a href="..&#x2F;modules/selector-css2.html">selector-css2</a></li> <li><a href="..&#x2F;modules/selector-css3.html">selector-css3</a></li> <li><a href="..&#x2F;modules/selector-native.html">selector-native</a></li> <li><a href="..&#x2F;modules/shim-plugin.html">shim-plugin</a></li> <li><a href="..&#x2F;modules/slider.html">slider</a></li> <li><a href="..&#x2F;modules/slider-base.html">slider-base</a></li> <li><a href="..&#x2F;modules/slider-value-range.html">slider-value-range</a></li> <li><a href="..&#x2F;modules/sortable.html">sortable</a></li> <li><a href="..&#x2F;modules/sortable-scroll.html">sortable-scroll</a></li> <li><a href="..&#x2F;modules/stylesheet.html">stylesheet</a></li> <li><a href="..&#x2F;modules/substitute.html">substitute</a></li> <li><a href="..&#x2F;modules/swf.html">swf</a></li> <li><a href="..&#x2F;modules/swfdetect.html">swfdetect</a></li> <li><a href="..&#x2F;modules/tabview.html">tabview</a></li> <li><a href="..&#x2F;modules/test.html">test</a></li> <li><a href="..&#x2F;modules/test-console.html">test-console</a></li> <li><a href="..&#x2F;modules/text.html">text</a></li> <li><a href="..&#x2F;modules/text-accentfold.html">text-accentfold</a></li> <li><a href="..&#x2F;modules/text-wordbreak.html">text-wordbreak</a></li> <li><a href="..&#x2F;modules/transition.html">transition</a></li> <li><a href="..&#x2F;modules/transition-timer.html">transition-timer</a></li> <li><a href="..&#x2F;modules/uploader.html">uploader</a></li> <li><a href="..&#x2F;modules/uploader-deprecated.html">uploader-deprecated</a></li> <li><a href="..&#x2F;modules/uploader-flash.html">uploader-flash</a></li> <li><a href="..&#x2F;modules/uploader-html5.html">uploader-html5</a></li> <li><a href="..&#x2F;modules/uploader-queue.html">uploader-queue</a></li> <li><a href="..&#x2F;modules/view.html">view</a></li> <li><a href="..&#x2F;modules/view-node-map.html">view-node-map</a></li> <li><a href="..&#x2F;modules/widget.html">widget</a></li> <li><a href="..&#x2F;modules/widget-anim.html">widget-anim</a></li> <li><a href="..&#x2F;modules/widget-autohide.html">widget-autohide</a></li> <li><a href="..&#x2F;modules/widget-base.html">widget-base</a></li> <li><a href="..&#x2F;modules/widget-base-ie.html">widget-base-ie</a></li> <li><a href="..&#x2F;modules/widget-buttons.html">widget-buttons</a></li> <li><a href="..&#x2F;modules/widget-child.html">widget-child</a></li> <li><a href="..&#x2F;modules/widget-htmlparser.html">widget-htmlparser</a></li> <li><a href="..&#x2F;modules/widget-locale.html">widget-locale</a></li> <li><a href="..&#x2F;modules/widget-modality.html">widget-modality</a></li> <li><a href="..&#x2F;modules/widget-parent.html">widget-parent</a></li> <li><a href="..&#x2F;modules/widget-position.html">widget-position</a></li> <li><a href="..&#x2F;modules/widget-position-align.html">widget-position-align</a></li> <li><a href="..&#x2F;modules/widget-position-constrain.html">widget-position-constrain</a></li> <li><a href="..&#x2F;modules/widget-skin.html">widget-skin</a></li> <li><a href="..&#x2F;modules/widget-stack.html">widget-stack</a></li> <li><a href="..&#x2F;modules/widget-stdmod.html">widget-stdmod</a></li> <li><a href="..&#x2F;modules/widget-uievents.html">widget-uievents</a></li> <li><a href="..&#x2F;modules/yql.html">yql</a></li> <li><a href="..&#x2F;modules/yql-nodejs.html">yql-nodejs</a></li> <li><a href="..&#x2F;modules/yql-winjs.html">yql-winjs</a></li> <li><a href="..&#x2F;modules/yui.html">yui</a></li> <li><a href="..&#x2F;modules/yui-base.html">yui-base</a></li> <li><a href="..&#x2F;modules/yui-later.html">yui-later</a></li> <li><a href="..&#x2F;modules/yui-log.html">yui-log</a></li> <li><a href="..&#x2F;modules/yui-throttle.html">yui-throttle</a></li> <li><a href="..&#x2F;modules/yui3.html">yui3</a></li> </ul> </div> </div> </div> </div> </div> <div class="yui3-u-3-4"> <div id="api-options"> Show: <label for="api-show-inherited"> <input type="checkbox" id="api-show-inherited" checked> Inherited </label> <label for="api-show-protected"> <input type="checkbox" id="api-show-protected"> Protected </label> <label for="api-show-private"> <input type="checkbox" id="api-show-private"> Private </label> <label for="api-show-deprecated"> <input type="checkbox" id="api-show-deprecated"> Deprecated </label> </div> <div class="apidocs"> <div id="docs-main"> <div class="content"> <h1>SyntheticEvent Class</h1> <div class="box meta"> <div class="foundat"> Defined in: <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l194"><code>event&#x2F;js&#x2F;synthetic.js:194</code></a> </div> Module: <a href="../modules/event-synthetic.html">event-synthetic</a><br> Parent Module: <a href="../modules/event.html">event</a> <p>Available since 3.1.0</p> </div> <div class="box intro"> <p>Wrapper class for the integration of new events into the YUI event infrastructure. Don't instantiate this object directly, use <code>Y.Event.define(type, config)</code>. See that method for details.</p> <p>Properties that MAY or SHOULD be specified in the configuration are noted below and in the description of <code>Y.Event.define</code>.</p> </div> <div class="constructor"> <h2>Constructor</h2> <div id="method_SyntheticEvent" class="method item"> <h3 class="name"><code>SyntheticEvent</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>cfg</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l194"><code>event&#x2F;js&#x2F;synthetic.js:194</code></a> </p> <p>Available since 3.1.0</p> </div> <div class="description"> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">cfg</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span> <div class="param-description"> <p>Implementation pieces and configuration</p> </div> </li> </ul> </div> </div> </div> <div id="classdocs" class="tabview"> <ul class="api-class-tabs"> <li class="api-class-tab index"><a href="#index">Index</a></li> <li class="api-class-tab methods"><a href="#methods">Methods</a></li> <li class="api-class-tab properties"><a href="#properties">Properties</a></li> </ul> <div> <div id="index" class="api-class-tabpanel index"> <h2 class="off-left">Item Index</h2> <div class="index-section methods"> <h3>Methods</h3> <ul class="index-list methods"> <li class="index-item method private"> <a href="#method__deleteSub">_deleteSub</a> </li> <li class="index-item method private"> <a href="#method__detach">_detach</a> </li> <li class="index-item method protected"> <a href="#method__init">_init</a> </li> <li class="index-item method private"> <a href="#method__on">_on</a> </li> <li class="index-item method private"> <a href="#method__subscribe">_subscribe</a> </li> <li class="index-item method"> <a href="#method_applyArgExtras">applyArgExtras</a> </li> <li class="index-item method"> <a href="#method_delegate">delegate</a> </li> <li class="index-item method"> <a href="#method_detach">detach</a> </li> <li class="index-item method"> <a href="#method_detachDelegate">detachDelegate</a> </li> <li class="index-item method protected"> <a href="#method_getRegistry">getRegistry</a> <span class="flag static">static</span> </li> <li class="index-item method"> <a href="#method_getSubs">getSubs</a> </li> <li class="index-item method"> <a href="#method_on">on</a> </li> <li class="index-item method"> <a href="#method_processArgs">processArgs</a> </li> <li class="index-item method"> <a href="#method_subMatch">subMatch</a> </li> </ul> </div> <div class="index-section properties"> <h3>Properties</h3> <ul class="index-list properties"> <li class="index-item property"> <a href="#property_preventDups">preventDups</a> </li> </ul> </div> </div> <div id="methods" class="api-class-tabpanel"> <h2 class="off-left">Methods</h2> <div id="method__deleteSub" class="method item private"> <h3 class="name"><code>_deleteSub</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>sub</code> </li> </ul><span class="paren">)</span> </div> <span class="flag private">private</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l249"><code>event&#x2F;js&#x2F;synthetic.js:249</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Alternate <code>_delete()</code> method for the CustomEvent object created to manage SyntheticEvent subscriptions.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the subscription to clean up</p> </div> </li> </ul> </div> </div> <div id="method__detach" class="method item private"> <h3 class="name"><code>_detach</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>args</code> </li> </ul><span class="paren">)</span> </div> <span class="flag private">private</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l567"><code>event&#x2F;js&#x2F;synthetic.js:567</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Removes the subscription(s) from the internal subscription dispatch mechanism. See <code>SyntheticEvent._deleteSub</code>.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>The arguments passed to <code>node.detach(...)</code></p> </div> </li> </ul> </div> </div> <div id="method__init" class="method item protected"> <h3 class="name"><code>_init</code></h3> <span class="paren">()</span> <span class="flag protected">protected</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l281"><code>event&#x2F;js&#x2F;synthetic.js:281</code></a> </p> </div> <div class="description"> <p>Construction logic for the event.</p> </div> </div> <div id="method__on" class="method item private"> <h3 class="name"><code>_on</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>args</code> </li> <li class="arg"> <code>delegate</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle</a></span> </span> <span class="flag private">private</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l429"><code>event&#x2F;js&#x2F;synthetic.js:429</code></a> </p> </div> <div class="description"> <p>Sets up the boilerplate for detaching the event and facilitating the execution of subscriber callbacks.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>array of arguments passed to <code>Y.on(...)</code> or <code>Y.delegate(...)</code></p> </div> </li> <li class="param"> <code class="param-name">delegate</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> <div class="param-description"> <p>true if called from <code>Y.delegate(...)</code></p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle</a></span>: the detach handle for this subscription </div> </div> </div> <div id="method__subscribe" class="method item private"> <h3 class="name"><code>_subscribe</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>method</code> </li> <li class="arg"> <code>args</code> </li> <li class="arg"> <code>extra</code> </li> <li class="arg"> <code>filter</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle</a></span> </span> <span class="flag private">private</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l490"><code>event&#x2F;js&#x2F;synthetic.js:490</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Creates a new Notifier object for use by this event's <code>on(...)</code> or <code>delegate(...)</code> implementation and register the custom event proxy in the DOM system for cleanup.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the Node hosting the event</p> </div> </li> <li class="param"> <code class="param-name">method</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span> <div class="param-description"> <p>"on" or "delegate"</p> </div> </li> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>the subscription arguments passed to either <code>Y.on(...)</code> or <code>Y.delegate(...)</code> after running through <code>processArgs(args)</code> to normalize the argument signature</p> </div> </li> <li class="param"> <code class="param-name">extra</code> <span class="type">Any</span> <div class="param-description"> <p>Extra data parsed from <code>processArgs(args)</code></p> </div> </li> <li class="param"> <code class="param-name">filter</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a> | <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span> <div class="param-description"> <p>the selector string or function filter passed to <code>Y.delegate(...)</code> (not present when called from <code>Y.on(...)</code>)</p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle</a></span>: </div> </div> </div> <div id="method_applyArgExtras" class="method item"> <h3 class="name"><code>applyArgExtras</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>extra</code> </li> <li class="arg"> <code>sub</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l545"><code>event&#x2F;js&#x2F;synthetic.js:545</code></a> </p> </div> <div class="description"> <p>Implementers MAY provide this method definition.</p> <p>Implement this function if you want extra data extracted during processArgs to be propagated to subscriptions on a per-node basis. That is to say, if you call <code>Y.on('xyz', fn, xtra, 'div')</code> the data returned from processArgs will be shared across the subscription objects for all the divs. If you want each subscription to receive unique information, do that processing here.</p> <p>The default implementation adds the data extracted by processArgs to the subscription object as <code>sub._extra</code>.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">extra</code> <span class="type">Any</span> <div class="param-description"> <p>Any extra data extracted from processArgs</p> </div> </li> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the individual subscription</p> </div> </li> </ul> </div> </div> <div id="method_delegate" class="method item"> <h3 class="name"><code>delegate</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>sub</code> </li> <li class="arg"> <code>notifier</code> </li> <li class="arg"> <code>filter</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l379"><code>event&#x2F;js&#x2F;synthetic.js:379</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Implementers SHOULD provide this method definition.</p> <p>Implementation logic for subscriptions done via <code>node.delegate(type, fn, filter)</code> or <code>Y.delegate(type, fn, container, filter)</code>. Like with <code>on()</code> above, this function should monitor the environment for the event being fired, and trigger subscription execution by calling <code>notifier.fire(e)</code>.</p> <p>This function receives a fourth argument, which is the filter used to identify which Node's are of interest to the subscription. The filter will be either a boolean function that accepts a target Node for each hierarchy level as the event bubbles, or a selector string. To translate selector strings into filter functions, use <code>Y.delegate.compileFilter(filter)</code>.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node the subscription is being applied to</p> </div> </li> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the object to track this subscription</p> </div> </li> <li class="param"> <code class="param-name">notifier</code> <span class="type"><a href="../classes/SyntheticEvent.Notifier.html" class="crosslink">SyntheticEvent.Notifier</a></span> <div class="param-description"> <p>call notifier.fire(..) to trigger the execution of the subscribers</p> </div> </li> <li class="param"> <code class="param-name">filter</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a> | <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span> <div class="param-description"> <p>Selector string or function that accepts an event object and returns null, a Node, or an array of Nodes matching the criteria for processing.</p> </div> </li> </ul> </div> </div> <div id="method_detach" class="method item"> <h3 class="name"><code>detach</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>sub</code> </li> <li class="arg"> <code>notifier</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l364"><code>event&#x2F;js&#x2F;synthetic.js:364</code></a> </p> </div> <div class="description"> <p>Implementers SHOULD provide this method definition.</p> <p>Implementation logic for detaching subscriptions done via <code>node.on(type, fn)</code>. This function should clean up any subscriptions made in the <code>on()</code> phase.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node the subscription was applied to</p> </div> </li> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the object tracking this subscription</p> </div> </li> <li class="param"> <code class="param-name">notifier</code> <span class="type"><a href="../classes/SyntheticEvent.Notifier.html" class="crosslink">SyntheticEvent.Notifier</a></span> <div class="param-description"> <p>the Notifier used to trigger the execution of the subscribers</p> </div> </li> </ul> </div> </div> <div id="method_detachDelegate" class="method item"> <h3 class="name"><code>detachDelegate</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>sub</code> </li> <li class="arg"> <code>notifier</code> </li> <li class="arg"> <code>filter</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l408"><code>event&#x2F;js&#x2F;synthetic.js:408</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Implementers SHOULD provide this method definition.</p> <p>Implementation logic for detaching subscriptions done via <code>node.delegate(type, fn, filter)</code> or <code>Y.delegate(type, fn, container, filter)</code>. This function should clean up any subscriptions made in the <code>delegate()</code> phase.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node the subscription was applied to</p> </div> </li> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the object tracking this subscription</p> </div> </li> <li class="param"> <code class="param-name">notifier</code> <span class="type"><a href="../classes/SyntheticEvent.Notifier.html" class="crosslink">SyntheticEvent.Notifier</a></span> <div class="param-description"> <p>the Notifier used to trigger the execution of the subscribers</p> </div> </li> <li class="param"> <code class="param-name">filter</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a> | <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span> <div class="param-description"> <p>Selector string or function that accepts an event object and returns null, a Node, or an array of Nodes matching the criteria for processing.</p> </div> </li> </ul> </div> </div> <div id="method_getRegistry" class="method item protected"> <h3 class="name"><code>getRegistry</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>type</code> </li> <li class="arg"> <code>create</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> </span> <span class="flag protected">protected</span> <span class="flag static">static</span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l216"><code>event&#x2F;js&#x2F;synthetic.js:216</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Returns the array of subscription handles for a node for the given event type. Passing true as the third argument will create a registry entry in the event system's DOM map to host the array if one doesn't yet exist.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node</p> </div> </li> <li class="param"> <code class="param-name">type</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span> <div class="param-description"> <p>the event</p> </div> </li> <li class="param"> <code class="param-name">create</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> <div class="param-description"> <p>create a registration entry to host a new array if one doesn't exist.</p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span>: </div> </div> </div> <div id="method_getSubs" class="method item"> <h3 class="name"><code>getSubs</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>args</code> </li> <li class="arg"> <code>filter</code> </li> <li class="arg"> <code>first</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle[]</a></span> </span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l603"><code>event&#x2F;js&#x2F;synthetic.js:603</code></a> </p> </div> <div class="description"> <p>Returns the detach handles of subscriptions on a node that satisfy a search/filter function. By default, the filter used is the <code>subMatch</code> method.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node hosting the event</p> </div> </li> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>the array of original subscription args passed to <code>Y.on(...)</code> (before <code>processArgs</code></p> </div> </li> <li class="param"> <code class="param-name">filter</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span> <div class="param-description"> <p>function used to identify a subscription for inclusion in the returned array</p> </div> </li> <li class="param"> <code class="param-name">first</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> <div class="param-description"> <p>stop after the first match (used to check for duplicate subscriptions)</p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type"><a href="../classes/EventHandle.html" class="crosslink">EventHandle[]</a></span>: detach handles for the matching subscriptions </div> </div> </div> <div id="method_on" class="method item"> <h3 class="name"><code>on</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>node</code> </li> <li class="arg"> <code>sub</code> </li> <li class="arg"> <code>notifier</code> </li> </ul><span class="paren">)</span> </div> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l341"><code>event&#x2F;js&#x2F;synthetic.js:341</code></a> </p> </div> <div class="description"> <p>Implementers SHOULD provide this method definition.</p> <p>Implementation logic for subscriptions done via <code>node.on(type, fn)</code> or <code>Y.on(type, fn, target)</code>. This function should set up the monitor(s) that will eventually fire the event. Typically this involves subscribing to at least one DOM event. It is recommended to store detach handles from any DOM subscriptions to make for easy cleanup in the <code>detach</code> method. Typically these handles are added to the <code>sub</code> object. Also for SyntheticEvents that leverage a single DOM subscription under the hood, it is recommended to pass the DOM event object to <code>notifier.fire(e)</code>. (The event name on the object will be updated).</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">node</code> <span class="type"><a href="../classes/Node.html" class="crosslink">Node</a></span> <div class="param-description"> <p>the node the subscription is being applied to</p> </div> </li> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the object to track this subscription</p> </div> </li> <li class="param"> <code class="param-name">notifier</code> <span class="type"><a href="../classes/SyntheticEvent.Notifier.html" class="crosslink">SyntheticEvent.Notifier</a></span> <div class="param-description"> <p>call notifier.fire(..) to trigger the execution of the subscribers</p> </div> </li> </ul> </div> </div> <div id="method_processArgs" class="method item"> <h3 class="name"><code>processArgs</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>args</code> </li> <li class="arg"> <code>delegate</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type">Any</span> </span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l297"><code>event&#x2F;js&#x2F;synthetic.js:297</code></a> </p> </div> <div class="description"> <p>Implementers MAY provide this method definition.</p> <p>Implement this function if the event supports a different subscription signature. This function is used by both <code>on()</code> and <code>delegate()</code>. The second parameter indicates that the event is being subscribed via <code>delegate()</code>.</p> <p>Implementations must remove extra arguments from the args list before returning. The required args for <code>on()</code> subscriptions are</p> <pre class="code"><code class="prettyprint">[type, callback, target, context, argN...]</code></pre> <p>The required args for <code>delegate()</code> subscriptions are</p> <pre class="code"><code class="prettyprint">[type, callback, target, filter, context, argN...]</code></pre> <p>The return value from this function will be stored on the subscription in the '_extra' property for reference elsewhere.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>parmeters passed to Y.on(..) or Y.delegate(..)</p> </div> </li> <li class="param"> <code class="param-name">delegate</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> <div class="param-description"> <p>true if the subscription is from Y.delegate</p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type">Any</span>: </div> </div> </div> <div id="method_subMatch" class="method item"> <h3 class="name"><code>subMatch</code></h3> <div class="args"> <span class="paren">(</span><ul class="args-list inline commas"> <li class="arg"> <code>sub</code> </li> <li class="arg"> <code>args</code> </li> </ul><span class="paren">)</span> </div> <span class="returns-inline"> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> </span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l646"><code>event&#x2F;js&#x2F;synthetic.js:646</code></a> </p> <p>Available since 3.2.0</p> </div> <div class="description"> <p>Implementers MAY override this to define what constitutes a &quot;same&quot; subscription. Override implementations should consider the lack of a comparator as a match, so calling <code>getSubs()</code> with no arguments will return all subs.</p> <p>Compares a set of subscription arguments against a Subscription object to determine if they match. The default implementation compares the callback function against the second argument passed to <code>Y.on(...)</code> or <code>node.detach(...)</code> etc.</p> </div> <div class="params"> <h4>Parameters:</h4> <ul class="params-list"> <li class="param"> <code class="param-name">sub</code> <span class="type">Subscription</span> <div class="param-description"> <p>the existing subscription</p> </div> </li> <li class="param"> <code class="param-name">args</code> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span> <div class="param-description"> <p>the calling arguments passed to <code>Y.on(...)</code> etc.</p> </div> </li> </ul> </div> <div class="returns"> <h4>Returns:</h4> <div class="returns-description"> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>: true if the sub can be described by the args present </div> </div> </div> </div> <div id="properties" class="api-class-tabpanel"> <h2 class="off-left">Properties</h2> <div id="property_preventDups" class="property item"> <h3 class="name"><code>preventDups</code></h3> <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span> <div class="meta"> <p> Defined in <a href="..&#x2F;files&#x2F;event_js_synthetic.js.html#l326"><code>event&#x2F;js&#x2F;synthetic.js:326</code></a> </p> </div> <div class="description"> <p>Implementers MAY override this property.</p> <p>Whether to prevent multiple subscriptions to this event that are classified as being the same. By default, this means the subscribed callback is the same function. See the <code>subMatch</code> method. Setting this to true will impact performance for high volume events.</p> </div> <p><strong>Default:</strong> false</p> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <script src="..&#x2F;assets/vendor/prettify/prettify-min.js"></script> <script>prettyPrint();</script> <script src="..&#x2F;assets/js/yui-prettify.js"></script> <script src="..&#x2F;assets/../api.js"></script> <script src="..&#x2F;assets/js/api-filter.js"></script> <script src="..&#x2F;assets/js/api-list.js"></script> <script src="..&#x2F;assets/js/api-search.js"></script> <script src="..&#x2F;assets/js/apidocs.js"></script> </body> </html>
artefactual-labs/trac
sites/all/libraries/yui/api/classes/SyntheticEvent.html
HTML
gpl-2.0
126,546
package be.cmpg.graph case class Interaction(from: Gene, to: Gene, typ: String = "any", direction: String = "undirected", regulatory: String = "regulatory", probability: Double = 0d) { lazy val genes = Set(from, to) lazy val toStr = { if (direction != "undirected" || from.name < to.name) { from.name + "\t" + typ + "\t" + to.name } else { // always return the same str if undirected to.name + "\t" + typ + "\t" + from.name } } override def equals(other: Any) = this.toStr.equals(other.toString()) override def hashCode: Int = toStr.hashCode() override def toString = toStr }
spulido99/SSA
src/main/scala/be/cmpg/graph/Interaction.scala
Scala
gpl-2.0
634
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CRAN - Package hpoPlot</title> <link rel="stylesheet" type="text/css" href="../../CRAN_web.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> table td { vertical-align: top; } </style> </head> <body> <h2>hpoPlot: Functions for Plotting HPO Terms</h2> <p>Collection of functions for manipulating sets of HPO terms and plotting them with a various options.</p> <table summary="Package hpoPlot summary"> <tr> <td>Version:</td> <td>2.4</td> </tr> <tr> <td>Depends:</td> <td>R (&ge; 3.0.0)</td> </tr> <tr> <td>Imports:</td> <td>methods, <a href="http://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html"><span class="BioC">Rgraphviz</span></a>, <a href="../functional/index.html">functional</a>, <a href="../magrittr/index.html">magrittr</a></td> </tr> <tr> <td>Suggests:</td> <td><a href="../knitr/index.html">knitr</a></td> </tr> <tr> <td>Published:</td> <td>2015-12-14</td> </tr> <tr> <td>Author:</td> <td>Daniel Greene</td> </tr> <tr> <td>Maintainer:</td> <td>Daniel Greene &#x3c;&#x64;&#x67;&#x33;&#x33;&#x33;&#x20;&#x61;&#x74;&#x20;&#x63;&#x61;&#x6d;&#x2e;&#x61;&#x63;&#x2e;&#x75;&#x6b;&#x3e;</td> </tr> <tr> <td>License:</td> <td><a href="../../licenses/GPL-2">GPL-2</a> | <a href="../../licenses/GPL-3">GPL-3</a> [expanded from: GPL (&ge; 2)]</td> </tr> <tr> <td>NeedsCompilation:</td> <td>no</td> </tr> <tr> <td>CRAN&nbsp;checks:</td> <td><a href="../../checks/check_results_hpoPlot.html">hpoPlot results</a></td> </tr> </table> <h4>Downloads:</h4> <table summary="Package hpoPlot downloads"> <tr> <td> Reference&nbsp;manual: </td> <td> <a href="hpoPlot.pdf"> hpoPlot.pdf </a> </td> </tr> <tr> <td>Vignettes:</td> <td> <a href="vignettes/hpoPlot-guide.html">Plotting HPO Phenotypes</a><br/> </td> </tr> <tr> <td> Package&nbsp;source: </td> <td> <a href="../../../src/contrib/hpoPlot_2.4.tar.gz"> hpoPlot_2.4.tar.gz </a> </td> </tr> <tr> <td> Windows&nbsp;binaries: </td> <td> r-devel: <a href="../../../bin/windows/contrib/3.5/hpoPlot_2.4.zip">hpoPlot_2.4.zip</a>, r-release: <a href="../../../bin/windows/contrib/3.4/hpoPlot_2.4.zip">hpoPlot_2.4.zip</a>, r-oldrel: <a href="../../../bin/windows/contrib/3.3/hpoPlot_2.4.zip">hpoPlot_2.4.zip</a> </td> </tr> <tr> <td> OS&nbsp;X&nbsp;El&nbsp;Capitan&nbsp;binaries: </td> <td> r-release: not available </td> </tr> <tr> <td> OS&nbsp;X&nbsp;Mavericks&nbsp;binaries: </td> <td> r-oldrel: <a href="../../../bin/macosx/mavericks/contrib/3.3/hpoPlot_2.4.tgz">hpoPlot_2.4.tgz</a> </td> </tr> <tr> <td> Old&nbsp;sources: </td> <td> <a href="../../../src/contrib/Archive/hpoPlot"> hpoPlot archive </a> </td> </tr> </table> <h4>Linking:</h4> <p>Please use the canonical form <a href="https://CRAN.R-project.org/package=hpoPlot"><samp>https://CRAN.R-project.org/package=hpoPlot</samp></a> to link to this page.</p> </body> </html>
esander91/NamespacePollution
Code/GetMetaDataFromCRAN/raw_html/hpoPlot.html
HTML
gpl-2.0
3,010
/* * Copyright (c) 2012-2013 Open Source Community - <http://www.peerfact.org> * Copyright (c) 2011-2012 University of Paderborn - UPB * Copyright (c) 2005-2011 KOM - Multimedia Communications Lab * * This file is part of PeerfactSim.KOM. * * PeerfactSim.KOM 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 * any later version. * * PeerfactSim.KOM 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 PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>. * */ package org.peerfact.impl.overlay.unstructured.heterogeneous.api; import org.peerfact.api.overlay.dht.DHTEntry; import org.peerfact.api.overlay.dht.DHTKey; import org.peerfact.api.overlay.dht.DHTValue; /** * Abstract resource that is published and queried in the network. Can be * anything that can be matched to a given query info. * * @author Leo Nobach <peerfact@kom.tu-darmstadt.de> * * @version 05/06/2011 */ public interface IResource extends DHTEntry<DHTKey<?>>, DHTValue { /** * Returns the size of this resource. * * @return */ int getSize(); }
flyroom/PeerfactSimKOM_Clone
src/org/peerfact/impl/overlay/unstructured/heterogeneous/api/IResource.java
Java
gpl-2.0
1,474
<!-- Generated by pkgdown: do not edit by hand --> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>score_check — score_check • OHICORE</title> <!-- jquery --> <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> <!-- Bootstrap --> <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <!-- Font Awesome icons --> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> <!-- clipboard.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script> <!-- sticky kit --> <script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script> <!-- pkgdown --> <link href="../pkgdown.css" rel="stylesheet"> <script src="../pkgdown.js"></script> <link href="../extra.css" rel="stylesheet"> <meta property="og:title" content="score_check — score_check" /> <meta property="og:description" content="Used to error check scores after addition of new data by comparing current scores to a previous commit. Outputs are saved in a file within the github repository called &quot;check scores&quot;. Outputs include 1) an interactive html plot to examine the change (current score minus previous score) in all score dimensions (status, trend, resilience, pressure, future) across all goals/subgoals; 2) a static png plot of the interactive html plot; 3) a csv file with the current and previous scores; 4) a comparison of the NA scores" /> <meta name="twitter:card" content="summary" /> <!-- mathjax --> <script src='https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container template-reference-topic"> <header> <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">OHICORE</a> <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.2</span> </span> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li> <a href="../index.html"> <span class="fa fa-home"></span> </a> </li> <li> <a href="../articles/introduction.html"> <span class="fa fa-play-circle"></span> Introduction </a> </li> <li> <a href="../reference/index.html"> <span class="fa fa-file-code-o"></span> Reference </a> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> <span class="fa fa-newspaper-o"></span> Articles <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> <li> <a href="../articles/dataprep.html">Data for the Toolbox</a> </li> <li> <a href="../articles/ecosystem.html">Toolbox Ecosystem</a> </li> <li> <a href="../articles/workflow.html">Workflow</a> </li> <li> <a href="../articles/functionsR.html">functions.R</a> </li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="../articles/faq.html"> <span class="fa fa-question-circle-o"></span> FAQ </a> </li> <li> <a href="https://github.com/OHI-Science/ohicore"> <span class="fa fa-github"></span> github </a> </li> </ul> </div><!--/.nav-collapse --> </div><!--/.container --> </div><!--/.navbar --> </header> <div class="row"> <div class="col-md-9 contents"> <div class="page-header"> <h1>score_check</h1> <small class="dont-index">Source: <a href='https://github.com/OHI-Science/ohicore/blob/master/R/score_check.R'><code>R/score_check.R</code></a></small> <div class="hidden name"><code>score_check.Rd</code></div> </div> <div class="ref-description"> <p>Used to error check scores after addition of new data by comparing current scores to a previous commit. Outputs are saved in a file within the github repository called "check scores". Outputs include 1) an interactive html plot to examine the change (current score minus previous score) in all score dimensions (status, trend, resilience, pressure, future) across all goals/subgoals; 2) a static png plot of the interactive html plot; 3) a csv file with the current and previous scores; 4) a comparison of the NA scores</p> </div> <pre class="usage"><span class='fu'>score_check</span>(<span class='no'>scenario_year</span>, <span class='kw'>commit</span> <span class='kw'>=</span> <span class='st'>"previous"</span>, <span class='no'>file_name</span>, <span class='kw'>save_csv</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>save_png</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>NA_compare</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</pre> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <table class="ref-arguments"> <colgroup><col class="name" /><col class="desc" /></colgroup> <tr> <th>scenario_year</th> <td><p>if there are multiple scenario years with an assessment, choose the year of interest</p></td> </tr> <tr> <th>commit</th> <td><p>commit that the current scores are compared to ('previous' for last commit or 7 digit SHA, e.g., '4da6b4a')</p></td> </tr> <tr> <th>file_name</th> <td><p>descriptive name used to save file outputs</p></td> </tr> <tr> <th>save_csv</th> <td><p>TRUE/FALSE, to save a csv file of the data</p></td> </tr> <tr> <th>save_png</th> <td><p>TRUE/FALSE, save static png file of interactive plot</p></td> </tr> <tr> <th>NA_compare</th> <td><p>TRUE/FALSE, compares the NA values between the datasets</p></td> </tr> </table> <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> <p>Returns an interactive html plot of the change in scores (current score - previous score) for all score dimensions and goals/subgoals. Other outputs can also be saved. #'</p> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <pre class="examples"># NOT RUN { # } </pre> </div> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <h2>Contents</h2> <ul class="nav nav-pills nav-stacked"> <li><a href="#arguments">Arguments</a></li> <li><a href="#value">Value</a></li> <li><a href="#examples">Examples</a></li> </ul> </div> </div> <footer> <div class="copyright"> <p>Developed by Melanie Frazier, Ben Best, Julia Stewart Lowndes, Casey O'Hara, Jamie Afflerbach, Darren Hardy, Ellie Campbell.</p> </div> <div class="pkgdown"> <p>Site built with <a href="http://pkgdown.r-lib.org/">pkgdown</a>.</p> </div> </footer> </div> </body> </html>
OHI-Science/ohicore
docs/reference/score_check.html
HTML
gpl-2.0
8,380
#include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> #include <asm/io.h> #define FLASH_ADDR 0x40000000 #define FLASH_SIZE 0x00800000 #define FLASH_BANK_MAX 4 // trivial struct to describe partition information struct mtd_part_def { int nums; unsigned char *type; struct mtd_partition* mtd_part; }; //static struct mtd_info *mymtd; static struct mtd_info* mtd_banks[FLASH_BANK_MAX]; static struct map_info* map_banks[FLASH_BANK_MAX]; static struct mtd_part_def part_banks[FLASH_BANK_MAX]; static unsigned long num_banks; static void __iomem *start_scan_addr; #ifdef CONFIG_MTD_PARTITIONS /* Currently, TQM8xxL has upto 8MiB flash */ static unsigned long tqm8xxl_max_flash_size = 0x00800000; static struct mtd_partition tqm8xxl_partitions[] = { { .name = "ppcboot", .offset = 0x00000000, .size = 0x00020000, /* 128KB */ .mask_flags = MTD_WRITEABLE, /* force read-only */ }, { .name = "kernel", /* default kernel image */ .offset = 0x00020000, .size = 0x000e0000, .mask_flags = MTD_WRITEABLE, /* force read-only */ }, { .name = "user", .offset = 0x00100000, .size = 0x00100000, }, { .name = "initrd", .offset = 0x00200000, .size = 0x00200000, } }; /* partition definition for second flash bank */ static struct mtd_partition tqm8xxl_fs_partitions[] = { { .name = "cramfs", .offset = 0x00000000, .size = 0x00200000, }, { .name = "jffs", .offset = 0x00200000, .size = 0x00200000, //.size = MTDPART_SIZ_FULL, } }; #endif static int __init init_tqm_mtd(void) { int idx = 0, ret = 0; unsigned long flash_addr, flash_size, mtd_size = 0; /* pointer to TQM8xxL board info data */ bd_t *bd = (bd_t *)__res; flash_addr = bd->bi_flashstart; flash_size = bd->bi_flashsize; //request maximum flash size address space start_scan_addr = ioremap(flash_addr, flash_size); if (!start_scan_addr) { printk(KERN_WARNING "%s:Failed to ioremap address:0x%x\n", __func__, flash_addr); return -EIO; } for (idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { if(mtd_size >= flash_size) break; printk(KERN_INFO "%s: chip probing count %d\n", __func__, idx); map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); if(map_banks[idx] == NULL) { ret = -ENOMEM; /* FIXME: What if some MTD devices were probed already? */ goto error_mem; } map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); if (!map_banks[idx]->name) { ret = -ENOMEM; /* FIXME: What if some MTD devices were probed already? */ goto error_mem; } sprintf(map_banks[idx]->name, "TQM8xxL%d", idx); map_banks[idx]->size = flash_size; map_banks[idx]->bankwidth = 4; simple_map_init(map_banks[idx]); map_banks[idx]->virt = start_scan_addr; map_banks[idx]->phys = flash_addr; /* FIXME: This looks utterly bogus, but I'm trying to preserve the behaviour of the original (shown here)... map_banks[idx]->map_priv_1 = start_scan_addr + ((idx > 0) ? (mtd_banks[idx-1] ? mtd_banks[idx-1]->size : 0) : 0); */ if (idx && mtd_banks[idx-1]) { map_banks[idx]->virt += mtd_banks[idx-1]->size; map_banks[idx]->phys += mtd_banks[idx-1]->size; } //start to probe flash chips mtd_banks[idx] = do_map_probe("cfi_probe", map_banks[idx]); if (mtd_banks[idx]) { mtd_banks[idx]->owner = THIS_MODULE; mtd_size += mtd_banks[idx]->size; num_banks++; printk(KERN_INFO "%s: bank%d, name:%s, size:%dbytes \n", __func__, num_banks, mtd_banks[idx]->name, mtd_banks[idx]->size); } } /* no supported flash chips found */ if (!num_banks) { printk(KERN_NOTICE "TQM8xxL: No support flash chips found!\n"); ret = -ENXIO; goto error_mem; } #ifdef CONFIG_MTD_PARTITIONS /* * Select Static partition definitions */ part_banks[0].mtd_part = tqm8xxl_partitions; part_banks[0].type = "Static image"; part_banks[0].nums = ARRAY_SIZE(tqm8xxl_partitions); part_banks[1].mtd_part = tqm8xxl_fs_partitions; part_banks[1].type = "Static file system"; part_banks[1].nums = ARRAY_SIZE(tqm8xxl_fs_partitions); for(idx = 0; idx < num_banks ; idx++) { if (part_banks[idx].nums == 0) { printk(KERN_NOTICE "TQM flash%d: no partition info available, registering whole flash at once\n", idx); add_mtd_device(mtd_banks[idx]); } else { printk(KERN_NOTICE "TQM flash%d: Using %s partition definition\n", idx, part_banks[idx].type); add_mtd_partitions(mtd_banks[idx], part_banks[idx].mtd_part, part_banks[idx].nums); } } #else printk(KERN_NOTICE "TQM flash: registering %d whole flash banks at once\n", num_banks); for(idx = 0 ; idx < num_banks ; idx++) add_mtd_device(mtd_banks[idx]); #endif return 0; error_mem: for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { if(map_banks[idx] != NULL) { kfree(map_banks[idx]->name); map_banks[idx]->name = NULL; kfree(map_banks[idx]); map_banks[idx] = NULL; } } error: iounmap(start_scan_addr); return ret; } static void __exit cleanup_tqm_mtd(void) { unsigned int idx = 0; for(idx = 0 ; idx < num_banks ; idx++) { /* destroy mtd_info previously allocated */ if (mtd_banks[idx]) { del_mtd_partitions(mtd_banks[idx]); map_destroy(mtd_banks[idx]); } /* release map_info not used anymore */ kfree(map_banks[idx]->name); kfree(map_banks[idx]); } if (start_scan_addr) { iounmap(start_scan_addr); start_scan_addr = 0; } } module_init(init_tqm_mtd); module_exit(cleanup_tqm_mtd); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Kirk Lee <kirk@hpc.ee.ntu.edu.tw>"); MODULE_DESCRIPTION("MTD map driver for TQM8xxL boards");
luckasfb/OT_903D-kernel-2.6.35.7
kernel/drivers/mtd/maps/tqm8xxl.c
C
gpl-2.0
5,729
<?php /** * @package Extly.Library * @subpackage lib_extly - Extly Framework * * @author Prieco S.A. <support@extly.com> * @copyright Copyright (C) 2007 - 2014 Prieco, S.A. All rights reserved. * @license http://http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL * @link http://www.extly.com http://support.extly.com */ // No direct access defined('_JEXEC') or die('Restricted access'); // Load F0F if (!defined('F0F_INCLUDED')) { include_once JPATH_LIBRARIES . '/f0f/include.php'; } if (!defined('F0F_INCLUDED')) { JError::raiseError('500', 'Your Extly Framework installation is broken; please re-install. Alternatively, extract the installation archive and copy the f0f directory inside your site\'s libraries directory.'); } if (!defined('EXTLY_VERSION')) { /** * @name EXTLY_VERSION */ define('EXTLY_VERSION', '3.3.6'); // CSS Styling define('EXTLY_BASE', '3_2_0'); defined('DS') || define('DS', DIRECTORY_SEPARATOR); defined('EPATH_LIBRARY') || define('EPATH_LIBRARY', JPATH_LIBRARIES . '/extly'); defined('EJSON_START') || define('EJSON_START', '@EXTLYSTART@'); defined('EJSON_END') || define('EJSON_END', '@EXTLYEND@'); defined('EXTLY_J3') || define('EXTLY_J3', (version_compare(JVERSION, '3.0', 'gt'))); defined('EXTLY_J25') || define('EXTLY_J25', !EXTLY_J3); } JLoader::register('Extly', EPATH_LIBRARY . '/core/extly.php'); JLoader::register('ETable', EPATH_LIBRARY . '/core/etable.php'); JLoader::register('ELog', EPATH_LIBRARY . '/core/elog.php'); JLoader::register('EParameter', EPATH_LIBRARY . '/core/eparameter.php'); JLoader::register('EForm', EPATH_LIBRARY . '/form/eform.php'); JLoader::register('EHtmlGrid', EPATH_LIBRARY . '/html/egrid.php'); JLoader::register('EHtml', EPATH_LIBRARY . '/html/ehtml.php'); JLoader::register('EHtmlFormbehavior', EPATH_LIBRARY . '/html/formbehavior.php'); JLoader::register('EHtmlSelect', EPATH_LIBRARY . '/html/html/eselect.php'); JLoader::register('EExtensionHelper', EPATH_LIBRARY . '/helpers/extension.php'); JLoader::register('ExtlyModelExtensions', EPATH_LIBRARY . '/models/extensions.php'); JLoader::register('ExtlyTableExtension', EPATH_LIBRARY . '/tables/extension.php'); JLoader::register('EDbProxyHelper', EPATH_LIBRARY . '/helpers/dbproxy.php'); /** * This is the base class for the Extlyframework. * * @package Extly.Library * @subpackage lib_extly * @since 1.0 */ class Extlyframework { }
shukdelmadrij/shukdelmadrij
libraries/extly/extlyframework.php
PHP
gpl-2.0
2,432
//#include "..\kgb_arch_mfc\kgb_arch_mfcdlg.cpp" // kgb_arch_decompressDlg.cpp : implementation file // #include "stdafx.h" #include "kgb_arch_decompress.h" #include "kgb_arch_decompressDlg.h" #include "dDecompress.h" //#include "../compress/compress.cpp" #include <vector> #include <string> #include "io.h" #include "dlgPasswd.h" #include <psapi.h> #include "../zip/zipArchive.h" using namespace std; int MEM = 3; //GLOBALNE ZMIENNE DLA STATYSTYK!!! __int64 _size; __int64 _done; __int64 _size_all; __int64 _done_all; __int64 _compressed; string _filename; __int64 sTime; #define COMPRESS_PREPARING "\1" #define COMPRESS_GETTING_FILE_SIZES "\2" #define COMPRESS_SORTING "\3" #define COMPRESS_ADDING_SFX_MOD "\4" #define COMPRESS_ENCODING "\5" #define DECOMPRESS_PREPARING "\1" #define DECOMPRESS_CREATING_DIRS "\2" #define DECOMPRESS_SKIPPING "\3" //GLOBALNE ZMIENNE DLA W¥TKÓW char *archive_name; vector<string> filename; vector<string> files4decompress; char passwd[32];//256bit bool sfx_arch; void resetSettings(){ free(archive_name); filename.clear(); files4decompress.clear(); MEM = 3; _size = 0; _done = 0; _size_all = 0; _done_all = 0; sTime = 0; passwd[0] = '\0'; sfx_arch = 0; } #ifdef _DEBUG #define new DEBUG_NEW #endif dDecompress _dDecompress; void zipGetFiles(char *arch, vector<string>&filenames, vector<__int64>&filesizes){ CZipArchive zip; zip.Open(arch, CZipArchive::zipOpenReadOnly); for(int i=0;i<zip.GetCount(true);i++){ CZipFileHeader fhInfo; zip.GetFileInfo(fhInfo, i); filenames.push_back(fhInfo.GetFileName().GetBuffer()); filesizes.push_back(fhInfo.GetEffComprSize() != 0 ? __int64((float)fhInfo.GetEffComprSize()*100.0f/fhInfo.GetCompressionRatio()) : 0); } zip.Close(); } DWORD WINAPI zipDecompress(LPVOID lpParam){ _filename = DECOMPRESS_PREPARING; sTime = _time64(NULL); CZipArchive zip; vector<string>filenames; vector<__int64>filesizes; FILE *archive = fopen(archive_name, "rb"); if(!archive){ MessageBox(0, loadString(IDS_ARCHIVE_DOESNT_EXIST), "KGB Archiver", 0); return false; } fseek(archive, 0L, SEEK_END); _compressed = ftell(archive); fclose(archive); zipGetFiles(archive_name, filenames, filesizes); //char buff[123]; for(int i=0;i<filesizes.size();i++){ _size_all += filesizes[i]; /*if(filesizes[i] <= 0){ sprintf(buff, "%s %lld", filenames[i].c_str(), filesizes[i]); MessageBox(0, buff, "", 0);}*/ } /*sprintf(buff, "%lld", _size_all); MessageBox(0, buff, "", 0);*/ //MessageBox(0, "", "", 0); zip.Open(archive_name, CZipArchive::zipOpenReadOnly); for(int i=0;i<filenames.size();i++){ if(files4decompress.size() != 0){ for(int j=0;j<files4decompress.size();j++){ if(filenames[i] == files4decompress[j]){ _filename = filenames[i]; try{ zip.ExtractFile(i, ""); }catch(...){ CZipFileHeader fhInfo; zip.GetFileInfo(fhInfo, i); if(fhInfo.IsEncrypted()){ dlgPasswd dlgPass; if(dlgPass.DoModal() != IDOK){ _dDecompress.EndDialog(IDCANCEL); return false; } zip.SetPassword(dlgPass._passwd); j--; continue; } } break; } } }else{ _filename = filenames[i]; try{ zip.ExtractFile(i, ""); }catch(...){ CZipFileHeader fhInfo; zip.GetFileInfo(fhInfo, i); if(fhInfo.IsEncrypted()){ dlgPasswd dlgPass; if(dlgPass.DoModal() != IDOK){ _dDecompress.EndDialog(IDCANCEL); return false; } zip.SetPassword(dlgPass._passwd); i--; continue; } } } _done_all += filesizes[i]; } zip.Close(); return 0; } // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // Ckgb_arch_decompressDlg dialog Ckgb_arch_decompressDlg::Ckgb_arch_decompressDlg(CWnd* pParent /*=NULL*/) : CDialog(Ckgb_arch_decompressDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void Ckgb_arch_decompressDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //DDX_Control(pDX, IDC_EARCHNAME, eArchName); DDX_Control(pDX, IDC_EARCHNAME2, eDestination); DDX_Control(pDX, IDC_LIST1, lFiles); DDX_Control(pDX, IDC_CHECK1, cSelect); } BEGIN_MESSAGE_MAP(Ckgb_arch_decompressDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2) // ON_BN_CLICKED(IDC_BBROWSE, OnBnClickedBbrowse) ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1) ON_BN_CLICKED(IDC_BBROWSE2, OnBnClickedBbrowse2) ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1) // ON_EN_CHANGE(IDC_EARCHNAME, OnEnChangeEarchname) END_MESSAGE_MAP() // Ckgb_arch_decompressDlg message handlers BOOL Ckgb_arch_decompressDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon //SetIcon(m_hIcon, TRUE); // Set small icon // TODO: Add extra initialization here lFiles.InsertColumn(0, loadString(IDS_FILE), LVCFMT_LEFT, 300); lFiles.InsertColumn(1, loadString(IDS_SIZE), LVCFMT_RIGHT, 100); char curDir[MAX_PATH]; GetCurrentDirectory(MAX_PATH, curDir); eDestination.SetWindowText(curDir); vector<string>files; vector<__int64>fsize; char arch[MAX_PATH]; HANDLE hProc = GetCurrentProcess(); HMODULE hMod; DWORD cbNeeded; EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleFileNameEx(hProc, hMod, arch, MAX_PATH); //pierwszy modu³ jest aplikacj¹ //MessageBox(""); //getFilesFromArchive(arch, files, fsize); zipGetFiles(arch, files, fsize); //MessageBox(""); for(unsigned long i=0;i<files.size();i++){ char buffer[32]; /*if(filesizes[i] < 1024) sprintf(buffer, "%dB", filesizes[i]); else if(filesizes[i] < 1024*1024) sprintf(buffer, "%dKB", filesizes[i]/1024); else sprintf(buffer, "%dMB", filesizes[i]/1024/1024); */ sprintf(buffer, "%.1fKB", (double)fsize[i]/1024.0); lFiles.InsertItem(0, i, 0, 0, 0, 0, 0); lFiles.SetItemText(i, 0, files[i].c_str()); lFiles.SetItemText(i, 1, buffer); } return TRUE; // return TRUE unless you set the focus to a control } void Ckgb_arch_decompressDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void Ckgb_arch_decompressDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR Ckgb_arch_decompressDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void Ckgb_arch_decompressDlg::OnBnClickedButton2() { EndDialog(IDCANCEL); } DWORD WINAPI updateForm(LPVOID lpParam){ char buffer[1024]; unsigned __int64 time_sTime; unsigned __int64 temp; while(1){ try{ if(_size_all != 0 && /*_size != 0 && _done != 0 && _done_all != 0 && */_dDecompress.m_hWnd != NULL){ sprintf(buffer, "%s %.1f%%", loadString(IDS_DECOMPRESS_PROGRESS), (float)((_done_all+_done)*100)/(float)(_size_all)); _dDecompress.SetWindowText(buffer); _dDecompress.pTotal.SetRange32(0, 100); _dDecompress.pTotal.SetPos(((_done_all+_done)*100)/(_size_all)); _dDecompress.pCurrent.SetRange32(0, 100); _dDecompress.pCurrent.SetPos((_done*100)/(_size+1)); if(_filename.c_str()[0] > 32) _dDecompress.sFilename.SetWindowText(_filename.c_str()); else _dDecompress.sFilename.SetWindowText(loadString(IDS_DECOMPRESS_STATUS+_filename.c_str()[0]-1)); sprintf(buffer, "%.1fKB", (float)_size_all/1024.0); _dDecompress.sFullSize.SetWindowText(buffer); sprintf(buffer, "%.1fKB", (float)_compressed/1024.0); _dDecompress.sCompressedSize.SetWindowText(buffer); sprintf(buffer, "%.1f%%", ((float)_compressed*100.0)/(float)(_size_all)); _dDecompress.sRatio.SetWindowText(buffer); time_sTime = time(NULL)-sTime; if((temp = time_sTime/3600) < 10) sprintf(buffer, "0"); sprintf(buffer, "%s%ld:", buffer, temp); if((temp = (time_sTime%3600)/60) < 10) sprintf(buffer, "%s0", buffer); sprintf(buffer, "%s%ld:", buffer, temp); if((temp = time_sTime%60) < 10) sprintf(buffer, "%s0", buffer); sprintf(buffer, "%s%ld", buffer, temp); _dDecompress.sTime.SetWindowText(buffer); buffer[0] = '\0'; time_sTime = (unsigned __int64)((double)time_sTime/((double)(_done+_done_all+1)/(double)(_size_all))) - time_sTime; if((temp = time_sTime/3600) < 10) sprintf(buffer, "0"); sprintf(buffer, "%s%ld:", buffer, temp); if((temp = (time_sTime%3600)/60) < 10) sprintf(buffer, "%s0", buffer); sprintf(buffer, "%s%ld:", buffer, temp); if((temp = time_sTime%60) < 10) sprintf(buffer, "%s0", buffer); sprintf(buffer, "%s%ld", buffer, temp); _dDecompress.sRemaining.SetWindowText(buffer); //_dDecompress.UpdateWindow(); //_shutdown = _dDecompress.cShutdown.GetCheck(); if(_done_all == _size_all){ _dDecompress.EndDialog(IDOK); //return 0; } } }catch(...){} Sleep(500); } free(buffer); return 0; } void Ckgb_arch_decompressDlg::OnBnClickedButton1() { if(eDestination.GetWindowTextLength() == 0){ MessageBox(loadString(IDS_CHOOSE_EXTRACT_DIR), "KGB Archiver"); return; } resetSettings(); archive_name = (char *)malloc(sizeof(char)*MAX_PATH); //eArchName.GetWindowText(archive_name, MAX_PATH); HANDLE hProc = GetCurrentProcess(); HMODULE hMod; DWORD cbNeeded; EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleFileNameEx(hProc, hMod, archive_name, MAX_PATH); //pierwszy modu³ jest aplikacj¹ if(_access(archive_name, 4) != 0){ MessageBox(loadString(IDS_ARCHIVE_NOT_FOUND), "KGB Archiver"); return; } char buffer[MAX_PATH]; eDestination.GetWindowText(buffer, MAX_PATH); CreateDirectory(buffer, NULL); if(!SetCurrentDirectory(buffer)){ MessageBox(loadString(IDS_CANT_CREATE_EXTRACT_DIR), "KGB Archiver"); return; } if(cSelect.GetCheck() == true){ if(lFiles.GetSelectedCount() == 0){ MessageBox(loadString(IDS_CHOOSE_FILES2DECOMPRESS), "KGB Archiver"); return; } POSITION i = lFiles.GetFirstSelectedItemPosition(); while(i != NULL){ //lFiles.DeleteItem(lFiles.GetNextSelectedItem(i)); //i = lFiles.GetFirstSelectedItemPosition(); char buffer[MAX_PATH]; lFiles.GetItemText(lFiles.GetNextSelectedItem(i), 0, buffer, MAX_PATH); files4decompress.push_back((string)buffer); } } ShowWindow(SW_HIDE); HANDLE hDecompress; DWORD hDecompressId; hDecompress = CreateThread(NULL, 0, zipDecompress, 0, 0, &hDecompressId); SetThreadPriority(hDecompress, THREAD_PRIORITY_LOWEST); HANDLE hUpdate; DWORD hUpdateId; hUpdate = CreateThread(NULL, 0, updateForm, 0, 0, &hUpdateId); if(_dDecompress.DoModal() == IDCANCEL){ TerminateThread(hDecompress, 0); MessageBox(loadString(IDS_EXTRACT_CANCELED), "KGB Archiver"); }else{ char buff[1024]; sprintf(buff, loadString(IDS_EXTRACT_SUCCED), (float)_size_all/1024.0, (float)_compressed/1024.0, ((float)_compressed*100.0)/(float)_size_all); MessageBox(buff, "KGB Archiver"); } TerminateThread(hUpdate, 0); EndDialog(IDOK); } void Ckgb_arch_decompressDlg::OnBnClickedBbrowse2() { BROWSEINFO bInfo; bInfo.hwndOwner = m_hWnd; bInfo.lpfn = NULL; bInfo.lParam = NULL; bInfo.lpszTitle = loadString(IDS_CHOOSE_DIR2DECOMPRESS); bInfo.pidlRoot = NULL; bInfo.ulFlags = BIF_USENEWUI | BIF_VALIDATE; bInfo.pszDisplayName = NULL;//foldername; LPITEMIDLIST pidl; if((pidl = SHBrowseForFolder(&bInfo)) != NULL){ char buff[MAX_PATH]; SHGetPathFromIDList(pidl, buff); //GetCurrentDirectory(MAX_PATH, foldername); //eDestination.SetWindowText(foldername); eDestination.SetWindowText(buff); } } void Ckgb_arch_decompressDlg::OnBnClickedCheck1() { lFiles.EnableWindow(cSelect.GetCheck()); } /*void Ckgb_arch_decompressDlg::OnEnChangeEarchname() { CString _arch; string arch; eArchName.GetWindowText(_arch); arch = _arch; vector<string> files; vector<unsigned long> filesizes; lFiles.DeleteAllItems(); if(fopen(arch.c_str(), "r") == 0) return; _fcloseall(); //dekodowanie archiwum if(arch.c_str()[arch.length()-1] == 'e' || arch.c_str()[arch.length()-1] == 'E'){ dlgPasswd dlgPass; if(dlgPass.DoModal() != IDOK){ eArchName.SetWindowText(""); return; } strcpy(passwd, dlgPass._passwd); for(int i=strlen(passwd);i<32;i++) passwd[i] = '\0'; char arch2[MAX_PATH]; //strcpy(arch2, arch.c_str()); GetTempPath(MAX_PATH, arch2); strcat(arch2, "temp.kgb"); //arch2[strlen(arch2)-1] = 'b'; aes_ctx ctx[1]; ctx->n_rnd = 0; // ensure all flags are initially set to zero ctx->n_blk = 0; aes_dec_key((const unsigned char*)passwd, 32, ctx); FILE *fin = fopen(arch.c_str(), "rb"); if(fin == 0) return; FILE *fout = fopen(arch2, "wb"); if(fout == 0) return; decfile(fin, fout, ctx, arch.c_str(), arch2); fclose(fin); fclose(fout); if(!checkArchiveFormat(arch2)){ _fcloseall(); DeleteFile(arch2); eArchName.SetWindowText(""); MessageBox("Nieprawid³owe has³o!"); return; } eArchName.SetWindowText(arch2); return; } if(!getFilesFromArchive((char *)arch.c_str(), files, filesizes)){ MessageBox("Wybrany plik nie jest prawid³owym archiwum KGB!"); eArchName.SetWindowText(""); return; } for(unsigned long i=0;i<files.size();i++){ char buffer[32]; /*if(filesizes[i] < 1024) sprintf(buffer, "%dB", filesizes[i]); else if(filesizes[i] < 1024*1024) sprintf(buffer, "%dKB", filesizes[i]/1024); else sprintf(buffer, "%dMB", filesizes[i]/1024/1024); * / sprintf(buffer, "%.1fKB", (double)filesizes[i]/1024.0); lFiles.InsertItem(0, i, 0, 0, 0, 0, 0); lFiles.SetItemText(i, 0, files[i].c_str()); lFiles.SetItemText(i, 1, buffer); } }*/
RandallFlagg/kgbarchiver
KGB Archiver 1/sfx/kgb_arch_sfx_zip/kgb_arch_decompressDlg.cpp
C++
gpl-2.0
15,501
#!/usr/bin/env python # -*- coding: utf-8 -*- class User(object): def __init__(self): self.first_name = None self.last_name = None self.username = None self.password = None def set_full_name(self, name): # Jaa välilyönnin mukaan pass
mtpajula/ijonmap
core/users/user.py
Python
gpl-2.0
308
/* putpwent.c */ #include "passwd.h" #ifdef L_putpwent int putpwent(pwd, f) struct passwd *pwd; FILE * f; { if (pwd == NULL || f == NULL) { errno = EINVAL; return -1; } if (fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n", pwd->pw_name, pwd->pw_passwd, pwd->pw_uid, pwd->pw_gid, pwd->pw_gecos, pwd->pw_dir, pwd->pw_shell) < 0) return -1; return 0; } #endif 
marioaugustorama/uzix-libc
LIBC/PUTPWENT.C
C++
gpl-2.0
402
# UPDATE THIS SECRET INFORMATION ! # # UNCOMMENT THIS FILE IN .gitignore BEFORE YOU COMMIT! # # SuperUser Default Password SUPER_USER_PASSWORD = 'CHANGEME' # Log into your Loggly account, visit: https://<Username>.loggly.com/tokens and copy the token here LOGGLY_TOKEN = 'CHANGEME' # Generate a very secure Django Secret to replace this one DJANGO_SECRET = 'CHANGEME' # OPTIONAL # # Replace the following with a copy of your environment variables if you wish to run the code locally # THe variables will only be available after you first deploy an app to Bluemix, whether the deployment succeeds or not. LOCALDEV_VCAP = { "cloudamqp": [ { "name": "CloudAMQP-sa", "label": "cloudamqp", "plan": "lemur", "credentials": { "uri": "amqp://CHANGEME:CHANGEME/CHANGEME", "http_api_uri": "https://CHANGEME:CHANGEME/api/" } } ], "user-provided": [ { "name": "PostgreSQL by Compose-lj", "label": "user-provided", "credentials": { "username": "CHANGEME", "password": "CHANGEME", "public_hostname": "localhost:5432" } } ] }
Chaffleson/blupy
settings_local.py
Python
gpl-2.0
1,195
/* * This file is part of the AshamaneCore Project. See AUTHORS file for Copyright information * Copyright (C) 2018+ MagicStormProject <https://github.com/MagicStormTeam> * * 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, see <http://www.gnu.org/licenses/>. */ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "ScriptedCreature.h" #include "ScriptMgr.h" #include "SpellAuras.h" #include "Player.h" #include "SpellScript.h" #include "ScriptedGossip.h" #include "InstanceScript.h" #include "antorus_the_burning_throne.h" enum Spells { SPELL_TAESHALACH_S_REACH = 243431, //SPELL_TAESHALACH_S_REACH = 245990, //SPELL_FLAME_REND = 244033, SPELL_FLAME_REND = 245463,//???? //SPELL_FLAME_REND = 254654, //SPELL_FOE_BREAKER = 244291, SPELL_FOE_BREAKER = 245458,//??? //SPELL_FOE_BREAKER = 254655, SPELL_WAKE_OF_FLAME = 244693, //SPELL_WAKE_OF_FLAME = 244736, SPELL_BURNING_RAGE = 244713, SPELL_CORRUPT_AEGIS = 244894, SPELL_SEARING_TEMPEST = 245301, //SPELL_SEARING_TEMPEST = 246014, SPELL_SCORCHING_BLAZE = 245994, SPELL_EMPOWERED_FLAME_REND = 247079, //SPELL_EMPOWERED_FLAME_REND = 255058, SPELL_RAVENOUS_BLAZE = 254452, SPELL_EMPOWERED_FOE_BREAKER = 255059, //SPELL_EMPOWERED_FOE_BREAKER = 255060, SPELL_EMPOWERED_SEARING_TEMPEST = 255061, //SPELL_EMPOWERED_SEARING_TEMPEST = 255062, SPELL_SEARING_BINDING = 255528, SPELL_TAESHALACH_TECHNIQUE = 256208, // 244688 NPC_EMBER_OF_TAESHALACH = 122532, SPELL_BLAZING_ERUPTION = 244912, SPELL_MOLTEN_REMNANTS = 245905, //SPELL_SEARING_TEMPEST = 254653, SPELL_UNENDING_BLAZE = 254695, SPELL_TITANS_ASSEMBLE_MOVIE = 254311, SPELL_FLARE = 245983 }; enum Events { // Intro EVENT_INTRO = 1, EVNET_PHASE_2 = 2, EVNET_PHASE_3 = 3, EVENT_A1 = 4, EVENT_A2 = 5, EVENT_A3 = 6, EVENT_A4 = 7 }; enum Talk { TALK_AGGRAMAR_AGGRO = 1, TALK_AGGRAMAR_DEATH = 2, TALK_AGGRAMAR_LOS = 3, TALK_AGGRAMAR_HP80 = 4, TALK_AGGRAMAR_WAKE_OF_FLAME = 5 }; enum Phases { PHASE_NORMAL, PHASE_INTRO, PHASE_1, PHASE_2, PHASE_3, PHASE_4, }; struct SpawnData { uint32 event, npcId; float X; float Y; float Z; float orientation; }; SpawnData const spawnData[] = { { EVNET_PHASE_2, NPC_EMBER_OF_TAESHALACH, -12679.456f, -2254.8264f, 2514.2646f }, { EVNET_PHASE_2, NPC_EMBER_OF_TAESHALACH, -12588.12f, -2254.8215f, 2514.6276f, 3.101369f }, { EVNET_PHASE_3, NPC_EMBER_OF_TAESHALACH, -12679.456f, -2254.8264f, 2514.2646f }, { EVNET_PHASE_3, NPC_EMBER_OF_TAESHALACH, -12588.12f, -2254.8215f, 2514.6276f, 3.101369f }, }; struct boss_aggramar : public BossAI { boss_aggramar(Creature* creature) : BossAI(creature, DATA_AGGRAMAR) { Initialize(); } void Initialize() { PhaseStatus = Phases::PHASE_INTRO; } void LoadNPC(uint32 event, const SpawnData* data) { while (data->event) { if (data->event == event) me->SummonCreature(data->npcId, Position(data->X, data->Y, data->Z, data->orientation), TEMPSUMMON_MANUAL_DESPAWN, WEEK); ++data; } } void EnterCombat(Unit* who) override { if (who->ToPlayer()) if (roll_chance_i(30)) Talk(TALK_AGGRAMAR_AGGRO); } void JustDied(Unit* killer) override { _JustDied(); instance->SetBossState(DATA_AGGRAMAR, DONE); if (killer->ToPlayer()) if (roll_chance_i(30)) Talk(TALK_AGGRAMAR_DEATH); instance->DoDelayedConversation(2000, 6127); } void DamageTaken(Unit* /*attacker*/, uint32& damage) override { if (me->HealthWillBeBelowPctDamaged(80, damage)) { PhaseStatus = PHASE_2; events.Reset(); me->GetMotionMaster()->MovePoint(1, Position(-12634.2f, -2255.2478f, 2514.2617f, 4.674f)); Talk(TALK_AGGRAMAR_HP80); DoCastSelf(SPELL_CORRUPT_AEGIS); LoadNPC(EVNET_PHASE_2, spawnData); killCount = 2; events.RescheduleEvent(EVNET_PHASE_2, 1s); } else if (me->HealthWillBeBelowPctDamaged(40, damage)) { PhaseStatus = PHASE_3; events.Reset(); me->GetMotionMaster()->MovePoint(1, Position(-12634.2f, -2255.2478f, 2514.2617f, 4.674f)); DoCastSelf(SPELL_CORRUPT_AEGIS); LoadNPC(EVNET_PHASE_3, spawnData); killCount = 2; events.RescheduleEvent(EVNET_PHASE_3, 1s); //SPELL_WAKE_OF_FLAME replace by 245983 flare Talk(7) } } void DoAction(int32 action) override { if (action == 1) { PhaseStatus = PHASE_INTRO; instance->SetBossState(DATA_AGGRAMAR, SPECIAL); events.Reset(); //events.ScheduleEvent(EVENT_INTRO_GLAIDALIS_1, 5000); } if (action == 2) { --killCount; if (killCount <= 0) { me->RemoveAurasDueToSpell(SPELL_CORRUPT_AEGIS); //events.ScheduleEvent(SPELL_FLAME_REND, 5s); //events.ScheduleEvent(SPELL_FOE_BREAKER, 5s); if(PhaseStatus<PHASE_2) events.ScheduleEvent(SPELL_WAKE_OF_FLAME, 6s); else events.ScheduleEvent(SPELL_FLARE, 6s); //events.ScheduleEvent(SPELL_BURNING_RAGE, 5s); //events.ScheduleEvent(SPELL_CORRUPT_AEGIS, 5s); //events.ScheduleEvent(SPELL_SEARING_TEMPEST, 5s); events.ScheduleEvent(SPELL_SCORCHING_BLAZE, 8s); events.ScheduleEvent(SPELL_TAESHALACH_TECHNIQUE, 60s); if (me->GetMap()->IsMythic()) { events.ScheduleEvent(SPELL_EMPOWERED_FLAME_REND, 5s); events.ScheduleEvent(SPELL_RAVENOUS_BLAZE, 5s); events.ScheduleEvent(SPELL_EMPOWERED_FOE_BREAKER, 5s); events.ScheduleEvent(SPELL_EMPOWERED_SEARING_TEMPEST, 5s); events.ScheduleEvent(SPELL_SEARING_BINDING, 5s); } } } } void ScheduleTasks() override { //Talk(0); DoCastSelf(SPELL_TAESHALACH_S_REACH); //events.ScheduleEvent(SPELL_FLAME_REND, 5s); //events.ScheduleEvent(SPELL_FOE_BREAKER, 5s); if (PhaseStatus<PHASE_2) events.ScheduleEvent(SPELL_WAKE_OF_FLAME, 6s); else events.ScheduleEvent(SPELL_FLARE, 6s); //events.ScheduleEvent(SPELL_BURNING_RAGE, 5s); //events.ScheduleEvent(SPELL_CORRUPT_AEGIS, 5s); //events.ScheduleEvent(SPELL_SEARING_TEMPEST, 5s); events.ScheduleEvent(SPELL_SCORCHING_BLAZE, 8s); events.ScheduleEvent(SPELL_TAESHALACH_TECHNIQUE, 60s); if (me->GetMap()->IsMythic()) { events.ScheduleEvent(SPELL_EMPOWERED_FLAME_REND, 5s); events.ScheduleEvent(SPELL_RAVENOUS_BLAZE, 5s); events.ScheduleEvent(SPELL_EMPOWERED_FOE_BREAKER, 5s); events.ScheduleEvent(SPELL_EMPOWERED_SEARING_TEMPEST, 5s); events.ScheduleEvent(SPELL_SEARING_BINDING, 5s); } } void ExecuteEvent(uint32 eventId) override { switch (eventId) { case SPELL_WAKE_OF_FLAME: { Talk(TALK_AGGRAMAR_WAKE_OF_FLAME); DoCast(SPELL_WAKE_OF_FLAME); events.Repeat(25s); break; } case SPELL_FLARE: { if (Unit* target1 = SelectTarget(SELECT_TARGET_RANDOM, 0.0, 0.0, true)) me->CastSpell(target1, SPELL_FLARE, false); if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0.0, 0.0, true)) me->CastSpell(target2, SPELL_FLARE, false); if (Unit* target3 = SelectTarget(SELECT_TARGET_RANDOM, 0.0, 0.0, true)) me->CastSpell(target3, SPELL_FLARE, false); events.Repeat(25s); break; } case SPELL_SEARING_TEMPEST: { DoCast(SPELL_SEARING_TEMPEST); //events.Repeat(20s); break; } case SPELL_SCORCHING_BLAZE: { if (Unit* target1 = SelectTarget(SELECT_TARGET_RANDOM, 0.0, 0.0, true)) me->CastSpell(target1, SPELL_SCORCHING_BLAZE, false); if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0.0, 0.0, true)) me->CastSpell(target2, SPELL_SCORCHING_BLAZE, false); events.Repeat(8s); break; } case SPELL_TAESHALACH_TECHNIQUE: { // alexkulya: text & textemote? //Talk(2); //Talk(3); DoCast(SPELL_TAESHALACH_TECHNIQUE); events.ScheduleEvent(EVENT_A1, 1s); events.Repeat(60s); break; } case EVENT_A1: { DoCast(SPELL_FOE_BREAKER); events.ScheduleEvent(EVENT_A2, 4s); break; } case EVENT_A2: { DoCast(SPELL_FLAME_REND); DoCast(SPELL_BURNING_RAGE); events.ScheduleEvent(EVENT_A3, 4s); break; } case EVENT_A3: { DoCast(SPELL_FOE_BREAKER); events.ScheduleEvent(EVENT_A4, 4s); break; } case EVENT_A4: { DoCast(SPELL_FLAME_REND); DoCast(SPELL_BURNING_RAGE); events.ScheduleEvent(SPELL_SEARING_TEMPEST, 5s); break; } case SPELL_EMPOWERED_FLAME_REND: { DoCast(SPELL_EMPOWERED_FLAME_REND); events.Repeat(5s); break; } case SPELL_RAVENOUS_BLAZE: { DoCast(SPELL_RAVENOUS_BLAZE); events.Repeat(5s); break; } case SPELL_EMPOWERED_FOE_BREAKER: { DoCast(SPELL_EMPOWERED_FOE_BREAKER); events.Repeat(5s); break; } case SPELL_EMPOWERED_SEARING_TEMPEST: { DoCast(SPELL_EMPOWERED_SEARING_TEMPEST); events.Repeat(5s); break; } case SPELL_SEARING_BINDING: { DoCast(SPELL_SEARING_BINDING); events.Repeat(5s); break; } default: break; } } void MoveInLineOfSight(Unit* who) override { if (who->IsPlayer() && me->IsWithinDist(who, 50.0f, false) && PhaseStatus == Phases::PHASE_INTRO) { PhaseStatus = Phases::PHASE_1; Talk(TALK_AGGRAMAR_LOS); me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_IMMUNE_TO_PC)); } } void JustSummoned(Creature* summon) override { BossAI::JustSummoned(summon); switch (summon->GetEntry()) { case NPC_EMBER_OF_TAESHALACH: { summon->SetFaction(me->GetFaction()); summon->GetMotionMaster()->MovePoint(1, Position(-12634.2f, -2255.2478f, 2514.2617f, 4.674f)); break; } } } uint8 PhaseStatus; uint8 killCount; }; struct npc_ember_of_taeshalach_122532 : public ScriptedAI { npc_ember_of_taeshalach_122532(Creature* creature) : ScriptedAI(creature) { } void UpdateAI(uint32 diff) override { events.Update(diff); if (!UpdateVictim()) return; } void JustDied(Unit* /*killer*/) override { if (Creature* aggramar = me->FindNearestCreature(NPC_AGGRAMAR, 50.0f, true)) aggramar->AI()->DoAction(2); DoCastSelf(SPELL_MOLTEN_REMNANTS); } void MoveInLineOfSight(Unit* who) override { if (who->GetEntry() == NPC_AGGRAMAR && me->IsWithinDist(who, 3.0f, false)) { DoCastAOE(SPELL_BLAZING_ERUPTION); me->KillSelf(); } } }; struct npc_magni_bronzebeard_128169 : public ScriptedAI { npc_magni_bronzebeard_128169(Creature* creature) : ScriptedAI(creature) { } bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) { CloseGossipMenuFor(player); player->CastSpell(player, SPELL_TITANS_ASSEMBLE_MOVIE, true); player->TeleportTo(4000, 1712, 2826.39f, -4567.94f, 291.95f, 0.02513274f); return false; } }; void AddSC_boss_aggramar() { RegisterCreatureAI(boss_aggramar); RegisterCreatureAI(npc_ember_of_taeshalach_122532); RegisterCreatureAI(npc_magni_bronzebeard_128169); }
AshamaneProject/AshamaneCore
src/server/scripts/BrokenIsles/Anthorus/boss_aggramar.cpp
C++
gpl-2.0
14,489
/* * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ package neomantic.com.sun.beans; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.util.Map; import java.util.WeakHashMap; /** * A hashtable-based cache with weak keys and weak values. * An entry in the map will be automatically removed * when its key is no longer in the ordinary use. * A value will be automatically removed as well * when it is no longer in the ordinary use. * * @since 1.7 * * @author Sergey A. Malenkov */ public final class WeakCache<K, V> { private final Map<K, Reference<V>> map = new WeakHashMap<K, Reference<V>>(); /** * Returns a value to which the specified {@code key} is mapped, * or {@code null} if this map contains no mapping for the {@code key}. * * @param key the key whose associated value is returned * @return a value to which the specified {@code key} is mapped */ public V get(K key) { Reference<V> reference = this.map.get(key); if (reference == null) { return null; } V value = reference.get(); if (value == null) { this.map.remove(key); } return value; } /** * Associates the specified {@code value} with the specified {@code key}. * Removes the mapping for the specified {@code key} from this cache * if it is present and the specified {@code value} is {@code null}. * If the cache previously contained a mapping for the {@code key}, * the old value is replaced by the specified {@code value}. * * @param key the key with which the specified value is associated * @param value the value to be associated with the specified key */ public void put(K key, V value) { if (value != null) { this.map.put(key, new WeakReference<V>(value)); } else { this.map.remove(key); } } /** * Removes all of the mappings from this cache. */ public void clear() { this.map.clear(); } }
neomantic/Android-SISC-Scheme-Eval
src/neomantic/com/sun/beans/WeakCache.java
Java
gpl-2.0
3,231
/* * Copyright (C) 2005-2017 Team Kodi * http://kodi.tv * * 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, 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 KODI; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #include "DialogNumeric.h" #include "addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h" #include "XBDateTime.h" #include "addons/AddonDll.h" #include "dialogs/GUIDialogNumeric.h" #include "utils/log.h" extern "C" { namespace ADDON { void Interface_GUIDialogNumeric::Init(AddonGlobalInterface* addonInterface) { addonInterface->toKodi->kodi_gui->dialogNumeric = static_cast<AddonToKodiFuncTable_kodi_gui_dialogNumeric*>(malloc(sizeof(AddonToKodiFuncTable_kodi_gui_dialogNumeric))); addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password = show_and_verify_new_password; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password = show_and_verify_password; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input = show_and_verify_input; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_get_time = show_and_get_time; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_get_date = show_and_get_date; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address = show_and_get_ip_address; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_get_number = show_and_get_number; addonInterface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds = show_and_get_seconds; } void Interface_GUIDialogNumeric::DeInit(AddonGlobalInterface* addonInterface) { free(addonInterface->toKodi->kodi_gui->dialogNumeric); } bool Interface_GUIDialogNumeric::show_and_verify_new_password(void* kodiBase, char** password) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } std::string str; bool bRet = CGUIDialogNumeric::ShowAndVerifyNewPassword(str); if (bRet) *password = strdup(str.c_str()); return bRet; } int Interface_GUIDialogNumeric::show_and_verify_password(void* kodiBase, const char* password, const char* heading, int retries) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return -1; } if (!password || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (password='%p', heading='%p') on addon '%s'", __FUNCTION__, password, heading, addon->ID().c_str()); return -1; } std::string pw(password); return CGUIDialogNumeric::ShowAndVerifyPassword(pw, heading, retries); } bool Interface_GUIDialogNumeric::show_and_verify_input(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!verify_in || !verify_out || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (verify_in='%p', verify_out='%p', heading='%p') on addon '%s'", __FUNCTION__, verify_in, verify_out, heading, addon->ID().c_str()); return false; } std::string str = verify_in; bool bRet = CGUIDialogNumeric::ShowAndVerifyInput(str, heading, verify_input); if (bRet) *verify_out = strdup(str.c_str()); return bRet; } bool Interface_GUIDialogNumeric::show_and_get_time(void* kodiBase, tm* time, const char* heading) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!time || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (time='%p', heading='%p') on addon '%s'", __FUNCTION__, time, heading, addon->ID().c_str()); return false; } SYSTEMTIME systemTime; CDateTime dateTime(*time); dateTime.GetAsSystemTime(systemTime); if (CGUIDialogNumeric::ShowAndGetTime(systemTime, heading)) { dateTime = systemTime; dateTime.GetAsTm(*time); return true; } return false; } bool Interface_GUIDialogNumeric::show_and_get_date(void* kodiBase, tm *date, const char *heading) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!date || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (date='%p', heading='%p') on addon '%s'", __FUNCTION__, date, heading, addon->ID().c_str()); return false; } SYSTEMTIME systemTime; CDateTime dateTime(*date); dateTime.GetAsSystemTime(systemTime); if (CGUIDialogNumeric::ShowAndGetDate(systemTime, heading)) { dateTime = systemTime; dateTime.GetAsTm(*date); return true; } return false; } bool Interface_GUIDialogNumeric::show_and_get_ip_address(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!ip_address_in || !ip_address_out || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (ip_address_in='%p', ip_address_out='%p', heading='%p') on addon '%s'", __FUNCTION__, ip_address_in, ip_address_out, heading, addon->ID().c_str()); return false; } std::string strIP = ip_address_in; bool bRet = CGUIDialogNumeric::ShowAndGetIPAddress(strIP, heading); if (bRet) *ip_address_out = strdup(strIP.c_str()); return bRet; } bool Interface_GUIDialogNumeric::show_and_get_number(void* kodiBase, const char* number_in, char** number_out, const char *heading, unsigned int auto_close_ms) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!number_in || !number_out || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (number_in='%p', number_out='%p', heading='%p') on addon '%s'", __FUNCTION__, number_in, number_out, heading, addon->ID().c_str()); return false; } std::string str = number_in; bool bRet = CGUIDialogNumeric::ShowAndGetNumber(str, heading, auto_close_ms); if (bRet) *number_out = strdup(str.c_str()); return bRet; } bool Interface_GUIDialogNumeric::show_and_get_seconds(void* kodiBase, const char* time_in, char** time_out, const char *heading) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid data", __FUNCTION__); return false; } if (!time_in || !time_out || !heading) { CLog::Log(LOGERROR, "Interface_GUIDialogNumeric::%s - invalid handler data (time_in='%p', time_out='%p', heading='%p') on addon '%s'", __FUNCTION__, time_in, time_out, heading, addon->ID().c_str()); return false; } std::string str = time_in; bool bRet = CGUIDialogNumeric::ShowAndGetSeconds(str, heading); if (bRet) *time_out = strdup(str.c_str()); return bRet; } } /* namespace ADDON */ } /* extern "C" */
ObvB/xbmc
xbmc/addons/interfaces/GUI/DialogNumeric.cpp
C++
gpl-2.0
8,182
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ use Magento\Framework\Component\ComponentRegistrar; $registrar = new ComponentRegistrar(); if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleGraphQlQueryExtension') === null) { ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleGraphQlQueryExtension', __DIR__); }
kunj1988/Magento2
dev/tests/api-functional/_files/Magento/TestModuleGraphQlQueryExtension/registration.php
PHP
gpl-2.0
420
# The set of languages for which implicit dependencies are needed: SET(CMAKE_DEPENDS_LANGUAGES "CXX" ) # The set of files for implicit dependencies of each language: SET(CMAKE_DEPENDS_CHECK_CXX "/home/adbms/mysqlsrc/mysql-5.6.21/storage/innobase/buf/buf0checksum.cc" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/CMakeFiles/innochecksum.dir/__/storage/innobase/buf/buf0checksum.cc.o" "/home/adbms/mysqlsrc/mysql-5.6.21/storage/innobase/ut/ut0crc32.cc" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/CMakeFiles/innochecksum.dir/__/storage/innobase/ut/ut0crc32.cc.o" "/home/adbms/mysqlsrc/mysql-5.6.21/storage/innobase/ut/ut0ut.cc" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/CMakeFiles/innochecksum.dir/__/storage/innobase/ut/ut0ut.cc.o" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/innochecksum.cc" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/CMakeFiles/innochecksum.dir/innochecksum.cc.o" ) SET(CMAKE_CXX_COMPILER_ID "GNU") # Preprocessor definitions for this target. SET(CMAKE_TARGET_DEFINITIONS "HAVE_CONFIG_H" "UNIV_INNOCHECKSUM" ) # Targets to which this target links. SET(CMAKE_TARGET_LINKED_INFO_FILES "/home/adbms/mysqlsrc/mysql-5.6.21/mysys/CMakeFiles/mysys.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/mysys_ssl/CMakeFiles/mysys_ssl.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/dbug/CMakeFiles/dbug.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/strings/CMakeFiles/strings.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/zlib/CMakeFiles/zlib.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/yassl/CMakeFiles/yassl.dir/DependInfo.cmake" "/home/adbms/mysqlsrc/mysql-5.6.21/extra/yassl/taocrypt/CMakeFiles/taocrypt.dir/DependInfo.cmake" ) # The include file search paths: SET(CMAKE_C_TARGET_INCLUDE_PATH "include" "zlib" "storage/ndb/include" "storage/ndb/include/util" "storage/ndb/include/ndbapi" "storage/ndb/include/portlib" "storage/ndb/include/mgmapi" "storage/innobase/include" ) SET(CMAKE_CXX_TARGET_INCLUDE_PATH ${CMAKE_C_TARGET_INCLUDE_PATH}) SET(CMAKE_Fortran_TARGET_INCLUDE_PATH ${CMAKE_C_TARGET_INCLUDE_PATH}) SET(CMAKE_ASM_TARGET_INCLUDE_PATH ${CMAKE_C_TARGET_INCLUDE_PATH})
havellay/ADBMS_ABY
extra/CMakeFiles/innochecksum.dir/DependInfo.cmake
CMake
gpl-2.0
2,189
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>PHPXRef 0.7.1 : Unnamed Project : Function Reference: show_toolbar()</title> <link rel="stylesheet" href="../sample.css" type="text/css"> <link rel="stylesheet" href="../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2> </td> </tr> </table> <!-- Generated by PHPXref 0.7.1 at Sat Nov 21 22:13:19 2015 --> <!-- PHPXref (c) 2000-2010 Gareth Watts - gareth@omnipotent.net --> <!-- http://phpxref.sourceforge.net/ --> <script src="../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <!-- ext='.html'; relbase='../'; subdir='_functions'; filename='index.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); logFunction('show_toolbar'); // --> </script> <script language="JavaScript" type="text/javascript"> if (gwGetCookie('xrefnav')=='off') document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>'); else document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>'); </script> <noscript> <p class="navlinks"> [ <a href="../nav.html" target="_top">Show Explorer</a> ] [ <a href="index.html" target="_top">Hide Navbar</a> ] </p> </noscript> [<a href="../index.html">Top level directory</a>]<br> <script language="JavaScript" type="text/javascript"> <!-- document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>'); document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">'); document.writeln('<tr><td class="searchbox-title">'); document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>'); document.writeln('<\/td><\/tr>'); document.writeln('<tr><td class="searchbox-body" id="searchbox-body">'); document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>'); document.writeln('<a class="searchbox-body" href="../_classes/index.html">Class<\/a>: '); document.writeln('<input type="text" size=10 value="" name="classname"><br>'); document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../_functions/index.html">Function<\/a>: '); document.writeln('<input type="text" size=10 value="" name="funcname"><br>'); document.writeln('<a class="searchbox-body" href="../_variables/index.html">Variable<\/a>: '); document.writeln('<input type="text" size=10 value="" name="varname"><br>'); document.writeln('<a class="searchbox-body" href="../_constants/index.html">Constant<\/a>: '); document.writeln('<input type="text" size=10 value="" name="constname"><br>'); document.writeln('<a class="searchbox-body" href="../_tables/index.html">Table<\/a>: '); document.writeln('<input type="text" size=10 value="" name="tablename"><br>'); document.writeln('<input type="submit" class="searchbox-button" value="Search">'); document.writeln('<\/form>'); document.writeln('<\/td><\/tr><\/table>'); document.writeln('<\/td><\/tr><\/table>'); // --> </script> <div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div> <h3>Function and Method Cross Reference</h3> <h2><a href="index.html#show_toolbar">show_toolbar()</a></h2> <b>Defined at:</b><ul> <li><a href="../inc/users/model/_user.funcs.php.html#show_toolbar">/inc/users/model/_user.funcs.php</a> -> <a onClick="logFunction('show_toolbar', '/inc/users/model/_user.funcs.php.source.html#l521')" href="../inc/users/model/_user.funcs.php.source.html#l521"> line 521</a></li> </ul> <b>Referenced 5 times:</b><ul> <li><a href="../default.php.html">/default.php</a> -> <a href="../default.php.source.html#l80"> line 80</a></li> <li><a href="../skins_site/access_denied.main.php.html">/skins_site/access_denied.main.php</a> -> <a href="../skins_site/access_denied.main.php.source.html#l31"> line 31</a></li> <li><a href="../skins_site/_html_header.inc.php.html">/skins_site/_html_header.inc.php</a> -> <a href="../skins_site/_html_header.inc.php.source.html#l40"> line 40</a></li> <li><a href="../skins_fallback_v5/_html_header.inc.php.html">/skins_fallback_v5/_html_header.inc.php</a> -> <a href="../skins_fallback_v5/_html_header.inc.php.source.html#l108"> line 108</a></li> <li><a href="../skins/photoalbums/_item_block.inc.php.html">/skins/photoalbums/_item_block.inc.php</a> -> <a href="../skins/photoalbums/_item_block.inc.php.source.html#l137"> line 137</a></li> </ul> <!-- A link to the phpxref site in your customized footer file is appreciated ;-) --> <br><hr> <table width="100%"> <tr><td>Generated: Sat Nov 21 22:13:19 2015</td> <td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td> </tr> </table> </body></html>
mgsolipa/b2evolution_phpxref
_functions/show_toolbar.html
HTML
gpl-2.0
5,553
/* * DAWN OF LIGHT - The first free open source DAoC server emulator * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ namespace Niflib { #if OpenTK using OpenTK; #elif SharpDX using SharpDX; #elif MonoGame using Microsoft.Xna.Framework; #endif using System; using System.IO; /// <summary> /// Class SkinData. /// </summary> public class SkinData { /// <summary> /// The transform /// </summary> public SkinTransform Transform; /// <summary> /// The bounding sphere offset /// </summary> public Vector3 BoundingSphereOffset; /// <summary> /// The bounding sphere radius /// </summary> public float BoundingSphereRadius; /// <summary> /// The unkown13 shorts /// </summary> public ushort[] Unkown13Shorts; /// <summary> /// The number vertices /// </summary> public ushort NumVertices; /// <summary> /// The vertex weights /// </summary> public SkinWeight[] VertexWeights; /// <summary> /// Initializes a new instance of the <see cref="SkinData"/> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> /// <param name="hasVertexWeights">if set to <c>true</c> [has vertex weights].</param> public SkinData(NiFile file, BinaryReader reader, bool hasVertexWeights) { this.Transform = new SkinTransform(file, reader); this.BoundingSphereOffset = reader.ReadVector3(); this.BoundingSphereRadius = reader.ReadSingle(); if (file.Version == eNifVersion.VER_20_3_0_9 && file.Header.UserVersion == 131072u) { this.Unkown13Shorts = new ushort[13]; for (int i = 0; i < 13; i++) { this.Unkown13Shorts[i] = reader.ReadUInt16(); } } this.NumVertices = reader.ReadUInt16(); if (hasVertexWeights) { this.VertexWeights = new SkinWeight[(int)this.NumVertices]; for (int j = 0; j < (int)this.NumVertices; j++) { this.VertexWeights[j] = new SkinWeight(file, reader); } } } } }
dol-leodagan/niflib.net
Niflib/SkinData.cs
C#
gpl-2.0
2,847
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package za.co.axon.monitor.config; /** * * @author aardvocate */ public class Web extends MonitorBase { public String url; }
segun/jmonit
src/za/co/axon/monitor/config/Web.java
Java
gpl-2.0
233
<?php error_reporting(E_ALL); if (!defined('DIR_KVZLIB')) { define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__)))))); } ?> // LANG::xml // Sample starts here <?php require_once DIR_KVZLIB.'/php/classes/KvzHTML.php'; $H = new KvzHTML(array( 'xml' => true, )); $cdataOpts = array('__cdata' => true); $H->setOption('echo', true); $H->xml(true, array( 'version' => '2.0', 'encoding' => 'UTF-16', )); $H->setOption('echo', false); echo $H->auth( $H->username('kvz', $cdataOpts) . $H->api_key(sha1('xxxxxxxxxxxxxxxx'), $cdataOpts) ); echo $H->users_list(true); echo $H->users(true, array('type' => 'array')); echo $H->user( $H->id(442, $cdataOpts) . $H->name('Jason Shellen', $cdataOpts) . $H->screen_name('shellen', $cdataOpts) . $H->location('iPhone: 37.889321,-122.173345', $cdataOpts) . $H->description('CEO and founder of Thing Labs, makers of Brizzly! Former Blogger/Google dude, father of two little dudes.', $cdataOpts) ); echo $H->users(false); echo $H->users_list(false); ?>
thebillkidy/desple.com
wp-content/themes/capsule/ui/lib/phpjs/ext/kvzlib/php/samples/classes/KvzHTML/sample5-xml-complex.php
PHP
gpl-2.0
1,109
from getdist import loadMCSamples,plots,covmat import numpy as np import os,fnmatch #filenames = fnmatch.filter(os.listdir("../output/chains/"),"mcmc_*.txt") #for index in range(len(filenames)): # os.rename("../output/chains/"+str(filenames[index]),"../output/chains/mcmc_final_output_"+str(index+1)+".txt") number_of_parameters = 10 samples = loadMCSamples('../output/chains/NC-run4/mcmc_final_output',settings={'ignore_rows':0.}) p = samples.getParams() samples.addDerived(np.log(1.e1**10*p.A_s),name='ln1010As',label='\ln 10^{10}A_s') samples.addDerived(np.log10(p.cs2_fld),name='logcs2fld',label='\log c_s^2') bestfit = samples.getLikeStats() means = samples.setMeans() filebestfit = open("../output/chains/bestfit.txt",'w') filemeans = open("../output/chains/means.txt",'w') for index in range(number_of_parameters) : filebestfit.write(str(bestfit.names[index].bestfit_sample)+"\n") filemeans.write(str(means[index])+"\n") filebestfit.close() filemeans.close() covariance_matrix = samples.getCov(pars=[0,1,2,10,4,5,6,11,8,9])#nparam=number_of_parameters) covariance_matrix_2 = covmat.CovMat(matrix=covariance_matrix) covariance_matrix_2.saveToFile('../output/chains/covariance_matrix.txt') print 'COVARIANCE MATRIX CREATED' exit()
wilmarcardonac/fisher-mcmc
analyzer/compute_cov.py
Python
gpl-2.0
1,275
<HTML> <!-- Mirrored from www.w3schools.com/asp/showaspcode.asp?source=demo_array by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:11:33 GMT --> <HEAD></HEAD> <FONT FACE="Verdana, Arial, Helvetica" SIZE=2> &lt;!DOCTYPE html><br>&lt;html><br>&lt;body><br><br><FONT COLOR=#ff0000>&lt;%<br>Dim famname(5),i<br>famname(0) = "Jan Egil"<br>famname(1) = "Tove"<br>famname(2) = "Hege"<br>famname(3) = "Stale"<br>famname(4) = "Kai Jim"<br>famname(5) = "Borge"<br><br>For i = 0 to 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.write(famname(i) & "&lt;br>")<br>Next<br>%&gt;</FONT><br><br>&lt;/body><br>&lt;/html><br> <!-- Mirrored from www.w3schools.com/asp/showaspcode.asp?source=demo_array by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:11:33 GMT --> </HTML>
platinhom/ManualHom
Coding/W3School/W3Schools_Offline_2015/www.w3schools.com/asp/showaspcodec454.html
HTML
gpl-2.0
787
/* * CINELERRA * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net> * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "asset.h" #include "bcsignals.h" #include "cache.h" #include "condition.h" #include "datatype.h" #include "edits.h" #include "edl.h" #include "edlsession.h" #include "file.h" #include "format.inc" #include "localsession.h" #include "mainsession.h" #include "mwindow.h" #include "overlayframe.h" #include "playabletracks.h" #include "playbackengine.h" #include "preferences.h" #include "preferencesthread.h" #include "renderengine.h" #include "strategies.inc" #include "tracks.h" #include "transportque.h" #include "units.h" #include "vedit.h" #include "vframe.h" #include "videoconfig.h" #include "videodevice.h" #include "virtualconsole.h" #include "virtualvconsole.h" #include "vmodule.h" #include "vrender.h" #include "vtrack.h" VRender::VRender(RenderEngine *renderengine) : CommonRender(renderengine) { data_type = TRACK_VIDEO; transition_temp = 0; overlayer = new OverlayFrame(renderengine->preferences->processors); input_temp = 0; vmodule_render_fragment = 0; playback_buffer = 0; session_frame = 0; asynchronous = 0; // render 1 frame at a time framerate_counter = 0; video_out = 0; render_strategy = -1; } VRender::~VRender() { if(input_temp) delete input_temp; if(transition_temp) delete transition_temp; if(overlayer) delete overlayer; } VirtualConsole* VRender::new_vconsole_object() { return new VirtualVConsole(renderengine, this); } int VRender::get_total_tracks() { return renderengine->get_edl()->tracks->total_video_tracks(); } Module* VRender::new_module(Track *track) { return new VModule(renderengine, this, 0, track); } int VRender::flash_output() { if(video_out) return renderengine->video->write_buffer(video_out, renderengine->get_edl()); else return 0; } int VRender::process_buffer(VFrame *video_out, int64_t input_position, int use_opengl) { // process buffer for non realtime int64_t render_len = 1; int reconfigure = 0; this->video_out = video_out; current_position = input_position; reconfigure = vconsole->test_reconfigure(input_position, render_len); if(reconfigure) restart_playback(); return process_buffer(input_position, use_opengl); } int VRender::process_buffer(int64_t input_position, int use_opengl) { VEdit *playable_edit = 0; int colormodel; int use_vconsole = 1; int use_brender = 0; int result = 0; int use_cache = renderengine->command->single_frame(); int use_asynchronous = renderengine->command->realtime && renderengine->get_edl()->session->video_every_frame && renderengine->get_edl()->session->video_asynchronous; const int debug = 0; // Determine the rendering strategy for this frame. use_vconsole = get_use_vconsole(&playable_edit, input_position, use_brender); if(debug) printf("VRender::process_buffer %d use_vconsole=%d\n", __LINE__, use_vconsole); // Negotiate color model colormodel = get_colormodel(playable_edit, use_vconsole, use_brender); if(debug) printf("VRender::process_buffer %d\n", __LINE__); // Get output buffer from device if(renderengine->command->realtime && !renderengine->is_nested) { renderengine->video->new_output_buffer(&video_out, colormodel); } if(debug) printf("VRender::process_buffer %d video_out=%p\n", __LINE__, video_out); // printf("VRender::process_buffer use_vconsole=%d colormodel=%d video_out=%p\n", // use_vconsole, // colormodel, // video_out); // Read directly from file to video_out if(!use_vconsole) { if(use_brender) { Asset *asset = renderengine->preferences->brender_asset; File *file = renderengine->get_vcache()->check_out(asset, renderengine->get_edl()); if(file) { int64_t corrected_position = current_position; if(renderengine->command->get_direction() == PLAY_REVERSE) corrected_position--; // Cache single frames only if(use_asynchronous) file->start_video_decode_thread(); else file->stop_video_thread(); if(use_cache) file->set_cache_frames(1); int64_t normalized_position = (int64_t)(corrected_position * asset->frame_rate / renderengine->get_edl()->session->frame_rate); file->set_video_position(normalized_position, 0); file->read_frame(video_out); if(use_cache) file->set_cache_frames(0); renderengine->get_vcache()->check_in(asset); } } else if(playable_edit) { if(debug) printf("VRender::process_buffer %d\n", __LINE__); result = ((VEdit*)playable_edit)->read_frame(video_out, current_position, renderengine->command->get_direction(), renderengine->get_vcache(), 1, use_cache, use_asynchronous); if(debug) printf("VRender::process_buffer %d\n", __LINE__); } video_out->set_opengl_state(VFrame::RAM); } else // Read into virtual console { // process this buffer now in the virtual console result = ((VirtualVConsole*)vconsole)->process_buffer(input_position, use_opengl); } return result; } // Determine if virtual console is needed int VRender::get_use_vconsole(VEdit* *playable_edit, int64_t position, int &use_brender) { *playable_edit = 0; // Background rendering completed if((use_brender = renderengine->brender_available(position, renderengine->command->get_direction())) != 0) return 0; // Descend into EDL nest return renderengine->get_edl()->get_use_vconsole(playable_edit, position, renderengine->command->get_direction(), vconsole->playable_tracks); } int VRender::get_colormodel(VEdit *playable_edit, int use_vconsole, int use_brender) { int colormodel = renderengine->get_edl()->session->color_model; if(!use_vconsole && !renderengine->command->single_frame()) { // Get best colormodel supported by the file int driver = renderengine->config->vconfig->driver; File *file; Asset *asset; if(use_brender) { asset = renderengine->preferences->brender_asset; } else { int64_t source_position = 0; asset = playable_edit->get_nested_asset(&source_position, current_position, renderengine->command->get_direction()); } if(asset) { file = renderengine->get_vcache()->check_out(asset, renderengine->get_edl()); if(file) { colormodel = file->get_best_colormodel(driver); renderengine->get_vcache()->check_in(asset); } } } return colormodel; } void VRender::run() { int reconfigure; const int debug = 0; // Want to know how many samples rendering each frame takes. // Then use this number to predict the next frame that should be rendered. // Be suspicious of frames that render late so have a countdown // before we start dropping. int64_t current_sample, start_sample, end_sample; // Absolute counts. int64_t skip_countdown = VRENDER_THRESHOLD; // frames remaining until drop int64_t delay_countdown = VRENDER_THRESHOLD; // Frames remaining until delay // Number of frames before next reconfigure int64_t current_input_length; // Number of frames to skip. int64_t frame_step = 1; int use_opengl = (renderengine->video && renderengine->video->out_config->driver == PLAYBACK_X11_GL); first_frame = 1; // Number of frames since start of rendering session_frame = 0; framerate_counter = 0; framerate_timer.update(); start_lock->unlock(); if(debug) printf("VRender::run %d\n", __LINE__); while(!done && !interrupt ) { // Perform the most time consuming part of frame decompression now. // Want the condition before, since only 1 frame is rendered // and the number of frames skipped after this frame varies. current_input_length = 1; reconfigure = vconsole->test_reconfigure(current_position, current_input_length); if(debug) printf("VRender::run %d\n", __LINE__); if(reconfigure) restart_playback(); if(debug) printf("VRender::run %d\n", __LINE__); process_buffer(current_position, use_opengl); if(debug) printf("VRender::run %d\n", __LINE__); if(renderengine->command->single_frame()) { if(debug) printf("VRender::run %d\n", __LINE__); flash_output(); frame_step = 1; done = 1; } else // Perform synchronization { // Determine the delay until the frame needs to be shown. current_sample = (int64_t)(renderengine->sync_position() * renderengine->command->get_speed()); // latest sample at which the frame can be shown. end_sample = Units::tosamples(session_frame, renderengine->get_edl()->session->sample_rate, renderengine->get_edl()->session->frame_rate); // earliest sample by which the frame needs to be shown. start_sample = Units::tosamples(session_frame - 1, renderengine->get_edl()->session->sample_rate, renderengine->get_edl()->session->frame_rate); if(first_frame || end_sample < current_sample) { // Frame rendered late or this is the first frame. Flash it now. //printf("VRender::run %d\n", __LINE__); flash_output(); if(renderengine->get_edl()->session->video_every_frame) { // User wants every frame. frame_step = 1; } else if(skip_countdown > 0) { // Maybe just a freak. frame_step = 1; skip_countdown--; } else { // Get the frames to skip. delay_countdown = VRENDER_THRESHOLD; frame_step = 1; frame_step += (int64_t)Units::toframes(current_sample, renderengine->get_edl()->session->sample_rate, renderengine->get_edl()->session->frame_rate); frame_step -= (int64_t)Units::toframes(end_sample, renderengine->get_edl()->session->sample_rate, renderengine->get_edl()->session->frame_rate); } } else { // Frame rendered early or just in time. frame_step = 1; if(delay_countdown > 0) { // Maybe just a freak delay_countdown--; } else { skip_countdown = VRENDER_THRESHOLD; if(start_sample > current_sample) { int64_t delay_time = (int64_t)((float)(start_sample - current_sample) * 1000 / renderengine->get_edl()->session->sample_rate); if( delay_time > 1000 ) delay_time = 1000; timer.delay(delay_time); } else { // Came after the earliest sample so keep going } } // Flash frame now. //printf("VRender::run %d " _LD "\n", __LINE__, current_input_length); flash_output(); } } if(debug) printf("VRender::run %d\n", __LINE__); // Trigger audio to start if(first_frame) { renderengine->first_frame_lock->unlock(); first_frame = 0; renderengine->reset_sync_position(); } if(debug) printf("VRender::run %d\n", __LINE__); session_frame += frame_step; // advance position in project current_input_length = frame_step; // Subtract frame_step in a loop to allow looped playback to drain // printf("VRender::run %d %d %d %d\n", // __LINE__, // done, // frame_step, // current_input_length); while(frame_step && current_input_length) { // trim current_input_length to range get_boundaries(current_input_length); // advance 1 frame advance_position(current_input_length); frame_step -= current_input_length; current_input_length = frame_step; if(done) break; // printf("VRender::run %d %d %d %d\n", // __LINE__, // done, // frame_step, // current_input_length); } if(debug) printf("VRender::run %d current_position=" _LD " done=%d\n", __LINE__, current_position, done); // Update tracking. if(renderengine->command->realtime && renderengine->playback_engine && renderengine->command->command != CURRENT_FRAME) { renderengine->playback_engine->update_tracking(fromunits(current_position)); } if(debug) printf("VRender::run %d\n", __LINE__); // Calculate the framerate counter framerate_counter++; if(framerate_counter >= renderengine->get_edl()->session->frame_rate && renderengine->command->realtime) { renderengine->update_framerate((float)framerate_counter / ((float)framerate_timer.get_difference() / 1000)); framerate_counter = 0; framerate_timer.update(); } if(debug) printf("VRender::run %d done=%d\n", __LINE__, done); if( !interrupt ) interrupt = renderengine->video->interrupt; } // In case we were interrupted before the first loop renderengine->first_frame_lock->unlock(); stop_plugins(); if(debug) printf("VRender::run %d done=%d\n", __LINE__, done); } int VRender::start_playback() { // start reading input and sending to vrenderthread // use a thread only if there's a video device if(renderengine->command->realtime) { start(); } return 0; } int64_t VRender::tounits(double position, int round) { if(round) return Units::round(position * renderengine->get_edl()->session->frame_rate); else return Units::to_int64(position * renderengine->get_edl()->session->frame_rate); } double VRender::fromunits(int64_t position) { return (double)position / renderengine->get_edl()->session->frame_rate; }
triceratops1/cinelerra
cinelerra-4.6/cinelerra-4.6.mod/cinelerra/vrender.C
C++
gpl-2.0
13,523
import os from core import aleinst CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) class Formula(): def __init__(self, request): self.request = request def search(self): package = aleinst.Aleinst(request=self.request[0:]) package.search() def main(self): self.search()
darker0n/ale
core/Formula/install.py
Python
gpl-2.0
326
/** ****************************************************************************** * @file GPIO/GPIO_IOToggle/Src/main.c * @author MCD Application Team * @version V1.2.2 * @date 09-October-2015 * @brief This example describes how to configure and use GPIOs through * the STM32F4xx HAL API. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2015 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F4xx_HAL_Examples * @{ */ /** @addtogroup GPIO_IOToggle * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static GPIO_InitTypeDef GPIO_InitStruct; /* Private function prototypes -----------------------------------------------*/ static void SystemClock_Config(void); static void Error_Handler(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program * @param None * @retval None */ int main(void) { /* This sample code shows how to use STM32F4xx GPIO HAL API to toggle PA05 IOs connected to LED2 on STM32F4xx-Nucleo board in an infinite loop. To proceed, 3 steps are required: */ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 84 MHz */ SystemClock_Config(); /* -1- Enable GPIOA Clock (to be able to program the configuration registers) */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* -2- Configure PA05 IO in output push-pull mode to drive external LED */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* -3- Toggle PA05 IO in an infinite loop */ while (1) { HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); /* Insert delay 100 ms */ HAL_Delay(100); } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSI) * SYSCLK(Hz) = 84000000 * HCLK(Hz) = 84000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSI Frequency(Hz) = 16000000 * PLL_M = 16 * PLL_N = 336 * PLL_P = 4 * PLL_Q = 7 * VDD(V) = 3.3 * Main regulator output voltage = Scale2 mode * Flash Latency(WS) = 2 * @param None * @retval None */ static void SystemClock_Config(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); /* Enable HSI Oscillator and activate PLL with HSI as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = 0x10; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 7; if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { while(1) { } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
kamfor/STMF4
STM/Projects/STM32F401RE-Nucleo/Examples/GPIO/GPIO_IOToggle/Src/main.c
C
gpl-2.0
7,685
package com.austinv11.peripheralsplusplus.capabilities.nano; import net.minecraft.entity.Entity; import javax.annotation.Nullable; import java.util.UUID; /** * Capability interface for entities that will hold nano bots */ public interface NanoBotHolder { /** * Get the bots the entity is infested with * @return number of bots on entity */ int getBots(); /** * Set the bots on an entity * @param bots number of bots to set on the entity */ void setBots(int bots); /** * Set the antenna UUID the item is registered to * @param antennaIdentifier antenna UUID */ void setAntenna(UUID antennaIdentifier); /** * Get the registered antenna id * @return antenna UUID */ @Nullable UUID getAntenna(); /** * Get the entity that this capability is handling * @return the entity that the bots are attached to */ @Nullable Entity getEntity(); /** * Sets the entity that the bots are attached to * If there is no entity set the entity will not be registered with the antenna registry on (re)load. * This should be set on the {@link net.minecraftforge.event.AttachCapabilitiesEvent<Entity>} event * @param entity entity the bots are on */ void setEntity(Entity entity); }
rolandoislas/PeripheralsPlusPlus
src/main/java/com/austinv11/peripheralsplusplus/capabilities/nano/NanoBotHolder.java
Java
gpl-2.0
1,324
<!DOCTYPE html> <html lang="en-US"> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_mistakes_return_4 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:36:14 GMT --> <head> <title>Tryit Editor v2.3</title> <meta id="viewport" name='viewport'> <script> (function() { if ( navigator.userAgent.match(/iPad/i) ) { document.getElementById('viewport').setAttribute("content", "width=device-width, initial-scale=0.9"); } }()); </script> <link rel="stylesheet" href="../trycss.css"> <!--[if lt IE 8]> <style> .textareacontainer, .iframecontainer {width:48%;} .textarea, .iframe {height:800px;} #textareaCode, #iframeResult {height:700px;} .menu img {display:none;} </style> <![endif]--> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','../../www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-3855518-1', 'auto'); ga('require', 'displayfeatures'); ga('send', 'pageview'); </script> <script> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); </script> <script> googletag.cmd.push(function() { googletag.defineSlot('/16833175/TryitLeaderboard', [[728, 90], [970, 90]], 'div-gpt-ad-1383036313516-0').addService(googletag.pubads()); googletag.pubads().setTargeting("content","tryjs"); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script> <script type="text/javascript"> function submitTryit() { var t=document.getElementById("textareaCode").value; t=t.replace(/=/gi,"w3equalsign"); var pos=t.search(/script/i) while (pos>0) { t=t.substring(0,pos) + "w3" + t.substr(pos,3) + "w3" + t.substr(pos+3,3) + "tag" + t.substr(pos+6); pos=t.search(/script/i); } if ( navigator.userAgent.match(/Safari/i) ) { t=escape(t); document.getElementById("bt").value="1"; } document.getElementById("code").value=t; document.getElementById("tryitform").action="tryit_view52a0.html?x=" + Math.random(); validateForm(); document.getElementById("iframeResult").contentWindow.name = "view"; document.getElementById("tryitform").submit(); } function validateForm() { var code=document.getElementById("code").value; if (code.length>8000) { document.getElementById("code").value="<h1>Error</h1>"; } } </script> <style> </style> </head> <body> <div id="ads"> <div style="position:relative;width:100%;margin-top:0px;margin-bottom:0px;"> <div style="width:974px;height:94px;position:relative;margin:0px;margin-top:5px;margin-bottom:5px;margin-right:auto;margin-left:auto;padding:0px;overflow:hidden;"> <!-- TryitLeaderboard --> <div id='div-gpt-ad-1383036313516-0' style='width:970px; height:90px;'> <script type='text/javascript'> googletag.cmd.push(function() { googletag.display('div-gpt-ad-1383036313516-0'); }); </script> </div> <div style="clear:both"></div> </div> </div> </div> <div class="container"> <div class="textareacontainer"> <div class="textarea"> <div class="headerText" style="width:auto;float:left;">Edit This Code:</div> <div class="headerBtnDiv" style="width:auto;float:right;margin-top:8px;margin-right:2.4%;"><button class="submit" type="button" onclick="submitTryit()">See Result &raquo;</button></div> <div class="textareawrapper"> <textarea autocomplete="off" class="code_input" id="textareaCode" wrap="logical" xrows="30" xcols="50"><!DOCTYPE html> <html> <body> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = myFunction(55); function myFunction(a) { var power = 10; return a * power; } </script> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_mistakes_return_4 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:36:14 GMT --> </html> </textarea> <form autocomplete="off" style="margin:0px;display:none;" action="http://www.w3schools.com/js/tryit_view.asp" method="post" target="view" id="tryitform" name="tryitform" onsubmit="validateForm();"> <input type="hidden" name="code" id="code" /> <input type="hidden" id="bt" name="bt" /> </form> </div> </div> </div> <div class="iframecontainer"> <div class="iframe"> <div class="headerText resultHeader">Result:</div> <div class="iframewrapper"> <iframe id="iframeResult" class="result_output" frameborder="0" name="view" xsrc="tryjs_mistakes_return_4.html"></iframe> </div> <div class="footerText">Try it Yourself - &copy; <a href="../index.html">w3schools.com</a></div> </div> </div> </div> <script>submitTryit()</script> </body> </html>
platinhom/ManualHom
Coding/W3School/W3Schools_Offline_2015/www.w3schools.com/js/tryit4e35.html
HTML
gpl-2.0
5,141
/* http://prismjs.com/download.html?themes=prism-dark&languages=markup+css+clike+javascript+coffeescript+css-extras+git+php+php-extras+jsx+scss+sql&plugins=line-highlight+line-numbers+show-language */ /** * prism.js Dark theme for JavaScript, CSS and HTML * Based on the slides of the talk “/Reg(exp){2}lained/” * @author Lea Verou */ code[class*="language-"], pre[class*="language-"] { color: white; text-shadow: 0 -.1em .2em black; font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; line-height: 1.5; -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; -webkit-hyphens: none; -moz-hyphens: none; -ms-hyphens: none; hyphens: none; } @media print { code[class*="language-"], pre[class*="language-"] { text-shadow: none; } } pre[class*="language-"], :not(pre) > code[class*="language-"] { background: hsl(30, 20%, 25%); } /* Code blocks */ pre[class*="language-"] { padding: 1em; margin: .5em 0; overflow: auto; border: .3em solid hsl(30, 20%, 40%); border-radius: .5em; box-shadow: 1px 1px .5em black inset; } /* Inline code */ :not(pre) > code[class*="language-"] { padding: .15em .2em .05em; border-radius: .3em; border: .13em solid hsl(30, 20%, 40%); box-shadow: 1px 1px .3em -.1em black inset; } .token.comment, .token.prolog, .token.doctype, .token.cdata { color: hsl(30, 20%, 50%); } .token.punctuation { opacity: .7; } .namespace { opacity: .7; } .token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: hsl(350, 40%, 70%); } .token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: hsl(75, 70%, 60%); } .token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string, .token.variable { color: hsl(40, 90%, 60%); } .token.atrule, .token.attr-value, .token.keyword { color: hsl(350, 40%, 70%); } .token.regex, .token.important { color: #e90; } .token.important, .token.bold { font-weight: bold; } .token.italic { font-style: italic; } .token.entity { cursor: help; } .token.deleted { color: red; } pre[data-line] { position: relative; padding: 1em 0 1em 3em; } .line-highlight { position: absolute; left: 0; right: 0; padding: inherit 0; margin-top: 1em; /* Same as .prism’s padding-top */ background: hsla(24, 20%, 50%,.08); background: -moz-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0)); background: -webkit-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0)); background: -o-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0)); background: linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0)); pointer-events: none; line-height: inherit; white-space: pre; } .line-highlight:before, .line-highlight[data-end]:after { content: attr(data-start); position: absolute; top: .4em; left: .6em; min-width: 1em; padding: 0 .5em; background-color: hsla(24, 20%, 50%,.4); color: hsl(24, 20%, 95%); font: bold 65%/1.5 sans-serif; text-align: center; vertical-align: .3em; border-radius: 999px; text-shadow: none; box-shadow: 0 1px white; } .line-highlight[data-end]:after { content: attr(data-end); top: auto; bottom: .4em; } pre.line-numbers { position: relative; padding-left: 3.8em; counter-reset: linenumber; } pre.line-numbers > code { position: relative; } .line-numbers .line-numbers-rows { position: absolute; pointer-events: none; top: 0; font-size: 100%; left: -3.8em; width: 3em; /* works for line-numbers below 1000 lines */ letter-spacing: -1px; border-right: 1px solid #999; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .line-numbers-rows > span { pointer-events: none; display: block; counter-increment: linenumber; } .line-numbers-rows > span:before { content: counter(linenumber); color: #999; display: block; padding-right: 0.8em; text-align: right; } pre[class*='language-'] { position: relative; } pre[class*='language-'][data-language]::before { content: attr(data-language); color: black; background-color: #CFCFCF; display: inline-block; position: absolute; top: 0; right: 0; font-size: 0.9em; border-radius: 0 0 0 5px; padding: 0 0.5em; text-shadow: none; }
mgratch/gravity-forms-slides
wp-content/themes/wp-presenter/assets/reveal/plugin/prism/prism.css
CSS
gpl-2.0
4,712
package impl; public class StopWordsFilter { private static String stopWordsList[] = { "的", "我们", "要", "自己", "之", "将", "“", "”", ",", "(", ")", "后", "应", "到", "某", "后", "个", "是", "位", "新", "一", "两", "在", "中", "或", "有", "更", "好", "" };// 常用停用词 public static boolean IsStopWord(String word) { for (int i = 0; i < stopWordsList.length; ++i) { if (word.equalsIgnoreCase(stopWordsList[i])) return true; } return false; } }
kevin-ww/text.classfication
src/main/java/impl/StopWordsFilter.java
Java
gpl-2.0
536
<?php namespace Drupal\Tests\extlink\FunctionalJavascript; /** * Testing the basic functionality of External Links. * * @group Extlink */ class ExtlinkTestTarget extends ExtlinkTestBase { /** * Checks to see if extlink adds target and rel attributes. */ public function testExtlinkTarget() { // Target Enabled. $this->config('extlink.settings')->set('extlink_target', TRUE)->save(); // Login. $this->drupalLogin($this->adminUser); // Create a node with an external link. $settings = [ 'type' => 'page', 'title' => 'test page', 'body' => [ [ 'value' => '<p><a href="http://google.com">Google!</a></p>', 'format' => $this->emptyFormat->id(), ], ], ]; $node = $this->drupalCreateNode($settings); // Get the page. $this->drupalGet($node->toUrl()); $page = $this->getSession()->getPage(); $this->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/Extlink.png'); $this->assertSession()->statusCodeEquals(200); $this->assertTrue($page->hasLink('Google!')); // Test that the page has the external link span. $externalLink = $page->find('css', 'span.ext'); $this->assertTrue($externalLink->isVisible(), 'External Link Exists.'); $link = $page->findLink('Google!'); // Link should have target attribute. $this->assertTrue($link->getAttribute('target') === '_blank', 'ExtLink target attribute is not "_blank".'); // Link should have rel attribute 'noopener noreferrer' $this->assertTrue($link->getAttribute('rel') === 'noopener noreferrer' || $link->getAttribute('rel') === 'noreferrer noopener', 'ExtLink rel attribute is not "noopener noreferrer".'); } /** * Checks to see if extlink changes the target attribute */ public function testExtlinkTargetNoOverride() { // Target Enabled. $this->config('extlink.settings')->set('extlink_target', TRUE)->save(); $this->config('extlink.settings')->set('extlink_target_no_override', TRUE)->save(); // Login. $this->drupalLogin($this->adminUser); // Create a node with an external link. $settings = [ 'type' => 'page', 'title' => 'test page', 'body' => [ [ 'value' => '<p><a href="http://google.com" target="_self">Google!</a></p>', 'format' => $this->emptyFormat->id(), ], ], ]; $node = $this->drupalCreateNode($settings); // Get the page. $this->drupalGet($node->toUrl()); $page = $this->getSession()->getPage(); $this->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/Extlink.png'); $this->assertSession()->statusCodeEquals(200); $this->assertTrue($page->hasLink('Google!')); // Test that the page has the external link span. $externalLink = $page->find('css', 'span.ext'); $this->assertTrue($externalLink->isVisible(), 'External Link Exists.'); $link = $page->findLink('Google!'); // Link should have target attribute. $this->assertTrue($link->getAttribute('target') === '_self', 'ExtLink target attribute is not "_self".'); // Link should have rel attribute 'noopener noreferrer' $this->assertTrue($link->getAttribute('rel') === 'noopener noreferrer' || $link->getAttribute('rel') === 'noreferrer noopener', 'ExtLink rel attribute is not "noopener noreferrer".'); } }
dbethala/longwood-volunteers
modules/extlink/tests/src/FunctionalJavascript/ExtlinkTestTarget.php
PHP
gpl-2.0
3,385
#include <stdio.h> #include <wiringPi.h> #define SW1 7 #define SW2 0 #define DIRA 5 //indietro #define DIRB 3 //avanti #define EN 6 //enable int main(void){ printf("Prova Motori 0: Prova Avanti-Retro di un motore in DC\n"); printf("\tIn base all'inpute di due pulsanti il motore cambia verso di rotazione\n\n"); wiringPiSetup(); pinMode(SW1, INPUT); pinMode(SW2, INPUT); pinMode(DIRA, OUTPUT); pinMode(DIRB, OUTPUT); pinMode(EN, OUTPUT); printf("Fine Setup\n"); digitalWrite(DIRA, 0); digitalWrite(DIRB, 0); digitalWrite(EN, 0); while(1){ if(digitalRead(SW1)!=1 && digitalRead(SW2)==1){ digitalWrite(EN, 1); digitalWrite(DIRA, 1); digitalWrite(DIRB, 0); printf("Motore avanti\n"); delay(50); } else if(digitalRead(SW2)!=1 && digitalRead(SW1)==1){ digitalWrite(EN, 1); digitalWrite(DIRA, 0); digitalWrite(DIRB, 1); printf("Motore indietro\n"); delay(50); } else{ digitalWrite(EN, 0); if(digitalRead(SW2)!=1 && digitalRead(SW1)!=1){ printf("SW1 on && SW2 on\n"); } } delay(10); } }
AT-Lab/Prove-Motori
ProvaMotoreDC.c
C
gpl-2.0
1,079
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>{#subject|default:Wysija template}</title> <style type="text/css"> {#css} </style> </head> <body bgcolor="{#styles.html.background|color}" style="background:{#styles.html.background|color};color:{#styles.body.color|color}; font-family:'{#styles.body.family}';font-size:{#styles.body.size}px;" alink="{#styles.a.color|color}" link="{#styles.a.color|color}" text="{#styles.body.color|color}"> <span id="wysija_wrapper" style="margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; display:block;"> <table cellspacing="0" id="wysija_container" align="center" style="background:none; border:none; border-collapse:collapse; border-color:none; border-spacing:0; margin-bottom:0; margin-left:auto; margin-right:auto; margin-top:0; width:600px;" width="600" cellpadding="0"> <tr> <td style="margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"> <table cellspacing="0" id="wysija_viewbrowser" align="center" style="background:none; background-color:{#styles.html.background|color}; border-collapse: collapse; border-spacing: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; width: 600px;" width="600" cellpadding="0"><tr valign="top"><td id="wysija_viewbrowser_content" style="margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" width="600"><p style="background-color:{#styles.html.background|color};{if #styles.viewbrowser.color}color:{#styles.viewbrowser.color|color};{/if}font-family:'{#styles.viewbrowser.family}'; font-size:{#styles.viewbrowser.size}px; height:auto; padding:8px; text-align:center;">{#viewbrowser}</p></td></tr></table> {#header} <table cellspacing="0" id="wysija_body" align="center" style="background: none; background-color:{#styles.body.background|color}; border-collapse: collapse; border-spacing: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; width: 600px;" width="600" cellpadding="0"><tr valign="top"><td id="wysija_body_content" style="margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;width:600px;" width="600">{#body}</td></tr></table> {#footer} <table cellspacing="0" id="wysija_unsubscribe" align="center" style="background:none; background-color:{#styles.html.background|color}; border-collapse: collapse; border-spacing: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; width: 600px;" width="600" cellpadding="0"><tr valign="top"><td id="wysija_unsubscribe_content" style="margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" width="600"><p style="background-color:{#styles.html.background|color}; color:{#styles.unsubscribe.color|color}; font-family:Verdana; font-size:12px; height:auto; padding:8px; text-align:center;">{#unsubscribe}</p></td></tr></table> </td> </tr> </table> </span> </body> </html>
MengChih/20120828
wp-content/plugins/wysija-newsletters/tools/templates/email_v2/email_template.html
HTML
gpl-2.0
3,822
/* Theme Name: cbjck Theme URI: https://github.com/dasmaeh/cbjck3 Author: dasmaeh Author URI: http://cbjck.de/author/jan Description: A theme developed for www.cbjck.de Version: 3.3 License: GNU General Public License License URI: license.txt Tags: This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. Based on _s (underscores) by by automattic (https://github.com/automattic/_s) and using icons by: - Iconset 'iconic' by P.J. Onori (http://somerandomdude.com/work/iconic/) - Iconset 'JustVector by Alex Peattie (http://www.alexpeattie.com/projects/justvector_icons/) as font by Matian Wabbit (http://blog.martianwabbit.com/post/4344642365/justvector-social-icons-font) */
dasmaeh/cbjck3
style.css
CSS
gpl-2.0
766
<!DOCTYPE html> <html> <h1>pringles_cream_union4</h1> <p>47/51 correct and 4/51false</p><br> <img src = "../../../BVD_M01/pringles_cream_union/pringles_cream_union4.jpg" alt = "pringles_cream_union4.html" style= " width:320px;height:240px;"> <h1> Falsely compared to: </h1><br> <img src = "../../../BVD_M01/red_bull/red_bull12.jpg" alt = "BVD_M01/red_bull/red_bull12.jpg" style= " width:320px;height:240px;"> <img src = "../../../BVD_M01/red_bull/red_bull12.jpg" alt = "BVD_M01/red_bull/red_bull12.jpg" style= " width:320px;height:240px;"> <img src = "../../../BVD_M01/red_bull/red_bull12.jpg" alt = "BVD_M01/red_bull/red_bull12.jpg" style= " width:320px;height:240px;"> <img src = "../../../BVD_M01/red_bull/red_bull9.jpg" alt = "BVD_M01/red_bull/red_bull9.jpg" style= " width:320px;height:240px;"> </html>
MarcGroef/ros-vision
catkin_ws/Reports/nightrun-500-10%-all/pringles_cream_union/pringles_cream_union4.html
HTML
gpl-2.0
808
/* * common.c * * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> * Copyright (C) 2009-2012 Tomi Valkeinen * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ #include <common.h> #include <font_8x8.h> void fb_open(int fb_num, struct fb_info *fb_info) { char str[64]; int fd,tty; tty = open("/dev/tty1", O_RDWR); if(ioctl(tty, KDSETMODE, KD_GRAPHICS) == -1) fprintf(stderr, "Failed to set graphics mode on tty1\n"); sprintf(str, "/dev/fb%d", fb_num); fd = open(str, O_RDWR); ASSERT(fd >= 0); fb_info->fd = fd; IOCTL1(fd, FBIOGET_VSCREENINFO, &fb_info->var); IOCTL1(fd, FBIOGET_FSCREENINFO, &fb_info->fix); fprintf(stderr, "fb res %dx%d virtual %dx%d, line_len %d, bpp %d\n", fb_info->var.xres, fb_info->var.yres, fb_info->var.xres_virtual, fb_info->var.yres_virtual, fb_info->fix.line_length, fb_info->var.bits_per_pixel); fflush(stderr); void *ptr = mmap(0, fb_info->var.yres_virtual * fb_info->fix.line_length, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); ASSERT(ptr != MAP_FAILED); fb_info->ptr = ptr; } static void fb_clear_area(struct fb_info *fb_info, int x, int y, int w, int h) { int i = 0; int loc; char *fbuffer = (char *)fb_info->ptr; struct fb_var_screeninfo *var = &fb_info->var; struct fb_fix_screeninfo *fix = &fb_info->fix; for (i = 0; i < h; i++) { loc = (x + var->xoffset) * (var->bits_per_pixel / 8) + (y + i + var->yoffset) * fix->line_length; memset(fbuffer + loc, 0, w * var->bits_per_pixel / 8); } } static void fb_put_char(struct fb_info *fb_info, int x, int y, char c, unsigned color) { int i, j, bits, loc; unsigned char *p8; unsigned short *p16; unsigned int *p32; struct fb_var_screeninfo *var = &fb_info->var; struct fb_fix_screeninfo *fix = &fb_info->fix; unsigned short c16; unsigned r = (color >> 16) & 0xff; unsigned g = (color >> 8) & 0xff; unsigned b = (color >> 0) & 0xff; r = r * 32 / 256; g = g * 64 / 256; b = b * 32 / 256; c16 = (r << 11) | (g << 5) | (b << 0); for (i = 0; i < 8; i++) { bits = fontdata_8x8[8 * c + i]; for (j = 0; j < 8; j++) { loc = (x + j + var->xoffset) * (var->bits_per_pixel / 8) + (y + i + var->yoffset) * fix->line_length; if (loc >= 0 && loc < (int)(fix->smem_len) && ((bits >> (7 - j)) & 1)) { switch (var->bits_per_pixel) { case 8: p8 = fb_info->ptr + loc; *p8 = color; case 16: p16 = fb_info->ptr + loc; *p16 = c16; break; case 24: case 32: p32 = fb_info->ptr + loc; *p32 = color; break; } } } } } int fb_put_string(struct fb_info *fb_info, int x, int y, const char *s, int maxlen, unsigned color, int clear, int clearlen) { int i; int w = 0; if (clear) fb_clear_area(fb_info, x, y, clearlen * 8, 8); for (i = 0; i < (int)strlen(s) && i < maxlen; i++) { fb_put_char(fb_info, (x + 8 * i), y, s[i], color); w += 8; } return w; }
jadonk/beagle-tester
src/common.c
C
gpl-2.0
3,424
/* * Greenshot - a free and open source screenshot tool * Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel * * For more information see: http://getgreenshot.org/ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ * * 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 1 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.Windows.Forms; using Greenshot.IniFile; using GreenshotPlugin.Core; namespace GreenshotDropboxPlugin { /// <summary> /// Description of ImgurConfiguration. /// </summary> [IniSection("Dropbox", Description = "Greenshot Dropbox Plugin configuration")] public class DropboxPluginConfiguration : IniSection { [IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")] public OutputFormat UploadFormat; [IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")] public int UploadJpegQuality; [IniProperty("AfterUploadLinkToClipBoard", Description = "After upload send Dropbox link to clipboard.", DefaultValue = "true")] public bool AfterUploadLinkToClipBoard; [IniProperty("DropboxToken", Description = "The Dropbox token", Encrypted = true, ExcludeIfNull = true)] public string DropboxToken; [IniProperty("DropboxTokenSecret", Description = "The Dropbox token secret", Encrypted = true, ExcludeIfNull = true)] public string DropboxTokenSecret; /// <summary> /// A form for token /// </summary> /// <returns>bool true if OK was pressed, false if cancel</returns> public bool ShowConfigDialog() { DialogResult result = new SettingsForm().ShowDialog(); if (result == DialogResult.OK) { return true; } return false; } } }
BartDM/GreenshotPlugin
GreenshotDropboxPlugin/DropboxPluginConfiguration.cs
C#
gpl-2.0
2,377
# -*- coding: utf-8 -*- # # papyon - a python client library for Msn # # Copyright (C) 2009 Collabora Ltd. # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class MediaRelay(object): def __init__(self): self.username = None self.password = None self.ip = "" self.port = 0 def __repr__(self): return "<Media Relay: %s %i username=\"%s\" password=\"%s\">" % (self.ip, self.port, self.username, self.password)
Kjir/papyon
papyon/media/relay.py
Python
gpl-2.0
1,127
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 CTTC * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Authors: Nicola Baldo <nbaldo@cttc.es> * Ghada Badawy <gbadawy@gmail.com> */ #ifndef WIFI_TX_VECTOR_H #define WIFI_TX_VECTOR_H #include <list> #include "wifi-mode.h" #include "wifi-phy-common.h" #include "ns3/he-ru.h" namespace ns3 { /// HE MU specific user transmission parameters. struct HeMuUserInfo { HeRu::RuSpec ru; ///< RU specification WifiMode mcs; ///< MCS uint8_t nss; ///< number of spatial streams }; /** * This class mimics the TXVECTOR which is to be * passed to the PHY in order to define the parameters which are to be * used for a transmission. See IEEE 802.11-2016 16.2.5 "Transmit PHY", * and also 8.3.4.1 "PHY SAP peer-to-peer service primitive * parameters". * * If this class is constructed with the constructor that takes no * arguments, then the client must explicitly set the mode and * transmit power level parameters before using them. Default * member initializers are provided for the other parameters, to * conform to a non-MIMO/long guard configuration, although these * may also be explicitly set after object construction. * * When used in a infrastructure context, WifiTxVector values should be * drawn from WifiRemoteStationManager parameters since rate adaptation * is responsible for picking the mode, number of streams, etc., but in * the case in which there is no such manager (e.g. mesh), the client * still needs to initialize at least the mode and transmit power level * appropriately. * * \note the above reference is valid for the DSSS PHY only (clause * 16). TXVECTOR is defined also for the other PHYs, however they * don't include the TXPWRLVL explicitly in the TXVECTOR. This is * somewhat strange, since all PHYs actually have a * PMD_TXPWRLVL.request primitive. We decide to include the power * level in WifiTxVector for all PHYs, since it serves better our * purposes, and furthermore it seems close to the way real devices * work (e.g., madwifi). */ class WifiTxVector { public: /// map of HE MU specific user info paramters indexed by STA-ID typedef std::map <uint16_t /* staId */, HeMuUserInfo /* HE MU specific user info */> HeMuUserInfoMap; WifiTxVector (); ~WifiTxVector (); /** * Create a TXVECTOR with the given parameters. * * \param mode WifiMode * \param powerLevel transmission power level * \param preamble preamble type * \param guardInterval the guard interval duration in nanoseconds * \param nTx the number of TX antennas * \param nss the number of spatial STBC streams (NSS) * \param ness the number of extension spatial streams (NESS) * \param channelWidth the channel width in MHz * \param aggregation enable or disable MPDU aggregation * \param stbc enable or disable STBC * \param ldpc enable or disable LDPC (BCC is used otherwise) * \param bssColor the BSS color * \param length the LENGTH field of the L-SIG */ WifiTxVector (WifiMode mode, uint8_t powerLevel, WifiPreamble preamble, uint16_t guardInterval, uint8_t nTx, uint8_t nss, uint8_t ness, uint16_t channelWidth, bool aggregation, bool stbc = false, bool ldpc = false, uint8_t bssColor = 0, uint16_t length = 0); /** * Copy constructor * \param txVector the TXVECTOR to copy */ WifiTxVector (const WifiTxVector& txVector); /** * \returns whether mode has been initialized */ bool GetModeInitialized (void) const; /** * If this TX vector is associated with an SU PPDU, return the selected * payload transmission mode. If this TX vector is associated with an * MU PPDU, return the transmission mode (MCS) selected for the transmission * to the station identified by the given STA-ID. * * \param staId the station ID for HE MU * \returns the selected payload transmission mode */ WifiMode GetMode (uint16_t staId = SU_STA_ID) const; /** * Sets the selected payload transmission mode * * \param mode the payload WifiMode */ void SetMode (WifiMode mode); /** * Sets the selected payload transmission mode for a given STA ID (for HE MU only) * * \param mode * \param staId the station ID for HE MU */ void SetMode (WifiMode mode, uint16_t staId); /** * Get the modulation class specified by this TXVECTOR. * * \return the Modulation Class specified by this TXVECTOR */ WifiModulationClass GetModulationClass (void) const; /** * \returns the transmission power level */ uint8_t GetTxPowerLevel (void) const; /** * Sets the selected transmission power level * * \param powerlevel the transmission power level */ void SetTxPowerLevel (uint8_t powerlevel); /** * \returns the preamble type */ WifiPreamble GetPreambleType (void) const; /** * Sets the preamble type * * \param preamble the preamble type */ void SetPreambleType (WifiPreamble preamble); /** * \returns the channel width (in MHz) */ uint16_t GetChannelWidth (void) const; /** * Sets the selected channelWidth (in MHz) * * \param channelWidth the channel width (in MHz) */ void SetChannelWidth (uint16_t channelWidth); /** * \returns the guard interval duration (in nanoseconds) */ uint16_t GetGuardInterval (void) const; /** * Sets the guard interval duration (in nanoseconds) * * \param guardInterval the guard interval duration (in nanoseconds) */ void SetGuardInterval (uint16_t guardInterval); /** * \returns the number of TX antennas */ uint8_t GetNTx (void) const; /** * Sets the number of TX antennas * * \param nTx the number of TX antennas */ void SetNTx (uint8_t nTx); /** * If this TX vector is associated with an SU PPDU, return the number of * spatial streams. If this TX vector is associated with an MU PPDU, * return the number of spatial streams for the transmission to the station * identified by the given STA-ID. * * \param staId the station ID for HE MU * \returns the number of spatial streams */ uint8_t GetNss (uint16_t staId = SU_STA_ID) const; /** * \returns the maximum number of Nss (namely if HE MU) */ uint8_t GetNssMax (void) const; /** * Sets the number of Nss * * \param nss the number of spatial streams */ void SetNss (uint8_t nss); /** * Sets the number of Nss for HE MU * * \param nss the number of spatial streams * \param staId the station ID for HE MU */ void SetNss (uint8_t nss, uint16_t staId); /** * \returns the number of extended spatial streams */ uint8_t GetNess (void) const; /** * Sets the Ness number * * \param ness the number of extended spatial streams */ void SetNess (uint8_t ness); /** * Checks whether the PSDU contains A-MPDU. * \returns true if this PSDU has A-MPDU aggregation, * false otherwise. */ bool IsAggregation (void) const; /** * Sets if PSDU contains A-MPDU. * * \param aggregation whether the PSDU contains A-MPDU or not. */ void SetAggregation (bool aggregation); /** * Check if STBC is used or not * * \returns true if STBC is used, * false otherwise */ bool IsStbc (void) const; /** * Sets if STBC is being used * * \param stbc enable or disable STBC */ void SetStbc (bool stbc); /** * Check if LDPC FEC coding is used or not * * \returns true if LDPC is used, * false if BCC is used */ bool IsLdpc (void) const; /** * Sets if LDPC FEC coding is being used * * \param ldpc enable or disable LDPC */ void SetLdpc (bool ldpc); /** * Set the BSS color * \param color the BSS color */ void SetBssColor (uint8_t color); /** * Get the BSS color * \return the BSS color */ uint8_t GetBssColor (void) const; /** * Set the LENGTH field of the L-SIG * \param length the LENGTH field of the L-SIG */ void SetLength (uint16_t length); /** * Get the LENGTH field of the L-SIG * \return the LENGTH field of the L-SIG */ uint16_t GetLength (void) const; /** * The standard disallows certain combinations of WifiMode, number of * spatial streams, and channel widths. This method can be used to * check whether this WifiTxVector contains an invalid combination. * * \return true if the WifiTxVector parameters are allowed by the standard */ bool IsValid (void) const; /** * Return true if this TX vector is used for a multi-user transmission. * * \return true if this TX vector is used for a multi-user transmission */ bool IsMu (void) const; /** * Return true if this TX vector is used for a downlink multi-user transmission. * * \return true if this TX vector is used for a downlink multi-user transmission */ bool IsDlMu (void) const; /** * Return true if this TX vector is used for an uplink multi-user transmission. * * \return true if this TX vector is used for an uplink multi-user transmission */ bool IsUlMu (void) const; /** * Get the RU specification for the STA-ID. * This is applicable only for HE MU. * * \param staId the station ID * \return the RU specification for the STA-ID */ HeRu::RuSpec GetRu (uint16_t staId) const; /** * Set the RU specification for the STA-ID. * This is applicable only for HE MU. * * \param ru the RU specification * \param staId the station ID */ void SetRu (HeRu::RuSpec ru, uint16_t staId); /** * Get the HE MU user-specific transmission information for the given STA-ID. * This is applicable only for HE MU. * * \param staId the station ID * \return the HE MU user-specific transmission information for the given STA-ID */ HeMuUserInfo GetHeMuUserInfo (uint16_t staId) const; /** * Set the HE MU user-specific transmission information for the given STA-ID. * This is applicable only for HE MU. * * \param staId the station ID * \param userInfo the HE MU user-specific transmission information */ void SetHeMuUserInfo (uint16_t staId, HeMuUserInfo userInfo); /** * Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID. * This is applicable only for HE MU. * * \return a const reference to the map of HE MU user-specific information indexed by STA-ID */ const HeMuUserInfoMap& GetHeMuUserInfoMap (void) const; /** * Get a reference to the map HE MU user-specific transmission information indexed by STA-ID. * This is applicable only for HE MU. * * \return a reference to the map of HE MU user-specific information indexed by STA-ID */ HeMuUserInfoMap& GetHeMuUserInfoMap (void); /** * Get the number of RUs per HE-SIG-B content channel. * This is applicable only for HE MU. MU-MIMO (i.e. multiple stations * per RU) is not supported yet. * See section 27.3.10.8.3 of IEEE 802.11ax draft 4.0. * * \return a pair containing the number of RUs in each HE-SIG-B content channel (resp. 1 and 2) */ std::pair<std::size_t, std::size_t> GetNumRusPerHeSigBContentChannel (void) const; private: WifiMode m_mode; /**< The DATARATE parameter in Table 15-4. It is the value that will be passed to PMD_RATE.request */ uint8_t m_txPowerLevel; /**< The TXPWR_LEVEL parameter in Table 15-4. It is the value that will be passed to PMD_TXPWRLVL.request */ WifiPreamble m_preamble; /**< preamble */ uint16_t m_channelWidth; /**< channel width in MHz */ uint16_t m_guardInterval; /**< guard interval duration in nanoseconds */ uint8_t m_nTx; /**< number of TX antennas */ uint8_t m_nss; /**< number of spatial streams */ uint8_t m_ness; /**< number of spatial streams in beamforming */ bool m_aggregation; /**< Flag whether the PSDU contains A-MPDU. */ bool m_stbc; /**< STBC used or not */ bool m_ldpc; /**< LDPC FEC coding if true, BCC otherwise*/ uint8_t m_bssColor; /**< BSS color */ uint16_t m_length; /**< LENGTH field of the L-SIG */ bool m_modeInitialized; /**< Internal initialization flag */ //MU information HeMuUserInfoMap m_muUserInfos; /**< HE MU specific per-user information indexed by station ID (STA-ID) corresponding to the 11 LSBs of the AID of the recipient STA This list shall be used only for HE MU */ }; /** * Serialize WifiTxVector to the given ostream. * * \param os the output stream * \param v the WifiTxVector to stringify * * \return ouput stream */ std::ostream & operator << (std::ostream & os,const WifiTxVector &v); } //namespace ns3 #endif /* WIFI_TX_VECTOR_H */
Gabrielcarvfer/NS3
src/wifi/model/wifi-tx-vector.h
C
gpl-2.0
13,921
/*************************************************************************** main.cpp (c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net> 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, 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. ***************************************************************************/ #define __MAIN_CPP #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <ctype.h> #include "gb_common.h" #include "c_clipper.h" #include "main.h" extern "C" { GB_INTERFACE GB EXPORT; GEOM_INTERFACE GEOM EXPORT; GB_DESC *GB_CLASSES [] EXPORT = { PolygonDesc, ClipperDesc, NULL }; const char *GB_INCLUDE EXPORT = "gb.geom"; int EXPORT GB_INIT(void) { GB.Component.Load("gb.geom"); GB.GetInterface("gb.geom", GEOM_INTERFACE_VERSION, &GEOM); return 0; } void EXPORT GB_EXIT() { } }
justlostintime/gambas
main/lib/clipper/main.cpp
C++
gpl-2.0
1,456
using UnityEngine; using System.Collections; public class AIController : MonoBehaviour { Transform lineStart, lineEnd; GameObject healthBar; float health = 250; float maxHealth = 250; GameObject character; Stats stats; Animator animateState; // Use this for initialization void Start () { animateState = transform.gameObject.GetComponent<Animator> (); character = GameObject.Find ("Character"); stats = GameObject.Find ("Canvas").GetComponent<Stats> (); lineStart = transform.FindChild ("Start").gameObject.transform; lineEnd = transform.FindChild ("End").gameObject.transform; healthBar = new GameObject ("HealthBar"); healthBar.AddComponent<SpriteRenderer> (); healthBar.GetComponent<SpriteRenderer> ().sprite = Resources.Load ("HealthBarVisual", typeof(Sprite)) as Sprite; healthBar.transform.parent = this.transform; healthBar.transform.position = new Vector2 (transform.position.x, transform.position.y + .75f); if (transform.FindChild ("AttackSpawn") != null) { //this is a caster health = 100; maxHealth = 100; InvokeRepeating ("FireWeapon", 0, .75f); } else { //this is a knight InvokeRepeating ("Attack", 0, .75f); } } // Update is called once per frame void Update () { //if there is a character in front of this entity if (Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Player")) || Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Enemy"))) { GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, GetComponent<Rigidbody2D> ().velocity.y); } else if (Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Ground"))) { GetComponent<Rigidbody2D> ().velocity = new Vector2 (GetComponent<Rigidbody2D> ().velocity.x, 8); } else if (transform.tag == "Enemy") { GetComponent<Rigidbody2D> ().velocity = new Vector2 (-2, GetComponent<Rigidbody2D> ().velocity.y); } else { GetComponent<Rigidbody2D> ().velocity = new Vector2 (2, GetComponent<Rigidbody2D> ().velocity.y); } } public void RemoveHealth(float amount) { health -= amount; healthBar.transform.localScale = new Vector3 (health / maxHealth, 1, 1); if (health <= 0 && transform.tag == "Enemy") { stats.ChangeXP (10); stats.ChangeGold (25); GameObject gold = Instantiate (Resources.Load ("gold")) as GameObject; gold.transform.position = new Vector2 (transform.position.x, transform.position.y + .3f); GameObject xp = Instantiate (Resources.Load ("xp")) as GameObject; xp.transform.position = new Vector2 (transform.position.x, transform.position.y + .5f); Destroy (this.gameObject); } else if (health <= 0) { Destroy (this.gameObject); } } void Attack() { RaycastHit2D hit = Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Player")); if (transform.tag == "Enemy" && Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Player")) && hit.collider.transform.name == "Character") { hit.collider.transform.gameObject.GetComponent<CharacterController>().RemoveHealth(20); animateState.SetBool ("isAttacking", true); } else if (transform.tag == "Enemy" && Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Player"))) { hit.collider.transform.gameObject.GetComponent<AIController>().RemoveHealth(20); animateState.SetBool ("isAttacking", true); } else if (transform.tag == "Player" && Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Enemy"))) { hit = Physics2D.Linecast (lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer ("Enemy")); hit.collider.transform.gameObject.GetComponent<AIController>().RemoveHealth(20); animateState.SetBool ("isAttacking", true); } else { animateState.SetBool ("isAttacking", false); } } void FireWeapon() { if (transform.tag == "Enemy") { float distance = 100; Transform target = transform; bool targetFound = false; if (Vector2.Distance (this.transform.position, character.transform.position) < 10) { target = character.transform; targetFound = true; } if (!targetFound) { for(int i = 0; i < GameObject.Find ("AllySpawnLocation").transform.childCount; i++) { if (Vector2.Distance (this.transform.position, GameObject.Find ("AllySpawnLocation").transform.GetChild(i).transform.position) < 10) { if (Vector2.Distance (this.transform.position, GameObject.Find ("AllySpawnLocation").transform.GetChild(i).transform.position) < distance) { distance = Vector2.Distance (this.transform.position, GameObject.Find ("AllySpawnLocation").transform.GetChild(i).transform.position); target = GameObject.Find ("AllySpawnLocation").transform.GetChild(i).transform; targetFound = true; } } } } if (targetFound) { GameObject IceBall = Instantiate(Resources.Load("Iceball")) as GameObject; IceBall.GetComponent<IceBolt>().SetTarget = target; IceBall.transform.position = transform.FindChild ("AttackSpawn").transform.position; Vector2 direction = new Vector2 (target.position.x - IceBall.transform.position.x, target.position.y - IceBall.transform.position.y); direction.Normalize (); IceBall.GetComponent<Rigidbody2D> ().velocity = direction * 10; } } else if (transform.tag == "Player") { float distance = 100; Transform target = transform; bool targetFound = false; for(int i = 0; i < GameObject.Find ("EnemySpawnLocation").transform.childCount; i++) { if (Vector2.Distance (this.transform.position, GameObject.Find ("EnemySpawnLocation").transform.GetChild(i).transform.position) < 10) { if (Vector2.Distance (this.transform.position, GameObject.Find ("EnemySpawnLocation").transform.GetChild(i).transform.position) < distance) { distance = Vector2.Distance (this.transform.position, GameObject.Find ("EnemySpawnLocation").transform.GetChild(i).transform.position); target = GameObject.Find ("EnemySpawnLocation").transform.GetChild(i).transform; targetFound = true; } } } if (targetFound) { GameObject IceBall = Instantiate(Resources.Load("Iceball")) as GameObject; IceBall.GetComponent<IceBolt>().SetTarget = target; IceBall.transform.position = transform.FindChild ("AttackSpawn").transform.position; Vector2 direction = new Vector2 (target.position.x - IceBall.transform.position.x, target.position.y - IceBall.transform.position.y); direction.Normalize (); IceBall.GetComponent<Rigidbody2D> ().velocity = direction * 10; } } // if (Vector2.Distance (character.transform.position, transform.position) < 10) { // //attack player // GameObject IceBall = Instantiate(Resources.Load("Iceball")) as GameObject; // IceBall.GetComponent<IceBolt>().SetTarget = "Player"; // IceBall.transform.position = transform.FindChild ("AttackSpawn").transform.position; // Vector2 direction = new Vector2 (character.transform.position.x - IceBall.transform.position.x, character.transform.position.y - IceBall.transform.position.y); // direction.Normalize (); // IceBall.GetComponent<Rigidbody2D> ().velocity = direction * 10; // } } }
UCCS-GDD/CS3350-ChampionOfTheNine
ChampionsOfTheNinePrototype/Assets/Scripts/AIController.cs
C#
gpl-2.0
7,286
<?php set_include_path(get_include_path().PATH_SEPARATOR.realpath('../../includes').PATH_SEPARATOR.realpath('../../').PATH_SEPARATOR.realpath('../').PATH_SEPARATOR); $dir = realpath(getcwd()); chdir("../../"); require_once ( 'WebStart.php'); require_once( 'Wiki.php' ); chdir($dir); $userRun = $wgUser; #The user that runs this script $user1 = User::newFromName("ThomasKelder"); $user2 = User::newFromName("TestUser"); $admin = User::newFromName("Thomas"); $anon = User::newFromId(0); $page_id = Title::newFromText('WP4', NS_PATHWAY)->getArticleId(); $title = Title::newFromId($page_id); $mgr = new PermissionManager($page_id); Test::echoStart("No permissions set"); #Remove all permissions from page $mgr->clearPermissions(); ##* can read $wgUser = $anon; $can = $title->userCan("read"); Test::assert("anonymous can read", $can, true); ##* can't edit $wgUser = $anon; $can = $title->userCan('edit'); Test::assert("anonymous can't edit", $can, false); ##users can read/edit $wgUser = $user1; $can = $title->userCan("read"); Test::assert("Users can read", $can, true); $can = $title->userCan('edit'); Test::assert("Users can edit", $can, true); #Set private for user1 Test::echoStart("Setting page private for user1"); $pms = new PagePermissions($page_id); $pms->addReadWrite($user1->getId()); $pms->addManage($user1->getId()); $mgr->setPermissions($pms); ##user1 can read/write/manage $wgUser = $user1; $can = $title->userCan("read"); Test::assert("User1 can read", $can, true); $can = $title->userCan('edit'); Test::assert("User1 can edit", $can, true); $can = $title->userCan(PermissionManager::$ACTION_MANAGE); Test::assert("User1 can manage", $can, true); ##admin can read/write/manage $wgUser = $admin; $can = $title->userCan("read"); Test::assert("User1 can read", $can, true); $can = $title->userCan('edit'); Test::assert("User1 can edit", $can, true); $can = $title->userCan(PermissionManager::$ACTION_MANAGE); Test::assert("User1 can manage", $can, true); ##user2 cannot read/write/manage $wgUser = $user2; $can = $title->userCan("read"); Test::assert("User2 can't read", $can, false); $can = $title->userCan('edit'); Test::assert("User2 can't read", $can, false); $can = $title->userCan(PermissionManager::$ACTION_MANAGE); Test::assert("User2 can't manage", $can, false); ##anonymous cannot read/write/manage $wgUser = $anon; $can = $title->userCan("read"); Test::assert("Anonymous can't read", $can, false); $can = $title->userCan('edit'); Test::assert("Anonymous can't edit", $can, false); #Add user2 Test::echoStart("Add user2 to read/write users"); $wgUser = $userRun; $pms->addReadWrite($user2->getId()); $mgr->setPermissions($pms); ##user2 can read/write/manage $wgUser = $user2; $can = $title->userCan("read"); Test::assert("User2 can read", $can, true); $can = $title->userCan('edit'); Test::assert("User1 can edit", $can, true); ##user1 can still read/write/manage $wgUser = $user1; $can = $title->userCan("read"); Test::assert("User1 can still read", $can, true); $can = $title->userCan('edit'); Test::assert("User1 can still edit", $can, true); #Remove read/write permissions for user2 Test::echoStart("Setting page private for user1"); $pms->clearPermissions($user2->getId()); $mgr->setPermissions($pms); ##user1 can read/write/manage $wgUser = $user1; $can = $title->userCan("read"); Test::assert("User1 can read", $can, true); $can = $title->userCan('edit'); Test::assert("User1 can edit", $can, true); ##user2 cannot read/write/manage $wgUser = $user2; $can = $title->userCan("read"); Test::assert("User2 can't read", $can, false); $can = $title->userCan('edit'); Test::assert("User2 can't read", $can, false); #Set expiration date to past ##permissions should be removed Test::echoStart("Simulating expiration"); $wgUser = $userRun; $pms->setExpires(wfTimestamp(TS_MW) - 1); $mgr->setPermissions($pms); ##user2 can read/edit again $wgUser = $user2; $can = $title->userCan("read"); Test::assert("User2 can read again", $can, true); $can = $title->userCan('edit'); Test::assert("User2 can edit again", $can, true); class Test { static function assert($test, $value, $expected) { echo("$test: "); if($value != $expected) { $e = new Exception(); echo("\t<font color='red'>Fail!</font>: value '$value' doesn't equal expected: '$expected'" . "<BR>\n" . $e->getTraceAsString() . "<BR>\n"); } else { echo("\t<font color='green'>Pass!</font><BR>\n"); } } static function echoStart($case) { echo("<h3>Testing $case</h3>\n"); } }
hexmode/wikipathways.org
wpi/test/testPrivatePathways.php
PHP
gpl-2.0
4,499
# ==Paramerer Controller # This manages the display of a parameter # # == Copyright # Copyright © 2006 Robert Shell, Alces Ltd All Rights Reserved # See license agreement for additional rights # # class Organize::ParametersController < ApplicationController use_authorization :organization, :use => [:list,:show,:new,:create,:edit,:update,:destroy] def index list render :action => 'list' end def list @assay = Assay.load(params[:id]) @report = Biorails::ReportLibrary.parameter_list("ParameterList") end def show @parameter = Parameter.find(params[:id]) end end
rshell/biorails
app/controllers/organize/parameters_controller.rb
Ruby
gpl-2.0
632
#include <cxxtest/TestSuite.h> #include "common/stdafx.h" #include "common/list.h" class ListTestSuite : public CxxTest::TestSuite { public: void test_empty_clear( void ) { Common::List<int> container; TS_ASSERT( container.empty() ); container.push_back(17); container.push_back(33); TS_ASSERT( !container.empty() ); container.clear(); TS_ASSERT( container.empty() ); } void test_iterator_begin_end( void ) { Common::List<int> container; // The container is initially empty ... TS_ASSERT( container.begin() == container.end() ); // ... then non-empty ... container.push_back(33); TS_ASSERT( container.begin() != container.end() ); // ... and again empty. container.clear(); TS_ASSERT( container.begin() == container.end() ); } void test_iterator( void ) { Common::List<int> container; Common::List<int>::iterator iter; // Fill the container with some random data container.push_back(17); container.push_back(33); container.push_back(-11); // Iterate over the container and verify that we encounter the elements in // the order we expect them to be. iter = container.begin(); TS_ASSERT( *iter == 17 ); ++iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 33 ); ++iter; TS_ASSERT( iter != container.end() ); // Also test the postinc TS_ASSERT( *iter == -11 ); iter++; TS_ASSERT( iter == container.end() ); } void test_insert( void ) { Common::List<int> container; Common::List<int>::iterator iter; // Fill the container with some random data container.push_back(17); container.push_back(33); container.push_back(-11); // Iterate to after the second element iter = container.begin(); ++iter; ++iter; // Now insert some values here container.insert(iter, 42); container.insert(iter, 43); iter = container.begin(); TS_ASSERT( *iter == 17 ); ++iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 33 ); ++iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 42 ); ++iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 43 ); ++iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == -11 ); ++iter; TS_ASSERT( iter == container.end() ); } void test_reverse( void ) { Common::List<int> container; Common::List<int>::iterator iter; // Fill the container with some random data container.push_back(17); container.push_back(33); container.push_back(-11); iter = container.reverse_begin(); TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == -11 ); --iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 33 ); --iter; TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 17 ); --iter; TS_ASSERT( iter == container.end() ); iter = container.reverse_begin(); iter = container.reverse_erase(iter); TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 33 ); iter = container.reverse_erase(iter); TS_ASSERT( iter != container.end() ); TS_ASSERT( *iter == 17 ); iter = container.reverse_erase(iter); TS_ASSERT( iter == container.end() ); TS_ASSERT( container.begin() == container.end() ); TS_ASSERT( container.reverse_begin() == container.end() ); } };
iPodLinux-Community/iScummVM
test/common/list.h
C
gpl-2.0
3,252
<html> <body> <div style="font-family:verdana, arial, sans-serif; color:#000000;"> <table width="725" align="center" cellpadding="0" cellspacing="0" border="0" style="border:2px solid #777777;"> <tr> <td style="vertical-align:top; padding:0px;"> <table width="725" height="86" cellpadding="0" cellspacing="0" border="0" background="http://newsletters.1btest.org/images/bluepiece.png"> <tr> <td width="590" height="86"><a href="http://seattle.onebrick.org"><img src="http://newsletters.1btest.org/images/skyline-seattle.png" width="590" height="86" alt="" border="0" style="display:block;"></a></td> <td>&nbsp;</td> </tr> <tr> <td colspan="2" height="27" align="center" style="background:#f19959"> <table width="700" height="27" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="300" height="27" align="left" style="vertical-align:middle;"><span style="font-family:arial, sans-serif; font-size:14px; font-weight:bold; color:#FFFFFF;">March 8th, 2012</span></td> <td width="250" height="27">&nbsp;</td> <td width="150" height="27" align="right" style="vertical-align:middle;"> <div style="display:block;"> <a href="http://www.facebook.com/OneBrickSeattle"><img src="http://newsletters.1btest.org/images/facebook_icon.png" width="21" height="21" alt="" border="0" ></a><img src="http://newsletters.1btest.org/images/clearpix.png" width="7" height="0" alt="" border="0"><a href="http://twitter.com/OneBrickSeattle"><img src="http://newsletters.1btest.org/images/twitter_icon.png" width="21" height="21" alt="" border="0" ></a> </div> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td style="vertical-align:top;"> <table height="500" cellpadding="0" cellspacing="0" border="0" style="font-family:verdana, arial, sans-serif; color:#000000;"> <tr> <td width="500" style="font-size:12px; padding:10px; vertical-align:top;"> <span style='color:#3573a3; font-size:15px; font-weight:bold; text-transform:uppercase; padding-top:5px; padding-bottom:5px;'>News and Announcements</span><br> <p> <span style='color:#000000; font-size:14px; font-weight:bold; padding-bottom:3px;'>Calling All Non-Profits in Need! </span><br> <br />Ever wonder how One Brick Seattle establishes partnerships with area non-profits or do you know of an area non-profit in need of volunteer assistance?&nbsp;<br /><br />As a volunteer organzation dedicated to improving our local community, One Brick Seattle is always interested in partnering with new non-profits. If you know of an organization that could use a few smiling One Brick Seattle volunteers for an upcoming event, please email us with the organization&#39;s name to sea-events@onebrick.org.<br /> </p> <p> <span style='color:#000000; font-size:14px; font-weight:bold; padding-bottom:3px;'>Making a Difference One Brick at a Time!</span><br> <img alt="" src="http://i820.photobucket.com/albums/zz124/astruck1/cfb45639-4d34-45d3-aea9-e4d53c2b768d.jpg" style="width: 170px; height: 219px; margin: 3px 5px; float: right;" /><br /><br />We would like to thank each person for assisting with the One Brick annual fundraising campaign over the past few months!<br /><br />With that said, we have experienced a significant budget shortfall when a pledged foundation determined that they were unable to follow through on their previous pledge. See what One Brick Supporter, Dave Shefferman, is doing to <a href="http://www.firstgiving.com/fundraiser/OneBrickEmergency/davesheffermansfundraisingpage" style="font-weight:bold;color:#de712c; text-decoration:none;">support this continued fundraising effort</a> and learn what you can do to keep One Brick a reality across the nation and in Seattle!<br /><br /><br /><br /><br /><br /><br />&nbsp;<br /> </p> <p> <span style='color:#000000; font-size:14px; font-weight:bold; padding-bottom:3px;'>Photo Highlights!</span><br> <br /><br />Volunteers prepping food at FareStart!<br /><br /><img alt="" src="http://i820.photobucket.com/albums/zz124/astruck1/img_3728_full.jpg" style="width: 640px; height: 480px; margin: 3px 5px;" /><br /><br /><a href="http://seattle.onebrick.org/photos/" style="font-weight:bold;color:#de712c; text-decoration:none;">Click here</a> to view more One Brick Seattle photos! </p> </td> <td width="225" style="padding:10px; background:#D2EDF7; vertical-align:top; font-size:11px;"> <div align="center"> <a href="http://seattle.onebrick.org/calendar/"><img src="http://newsletters.1btest.org/images/calendar.png" alt="calendar" width="130" height="110" border="0" style="display:block;"></a><br> <a href="http://seattle.onebrick.org/calendar/" style="color:#3573a3; font-size:14px; font-weight:bold; text-transform:uppercase; text-decoration:none;">On the Calendar...</a> </div> <p> <p> <div style='font-size:11px; text-align:left;'> Sun, Mar 25th (2:00pm)<br> <a href='http://seattle.onebrick.org/event/?eventid=10564' style='font-family:verdana, sans-serif; font-size:12px; font-weight:bold; color:#de712c; text-decoration:none;'>Feed the hungry with OPERATION: Sack Lunch</a><br> Volunteer opportunities include meal prep, sack lunch assembly, serving, and clean-up. </div> </p> <p> <div style='font-size:11px; text-align:left;'> Tue, Mar 27th (6:00pm)<br> <a href='http://seattle.onebrick.org/event/?eventid=10651' style='font-family:verdana, sans-serif; font-size:12px; font-weight:bold; color:#de712c; text-decoration:none;'>Help Feed the Hungry @ Food Lifeline</a><br> Help Food Lifeline repack the bulk donations it receives and provide food to over 300 food banks, shelters, etc. </div> </p> <p> <div style='font-size:11px; text-align:left;'> Sun, Apr 1st (12:00pm)<br> <a href='http://seattle.onebrick.org/event/?eventid=11132' style='font-family:verdana, sans-serif; font-size:12px; font-weight:bold; color:#de712c; text-decoration:none;'>Athlete assistance at Rainman Indoor Triathlon</a><br> Count laps and set up bikes at the Rainman Indoor Triathlon </div> </p> <p> <div style='font-size:11px; text-align:left;'> Thu, Apr 5th (5:30pm)<br> <a href='http://seattle.onebrick.org/event/?eventid=11127' style='font-family:verdana, sans-serif; font-size:12px; font-weight:bold; color:#de712c; text-decoration:none;'>Condom Kit Assembly Party</a><br> Assist the Lifelong AIDS Alliance in compiling kits. </div> </p> </p> <br> <div align="center"> <a href="http://seattle.onebrick.org/about/getinvolved/" style="color:#3573a3; font-size:14px; font-weight:bold; text-transform:uppercase; text-decoration:none;">Get More Involved!</a> </div> <p> One Brick chapters are 100% volunteer-run! We have no employees...we don't even maintain offices! <br><br> What One Brick DOES have is a lot of dedicated volunteers who make it all happen. And we're always looking for more people like YOU to join our team! <br><br> For more information and to join our leadership team <a href="http://seattle.onebrick.org/about/getinvolved/" style='font-weight:bold; color:#de712c; text-decoration:none;'>click here</a>. <br><br> To find out about using our services for your organization's event, please visit our <a href="http://seattle.onebrick.org/requesthelp/" style='font-weight:bold; color:#de712c; text-decoration:none;'>Requesting Help</a> page. </p> </td> </tr> </table> </td> </tr> </table> </div> </body> </html>
Laugh10704/onebrick
sites/all/modules/brick/newsletter_tool/newsletters/SEA/SEA_2012-03-08.html
HTML
gpl-2.0
8,466
using System.Drawing; using System.Threading.Tasks; namespace GoF_TryOut.Proxy.Straight { public class Client { public Client() { var myImage = new MyImage(""); var bitmap = myImage.GetImage() ?? myImage.GetPreview(); } } public class MyImage { private readonly string path; private readonly Bitmap preview; private Bitmap fullImage; private Task<Bitmap> task; public MyImage(string path) { this.path = path; preview = new Bitmap(path); } private Bitmap LoadImage() { return new Bitmap(path); } public Bitmap GetPreview() { return preview; } public Bitmap GetImage() { task = new Task<Bitmap>(LoadImage); task.Start(); if (task.IsCompleted) { if (fullImage == null) { fullImage = task.Result; return fullImage; } return fullImage; } return preview; } } }
VioletTape/Trainings
DEV-001_GoF/GoF_TryOut/GoF_TryOut/Proxy/Straight/Client.cs
C#
gpl-2.0
1,114
package core import ( "github.com/justinsb/gova/log" ) type CleanupOldMachines struct { huddle *Huddle state map[string]int deleteThreshold int } func (self *CleanupOldMachines) Run() error { state, err := self.huddle.cleanupOldMachines(self.state, self.deleteThreshold) if err != nil { log.Warn("Error cleaning up old machines", err) return err } self.state = state return nil } func (self *CleanupOldMachines) String() string { return "CleanupOldMachines" }
jxaas/jxaas
core/scheduled_machine_cleanup.go
GO
gpl-2.0
490
{% extends "base.html" %} {% block title %}Profile{% endblock %} {% block body %} <div class="well"> <h2>Enter Profile Info</h2> <form method="POST" action="."> {% csrf_token %} <table class="table"> {{ form.as_table }} </table> <button class="btn btn-primary" type="submit">Go!</button> </form> </div> {% endblock body %}
jpulec/niteabout
niteabout/templates/main/require_profile.html
HTML
gpl-2.0
373
#ifndef DEBUG_H #define DEBUG_H #include "common.h" void debug_init(void); void debug_shut(void); void print_nl(void); void print_str(char *str); void print_str_nl(char *str); void print_num(uint32_t n); void print_hex(uint32_t n); char scan_char(void); void scan_line(char *line, int max_len); #endif
sysplay/bbb
EmbC/debug.h
C
gpl-2.0
306
/** * @package WordPress * @subpackage Dental Clinic * @version 1.0.0 * * Post, Page, Project & Profile Options Styles * Created by CMSMasters * */ body.wp-admin a, body.wp-admin input, body.wp-admin textarea, body.wp-admin select {outline:none;} input[type=number] { width: 65px; padding: 2px 0 2px 6px; margin-right: 10px; } input.long_size[type=number] { width: 100px; } input[type=range] { width: 150px; float: left; padding: 0; margin: 0; } input[type=range] + input[type=text] { float: left; margin: -3px 10px 0; } #wp_editbtns_video { display:none; position:absolute; padding:2px; z-index:999998; } .ui-helper-hidden {display:none;} .ui-helper-hidden-accessible { position:absolute !important; clip:rect(1px 1px 1px 1px); clip:rect(1px,1px,1px,1px); } .ui-helper-reset { border:0; list-style:none; font-size:100%; line-height:1.3; text-decoration:none; margin:0; padding:0; outline:0; } .ui-helper-clearfix:after { content:"."; display:block; height:0; visibility:hidden; clear:both; } .ui-helper-clearfix {display:inline-block;} * html .ui-helper-clearfix {height:1%;} .ui-helper-clearfix {display:block;} .ui-helper-zfix { width:100%; height:100%; position:absolute; top:0; left:0; opacity:0; filter:alpha(opacity=0); } .ui-state-disabled {cursor:default !important;} .ui-widget-overlay { width:100%; height:100%; position:absolute; top:0; left:0; } .fl {float:left;} .fr {float:right;} .cl {clear:both;} .ovh {overflow:hidden;} .nav-tab-content { display:none; } .nav-tab-content.nav-tab-content-active { display:block; } #poststuff h2.nav-tab-wrapper { border-bottom-color:#dddddd; padding-bottom:0; padding-left:10px; margin:20px 0 0; } .nav-tab { border-color:#dddddd; background-color:#f5f5f5; margin-right:7px; } .nav-tab.nav-tab-active { border-color:#dddddd; border-bottom-color:#ffffff; background:none; } .form-table > tbody > tr:first-child {border-top:0;} .form-table > tbody > tr > th, .form-table > tbody > tr > td { padding-top:20px; padding-bottom:20px; } .form-table > tbody > tr > th {font-weight:bold;} .form-table table td { padding:0 20px 0 0; } .cmsms_tr_radio_img input[type="radio"], .cmsms_tr_radio_img_pj input[type="radio"] {margin:-1px 5px 0 0;} .cmsms_tr_images_list .cmsms_gallery img { border: 1px solid #dddddd; background-color: #f5f5f5; display: block; padding: 3px; margin-top: 10px; min-width: 50px; min-height: 50px; max-width: 100%; cursor: pointer; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .cmsms_tr_images_list .cmsms_gallery .cmsms_gallery_cancel { background-color: #f5f5f5; color: #555555; display: block; font-size: 14px; line-height: 22px; text-align: center; width: 22px; height: 22px; position: absolute; bottom: 4px; left: 4px; -webkit-border-radius: 0 3px 0 0; -moz-border-radius: 0 3px 0 0; border-radius: 0 3px 0 0; -webkit-transition: color .3s ease-in-out; -moz-transition: color .3s ease-in-out; -ms-transition: color .3s ease-in-out; -o-transition: color .3s ease-in-out; transition: color .3s ease-in-out; } .cmsms_tr_images_list .cmsms_gallery .cmsms_gallery_cancel:hover { color: #dd0000; } .cmsms_tr_images_list .cmsms_gallery { display: block; position: relative; } .cmsms_tr_images_list .cmsms_gallery li { display: block; float: left; padding: 0; margin: 0 7px 7px 0; position: relative; } .cmsms_tr_images_list .cmsms_gallery li.ui-sortable-placeholder { width: 98px; height: 98px; margin: 1px 8px 8px 1px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .cmsms_tr_images_list .cmsms_gallery li img { width: 100px; height: 100px; margin: 0; cursor: move; } .pickcolor_example { border:1px solid #dfdfdf; padding:4px 14px; margin:0 7px 0 3px; } .cmsms_heading_icons_list { margin:0; position:relative; overflow:hidden; } .cmsms_heading_icons_list .cmsms_heading_icon { display:inline-block; padding:0 15px 10px 0; margin-bottom:0; } .cmsms_heading_icons_list .cmsms_heading_icon a {display:block;} .cmsms_heading_icons_list .cmsms_heading_icon a img { display:block; padding:6px; max-width:100px; max-height:100px; } .cmsms_heading_icons_list .cmsms_heading_icon.selected a img { border:1px solid #dddddd; background-color:#f5f5f5; padding:5px; } .post_image_list_parent { display:none; position:relative; overflow:hidden; min-height:20px; } .post_images_nav { border-top:1px solid #cccccc; border-bottom:1px solid #cccccc; display:none; padding:10px 0; position:relative; overflow:hidden; clear:both; } tr.cmsms_tr_repeatable .ovh, tr.cmsms_tr_repeatable .custom_repeatable, tr.cmsms_tr_repeatable_link .ovh, tr.cmsms_tr_repeatable_link .custom_repeatable, tr.cmsms_tr_repeatable_multiple .ovh, tr.cmsms_tr_repeatable_multiple .custom_repeatable { border-bottom:1px dotted #cccccc; width:80%; margin-top:0; } tr.cmsms_tr_repeatable_link .ovh, tr.cmsms_tr_repeatable_multiple .ovh {padding-bottom:5px;} tr.cmsms_tr_repeatable_link .custom_repeatable, tr.cmsms_tr_repeatable_media .custom_repeatable, tr.cmsms_tr_repeatable_multiple .custom_repeatable {margin-top:7px;} tr.cmsms_tr_repeatable_link .ovh .fl, tr.cmsms_tr_repeatable_multiple .ovh .fl {padding:0 0 0 5px;} tr.cmsms_tr_repeatable_multiple .ovh .fl {width:40%;} tr.cmsms_tr_repeatable_link .ovh .fl:first-child, tr.cmsms_tr_repeatable_multiple .ovh .fl:first-child {padding-left:30px;} tr.cmsms_tr_repeatable .custom_repeatable li, tr.cmsms_tr_repeatable_link .custom_repeatable li, tr.cmsms_tr_repeatable_media .custom_repeatable li, tr.cmsms_tr_repeatable_multiple .custom_repeatable li { position:relative; overflow:hidden; } tr.cmsms_tr_repeatable .custom_repeatable li span.hndle, tr.cmsms_tr_repeatable_multiple .custom_repeatable li span.hndle, tr.cmsms_tr_repeatable_link .custom_repeatable li span.hndle { color:#707070; font-size:15px; line-height:16px; display:block; width:16px; height:16px; float:left; padding:5px 5px 5px 0; position:relative; } tr.cmsms_tr_repeatable .custom_repeatable li input[type="text"], tr.cmsms_tr_repeatable_multiple .custom_repeatable li input[type="text"], tr.cmsms_tr_repeatable_multiple .custom_repeatable li textarea, tr.cmsms_tr_repeatable_media .custom_repeatable li input[type="text"], tr.cmsms_tr_repeatable_link .custom_repeatable li input[type="text"] { float:left; margin-right:5px; } tr.cmsms_tr_repeatable_multiple .custom_repeatable li input[type="text"], tr.cmsms_tr_repeatable_multiple .custom_repeatable li textarea {width:40%;} tr.cmsms_tr_repeatable_multiple .custom_repeatable li textarea {resize:vertical;} tr.cmsms_tr_repeatable .custom_repeatable li a.repeatable-remove, tr.cmsms_tr_repeatable_multiple .custom_repeatable li a.repeatable-copy, tr.cmsms_tr_repeatable_multiple .custom_repeatable li a.repeatable-remove, tr.cmsms_tr_repeatable_media .custom_repeatable li a.repeatable-remove, tr.cmsms_tr_repeatable_link .custom_repeatable li a.repeatable-remove { color:#707070; margin-top:1px; float:left; font-size:14px; line-height:28px; } tr.cmsms_tr_repeatable_multiple .custom_repeatable li a.repeatable-copy { margin-right:5px; } tr.cmsms_tr_repeatable .custom_repeatable li a.repeatable-remove:hover, tr.cmsms_tr_repeatable_multiple .custom_repeatable li a.repeatable-remove:hover, tr.cmsms_tr_repeatable_media .custom_repeatable li a.repeatable-remove:hover, tr.cmsms_tr_repeatable_link .custom_repeatable li a.repeatable-remove:hover { color:#dd0000; } tr.cmsms_tr_repeatable_multiple .custom_repeatable li a.repeatable-copy:hover { color:#0074a2; } tr.cmsms_tr_repeatable_media .custom_repeatable { border-top:1px dotted #cccccc; width:60%; } tr.cmsms_tr_repeatable_media .custom_repeatable {padding-top:7px;} tr.cmsms_tr_repeatable_media .custom_repeatable li input.cmsms_link {width:60%;} tr.cmsms_tr_repeatable_link .ovh .fl {width:50%;} tr.cmsms_tr_repeatable_link .ovh .fl:first-child {width:30%;} tr.cmsms_tr_repeatable .custom_repeatable li input[type="text"], tr.cmsms_tr_repeatable_link .custom_repeatable li input[type="text"] {width:50%;} tr.cmsms_tr_repeatable_link .custom_repeatable li input[type="text"].cmsms_name {width:30%;} tr.cmsms_tr_repeatable a.repeatable-add, tr.cmsms_tr_repeatable_multiple a.repeatable-multiple-add, tr.cmsms_tr_repeatable_media a.repeatable-media-add, tr.cmsms_tr_repeatable_link a.repeatable-link-add { color:#707070; margin-top:1px; font-size:14px; line-height:29px; } tr.cmsms_tr_repeatable a.repeatable-add:hover, tr.cmsms_tr_repeatable_multiple a.repeatable-multiple-add:hover, tr.cmsms_tr_repeatable_media a.repeatable-media-add:hover, tr.cmsms_tr_repeatable_link a.repeatable-link-add:hover { color:#00dd00; } .wp-color-result:after { -webkit-border-radius:0 1px 1px 0; -moz-border-radius:0 1px 1px 0; border-radius:0 1px 1px 0; } #poststuff .form-table .icon_management h3 { padding: 0 0 10px; cursor: default; } .form-table .icon_management .icon_del, .form-table .icon_management .icon_move { background-color: #ffffff; color: #707070; display: block; font-size: 14px; line-height: 22px; text-align: center; width: 22px; height: 22px; position: absolute; bottom: 4px; left: 4px; -webkit-border-radius: 0 3px 0 0; -moz-border-radius: 0 3px 0 0; border-radius: 0 3px 0 0; -webkit-transition: color .3s ease-in-out; -moz-transition: color .3s ease-in-out; -ms-transition: color .3s ease-in-out; -o-transition: color .3s ease-in-out; transition: color .3s ease-in-out; } .form-table .icon_management .icon_del { bottom: 3px; left: 3px; } .form-table .icon_management .icon_move { font-size: 15px; line-height: 24px; width: 24px; height: 24px; bottom: auto; left: auto; top: 3px; right: 3px; cursor: move; -webkit-border-radius: 0 0 0 3px; -moz-border-radius: 0 0 0 3px; border-radius: 0 0 0 3px; } .form-table .icon_management .icon_move:before { margin-top: 4px; -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); transform: rotate(90deg); } .form-table .icon_management .icon_del:hover { color: #dd0000; } .form-table td .icon_management p { margin-top:0; position:relative; } .form-table td .icon_management p:after { content: ''; display: block; clear: both; } .form-table td .icon_management small { position:absolute; top:0; left:0; } .form-table td .icon_management small a { display:block; width:20px; height:20px; } .icon_management > ul { border-top: 1px dotted #dddddd; display: block; width: 80%; padding-top: 10px; margin-top: 20px; position: relative; } .icon_management ul:after { content: ''; display: block; clear: both; } .icon_management ul li { border: 1px solid #cccccc; background-color: #ffffff; display: block; width: 100px; height: 100px; float: left; padding: 3px; margin: 25px 25px 0 0; position: relative; overflow: hidden; cursor: pointer; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .icon_management ul li.ui-sortable-highlight { border: 1px solid #e6db55; background-color: #ffffe0; display: block; width: 100px; height: 100px; } .icon_management ul li div { background-color: #f9f9f9; font-size: 24px; line-height: 92px; text-align: center; height: 92px; } #add_icon, #edit_icon { display: none; } .icon_upload_link { display: block; padding-bottom: 10px; } .icon_upload_link label { display: block; margin-bottom: 10px; } .icon_upload_link label input[type="text"] { margin-right: 10px; } .cmsms_funds_stat_wrap { background-color: #f1f1f1; width: 100%; height: 10px; margin: 20px 0; position: relative; } .cmsms_funds_stat { background-color: #0074a2; height: 10px; position: relative; } .cmsms_funds_stat span, .cmsms_funds_stat strong { position: absolute; right: 0; } .cmsms_funds_stat span { top: -20px; } .cmsms_funds_stat strong { bottom: -20px; }
EtewaZINSOU/webRadio
wp-content/themes/dental-clinic/framework/admin/options/css/cmsms-theme-options.css
CSS
gpl-2.0
12,084
<?php /** * @version $Id: AbstractItem.php 30067 2016-03-08 13:44:25Z matias $ * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2016 RocketTheme, LLC * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only */ abstract class RokCommon_Form_AbstractItem implements RokCommon_Form_IItem { /** * @var RokCommon_Service_Container */ protected $container; /** * The JForm object of the form attached to the form field. * * @var object * @since 1.6 */ protected $form; /** * The form control prefix for field names from the JForm object attached to the form field. * * @var string * @since 1.6 */ protected $formControl; /** * The hidden state for the form field. * * @var boolean * @since 1.6 */ protected $hidden = false; /** * True to translate the field label string. * True to translate the field label string. * * @var boolean * @since 1.6 */ protected $translateLabel = true; /** * True to translate the field description string. * * @var boolean * @since 1.6 */ protected $translateDescription = true; /** * The JXMLElement object of the <field /> XML element that describes the form field. * * @var object * @since 1.6 */ protected $element; /** * The document id for the form field. * * @var string * @since 1.6 */ protected $id; /** * The input for the form field. * * @var string * @since 1.6 */ protected $input; /** * The label for the form field. * * @var string * @since 1.6 */ protected $label; /** * The name of the form field. * * @var string * @since 1.6 */ protected $name; /** * The name of the field. * * @var string * @since 1.6 */ protected $fieldname; /** * The group of the field. * * @var string * @since 1.6 */ protected $group; /** * The form field type. * * @var string * @since 1.6 */ protected $type; protected $basetype; /** * The value of the form field. * * @var mixed * @since 1.6 */ protected $value; /** * @var string */ protected $panel_position = 'left'; /** * @var bool */ protected $show_label = true; /** * @var mixed */ protected $base_value; /** * @var bool */ protected $customized = false; /** * @var bool */ protected $setinoverride = true; /** * @var string */ protected $class; /** * @var bool */ protected $detached; /** * @var mixed */ protected $default; protected $assets_content; /** * Method to instantiate the form field object. * * @param object $form The form to attach to the form field object. * * @return void * @since 1.6 */ public function __construct(RokCommon_Form $form = null) { $this->container = RokCommon_Service::getContainer(); // If there is a form passed into the constructor set the form and form control properties. if ($form instanceof RokCommon_Form) { $this->form = $form; $this->formControl = $form->getFormControl(); } } /** * @param $name * @param $value * * @return void */ public function __set($name, $value) { if (property_exists($this, $name)) { $this->{$name} = $value; } } /** * Method to get the field title. * * @return string The field title. * @since 11.1 */ public function getTitle() { // Initialise variables. $title = ''; if ($this->hidden) { return $title; } // Get the label text from the XML element, defaulting to the element name. $title = $this->element['label'] ? (string)$this->element['label'] : (string)$this->element['name']; $title = $this->translateLabel ? JText::_($title) : $title; return $title; } /** * Method to get the field label markup. * * @return string The field label markup. * @since 1.6 */ public function getLabel() { // Initialise variables. $label = ''; if ($this->hidden) { return $label; } // Get the label text from the XML element, defaulting to the element name. $text = $this->element['label'] ? (string)$this->element['label'] : (string)$this->element['name']; $text = $this->translateLabel ? JText::_($text) : $text; // Build the class for the label. $class = !empty($this->description) ? 'hasTip' : ''; $class = $this->required == true ? $class . ' required' : $class; // Add the opening label tag and main attributes attributes. $label .= '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="' . $class . '"'; // If a description is specified, use it to build a tooltip. if (!empty($this->description)) { $label .= ' title="' . htmlspecialchars(trim($text, ':') . '::' . ($this->translateDescription ? JText::_($this->description) : $this->description), ENT_COMPAT, 'UTF-8') . '"'; } // Add the label text and closing tag. $label .= '>' . $text . '</label>'; return $label; } /** * Method to attach a JForm object to the field. * * @param \RokCommon_Form $form The JForm object to attach to the form field. * * @return object The form field object so that the method can be used in a chain. * @since 1.6 */ public function setForm(RokCommon_Form $form) { $this->form = $form; $this->formControl = $form->getFormControl(); return $this; } /** * Method to get the name used for the field input tag. * * @param string $fieldName The field element name. * * @return string The name to be used for the field input tag. * * @since 11.1 */ public function getName($fieldName) { /** @var $namehandler RokCommon_Form_IItemNameHandler */ $namehandler = $this->container->getService('form.namehandler'); return $namehandler->getName($fieldName, $this->group, $this->formControl, false); } /** * Method to get the id used for the field input tag. * * @param string $fieldId The field element id. * @param string $fieldName The field element name. * * @return string The id to be used for the field input tag. * @since 1.6 */ public function getId($fieldId, $fieldName) { /** @var $namehandler RokCommon_Form_IItemNameHandler */ $namehandler = $this->container->getService('form.namehandler'); return $namehandler->getId($fieldName, $fieldId, $this->group, $this->formControl, false); } /** * Method to get certain otherwise inaccessible properties from the form field object. * * @param string $name The property name for which to the the value. * * @return mixed|null The property value or null. * @since 1.6 */ public function __get($name) { switch ($name) { case 'input': // If the input hasn't yet been generated, generate it. if (empty($this->input)) { $this->input = $this->getInput(); } return $this->input; break; case 'label': // If the label hasn't yet been generated, generate it. if (empty($this->label)) { $this->label = $this->getLabel(); } return $this->label; break; case 'title': return $this->getTitle(); break; default : if (property_exists($this, $name) && isset($this->{$name})) { return $this->{$name}; } elseif (method_exists($this, 'get' . ucfirst($name))) { return call_user_func(array($this, 'get' . ucfirst($name))); } elseif (property_exists($this, $name)) { return $this->{$name}; } elseif (isset($this->element[$name])) { return (string)$this->element[$name]; } else { return null; } break; } } /** * Method to attach a JForm object to the field. * * @param object $element The JXMLElement object representing the <field /> tag for the * form field object. * @param mixed $value The form field default value for display. * @param string $group The field name group control value. This acts as as an array * container for the field. For example if the field has name="foo" * and the group value is set to "bar" then the full field name * would end up being "bar[foo]". * * @return boolean True on success. * @since 1.6 */ public function setup(& $element, $value, $group = null) { global $gantry; // Make sure there is a valid JFormField XML element. if (!($element instanceof RokCommon_XMLElement)) { return false; } // Reset the input and label values. $this->input = null; $this->label = null; // Set the xml element object. $this->element = $element; // Get some important attributes from the form field element. $class = (string)$element['class']; $id = (string)$element['id']; $name = (string)$element['name']; $type = (string)$element['type']; $panel_position = (string)$element['panel_position']; $this->show_label = ((string)$element['show_label'] == 'false') ? false : true; $this->setinoverride = ((string)$element['setinoverride'] == 'false') ? false : true; $default = (string)$element['default']; // if (!empty($name)) { // if (empty($group)) { // $gantry_name = $name; // } else { // $groups = explode('.', $group); // if (count($groups > 0)) { // //array_shift($groups); // $groups[] = $name; // $gantry_name = implode('-', $groups); // } // } // // TODO set this up to get for Default not for RokCommon param value // //$this->base_value = $gantry->get($gantry_name, null); // } // Set the field description text. $this->description = (string)$element['description']; // Set the visibility. $this->hidden = ((string)$element['type'] == 'hidden' || (string)$element['hidden'] == 'true'); // Determine whether to translate the field label and/or description. $this->translateLabel = !((string)$this->element['translate_label'] == 'false' || (string)$this->element['translate_label'] == '0'); $this->translateDescription = !((string)$this->element['translate_description'] == 'false' || (string)$this->element['translate_description'] == '0'); // Set the group of the field. $this->group = $group; // Set the field name and id. $this->fieldname = $name; $this->name = $this->getName($name, $group); $this->id = $this->getId($id, $name, $group); $this->type = $type; $this->class = $class; if ($panel_position != null) $this->panel_position = $panel_position; // Set the field default value. $this->value = $value; if (null != $this->default && $this->default != $this->value) $this->customized = true; return true; } /** * @static * @return void */ public static function initialize() { } /** * @static * @return void */ public static function finalize() { } /** * @param $callback * * @return mixed */ public function render($callback) { return call_user_func_array($callback, array($this)); } }
bmacenbacher/multison
libraries/rokcommon/RokCommon/Form/AbstractItem.php
PHP
gpl-2.0
11,359
/* Copyright (C) 2006 - 2011 ScriptDev2 <http://www.scriptdev2.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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData SDName: Instance_Dark_Portal SD%Complete: 50 SDComment: Quest support: 9836, 10297. Currently in progress. SDCategory: Caverns of Time, The Dark Portal EndScriptData */ #include "precompiled.h" #include "dark_portal.h" inline uint32 RandRiftBoss() { return (urand(0, 1) ? NPC_RKEEP : NPC_RLORD); } float PortalLocation[4][4]= { {-2041.06f, 7042.08f, 29.99f, 1.30f}, {-1968.18f, 7042.11f, 21.93f, 2.12f}, {-1885.82f, 7107.36f, 22.32f, 3.07f}, {-1928.11f, 7175.95f, 22.11f, 3.44f} }; struct Wave { uint32 PortalBoss; // protector of current portal uint32 NextPortalTime; // time to next portal, or 0 if portal boss need to be killed }; static Wave RiftWaves[]= { {RIFT_BOSS, 0}, {NPC_DEJA, 0}, {RIFT_BOSS, 120000}, {NPC_TEMPO, 140000}, {RIFT_BOSS, 120000}, {NPC_AEONUS, 0} }; struct MANGOS_DLL_DECL instance_dark_portal : public ScriptedInstance { instance_dark_portal(Map* pMap) : ScriptedInstance(pMap) {Initialize();}; uint32 m_auiEncounter[MAX_ENCOUNTER]; uint32 m_uiRiftPortalCount; uint32 m_uiShieldPercent; uint8 m_uiRiftWaveCount; uint8 m_uiRiftWaveId; uint32 m_uiNextPortal_Timer; uint64 m_uiMedivhGUID; uint8 m_uiCurrentRiftId; void Initialize() { m_uiMedivhGUID = 0; Clear(); } void Clear() { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); m_uiRiftPortalCount = 0; m_uiShieldPercent = 100; m_uiRiftWaveCount = 0; m_uiRiftWaveId = 0; m_uiCurrentRiftId = 0; m_uiNextPortal_Timer = 0; } void InitWorldState(bool Enable = true) { DoUpdateWorldState(WORLD_STATE_BM,Enable ? 1 : 0); DoUpdateWorldState(WORLD_STATE_BM_SHIELD, 100); DoUpdateWorldState(WORLD_STATE_BM_RIFT, 0); } bool IsEncounterInProgress() const { if (m_auiEncounter[0] == IN_PROGRESS) return true; return false; } void OnPlayerEnter(Player* pPlayer) { if (m_auiEncounter[0] == IN_PROGRESS) return; pPlayer->SendUpdateWorldState(WORLD_STATE_BM, 0); } void OnCreatureCreate(Creature* pCreature) { if (pCreature->GetEntry() == NPC_MEDIVH) m_uiMedivhGUID = pCreature->GetGUID(); } // what other conditions to check? bool CanProgressEvent() { if (instance->GetPlayers().isEmpty()) return false; return true; } uint8 GetRiftWaveId() { switch(m_uiRiftPortalCount) { case 6: m_uiRiftWaveId = 2; return 1; case 12: m_uiRiftWaveId = 4; return 3; case 18: return 5; default: return m_uiRiftWaveId; } } void SetData(uint32 uiType, uint32 uiData) { switch(uiType) { case TYPE_MEDIVH: if (uiData == SPECIAL && m_auiEncounter[0] == IN_PROGRESS) { --m_uiShieldPercent; DoUpdateWorldState(WORLD_STATE_BM_SHIELD, m_uiShieldPercent); if (!m_uiShieldPercent) { if (Creature* pMedivh = instance->GetCreature(m_uiMedivhGUID)) { if (pMedivh->isAlive()) { pMedivh->DealDamage(pMedivh, pMedivh->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); m_auiEncounter[0] = FAIL; m_auiEncounter[1] = NOT_STARTED; } } } } else { if (uiData == IN_PROGRESS) { debug_log("½Å±¾¿â£º Instance Dark Portal: Starting event."); InitWorldState(); m_auiEncounter[1] = IN_PROGRESS; m_uiNextPortal_Timer = 15000; } if (uiData == DONE) { // this may be completed further out in the post-event debug_log("½Å±¾¿â£º Instance Dark Portal: Event completed."); Map::PlayerList const& players = instance->GetPlayers(); if (!players.isEmpty()) { for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { if (Player* pPlayer = itr->getSource()) { if (pPlayer->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE) pPlayer->AreaExploredOrEventHappens(QUEST_OPENING_PORTAL); if (pPlayer->GetQuestStatus(QUEST_MASTER_TOUCH) == QUEST_STATUS_INCOMPLETE) pPlayer->AreaExploredOrEventHappens(QUEST_MASTER_TOUCH); } } } } m_auiEncounter[0] = uiData; } break; case TYPE_RIFT: if (uiData == SPECIAL) { if (m_uiRiftPortalCount < 7) m_uiNextPortal_Timer = 5000; } else m_auiEncounter[1] = uiData; break; } } uint32 GetData(uint32 uiType) { switch(uiType) { case TYPE_MEDIVH: return m_auiEncounter[0]; case TYPE_RIFT: return m_auiEncounter[1]; case DATA_PORTAL_COUNT: return m_uiRiftPortalCount; case DATA_SHIELD: return m_uiShieldPercent; } return 0; } uint64 GetData64(uint32 uiData) { if (uiData == DATA_MEDIVH) return m_uiMedivhGUID; return 0; } Creature* SummonedPortalBoss(Creature* pSource) { uint32 uiEntry = RiftWaves[GetRiftWaveId()].PortalBoss; if (uiEntry == RIFT_BOSS) uiEntry = RandRiftBoss(); float x, y, z; pSource->GetRandomPoint(pSource->GetPositionX(), pSource->GetPositionY(), pSource->GetPositionZ(), 10.0f, x, y, z); // uncomment the following if something doesn't work correctly, otherwise just delete // pSource->UpdateAllowedPositionZ(x, y, z); debug_log("½Å±¾¿â£º Instance Dark Portal: Summoning rift boss uiEntry %u.", uiEntry); if (Creature* pSummoned = pSource->SummonCreature(uiEntry, x, y, z, pSource->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) return pSummoned; debug_log("½Å±¾¿â£º Instance Dark Portal: what just happened there? No boss, no loot, no fun..."); return NULL; } void DoSpawnPortal() { if (Creature* pMedivh = instance->GetCreature(m_uiMedivhGUID)) { uint8 uiTmp = urand(0, 2); if (uiTmp >= m_uiCurrentRiftId) ++uiTmp; debug_log("½Å±¾¿â£º Instance Dark Portal: Creating Time Rift at locationId %i (old locationId was %u).", uiTmp, m_uiCurrentRiftId); m_uiCurrentRiftId = uiTmp; if (Creature* pTemp = pMedivh->SummonCreature(NPC_TIME_RIFT, PortalLocation[uiTmp][0], PortalLocation[uiTmp][1], PortalLocation[uiTmp][2], PortalLocation[uiTmp][3], TEMPSUMMON_CORPSE_DESPAWN, 0)) { pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); if (Creature* pBoss = SummonedPortalBoss(pTemp)) { if (pBoss->GetEntry() == NPC_AEONUS) pBoss->AddThreat(pMedivh); else { pBoss->AddThreat(pTemp); pTemp->CastSpell(pBoss, SPELL_RIFT_CHANNEL, false); } } } } } void Update(uint32 uiDiff) { if (m_auiEncounter[1] != IN_PROGRESS) return; //add delay timer? if (!CanProgressEvent()) { Clear(); return; } if (m_uiNextPortal_Timer) { if (m_uiNextPortal_Timer <= uiDiff) { ++m_uiRiftPortalCount; DoUpdateWorldState(WORLD_STATE_BM_RIFT, m_uiRiftPortalCount); DoSpawnPortal(); m_uiNextPortal_Timer = RiftWaves[GetRiftWaveId()].NextPortalTime; } else m_uiNextPortal_Timer -= uiDiff; } } }; InstanceData* GetInstanceData_instance_dark_portal(Map* pMap) { return new instance_dark_portal(pMap); } void AddSC_instance_dark_portal() { Script* newscript; newscript = new Script; newscript->Name = "instance_dark_portal"; newscript->GetInstanceData = &GetInstanceData_instance_dark_portal; newscript->RegisterSelf(); }
gelu/ChgSD2
scripts/kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp
C++
gpl-2.0
10,305
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>Uses of Class org.apache.commons.math3.optimization.direct.AbstractSimplex (Apache Commons Math 3.4.1 API)</title> <link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.apache.commons.math3.optimization.direct.AbstractSimplex (Apache Commons Math 3.4.1 API)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> </div> <div class="subNav"> <ul class="navList"> <li>PREV</li> <li>NEXT</li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?org/apache/commons/math3/optimization/direct//class-useAbstractSimplex.html" target="_top">FRAMES</a></li> <li><a href="AbstractSimplex.html" target="_top">NO FRAMES</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h2 title="Uses of Class org.apache.commons.math3.optimization.direct.AbstractSimplex" class="title">Uses of Class<br>org.apache.commons.math3.optimization.direct.AbstractSimplex</h2> </div> <div class="classUseContainer"> <ul class="blockList"> <li class="blockList"> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation"> <caption><span>Packages that use <a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">AbstractSimplex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="#org.apache.commons.math3.optimization.direct">org.apache.commons.math3.optimization.direct</a></td> <td class="colLast"> <div class="block"> This package provides optimization algorithms that don't require derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="org.apache.commons.math3.optimization.direct"> <!-- --> </a> <h3>Uses of <a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">AbstractSimplex</a> in <a href="../../../../../../../org/apache/commons/math3/optimization/direct/package-summary.html">org.apache.commons.math3.optimization.direct</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subclasses, and an explanation"> <caption><span>Subclasses of <a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">AbstractSimplex</a> in <a href="../../../../../../../org/apache/commons/math3/optimization/direct/package-summary.html">org.apache.commons.math3.optimization.direct</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/optimization/direct/MultiDirectionalSimplex.html" title="class in org.apache.commons.math3.optimization.direct">MultiDirectionalSimplex</a></strong></code> <div class="block"><strong>Deprecated.</strong>&nbsp; <div class="block"><i>As of 3.1 (to be removed in 4.0).</i></div> </div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../../../../../org/apache/commons/math3/optimization/direct/NelderMeadSimplex.html" title="class in org.apache.commons.math3.optimization.direct">NelderMeadSimplex</a></strong></code> <div class="block"><strong>Deprecated.</strong>&nbsp; <div class="block"><i>As of 3.1 (to be removed in 4.0).</i></div> </div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../../../org/apache/commons/math3/optimization/direct/package-summary.html">org.apache.commons.math3.optimization.direct</a> with parameters of type <a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">AbstractSimplex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">SimplexOptimizer.</span><code><strong><a href="../../../../../../../org/apache/commons/math3/optimization/direct/SimplexOptimizer.html#setSimplex(org.apache.commons.math3.optimization.direct.AbstractSimplex)">setSimplex</a></strong>(<a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">AbstractSimplex</a>&nbsp;simplex)</code> <div class="block"><strong>Deprecated.</strong>&nbsp; <div class="block"><i>As of 3.1. The initial simplex can now be passed as an argument of the <a href="../../../../../../../org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.html#optimize(int, FUNC, org.apache.commons.math3.optimization.GoalType, org.apache.commons.math3.optimization.OptimizationData...)"><code>BaseAbstractMultivariateOptimizer.optimize(int,MultivariateFunction,GoalType,OptimizationData[])</code></a> method.</i></div> </div> </td> </tr> </tbody> </table> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../../../org/apache/commons/math3/optimization/direct/AbstractSimplex.html" title="class in org.apache.commons.math3.optimization.direct">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> </div> <div class="subNav"> <ul class="navList"> <li>PREV</li> <li>NEXT</li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?org/apache/commons/math3/optimization/direct//class-useAbstractSimplex.html" target="_top">FRAMES</a></li> <li><a href="AbstractSimplex.html" target="_top">NO FRAMES</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small>Copyright &#169; 2003&#x2013;2015 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> </body> </html>
as-1/STSP
libraries/commons-math3-3.4.1/docs/apidocs/org/apache/commons/math3/optimization/direct/class-use/AbstractSimplex.html
HTML
gpl-2.0
9,612
package com.github.randoapp.api.listeners; import com.github.randoapp.db.model.Rando; public interface UploadRandoListener { void onUpload(Rando rando); }
RandoApp/Rando-android
src/main/java/com/github/randoapp/api/listeners/UploadRandoListener.java
Java
gpl-2.0
162
<?php /** * Copyright (c) 2007-2011, Servigistics, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the name of Servigistics, Inc. 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 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. * * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com) * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD * @version $Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $ * * @package Apache * @subpackage Solr * @author Donovan Jimenez <djimenez@conduit-it.com> */ // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1) // Doesn't follow typical include path conventions, but is more convenient for users require_once(dirname(__FILE__) . '/Exception.php'); require_once(dirname(__FILE__) . '/HttpTransportException.php'); require_once(dirname(__FILE__) . '/InvalidArgumentException.php'); require_once(dirname(__FILE__) . '/Document.php'); require_once(dirname(__FILE__) . '/Response.php'); require_once(dirname(__FILE__) . '/HttpTransport/Interface.php'); /** * Starting point for the Solr API. Represents a Solr server resource and has * methods for pinging, adding, deleting, committing, optimizing and searching. * * Example Usage: * <code> * ... * $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr') * * if ($solr->ping()) * { * $solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :) * * $document = new Apache_Solr_Document(); * $document->id = uniqid(); //or something else suitably unique * * $document->title = 'Some Title'; * $document->content = 'Some content for this wonderful document. Blah blah blah.'; * * $solr->addDocument($document); //if you're going to be adding documents in bulk using addDocuments * //with an array of documents is faster * * $solr->commit(); //commit to see the deletes and the document * $solr->optimize(); //merges multiple segments into one * * //and the one we all care about, search! * //any other common or custom parameters to the request handler can go in the * //optional 4th array argument. * $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc')); * } * ... * </code> * * @todo Investigate using other HTTP clients other than file_get_contents built-in handler. Could provide performance * improvements when dealing with multiple requests by using HTTP's keep alive functionality */ class Apache_Solr_Service { /** * SVN Revision meta data for this class */ const SVN_REVISION = '$Revision: 59 $'; /** * SVN ID meta data for this class */ const SVN_ID = '$Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $'; /** * Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning */ const SOLR_WRITER = 'json'; /** * NamedList Treatment constants */ const NAMED_LIST_FLAT = 'flat'; const NAMED_LIST_MAP = 'map'; /** * Search HTTP Methods */ const METHOD_GET = 'GET'; const METHOD_POST = 'POST'; /** * Servlet mappings */ const PING_SERVLET = 'admin/ping'; const UPDATE_SERVLET = 'update'; const SEARCH_SERVLET = 'select'; const THREADS_SERVLET = 'admin/threads'; const EXTRACT_SERVLET = 'update/extract'; /** * Server identification strings * * @var string */ protected $_host, $_port, $_path; /** * Whether {@link Apache_Solr_Response} objects should create {@link Apache_Solr_Document}s in * the returned parsed data * * @var boolean */ protected $_createDocuments = true; /** * Whether {@link Apache_Solr_Response} objects should have multivalue fields with only a single value * collapsed to appear as a single value would. * * @var boolean */ protected $_collapseSingleValueArrays = true; /** * How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values * are {@link Apache_Solr_Service::NAMED_LIST_MAP} (default) or {@link Apache_Solr_Service::NAMED_LIST_FLAT}. * * @var string */ protected $_namedListTreatment = self::NAMED_LIST_MAP; /** * Query delimiters. Someone might want to be able to change * these (to use &amp; instead of & for example), so I've provided them. * * @var string */ protected $_queryDelimiter = '?', $_queryStringDelimiter = '&', $_queryBracketsEscaped = true; /** * Constructed servlet full path URLs * * @var string */ protected $_pingUrl, $_updateUrl, $_searchUrl, $_threadsUrl; /** * Keep track of whether our URLs have been constructed * * @var boolean */ protected $_urlsInited = false; /** * HTTP Transport implementation (pluggable) * * @var Apache_Solr_HttpTransport_Interface */ protected $_httpTransport = false; /** * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc. * * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead * * @param string $value * @return string */ static public function escape($value) { //list taken from http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters $pattern = '/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/'; $replace = '\\\$1'; return preg_replace($pattern, $replace, $value); } /** * Escape a value meant to be contained in a phrase for special query characters * * @param string $value * @return string */ static public function escapePhrase($value) { $pattern = '/("|\\\)/'; $replace = '\\\$1'; return preg_replace($pattern, $replace, $value); } /** * Convenience function for creating phrase syntax from a value * * @param string $value * @return string */ static public function phrase($value) { return '"' . self::escapePhrase($value) . '"'; } /** * Constructor. All parameters are optional and will take on default values * if not specified. * * @param string $host * @param string $port * @param string $path * @param Apache_Solr_HttpTransport_Interface $httpTransport */ public function __construct($host = 'localhost', $port = 8180, $path = '/solr/', $httpTransport = false) { $this->setHost($host); $this->setPort($port); $this->setPath($path); $this->_initUrls(); if ($httpTransport) { $this->setHttpTransport($httpTransport); } // check that our php version is >= 5.1.3 so we can correct for http_build_query behavior later $this->_queryBracketsEscaped = version_compare(phpversion(), '5.1.3', '>='); } /** * Return a valid http URL given this server's host, port and path and a provided servlet name * * @param string $servlet * @return string */ protected function _constructUrl($servlet, $params = array()) { if (count($params)) { //escape all parameters appropriately for inclusion in the query string $escapedParams = array(); foreach ($params as $key => $value) { $escapedParams[] = urlencode($key) . '=' . urlencode($value); } $queryString = $this->_queryDelimiter . implode($this->_queryStringDelimiter, $escapedParams); } else { $queryString = ''; } return 'http://' . $this->_host . ':' . $this->_port . $this->_path . $servlet . $queryString; } /** * Construct the Full URLs for the three servlets we reference */ protected function _initUrls() { //Initialize our full servlet URLs now that we have server information $this->_extractUrl = $this->_constructUrl(self::EXTRACT_SERVLET); $this->_pingUrl = $this->_constructUrl(self::PING_SERVLET); $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET); $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER )); $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER )); $this->_urlsInited = true; } protected function _generateQueryString($params) { // use http_build_query to encode our arguments because its faster // than urlencoding all the parts ourselves in a loop // // because http_build_query treats arrays differently than we want to, correct the query // string by changing foo[#]=bar (# being an actual number) parameter strings to just // multiple foo=bar strings. This regex should always work since '=' will be urlencoded // anywhere else the regex isn't expecting it // // NOTE: before php 5.1.3 brackets were not url encoded by http_build query - we've checked // the php version in the constructor and put the results in the instance variable. Also, before // 5.1.2 the arg_separator parameter was not available, so don't use it if ($this->_queryBracketsEscaped) { $queryString = http_build_query($params, null, $this->_queryStringDelimiter); return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); } else { $queryString = http_build_query($params); return preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $queryString); } } /** * Central method for making a get operation against this Solr Server * * @param string $url * @param float $timeout Read timeout in seconds * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If a non 200 response status is returned */ protected function _sendRawGet($url, $timeout = FALSE) { $httpTransport = $this->getHttpTransport(); $httpResponse = $httpTransport->performGetRequest($url, $timeout); $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); if ($solrResponse->getHttpStatus() != 200) { throw new Apache_Solr_HttpTransportException($solrResponse); } return $solrResponse; } /** * Central method for making a post operation against this Solr Server * * @param string $url * @param string $rawPost * @param float $timeout Read timeout in seconds * @param string $contentType * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If a non 200 response status is returned */ protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') { $httpTransport = $this->getHttpTransport(); $httpResponse = $httpTransport->performPostRequest($url, $rawPost, $contentType, $timeout); $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); if ($solrResponse->getHttpStatus() != 200) { throw new Apache_Solr_HttpTransportException($solrResponse); } return $solrResponse; } /** * Returns the set host * * @return string */ public function getHost() { return $this->_host; } /** * Set the host used. If empty will fallback to constants * * @param string $host * * @throws Apache_Solr_InvalidArgumentException If the host parameter is empty */ public function setHost($host) { //Use the provided host or use the default if (empty($host)) { throw new Apache_Solr_InvalidArgumentException('Host parameter is empty'); } else { $this->_host = $host; } if ($this->_urlsInited) { $this->_initUrls(); } } /** * Get the set port * * @return integer */ public function getPort() { return $this->_port; } /** * Set the port used. If empty will fallback to constants * * @param integer $port * * @throws Apache_Solr_InvalidArgumentException If the port parameter is empty */ public function setPort($port) { //Use the provided port or use the default $port = (int) $port; if ($port <= 0) { throw new Apache_Solr_InvalidArgumentException('Port is not a valid port number'); } else { $this->_port = $port; } if ($this->_urlsInited) { $this->_initUrls(); } } /** * Get the set path. * * @return string */ public function getPath() { return $this->_path; } /** * Set the path used. If empty will fallback to constants * * @param string $path */ public function setPath($path) { $path = trim($path, '/'); $this->_path = '/' . $path . '/'; if ($this->_urlsInited) { $this->_initUrls(); } } /** * Get the current configured HTTP Transport * * @return HttpTransportInterface */ public function getHttpTransport() { // lazy load a default if one has not be set if ($this->_httpTransport === false) { require_once(dirname(__FILE__) . '/HttpTransport/FileGetContents.php'); $this->_httpTransport = new Apache_Solr_HttpTransport_FileGetContents(); } return $this->_httpTransport; } /** * Set the HTTP Transport implemenation that will be used for all HTTP requests * * @param Apache_Solr_HttpTransport_Interface */ public function setHttpTransport(Apache_Solr_HttpTransport_Interface $httpTransport) { $this->_httpTransport = $httpTransport; } /** * Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will * parse the response and create {@link Apache_Solr_Document} instances in place. * * @param boolean $createDocuments */ public function setCreateDocuments($createDocuments) { $this->_createDocuments = (bool) $createDocuments; } /** * Get the current state of teh create documents flag. * * @return boolean */ public function getCreateDocuments() { return $this->_createDocuments; } /** * Set the collapse single value arrays flag. * * @param boolean $collapseSingleValueArrays */ public function setCollapseSingleValueArrays($collapseSingleValueArrays) { $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays; } /** * Get the current state of the collapse single value arrays flag. * * @return boolean */ public function getCollapseSingleValueArrays() { return $this->_collapseSingleValueArrays; } /** * Get the current default timeout setting (initially the default_socket_timeout ini setting) * in seconds * * @return float * * @deprecated Use the getDefaultTimeout method on the HTTP transport implementation */ public function getDefaultTimeout() { return $this->getHttpTransport()->getDefaultTimeout(); } /** * Set the default timeout for all calls that aren't passed a specific timeout * * @param float $timeout Timeout value in seconds * * @deprecated Use the setDefaultTimeout method on the HTTP transport implementation */ public function setDefaultTimeout($timeout) { $this->getHttpTransport()->setDefaultTimeout($timeout); } /** * Set how NamedLists should be formatted in the response data. This mainly effects * the facet counts format. * * @param string $namedListTreatment * @throws Apache_Solr_InvalidArgumentException If invalid option is set */ public function setNamedListTreatment($namedListTreatment) { switch ((string) $namedListTreatment) { case Apache_Solr_Service::NAMED_LIST_FLAT: $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_FLAT; break; case Apache_Solr_Service::NAMED_LIST_MAP: $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_MAP; break; default: throw new Apache_Solr_InvalidArgumentException('Not a valid named list treatement option'); } } /** * Get the current setting for named list treatment. * * @return string */ public function getNamedListTreatment() { return $this->_namedListTreatment; } /** * Set the string used to separate the path form the query string. * Defaulted to '?' * * @param string $queryDelimiter */ public function setQueryDelimiter($queryDelimiter) { $this->_queryDelimiter = $queryDelimiter; } /** * Set the string used to separate the parameters in thequery string * Defaulted to '&' * * @param string $queryStringDelimiter */ public function setQueryStringDelimiter($queryStringDelimiter) { $this->_queryStringDelimiter = $queryStringDelimiter; } /** * Call the /admin/ping servlet, can be used to quickly tell if a connection to the * server is able to be made. * * @param float $timeout maximum time to wait for ping in seconds, -1 for unlimited (default is 2) * @return float Actual time taken to ping the server, FALSE if timeout or HTTP error status occurs */ public function ping($timeout = 2) { $start = microtime(true); $httpTransport = $this->getHttpTransport(); $httpResponse = $httpTransport->performHeadRequest($this->_pingUrl, $timeout); $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); if ($solrResponse->getHttpStatus() == 200) { return microtime(true) - $start; } else { return false; } } /** * Call the /admin/threads servlet and retrieve information about all threads in the * Solr servlet's thread group. Useful for diagnostics. * * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function threads() { return $this->_sendRawGet($this->_threadsUrl); } /** * Raw Add Method. Takes a raw post body and sends it to the update service. Post body * should be a complete and well formed "add" xml document. * * @param string $rawPost * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function add($rawPost) { return $this->_sendRawPost($this->_updateUrl, $rawPost); } /** * Add a Solr Document to the index * * @param Apache_Solr_Document $document * @param boolean $allowDups * @param boolean $overwritePending * @param boolean $overwriteCommitted * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request. * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0) { $dupValue = $allowDups ? 'true' : 'false'; $pendingValue = $overwritePending ? 'true' : 'false'; $committedValue = $overwriteCommitted ? 'true' : 'false'; $commitWithin = (int) $commitWithin; $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : ''; $rawPost = "<add{$commitWithinString}>"; $rawPost .= $this->_documentToXmlFragment($document); $rawPost .= '</add>'; return $this->add($rawPost); } /** * Add an array of Solr Documents to the index all at once * * @param array $documents Should be an array of Apache_Solr_Document instances * @param boolean $allowDups * @param boolean $overwritePending * @param boolean $overwriteCommitted * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request. * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0) { $dupValue = $allowDups ? 'true' : 'false'; $pendingValue = $overwritePending ? 'true' : 'false'; $committedValue = $overwriteCommitted ? 'true' : 'false'; $commitWithin = (int) $commitWithin; $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : ''; $rawPost = "<add{$commitWithinString}>"; foreach ($documents as $document) { if ($document instanceof Apache_Solr_Document) { $rawPost .= $this->_documentToXmlFragment($document); } } $rawPost .= '</add>'; return $this->add($rawPost); } /** * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call * * @return string */ protected function _documentToXmlFragment(Apache_Solr_Document $document) { $xml = '<doc'; if ($document->getBoost() !== false) { $xml .= ' boost="' . $document->getBoost() . '"'; } $xml .= '>'; foreach ($document as $key => $value) { $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); $fieldBoost = $document->getFieldBoost($key); if (is_array($value)) { foreach ($value as $multivalue) { $xml .= '<field name="' . $key . '"'; if ($fieldBoost !== false) { $xml .= ' boost="' . $fieldBoost . '"'; // only set the boost for the first field in the set $fieldBoost = false; } $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8'); $xml .= '>' . $multivalue . '</field>'; } } else { $xml .= '<field name="' . $key . '"'; if ($fieldBoost !== false) { $xml .= ' boost="' . $fieldBoost . '"'; } $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); $xml .= '>' . $value . '</field>'; } } $xml .= '</doc>'; // replace any control characters to avoid Solr XML parser exception return $this->_stripCtrlChars($xml); } /** * Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space. * * @param string $string * @return string */ protected function _stripCtrlChars($string) { // See: http://w3.org/International/questions/qa-forms-utf-8.html // Printable utf-8 does not include any of these chars below x7F return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $string); } /** * Send a commit command. Will be synchronous unless both wait parameters are set to false. * * @param boolean $expungeDeletes Defaults to false, merge segments with deletes away * @param boolean $waitFlush Defaults to true, block until index changes are flushed to disk * @param boolean $waitSearcher Defaults to true, block until a new searcher is opened and registered as the main query searcher, making the changes visible * @param float $timeout Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function commit($expungeDeletes = false, $waitFlush = true, $waitSearcher = true, $timeout = 3600) { $expungeValue = $expungeDeletes ? 'true' : 'false'; $flushValue = $waitFlush ? 'true' : 'false'; $searcherValue = $waitSearcher ? 'true' : 'false'; $rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitSearcher="' . $searcherValue . '" />'; return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); } /** * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be * a complete and well formed "delete" xml document * * @param string $rawPost Expected to be utf-8 encoded xml document * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function delete($rawPost, $timeout = 3600) { return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); } /** * Create a delete document based on document ID * * @param string $id Expected to be utf-8 encoded * @param boolean $fromPending * @param boolean $fromCommitted * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function deleteById($id, $fromPending = true, $fromCommitted = true, $timeout = 3600) { $pendingValue = $fromPending ? 'true' : 'false'; $committedValue = $fromCommitted ? 'true' : 'false'; //escape special xml characters $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><id>' . $id . '</id></delete>'; return $this->delete($rawPost, $timeout); } /** * Create and post a delete document based on multiple document IDs. * * @param array $ids Expected to be utf-8 encoded strings * @param boolean $fromPending * @param boolean $fromCommitted * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function deleteByMultipleIds($ids, $fromPending = true, $fromCommitted = true, $timeout = 3600) { $pendingValue = $fromPending ? 'true' : 'false'; $committedValue = $fromCommitted ? 'true' : 'false'; $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '">'; foreach ($ids as $id) { //escape special xml characters $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); $rawPost .= '<id>' . $id . '</id>'; } $rawPost .= '</delete>'; return $this->delete($rawPost, $timeout); } /** * Create a delete document based on a query and submit it * * @param string $rawQuery Expected to be utf-8 encoded * @param boolean $fromPending * @param boolean $fromCommitted * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true, $timeout = 3600) { $pendingValue = $fromPending ? 'true' : 'false'; $committedValue = $fromCommitted ? 'true' : 'false'; // escape special xml characters $rawQuery = htmlspecialchars($rawQuery, ENT_NOQUOTES, 'UTF-8'); $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><query>' . $rawQuery . '</query></delete>'; return $this->delete($rawPost, $timeout); } /** * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how * to use Solr Cell and what parameters are available. * * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). * * @param string $file Path to file to extract data from * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) * @param string $mimetype optional mimetype specification (for the file being extracted) * * @return Apache_Solr_Response * * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. */ public function extract($file, $params = array(), $document = null, $mimetype = 'application/octet-stream') { // check if $params is an array (allow null for default empty array) if (!is_null($params)) { if (!is_array($params)) { throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); } } else { $params = array(); } // if $file is an http request, defer to extractFromUrl instead if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') { return $this->extractFromUrl($file, $params, $document, $mimetype); } // read the contents of the file $contents = @file_get_contents($file); if ($contents !== false) { // add the resource.name parameter if not specified if (!isset($params['resource.name'])) { $params['resource.name'] = basename($file); } // delegate the rest to extractFromString return $this->extractFromString($contents, $params, $document, $mimetype); } else { throw new Apache_Solr_InvalidArgumentException("File '{$file}' is empty or could not be read"); } } /** * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how * to use Solr Cell and what parameters are available. * * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). * * @param string $data Data that will be passed to Solr Cell * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) * @param string $mimetype optional mimetype specification (for the file being extracted) * * @return Apache_Solr_Response * * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. * * @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted. */ public function extractFromString($data, $params = array(), $document = null, $mimetype = 'application/octet-stream') { // check if $params is an array (allow null for default empty array) if (!is_null($params)) { if (!is_array($params)) { throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); } } else { $params = array(); } // make sure we receive our response in JSON and have proper name list treatment $params['wt'] = self::SOLR_WRITER; $params['json.nl'] = $this->_namedListTreatment; // check if $document is an Apache_Solr_Document instance if (!is_null($document) && $document instanceof Apache_Solr_Document) { // iterate document, adding literal.* and boost.* fields to $params as appropriate foreach ($document as $field => $fieldValue) { // check if we need to add a boost.* parameters $fieldBoost = $document->getFieldBoost($field); if ($fieldBoost !== false) { $params["boost.{$field}"] = $fieldBoost; } // add the literal.* parameter $params["literal.{$field}"] = $fieldValue; } } // params will be sent to SOLR in the QUERY STRING $queryString = $this->_generateQueryString($params); // the file contents will be sent to SOLR as the POST BODY - we use application/octect-stream as default mimetype return $this->_sendRawPost($this->_extractUrl . $this->_queryDelimiter . $queryString, $data, false, $mimetype); } /** * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how * to use Solr Cell and what parameters are available. * * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). * * @param string $url URL * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) * @param string $mimetype optional mimetype specification (for the file being extracted) * * @return Apache_Solr_Response * * @throws Apache_Solr_InvalidArgumentException if $url, $params, or $document are invalid. */ public function extractFromUrl($url, $params = array(), $document = null, $mimetype = 'application/octet-stream') { // check if $params is an array (allow null for default empty array) if (!is_null($params)) { if (!is_array($params)) { throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); } } else { $params = array(); } $httpTransport = $this->getHttpTransport(); // read the contents of the URL using our configured Http Transport and default timeout $httpResponse = $httpTransport->performGetRequest($url); // check that its a 200 response if ($httpResponse->getStatusCode() == 200) { // add the resource.name parameter if not specified if (!isset($params['resource.name'])) { $params['resource.name'] = $url; } // delegate the rest to extractFromString return $this->extractFromString($httpResponse->getBody(), $params, $document, $mimetype); } else { throw new Apache_Solr_InvalidArgumentException("URL '{$url}' returned non 200 response code"); } } /** * Send an optimize command. Will be synchronous unless both wait parameters are set * to false. * * @param boolean $waitFlush * @param boolean $waitSearcher * @param float $timeout Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call */ public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600) { $flushValue = $waitFlush ? 'true' : 'false'; $searcherValue = $waitSearcher ? 'true' : 'false'; $rawPost = '<optimize waitSearcher="' . $searcherValue . '" />'; return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); } /** * Simple Search interface * * @param string $query The raw query string * @param int $offset The starting offset for result documents * @param int $limit The maximum number of result documents to return * @param array $params key / value pairs for other query parameters (see Solr documentation), use arrays for parameter keys used more than once (e.g. facet.field) * @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST) * @return Apache_Solr_Response * * @throws Apache_Solr_HttpTransportException If an error occurs during the service call * @throws Apache_Solr_InvalidArgumentException If an invalid HTTP method is used */ public function search($query, $offset = 0, $limit = 10, $params = array(), $method = self::METHOD_GET) { // ensure params is an array if (!is_null($params)) { if (!is_array($params)) { // params was specified but was not an array - invalid throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); } } else { $params = array(); } // construct our full parameters // common parameters in this interface $params['wt'] = self::SOLR_WRITER; $params['json.nl'] = $this->_namedListTreatment; $params['q'] = $query; $params['start'] = $offset; $params['rows'] = $limit; $queryString = $this->_generateQueryString($params); if ($method == self::METHOD_GET) { return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString); } else if ($method == self::METHOD_POST) { return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded; charset=UTF-8'); } else { throw new Apache_Solr_InvalidArgumentException("Unsupported method '$method', please use the Apache_Solr_Service::METHOD_* constants"); } } }
ekilfeather/open-storyscope
profiles/storyscope/libraries/SolrPhpClient/Apache/Solr/Service.php
PHP
gpl-2.0
39,313
##Conventions This entire doc is really just a bunch of stuff you'll probably need to know, or at least reference to contribute successfully to Reaction development. Our core is being built with a preference for Coffeescript + LESS, but JavaScript is welcome in packages. [There has been some discussion about moving to ES6.](https://github.com/reactioncommerce/reaction/issues/320) ##Issues For development tasks/issues please use the [Reaction project issues](https://github.com/ongoworks/reaction/issues?state=open). We're keeping this as the central issue tracking for all [reactioncommerce:*](https://github.com/reactioncommerce/) packages. You can also view issues on our [waffle board](https://waffle.io/reactioncommerce/reaction). The default branch for reaction, reaction-core, reaction-core-theme is *development*. Pull requests made into the *development* branch, will be reviewed and accepted into development for a quick release, while we work on specific feature branches separately, to be merged into *development*. We're trying to practice the art of liberally creating issues for every development task, rather than just 'community' bugs. This can be much noisier but we're trying to ensure we're publicly capturing and sharing all the tasks so everyone can have detailed insight into the project progress. The [help wanted](https://github.com/reactioncommerce/reaction/labels/help%20wanted) label calls out issues that prioritize where community member contributions would be relatively easy. Of course, all contributions are welcome. The [ready](https://github.com/reactioncommerce/reaction/labels/ready) label groups issues that can be worked on immediately; requirements documentation should be complete (work to do on this). If you want to take ownership of one these [![Stories in Ready](https://badge.waffle.io/reactioncommerce/reaction.svg?label=ready&title=Ready)](http://waffle.io/reactioncommerce/reaction) issues, self assign it and change to "in progress" label when the item is actually being worked on, or comment in the issue. Of course, [in progress](https://github.com/reactioncommerce/reaction/labels/in%20progress) labels are actively being worked on. ##Releases We will publish packages, and merge `development` into `master`, whenever a major feature set becomes test-able. No pull requests to `master` will be accepted. `master` should always be a stable branch, but with a rapid merge cycle from `development`. The [release](https://github.com/reactioncommerce/reaction/releases) and published packages will be tagged for minor release or higher, and sometimes for special case patches. ##Testing We're testing a couple of [Velocity packages](http://velocity.meteor.com/). See: https://github.com/reactioncommerce/reaction/issues/241 Velocity doesn't currently make it easy to test packages separately from the app, [but hopefully will soon](https://github.com/meteor-velocity/velocity/pull/231). In the meantime we are testing reaction-core and other core packages with Velocity by copying the tests into the main Reaction app's `/tests` directory and running from there. A few things you should know: * First you'll need to uncomment `mike:mocha` and `sanjo:jasmine` in the `/.meteor/packages` file in the main meteor app. * You should set your `NODE_ENV` enviornment variable to 'development' to open up ports that velocity uses. The easiest way to do this is to run `export NODE_ENV="development"` before you start `meteor` * After doing that, your Velocity tests should run when you run `meteor run` * If you change or update the file structure in your `/tests` folder you may need to delete your `/packages/tests-proxy` directory. [This is a known issue with sanjo:jasmine](https://github.com/meteor-velocity/node-soft-mirror/issues/9#issuecomment-74386394) * If you run `meteor --test` your tests will only run once and will not re-run when you update files. * Tests should be kept in the packages that they are testing, which means that _for now_ you will need to write your tests in the main Reaction app and then copy them to the package before creating a pull-request. Do not submit pull-requests to the main Reaction app with tests that are for packages. Yes, it's a bit arduous right now, but that should be getting cleared up soon. We'd like for new features to include at least basic test-coverage. If you are unsure about how to do this just ask and, we can point you in the right direction. * Feature branches can be merged and released when they are feature incomplete, but soon we're planning on enforcing a passing test written for every pull request.* _Writing tests is a great way to get to know the codebase a little better too._ [We've got an open issue on testing where any problems you run into while testing can go for now.](https://github.com/reactioncommerce/reaction/issues/241) ##Pull Requests **Caution: your own research may be needed here, feedback is appreciated!** Please make sure your pull requests are to the active `development` branch, no pull requests to `master` will be accepted. When you create a pull request, you can click the 'edit' button to change the "to" branch. Please cleanup your PR into as few commits as possible (single is good). In your branch: ```bash git rebase -i origin/development ``` In the editor that opens, replace the words "pick" with "squash" next to the commits you want to squash into the commit before it(so all but the first one, for a single commit). Save and close the editor, and another editor instance will open the combined commit messages, tidy them up and save and close the editor. If you need to edit the commit message later you can use ```bash git commit --amend ``` You can now `push` your branch to GitHub. If you've already published this branch, you should create a new branch, or use `--force` (rewrites history) ```bash git push --force ``` Finally, [create a pull request](https://help.github.com/articles/creating-a-pull-request/) into the `development` branch of the appropriate reaction package. ##Style Guide *A work in progress, but these are good guides.* Read [Meteor Style Guide](https://github.com/meteor/meteor/wiki/Meteor-Style-Guide) for ideas on format and style of contributions. Generally, follow the [CoffeeScript Style Guide](https://github.com/polarmobile/coffeescript-style-guide) as well. **event,template** When using event, template parameters in methods, use full names 'click': (event, template) -> **return** As much as possible, include the `return` keyword in all functions. Include it alone if you want to return `undefined` since coffeescript will otherwise try to return some other value, and it may not be what you expect or want. Using explicit `return` also makes the code more readable for others. **comments** Use of `{{!-- comment --}}` rather than `<!-- comment -->` is suggested, this isn't outputed in production. ###Folder structure public *public file assets* private *private files* settings *runtime configuration files* packages -> client -> templates *all client templates* -> functionalTriad *camelCased short functional template naming* functionalTriad.less *triad of functional group, new functionality goes in sub* functionalTriad.html functionalTriad.coffee -> subFunctionalTriad subFunctionalTriad.less subFunctionalTriad.html subFunctionalTriad.coffee -> lib *client specific shared libraries* register.coffee *files common to all client side* *register adds to reaction dashboard* routing.coffee subscriptions.coffee -> common *code common to client and server* -> collections -> schemas -> helpers -> hooks -> lib *libraries for server side* -> server *server side code* methods.coffee publications.coffee package.js *package declarations for meteor* ###Presentation layer See [themes.md](themes.md) for details on the themes and LESS implementation. -> functionalTriad.less class="functional-triad-class" *hyphenated class names, replace camel casing* id="functional-triad-id" functionalTriad.html <template name="functionalTriad"> functionalTriad.coffee Template.functionalTriad.helpers Template.functionalTriad.events ##Server Methods ###Variable Scope & Namespaces *common/packageGlobals.js:* ```js // exported, global/window scope ReactionCore = {}; ReactionCore.Schemas = {}; // Schemas defined in common/schemas ReactionCore.Collections = {}; //Collections defined in common/collections ReactionCore.Helpers = {}; //Misc.helpers defined in common/helpers ReactionCore.MetaData = {}; // SEO, Metadata object ReactionCore.Locale = {}; //i18n translation object ReactionCore.Events = {}; // Logger instantiation (server) ``` *common/collections/collections.coffee:* ```coffee Product = ReactionCore.Collections.Product = new Mongo.Collection("Product") # etc... ``` *anyfile.coffee:* ```coffee # If we're going to use Product collection in this file, which could be in core or in an add-on pkg, # we can optionally assign to a file-scope variable at the top of the file to keep our code short. Product = ReactionCore.Collections.Product # etc... # At some point, in some file, we eventually define all the variables from packageGlobals.js helperOne = -> return true ``` The `reaction-core` package exports `ReactionCore`, on both client and server: ```js api.export(["ReactionCore"]); ``` ###Logging We use Bunyan for server logging https://github.com/trentm/node-bunyan. Client logging is standard Meteor client handling of `console.log`. The ongoworks:bunyan package exports `loggers`, and is instantiated by the `ReactionCore.Events` global that can be used anywhere in Reaction code. To enable logging set/add `isDebug: true` in `settings.json`. Value can be any valid `bunyan level` in settings.json, or true/false. Setting a level of *debug* `isDebug: "debug"` or higher will display verbose logs as JSON. The JSON format is also the storage / display format for production. *Recommend running meteor with `--raw-log` to remove Meteor's default console formatting. This is the default when you use `./bin/run` to start Meteor.* Feel free to include verbose logging, but follow [Bunyan recommendations on log levels](https://github.com/trentm/node-bunyan#levels) and use appropriate levels for your messages. ``` The log levels in bunyan are as follows. The level descriptions are best practice opinions. "fatal" (60): The service/app is going to stop or become unusable now. An operator should definitely look into this soon. "error" (50): Fatal for a particular request, but the service/app continues servicing other requests. An operator should look at this soon(ish). "warn" (40): A note on something that should probably be looked at by an operator eventually. "info" (30): Detail on regular operation. "debug" (20): Anything else, i.e. too verbose to be included in "info" level. "trace" (10): Logging from external libraries used by your app or very detailed application logging. Suggestions: Use "debug" sparingly. Information that will be useful to debug errors post mortem should usually be included in "info" messages if it's generally relevant or else with the corresponding "error" event. Don't rely on spewing mostly irrelevant debug messages all the time and sifting through them when an error occurs. ``` Example: ``` ReactionCore.Events.info "Something we want to see during development" ```
yuxiang-zhou/3dShop
packages/shop-core/docs/conventions.md
Markdown
gpl-2.0
11,539
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package tesisweb.controller.general; /** * * @author root */ /* ******************************************* // Copyright 2010-2012, Anthony Hand // // File version date: January 21, 2012 // Update: // - Moved Windows Phone 7 to the iPhone Tier. WP7.5's IE 9-based browser is good enough now. // - Added a new variable for 2 versions of the new BlackBerry Bold Touch (9900 and 9930): deviceBBBoldTouch. // - Updated DetectBlackBerryTouch() to support the 2 versions of the new BlackBerry Bold Touch (9900 and 9930). // - Updated DetectKindle() to focus on eInk devices only. The Kindle Fire should be detected as a regular Android device. // // File version date: August 22, 2011 // Update: // - Updated DetectAndroidTablet() to fix a bug I introduced in the last fix! // // File version date: August 16, 2011 // Update: // - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone. // // File version date: August 7, 2011 // Update: // - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed. // - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile. // - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet(). // - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS. // // // LICENSE INFORMATION // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific // language governing permissions and limitations under the License. // // // ABOUT THIS PROJECT // Project Owner: Anthony Hand // Email: anthony.hand@gmail.com // Web Site: http://www.mobileesp.com // Source Files: http://code.google.com/p/mobileesp/ // // Versions of this code are available for: // PHP, JavaScript, Java, ASP.NET (C#), and Ruby // // ******************************************* */ /** * The DetectSmartPhone class encapsulates information about * a browser's connection to your web site. * You can use it to find out whether the browser asking for * your site's content is probably running on a mobile device. * The methods were written so you can be as granular as you want. * For example, enquiring whether it's as specific as an iPod Touch or * as general as a smartphone class device. * The object's methods return true, or false. */ public class UserAgentInfo { // User-Agent and Accept HTTP request headers private String userAgent = ""; private String httpAccept = ""; // Let's store values for quickly accessing the same info multiple times. public boolean isIphone = false; public boolean isAndroidPhone = false; public boolean isTierTablet = false; public boolean isTierIphone = false; public boolean isTierRichCss = false; public boolean isTierGenericMobile = false; // Initialize some initial smartphone string variables. public static final String engineWebKit = "webkit"; public static final String deviceIphone = "iphone"; public static final String deviceIpod = "ipod"; public static final String deviceIpad = "ipad"; public static final String deviceMacPpc = "macintosh"; //Used for disambiguation public static final String deviceAndroid = "android"; public static final String deviceGoogleTV = "googletv"; public static final String deviceXoom = "xoom"; //Motorola Xoom public static final String deviceHtcFlyer = "htc_flyer"; //HTC Flyer public static final String deviceSymbian = "symbian"; public static final String deviceS60 = "series60"; public static final String deviceS70 = "series70"; public static final String deviceS80 = "series80"; public static final String deviceS90 = "series90"; public static final String deviceWinPhone7 = "windows phone os 7"; public static final String deviceWinMob = "windows ce"; public static final String deviceWindows = "windows"; public static final String deviceIeMob = "iemobile"; public static final String devicePpc = "ppc"; //Stands for PocketPC public static final String enginePie = "wm5 pie"; //An old Windows Mobile public static final String deviceBB = "blackberry"; public static final String vndRIM = "vnd.rim"; //Detectable when BB devices emulate IE or Firefox public static final String deviceBBStorm = "blackberry95"; //Storm 1 and 2 public static final String deviceBBBold = "blackberry97"; //Bold 97x0 (non-touch) public static final String deviceBBBoldTouch = "blackberry 99"; //Bold 99x0 (touchscreen) public static final String deviceBBTour = "blackberry96"; //Tour public static final String deviceBBCurve = "blackberry89"; //Curve 2 public static final String deviceBBTorch = "blackberry 98"; //Torch public static final String deviceBBPlaybook = "playbook"; //PlayBook tablet public static final String devicePalm = "palm"; public static final String deviceWebOS = "webos"; //For Palm's line of WebOS devices public static final String deviceWebOShp = "hpwos"; //For HP's line of WebOS devices public static final String engineBlazer = "blazer"; //Old Palm public static final String engineXiino = "xiino"; //Another old Palm public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one. public static final String deviceNuvifone = "nuvifone"; //Garmin Nuvifone //Initialize variables for mobile-specific content. public static final String vndwap = "vnd.wap"; public static final String wml = "wml"; //Initialize variables for other random devices and mobile browsers. public static final String deviceTablet = "tablet"; //Generic term for slate and tablet devices public static final String deviceBrew = "brew"; public static final String deviceDanger = "danger"; public static final String deviceHiptop = "hiptop"; public static final String devicePlaystation = "playstation"; public static final String deviceNintendoDs = "nitro"; public static final String deviceNintendo = "nintendo"; public static final String deviceWii = "wii"; public static final String deviceXbox = "xbox"; public static final String deviceArchos = "archos"; public static final String engineOpera = "opera"; //Popular browser public static final String engineNetfront = "netfront"; //Common embedded OS browser public static final String engineUpBrowser = "up.browser"; //common on some phones public static final String engineOpenWeb = "openweb"; //Transcoding by OpenWave server public static final String deviceMidp = "midp"; //a mobile Java technology public static final String uplink = "up.link"; public static final String engineTelecaQ = "teleca q"; //a modern feature phone browser public static final String devicePda = "pda"; //some devices report themselves as PDAs public static final String mini = "mini"; //Some mobile browsers put "mini" in their names. public static final String mobile = "mobile"; //Some mobile browsers put "mobile" in their user agent strings. public static final String mobi = "mobi"; //Some mobile browsers put "mobi" in their user agent strings. //Use Maemo, Tablet, and Linux to test for Nokia"s Internet Tablets. public static final String maemo = "maemo"; public static final String linux = "linux"; public static final String qtembedded = "qt embedded"; //for Sony Mylo public static final String mylocom2 = "com2"; //for Sony Mylo also //In some UserAgents, the only clue is the manufacturer. public static final String manuSonyEricsson = "sonyericsson"; public static final String manuericsson = "ericsson"; public static final String manuSamsung1 = "sec-sgh"; public static final String manuSony = "sony"; public static final String manuHtc = "htc"; //Popular Android and WinMo manufacturer //In some UserAgents, the only clue is the operator. public static final String svcDocomo = "docomo"; public static final String svcKddi = "kddi"; public static final String svcVodafone = "vodafone"; //Disambiguation strings. public static final String disUpdate = "update"; //pda vs. update /** * Initialize the userAgent and httpAccept variables * * @param userAgent the User-Agent header * @param httpAccept the Accept header */ public UserAgentInfo(String userAgent, String httpAccept) { if (userAgent != null) { this.userAgent = userAgent.toLowerCase(); } if (httpAccept != null) { this.httpAccept = httpAccept.toLowerCase(); } //Intialize key stored values. initDeviceScan(); } /** * Is the device is any Mobile Device (in list of course) * @return */ public boolean isMobileDevice(){ if(isIphone || isAndroidPhone || isTierTablet || isTierIphone || isTierRichCss || isTierGenericMobile) return true; return false; } /** * Return the lower case HTTP_USER_AGENT * @return userAgent */ public String getUserAgent() { return userAgent; } /** * Return the lower case HTTP_ACCEPT * @return httpAccept */ public String getHttpAccept() { return httpAccept; } /** * Return whether the device is an Iphone or iPod Touch * @return isIphone */ public boolean getIsIphone() { return isIphone; } /** * Return whether the device is in the Tablet Tier. * @return isTierTablet */ public boolean getIsTierTablet() { return isTierTablet; } /** * Return whether the device is in the Iphone Tier. * @return isTierIphone */ public boolean getIsTierIphone() { return isTierIphone; } /** * Return whether the device is in the 'Rich CSS' tier of mobile devices. * @return isTierRichCss */ public boolean getIsTierRichCss() { return isTierRichCss; } /** * Return whether the device is a generic, less-capable mobile device. * @return isTierGenericMobile */ public boolean getIsTierGenericMobile() { return isTierGenericMobile; } /** * Initialize Key Stored Values. */ public void initDeviceScan() { this.isIphone = detectIphoneOrIpod(); this.isAndroidPhone = detectAndroidPhone(); this.isTierTablet = detectTierTablet(); this.isTierIphone = detectTierIphone(); this.isTierRichCss = detectTierRichCss(); this.isTierGenericMobile = detectTierOtherPhones(); } /** * Detects if the current device is an iPhone. * @return detection of an iPhone */ public boolean detectIphone() { // The iPad and iPod touch say they're an iPhone! So let's disambiguate. if (userAgent.indexOf(deviceIphone) != -1 && !detectIpad() && !detectIpod()) { return true; } return false; } /** * Detects if the current device is an iPod Touch. * @return detection of an iPod Touch */ public boolean detectIpod() { if (userAgent.indexOf(deviceIpod) != -1) { return true; } return false; } /** * Detects if the current device is an iPad tablet. * @return detection of an iPad */ public boolean detectIpad() { if (userAgent.indexOf(deviceIpad) != -1 && detectWebkit()) { return true; } return false; } /** * Detects if the current device is an iPhone or iPod Touch. * @return detection of an iPhone or iPod Touch */ public boolean detectIphoneOrIpod() { //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay. if (userAgent.indexOf(deviceIphone) != -1 || userAgent.indexOf(deviceIpod) != -1) { return true; } return false; } /** * Detects *any* iOS device: iPhone, iPod Touch, iPad. * @return detection of an Apple iOS device */ public boolean detectIos() { if (detectIphoneOrIpod() || detectIpad()) { return true; } return false; } /** * Detects *any* Android OS-based device: phone, tablet, and multi-media player. * Also detects Google TV. * @return detection of an Android device */ public boolean detectAndroid() { if ((userAgent.indexOf(deviceAndroid) != -1) || detectGoogleTV()) return true; //Special check for the HTC Flyer 7" tablet. It should report here. if (userAgent.indexOf(deviceHtcFlyer) != -1) return true; return false; } /** * Detects if the current device is a (small-ish) Android OS-based device * used for calling and/or multi-media (like a Samsung Galaxy Player). * Google says these devices will have 'Android' AND 'mobile' in user agent. * Ignores tablets (Honeycomb and later). * @return detection of an Android phone */ public boolean detectAndroidPhone() { if (detectAndroid() && (userAgent.indexOf(mobile) != -1)) return true; //Special check for Android phones with Opera Mobile. They should report here. if (detectOperaAndroidPhone()) return true; //Special check for the HTC Flyer 7" tablet. It should report here. if (userAgent.indexOf(deviceHtcFlyer) != -1) return true; return false; } /** * Detects if the current device is a (self-reported) Android tablet. * Google says these devices will have 'Android' and NOT 'mobile' in their user agent. * @return detection of an Android tablet */ public boolean detectAndroidTablet() { //First, let's make sure we're on an Android device. if (!detectAndroid()) return false; //Special check for Opera Android Phones. They should NOT report here. if (detectOperaMobile()) return false; //Special check for the HTC Flyer 7" tablet. It should NOT report here. if (userAgent.indexOf(deviceHtcFlyer) != -1) return false; //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet. if ((userAgent.indexOf(mobile) > -1)) return false; else return true; } /** * Detects if the current device is an Android OS-based device and * the browser is based on WebKit. * @return detection of an Android WebKit browser */ public boolean detectAndroidWebKit() { if (detectAndroid() && detectWebkit()) { return true; } return false; } /** * Detects if the current device is a GoogleTV. * @return detection of GoogleTV */ public boolean detectGoogleTV() { if (userAgent.indexOf(deviceGoogleTV) != -1) { return true; } return false; } /** * Detects if the current browser is based on WebKit. * @return detection of a WebKit browser */ public boolean detectWebkit() { if (userAgent.indexOf(engineWebKit) != -1) { return true; } return false; } /** * Detects if the current browser is the Symbian S60 Open Source Browser. * @return detection of Symbian S60 Browser */ public boolean detectS60OssBrowser() { //First, test for WebKit, then make sure it's either Symbian or S60. if (detectWebkit() && (userAgent.indexOf(deviceSymbian) != -1 || userAgent.indexOf(deviceS60) != -1)) { return true; } return false; } /** * * Detects if the current device is any Symbian OS-based device, * including older S60, Series 70, Series 80, Series 90, and UIQ, * or other browsers running on these devices. * @return detection of SymbianOS */ public boolean detectSymbianOS() { if (userAgent.indexOf(deviceSymbian) != -1 || userAgent.indexOf(deviceS60) != -1 || userAgent.indexOf(deviceS70) != -1 || userAgent.indexOf(deviceS80) != -1 || userAgent.indexOf(deviceS90) != -1) { return true; } return false; } /** * Detects if the current browser is a * Windows Phone 7 device. * @return detection of Windows Phone 7 */ public boolean detectWindowsPhone7() { if (userAgent.indexOf(deviceWinPhone7) != -1) { return true; } return false; } /** * Detects if the current browser is a Windows Mobile device. * Excludes Windows Phone 7 devices. * Focuses on Windows Mobile 6.xx and earlier. * @return detection of Windows Mobile */ public boolean detectWindowsMobile() { //Exclude new Windows Phone 7. if (detectWindowsPhone7()) { return false; } //Most devices use 'Windows CE', but some report 'iemobile' // and some older ones report as 'PIE' for Pocket IE. // We also look for instances of HTC and Windows for many of their WinMo devices. if (userAgent.indexOf(deviceWinMob) != -1 || userAgent.indexOf(deviceWinMob) != -1 || userAgent.indexOf(deviceIeMob) != -1 || userAgent.indexOf(enginePie) != -1 || (userAgent.indexOf(manuHtc) != -1 && userAgent.indexOf(deviceWindows) != -1) || (detectWapWml() && userAgent.indexOf(deviceWindows) != -1)) { return true; } //Test for Windows Mobile PPC but not old Macintosh PowerPC. if (userAgent.indexOf(devicePpc) != -1 && !(userAgent.indexOf(deviceMacPpc) != -1)) return true; return false; } /** * Detects if the current browser is any BlackBerry. * Includes the PlayBook. * @return detection of Blackberry */ public boolean detectBlackBerry() { if (userAgent.indexOf(deviceBB) != -1 || httpAccept.indexOf(vndRIM) != -1) { return true; } return false; } /** * Detects if the current browser is on a BlackBerry tablet device. * Example: PlayBook * @return detection of a Blackberry Tablet */ public boolean detectBlackBerryTablet() { if (userAgent.indexOf(deviceBBPlaybook) != -1) { return true; } return false; } /** * Detects if the current browser is a BlackBerry device AND uses a * WebKit-based browser. These are signatures for the new BlackBerry OS 6. * Examples: Torch. Includes the Playbook. * @return detection of a Blackberry device with WebKit browser */ public boolean detectBlackBerryWebKit() { if (detectBlackBerry() && userAgent.indexOf(engineWebKit) != -1) { return true; } return false; } /** * Detects if the current browser is a BlackBerry Touch * device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook. * @return detection of a Blackberry touchscreen device */ public boolean detectBlackBerryTouch() { if (detectBlackBerry() && (userAgent.indexOf(deviceBBStorm) != -1 || userAgent.indexOf(deviceBBTorch) != -1 || userAgent.indexOf(deviceBBBoldTouch) != -1)) { return true; } return false; } /** * Detects if the current browser is a BlackBerry device AND * has a more capable recent browser. Excludes the Playbook. * Examples, Storm, Bold, Tour, Curve2 * Excludes the new BlackBerry OS 6 and 7 browser!! * @return detection of a Blackberry device with a better browser */ public boolean detectBlackBerryHigh() { //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser if (detectBlackBerryWebKit()) return false; if (detectBlackBerry()) { if (detectBlackBerryTouch() || userAgent.indexOf(deviceBBBold) != -1 || userAgent.indexOf(deviceBBTour) != -1 || userAgent.indexOf(deviceBBCurve) != -1) { return true; } else { return false; } } else { return false; } } /** * Detects if the current browser is a BlackBerry device AND * has an older, less capable browser. * Examples: Pearl, 8800, Curve1 * @return detection of a Blackberry device with a poorer browser */ public boolean detectBlackBerryLow() { if (detectBlackBerry()) { //Assume that if it's not in the High tier, then it's Low if (detectBlackBerryHigh() || detectBlackBerryWebKit()) { return false; } else { return true; } } else { return false; } } /** * Detects if the current browser is on a PalmOS device. * @return detection of a PalmOS device */ public boolean detectPalmOS() { //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino. if (userAgent.indexOf(devicePalm) != -1 || userAgent.indexOf(engineBlazer) != -1 || userAgent.indexOf(engineXiino) != -1) { //Make sure it's not WebOS first if (detectPalmWebOS()) { return false; } else { return true; } } return false; } /** * Detects if the current browser is on a Palm device * running the new WebOS. * @return detection of a Palm WebOS device */ public boolean detectPalmWebOS() { if (userAgent.indexOf(deviceWebOS) != -1) { return true; } return false; } /** * Detects if the current browser is on an HP tablet running WebOS. * @return detection of an HP WebOS tablet */ public boolean detectWebOSTablet() { if (userAgent.indexOf(deviceWebOShp) != -1 && userAgent.indexOf(deviceTablet) != -1) { return true; } return false; } /** * Detects if the current browser is a * Garmin Nuvifone. * @return detection of a Garmin Nuvifone */ public boolean detectGarminNuvifone() { if (userAgent.indexOf(deviceNuvifone) != -1) { return true; } return false; } /** * Check to see whether the device is any device * in the 'smartphone' category. * @return detection of a general smartphone device */ public boolean detectSmartphone() { return (isIphone || isAndroidPhone || isTierIphone || detectS60OssBrowser() || detectSymbianOS() || detectWindowsMobile() || detectWindowsPhone7() || detectBlackBerry() || detectPalmWebOS() || detectPalmOS() || detectGarminNuvifone()); } /** * Detects whether the device is a Brew-powered device. * @return detection of a Brew device */ public boolean detectBrewDevice() { if (userAgent.indexOf(deviceBrew) != -1) { return true; } return false; } /** * Detects the Danger Hiptop device. * @return detection of a Danger Hiptop */ public boolean detectDangerHiptop() { if (userAgent.indexOf(deviceDanger) != -1 || userAgent.indexOf(deviceHiptop) != -1) { return true; } return false; } /** * Detects Opera Mobile or Opera Mini. * @return detection of an Opera browser for a mobile device */ public boolean detectOperaMobile() { if (userAgent.indexOf(engineOpera) != -1 && (userAgent.indexOf(mini) != -1 || userAgent.indexOf(mobi) != -1)) { return true; } return false; } /** * Detects Opera Mobile on an Android phone. * @return detection of an Opera browser on an Android phone */ public boolean detectOperaAndroidPhone() { if (userAgent.indexOf(engineOpera) != -1 && (userAgent.indexOf(deviceAndroid) != -1 && userAgent.indexOf(mobi) != -1)) { return true; } return false; } /** * Detects Opera Mobile on an Android tablet. * @return detection of an Opera browser on an Android tablet */ public boolean detectOperaAndroidTablet() { if (userAgent.indexOf(engineOpera) != -1 && (userAgent.indexOf(deviceAndroid) != -1 && userAgent.indexOf(deviceTablet) != -1)) { return true; } return false; } /** * Detects whether the device supports WAP or WML. * @return detection of a WAP- or WML-capable device */ public boolean detectWapWml() { if (httpAccept.indexOf(vndwap) != -1 || httpAccept.indexOf(wml) != -1) { return true; } return false; } /** * Detects if the current device is an Amazon Kindle (eInk devices only). * Note: For the Kindle Fire, use the normal Android methods. * @return detection of a Kindle */ public boolean detectKindle() { if (userAgent.indexOf(deviceKindle)!= -1 && !detectAndroid()) { return true; } return false; } /** * Detects if the current device is a mobile device. * This method catches most of the popular modern devices. * Excludes Apple iPads and other modern tablets. * @return detection of any mobile device using the quicker method */ public boolean detectMobileQuick() { //Let's exclude tablets if (isTierTablet) { return false; } //Most mobile browsing is done on smartphones if (detectSmartphone()) { return true; } if (detectWapWml() || detectBrewDevice() || detectOperaMobile()) { return true; } if ((userAgent.indexOf(engineNetfront) != -1) || (userAgent.indexOf(engineUpBrowser) != -1) || (userAgent.indexOf(engineOpenWeb) != -1)) { return true; } if (detectDangerHiptop() || detectMidpCapable() || detectMaemoTablet() || detectArchos()) { return true; } if ((userAgent.indexOf(devicePda) != -1) && (userAgent.indexOf(disUpdate) < 0)) //no index found { return true; } if (userAgent.indexOf(mobile) != -1) { return true; } return false; } /** * Detects if the current device is a Sony Playstation. * @return detection of Sony Playstation */ public boolean detectSonyPlaystation() { if (userAgent.indexOf(devicePlaystation) != -1) { return true; } return false; } /** * Detects if the current device is a Nintendo game device. * @return detection of Nintendo */ public boolean detectNintendo() { if (userAgent.indexOf(deviceNintendo) != -1 || userAgent.indexOf(deviceWii) != -1 || userAgent.indexOf(deviceNintendoDs) != -1) { return true; } return false; } /** * Detects if the current device is a Microsoft Xbox. * @return detection of Xbox */ public boolean detectXbox() { if (userAgent.indexOf(deviceXbox) != -1) { return true; } return false; } /** * Detects if the current device is an Internet-capable game console. * @return detection of any Game Console */ public boolean detectGameConsole() { if (detectSonyPlaystation() || detectNintendo() || detectXbox()) { return true; } return false; } /** * Detects if the current device supports MIDP, a mobile Java technology. * @return detection of a MIDP mobile Java-capable device */ public boolean detectMidpCapable() { if (userAgent.indexOf(deviceMidp) != -1 || httpAccept.indexOf(deviceMidp) != -1) { return true; } return false; } /** * Detects if the current device is on one of the Maemo-based Nokia Internet Tablets. * @return detection of a Maemo OS tablet */ public boolean detectMaemoTablet() { if (userAgent.indexOf(maemo) != -1) { return true; } else if (userAgent.indexOf(linux) != -1 && userAgent.indexOf(deviceTablet) != -1 && !detectWebOSTablet() && !detectAndroid()) { return true; } return false; } /** * Detects if the current device is an Archos media player/Internet tablet. * @return detection of an Archos media player */ public boolean detectArchos() { if (userAgent.indexOf(deviceArchos) != -1) { return true; } return false; } /** * Detects if the current browser is a Sony Mylo device. * @return detection of a Sony Mylo device */ public boolean detectSonyMylo() { if (userAgent.indexOf(manuSony) != -1 && (userAgent.indexOf(qtembedded) != -1 || userAgent.indexOf(mylocom2) != -1)) { return true; } return false; } /** * The longer and more thorough way to detect for a mobile device. * Will probably detect most feature phones, * smartphone-class devices, Internet Tablets, * Internet-enabled game consoles, etc. * This ought to catch a lot of the more obscure and older devices, also -- * but no promises on thoroughness! * @return detection of any mobile device using the more thorough method */ public boolean detectMobileLong() { if (detectMobileQuick() || detectGameConsole() || detectSonyMylo()) { return true; } //detect older phones from certain manufacturers and operators. if (userAgent.indexOf(uplink) != -1) { return true; } if (userAgent.indexOf(manuSonyEricsson) != -1) { return true; } if (userAgent.indexOf(manuericsson) != -1) { return true; } if (userAgent.indexOf(manuSamsung1) != -1) { return true; } if (userAgent.indexOf(svcDocomo) != -1) { return true; } if (userAgent.indexOf(svcKddi) != -1) { return true; } if (userAgent.indexOf(svcVodafone) != -1) { return true; } return false; } //***************************** // For Mobile Web Site Design //***************************** /** * The quick way to detect for a tier of devices. * This method detects for the new generation of * HTML 5 capable, larger screen tablets. * Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc. * @return detection of any device in the Tablet Tier */ public boolean detectTierTablet() { if (detectIpad() || detectAndroidTablet() || detectBlackBerryTablet() || detectWebOSTablet()) { return true; } return false; } /** * The quick way to detect for a tier of devices. * This method detects for devices which can * display iPhone-optimized web content. * Includes iPhone, iPod Touch, Android, Windows Phone 7, Palm WebOS, etc. * @return detection of any device in the iPhone/Android/WP7/WebOS Tier */ public boolean detectTierIphone() { if (isIphone || isAndroidPhone || (detectBlackBerryWebKit() && detectBlackBerryTouch()) || detectWindowsPhone7() || detectPalmWebOS() || detectGarminNuvifone()) { return true; } return false; } /** * The quick way to detect for a tier of devices. * This method detects for devices which are likely to be capable * of viewing CSS content optimized for the iPhone, * but may not necessarily support JavaScript. * Excludes all iPhone Tier devices. * @return detection of any device in the 'Rich CSS' Tier */ public boolean detectTierRichCss() { boolean result = false; //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY if (detectMobileQuick()) { if (!detectTierIphone()) { //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY //Older Windows 'Mobile' isn't good enough for iPhone Tier. if (detectWebkit() || detectS60OssBrowser() || detectBlackBerryHigh() || detectWindowsMobile() || userAgent.indexOf(engineTelecaQ) != -1) { result= true; } // if detectWebkit() } //if !detectTierIphone() } //if detectMobileQuick() return result; } /** * The quick way to detect for a tier of devices. * This method detects for all other types of phones, * but excludes the iPhone and RichCSS Tier devices. * @return detection of a mobile device in the less capable tier */ public boolean detectTierOtherPhones() { //Exclude devices in the other 2 categories if (detectMobileLong() && !detectTierIphone() && !detectTierRichCss()) { return true; } return false; } }
ferremarce/TEST_USABILIDAD
src/main/java/tesisweb/controller/general/UserAgentInfo.java
Java
gpl-2.0
35,267
<h2>Auswertung abgegebener Fragebögen</h2> <p>Hier finden Sie die Auswertung der abgegebenen Fragebögen. Sie habe außerdem die Möglichkeit die Antworten z.B. nach Excel zu exportieren.</p>
nadavkav/MoodleTAO
mod/feedback/lang/de_utf8/help/feedback/viewcompleted.html
HTML
gpl-2.0
193
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml invoiced report page content block * * @api * @author Magento Core Team <core@magentocommerce.com> * @since 100.0.2 */ class Invoiced extends \Magento\Backend\Block\Widget\Grid\Container { /** * Template file * * @var string */ protected $_template = 'Magento_Reports::report/grid/container.phtml'; /** * {@inheritdoc} */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; $this->_controller = 'adminhtml_sales_invoiced'; $this->_headerText = __('Total Invoiced vs. Paid Report'); parent::_construct(); $this->buttonList->remove('add'); $this->addButton( 'filter_form_submit', ['label' => __('Show Report'), 'onclick' => 'filterFormSubmit()', 'class' => 'primary'] ); } /** * Get filter URL * * @return string */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); return $this->getUrl('*/*/invoiced', ['_current' => true]); } }
kunj1988/Magento2
app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php
PHP
gpl-2.0
1,251
/* * Copyright (C) 2007 Google, Inc. * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/platform_device.h> #include <linux/sched.h> #include <linux/dma-mapping.h> #include <linux/io.h> #include <linux/crc16.h> #include <linux/bitrev.h> #include <asm/dma.h> #include <asm/mach/flash.h> #include <mach/dma.h> #include "msm_nand.h" unsigned long msm_nand_phys; unsigned long msm_nandc01_phys; unsigned long msm_nandc10_phys; unsigned long msm_nandc11_phys; unsigned long ebi2_register_base; uint32_t dual_nand_ctlr_present; uint32_t interleave_enable; unsigned crci_mask; #define MSM_NAND_DMA_BUFFER_SIZE SZ_8K #define MSM_NAND_DMA_BUFFER_SLOTS \ (MSM_NAND_DMA_BUFFER_SIZE / (sizeof(((atomic_t *)0)->counter) * 8)) #define MSM_NAND_CFG0_RAW 0xA80420C0 #define MSM_NAND_CFG1_RAW 0x5045D #define MSM_NAND_CFG0_RAW_ONFI_IDENTIFIER 0x88000800 #define MSM_NAND_CFG0_RAW_ONFI_PARAM_INFO 0x88040000 #define MSM_NAND_CFG1_RAW_ONFI_IDENTIFIER 0x0005045d #define MSM_NAND_CFG1_RAW_ONFI_PARAM_INFO 0x0005045d #define ONFI_IDENTIFIER_LENGTH 0x0004 #define ONFI_PARAM_INFO_LENGTH 0x0200 #define ONFI_PARAM_PAGE_LENGTH 0x0100 #define ONFI_PARAMETER_PAGE_SIGNATURE 0x49464E4F #define FLASH_READ_ONFI_IDENTIFIER_COMMAND 0x90 #define FLASH_READ_ONFI_IDENTIFIER_ADDRESS 0x20 #define FLASH_READ_ONFI_PARAMETERS_COMMAND 0xEC #define FLASH_READ_ONFI_PARAMETERS_ADDRESS 0x00 #define VERBOSE 0 struct msm_nand_chip { struct device *dev; wait_queue_head_t wait_queue; atomic_t dma_buffer_busy; unsigned dma_channel; uint8_t *dma_buffer; dma_addr_t dma_addr; unsigned CFG0, CFG1; uint32_t ecc_buf_cfg; }; #define CFG1_WIDE_FLASH (1U << 1) /* TODO: move datamover code out */ #define SRC_CRCI_NAND_CMD CMD_SRC_CRCI(DMOV_NAND_CRCI_CMD) #define DST_CRCI_NAND_CMD CMD_DST_CRCI(DMOV_NAND_CRCI_CMD) #define SRC_CRCI_NAND_DATA CMD_SRC_CRCI(DMOV_NAND_CRCI_DATA) #define DST_CRCI_NAND_DATA CMD_DST_CRCI(DMOV_NAND_CRCI_DATA) #define msm_virt_to_dma(chip, vaddr) \ ((void)(*(vaddr)), (chip)->dma_addr + \ ((uint8_t *)(vaddr) - (chip)->dma_buffer)) /** * msm_nand_oob_64 - oob info for 2KB page */ static struct nand_ecclayout msm_nand_oob_64 = { .eccbytes = 40, .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, }, .oobavail = 16, .oobfree = { {30, 16}, } }; /** * msm_nand_oob_128 - oob info for 4KB page */ static struct nand_ecclayout msm_nand_oob_128 = { .eccbytes = 80, .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, }, .oobavail = 32, .oobfree = { {70, 32}, } }; /** * msm_nand_oob_256 - oob info for 8KB page */ static struct nand_ecclayout msm_nand_oob_256 = { .eccbytes = 160, .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96, 97, 98 , 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, }, .oobavail = 64, .oobfree = { {151, 64}, } }; /** * msm_onenand_oob_64 - oob info for large (2KB) page */ static struct nand_ecclayout msm_onenand_oob_64 = { .eccbytes = 20, .eccpos = { 8, 9, 10, 11, 12, 24, 25, 26, 27, 28, 40, 41, 42, 43, 44, 56, 57, 58, 59, 60, }, .oobavail = 20, .oobfree = { {2, 3}, {14, 2}, {18, 3}, {30, 2}, {34, 3}, {46, 2}, {50, 3}, {62, 2} } }; static void *msm_nand_get_dma_buffer(struct msm_nand_chip *chip, size_t size) { unsigned int bitmask, free_bitmask, old_bitmask; unsigned int need_mask, current_need_mask; int free_index; need_mask = (1UL << DIV_ROUND_UP(size, MSM_NAND_DMA_BUFFER_SLOTS)) - 1; bitmask = atomic_read(&chip->dma_buffer_busy); free_bitmask = ~bitmask; do { free_index = __ffs(free_bitmask); current_need_mask = need_mask << free_index; if (size + free_index * MSM_NAND_DMA_BUFFER_SLOTS >= MSM_NAND_DMA_BUFFER_SIZE) return NULL; if ((bitmask & current_need_mask) == 0) { old_bitmask = atomic_cmpxchg(&chip->dma_buffer_busy, bitmask, bitmask | current_need_mask); if (old_bitmask == bitmask) return chip->dma_buffer + free_index * MSM_NAND_DMA_BUFFER_SLOTS; free_bitmask = 0; /* force return */ } /* current free range was too small, clear all free bits */ /* below the top busy bit within current_need_mask */ free_bitmask &= ~(~0U >> (32 - fls(bitmask & current_need_mask))); } while (free_bitmask); return NULL; } static void msm_nand_release_dma_buffer(struct msm_nand_chip *chip, void *buffer, size_t size) { int index; unsigned int used_mask; used_mask = (1UL << DIV_ROUND_UP(size, MSM_NAND_DMA_BUFFER_SLOTS)) - 1; index = ((uint8_t *)buffer - chip->dma_buffer) / MSM_NAND_DMA_BUFFER_SLOTS; atomic_sub(used_mask << index, &chip->dma_buffer_busy); wake_up(&chip->wait_queue); } unsigned flash_rd_reg(struct msm_nand_chip *chip, unsigned addr) { struct { dmov_s cmd; unsigned cmdptr; unsigned data; } *dma_buffer; unsigned rv; wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); dma_buffer->cmd.cmd = CMD_LC | CMD_OCB | CMD_OCU; dma_buffer->cmd.src = addr; dma_buffer->cmd.dst = msm_virt_to_dma(chip, &dma_buffer->data); dma_buffer->cmd.len = 4; dma_buffer->cmdptr = (msm_virt_to_dma(chip, &dma_buffer->cmd) >> 3) | CMD_PTR_LP; dma_buffer->data = 0xeeeeeeee; dsb(); msm_dmov_exec_cmd( chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); rv = dma_buffer->data; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); return rv; } void flash_wr_reg(struct msm_nand_chip *chip, unsigned addr, unsigned val) { struct { dmov_s cmd; unsigned cmdptr; unsigned data; } *dma_buffer; wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); dma_buffer->cmd.cmd = CMD_LC | CMD_OCB | CMD_OCU; dma_buffer->cmd.src = msm_virt_to_dma(chip, &dma_buffer->data); dma_buffer->cmd.dst = addr; dma_buffer->cmd.len = 4; dma_buffer->cmdptr = (msm_virt_to_dma(chip, &dma_buffer->cmd) >> 3) | CMD_PTR_LP; dma_buffer->data = val; dsb(); msm_dmov_exec_cmd( chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); } static dma_addr_t msm_nand_dma_map(struct device *dev, void *addr, size_t size, enum dma_data_direction dir) { struct page *page; unsigned long offset = (unsigned long)addr & ~PAGE_MASK; if (virt_addr_valid(addr)) page = virt_to_page(addr); else { if (WARN_ON(size + offset > PAGE_SIZE)) return ~0; page = vmalloc_to_page(addr); } return dma_map_page(dev, page, offset, size, dir); } uint32_t flash_read_id(struct msm_nand_chip *chip) { struct { dmov_s cmd[7]; unsigned cmdptr; unsigned data[7]; } *dma_buffer; uint32_t rv; wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); dma_buffer->data[0] = 0 | 4; dma_buffer->data[1] = MSM_NAND_CMD_FETCH_ID; dma_buffer->data[2] = 1; dma_buffer->data[3] = 0xeeeeeeee; dma_buffer->data[4] = 0xeeeeeeee; dma_buffer->data[5] = flash_rd_reg(chip, MSM_NAND_SFLASHC_BURST_CFG); dma_buffer->data[6] = 0x00000000; BUILD_BUG_ON(6 != ARRAY_SIZE(dma_buffer->data) - 1); dma_buffer->cmd[0].cmd = 0 | CMD_OCB; dma_buffer->cmd[0].src = msm_virt_to_dma(chip, &dma_buffer->data[6]); dma_buffer->cmd[0].dst = MSM_NAND_SFLASHC_BURST_CFG; dma_buffer->cmd[0].len = 4; dma_buffer->cmd[1].cmd = 0; dma_buffer->cmd[1].src = msm_virt_to_dma(chip, &dma_buffer->data[0]); dma_buffer->cmd[1].dst = MSM_NAND_FLASH_CHIP_SELECT; dma_buffer->cmd[1].len = 4; dma_buffer->cmd[2].cmd = DST_CRCI_NAND_CMD; dma_buffer->cmd[2].src = msm_virt_to_dma(chip, &dma_buffer->data[1]); dma_buffer->cmd[2].dst = MSM_NAND_FLASH_CMD; dma_buffer->cmd[2].len = 4; dma_buffer->cmd[3].cmd = 0; dma_buffer->cmd[3].src = msm_virt_to_dma(chip, &dma_buffer->data[2]); dma_buffer->cmd[3].dst = MSM_NAND_EXEC_CMD; dma_buffer->cmd[3].len = 4; dma_buffer->cmd[4].cmd = SRC_CRCI_NAND_DATA; dma_buffer->cmd[4].src = MSM_NAND_FLASH_STATUS; dma_buffer->cmd[4].dst = msm_virt_to_dma(chip, &dma_buffer->data[3]); dma_buffer->cmd[4].len = 4; dma_buffer->cmd[5].cmd = 0; dma_buffer->cmd[5].src = MSM_NAND_READ_ID; dma_buffer->cmd[5].dst = msm_virt_to_dma(chip, &dma_buffer->data[4]); dma_buffer->cmd[5].len = 4; dma_buffer->cmd[6].cmd = CMD_OCU | CMD_LC; dma_buffer->cmd[6].src = msm_virt_to_dma(chip, &dma_buffer->data[5]); dma_buffer->cmd[6].dst = MSM_NAND_SFLASHC_BURST_CFG; dma_buffer->cmd[6].len = 4; BUILD_BUG_ON(6 != ARRAY_SIZE(dma_buffer->cmd) - 1); dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3 ) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); pr_info("status: %x\n", dma_buffer->data[3]); pr_info("nandid: %x maker %02x device %02x\n", dma_buffer->data[4], dma_buffer->data[4] & 0xff, (dma_buffer->data[4] >> 8) & 0xff); rv = dma_buffer->data[4]; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); return rv; } struct flash_identification { uint32_t flash_id; uint32_t mask; uint32_t density; uint32_t widebus; uint32_t pagesize; uint32_t blksize; uint32_t oobsize; }; static struct flash_identification supported_flash[] = { /* Flash ID ID Mask Density(MB) Wid Pgsz Blksz oobsz Manuf */ {0x00000000, 0xFFFFFFFF, 0, 0, 0, 0, 0, }, /*ONFI*/ {0x1500aaec, 0xFF00FFFF, (256<<20), 0, 2048, (2048<<6), 64, }, /*Sams*/ {0x5500baec, 0xFF00FFFF, (256<<20), 1, 2048, (2048<<6), 64, }, /*Sams*/ {0x6600bcec, 0xFF00FFFF, (512<<20), 1, 4096, (4096<<6), 128,}, /*Sams*/ {0x1500aa98, 0xFFFFFFFF, (256<<20), 0, 2048, (2048<<6), 64, }, /*Tosh*/ {0x5500ba98, 0xFFFFFFFF, (256<<20), 1, 2048, (2048<<6), 64, }, /*Tosh*/ {0xd580b12c, 0xFFFFFFFF, (128<<20), 1, 2048, (2048<<6), 64, }, /*Micr*/ {0x5580ba2c, 0xFFFFFFFF, (256<<20), 1, 2048, (2048<<6), 64, }, /*Micr*/ {0x5590bc2c, 0xFFFFFFFF, (512<<20), 1, 2048, (2048<<6), 64, }, /*Micr*/ {0x5580baad, 0xFFFFFFFF, (256<<20), 1, 2048, (2048<<6), 64, }, /*Hynx*/ {0x5510baad, 0xFFFFFFFF, (256<<20), 1, 2048, (2048<<6), 64, }, /*Hynx*/ /* Note: Width flag is 0 for 8 bit Flash and 1 for 16 bit flash */ /* Note: The First row will be filled at runtime during ONFI probe */ }; uint16_t flash_onfi_crc_check(uint8_t *buffer, uint16_t count) { int i; uint16_t result; for (i = 0; i < count; i++) buffer[i] = bitrev8(buffer[i]); result = bitrev16(crc16(bitrev16(0x4f4e), buffer, count)); for (i = 0; i < count; i++) buffer[i] = bitrev8(buffer[i]); return result; } uint32_t flash_onfi_probe(struct msm_nand_chip *chip) { struct onfi_param_page { uint32_t parameter_page_signature; uint16_t revision_number; uint16_t features_supported; uint16_t optional_commands_supported; uint8_t reserved0[22]; uint8_t device_manufacturer[12]; uint8_t device_model[20]; uint8_t jedec_manufacturer_id; uint16_t date_code; uint8_t reserved1[13]; uint32_t number_of_data_bytes_per_page; uint16_t number_of_spare_bytes_per_page; uint32_t number_of_data_bytes_per_partial_page; uint16_t number_of_spare_bytes_per_partial_page; uint32_t number_of_pages_per_block; uint32_t number_of_blocks_per_logical_unit; uint8_t number_of_logical_units; uint8_t number_of_address_cycles; uint8_t number_of_bits_per_cell; uint16_t maximum_bad_blocks_per_logical_unit; uint16_t block_endurance; uint8_t guaranteed_valid_begin_blocks; uint16_t guaranteed_valid_begin_blocks_endurance; uint8_t number_of_programs_per_page; uint8_t partial_program_attributes; uint8_t number_of_bits_ecc_correctaility; uint8_t number_of_interleaved_address_bits; uint8_t interleaved_operation_attributes; uint8_t reserved2[13]; uint8_t io_pin_capacitance; uint16_t timing_mode_support; uint16_t program_cache_timing_mode_support; uint16_t maximum_page_programming_time; uint16_t maximum_block_erase_time; uint16_t maximum_page_read_time; uint16_t maximum_change_column_setup_time; uint8_t reserved3[23]; uint16_t vendor_specific_revision_number; uint8_t vendor_specific[88]; uint16_t integrity_crc; } __attribute__((__packed__)); struct onfi_param_page *onfi_param_page_ptr; uint8_t *onfi_identifier_buf = NULL; uint8_t *onfi_param_info_buf = NULL; struct { dmov_s cmd[11]; unsigned cmdptr; struct { uint32_t cmd; uint32_t addr0; uint32_t addr1; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t flash_status; uint32_t devcmd1_orig; uint32_t devcmdvld_orig; uint32_t devcmd1_mod; uint32_t devcmdvld_mod; uint32_t sflash_bcfg_orig; uint32_t sflash_bcfg_mod; } data; } *dma_buffer; dmov_s *cmd; unsigned page_address = 0; int err = 0; dma_addr_t dma_addr_param_info = 0; dma_addr_t dma_addr_identifier = 0; unsigned cmd_set_count = 2; unsigned crc_chk_count = 0; if (msm_nand_data.nr_parts) { page_address = ((msm_nand_data.parts[0]).offset << 6); } else { pr_err("flash_onfi_probe: " "No partition info available\n"); err = -EIO; return err; } wait_event(chip->wait_queue, (onfi_identifier_buf = msm_nand_get_dma_buffer(chip, ONFI_IDENTIFIER_LENGTH))); dma_addr_identifier = msm_virt_to_dma(chip, onfi_identifier_buf); wait_event(chip->wait_queue, (onfi_param_info_buf = msm_nand_get_dma_buffer(chip, ONFI_PARAM_INFO_LENGTH))); dma_addr_param_info = msm_virt_to_dma(chip, onfi_param_info_buf); wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); dma_buffer->data.sflash_bcfg_orig = flash_rd_reg (chip, MSM_NAND_SFLASHC_BURST_CFG); dma_buffer->data.devcmd1_orig = flash_rd_reg(chip, MSM_NAND_DEV_CMD1); dma_buffer->data.devcmdvld_orig = flash_rd_reg(chip, MSM_NAND_DEV_CMD_VLD); while (cmd_set_count-- > 0) { cmd = dma_buffer->cmd; dma_buffer->data.devcmd1_mod = (dma_buffer->data.devcmd1_orig & 0xFFFFFF00) | (cmd_set_count ? FLASH_READ_ONFI_IDENTIFIER_COMMAND : FLASH_READ_ONFI_PARAMETERS_COMMAND); dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; dma_buffer->data.addr0 = (page_address << 16) | (cmd_set_count ? FLASH_READ_ONFI_IDENTIFIER_ADDRESS : FLASH_READ_ONFI_PARAMETERS_ADDRESS); dma_buffer->data.addr1 = (page_address >> 16) & 0xFF; dma_buffer->data.cfg0 = (cmd_set_count ? MSM_NAND_CFG0_RAW_ONFI_IDENTIFIER : MSM_NAND_CFG0_RAW_ONFI_PARAM_INFO); dma_buffer->data.cfg1 = (cmd_set_count ? MSM_NAND_CFG1_RAW_ONFI_IDENTIFIER : MSM_NAND_CFG1_RAW_ONFI_PARAM_INFO); dma_buffer->data.sflash_bcfg_mod = 0x00000000; dma_buffer->data.devcmdvld_mod = (dma_buffer-> data.devcmdvld_orig & 0xFFFFFFFE); dma_buffer->data.exec = 1; dma_buffer->data.flash_status = 0xeeeeeeee; /* Put the Nand ctlr in Async mode and disable SFlash ctlr */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sflash_bcfg_mod); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready, & write CMD,ADDR0,ADDR1,CHIPSEL regs */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = MSM_NAND_FLASH_CMD; cmd->len = 12; cmd++; /* Configure the CFG0 and CFG1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = MSM_NAND_DEV0_CFG0; cmd->len = 8; cmd++; /* Configure the DEV_CMD_VLD register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.devcmdvld_mod); cmd->dst = MSM_NAND_DEV_CMD_VLD; cmd->len = 4; cmd++; /* Configure the DEV_CMD1 register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.devcmd1_mod); cmd->dst = MSM_NAND_DEV_CMD1; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = MSM_NAND_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the two status registers */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_FLASH_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status); cmd->len = 4; cmd++; /* Read data block - valid only if status says success */ cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER; cmd->dst = (cmd_set_count ? dma_addr_identifier : dma_addr_param_info); cmd->len = (cmd_set_count ? ONFI_IDENTIFIER_LENGTH : ONFI_PARAM_INFO_LENGTH); cmd++; /* Restore the DEV_CMD1 register */ cmd->cmd = 0 ; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.devcmd1_orig); cmd->dst = MSM_NAND_DEV_CMD1; cmd->len = 4; cmd++; /* Restore the DEV_CMD_VLD register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.devcmdvld_orig); cmd->dst = MSM_NAND_DEV_CMD_VLD; cmd->len = 4; cmd++; /* Restore the SFLASH_BURST_CONFIG register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sflash_bcfg_orig); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; BUILD_BUG_ON(11 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* Check for errors, protection violations etc */ if (dma_buffer->data.flash_status & 0x110) { pr_info("MPU/OP error (0x%x) during " "ONFI probe\n", dma_buffer->data.flash_status); err = -EIO; break; } if (cmd_set_count) { onfi_param_page_ptr = (struct onfi_param_page *) (&(onfi_identifier_buf[0])); if (onfi_param_page_ptr->parameter_page_signature != ONFI_PARAMETER_PAGE_SIGNATURE) { pr_info("ONFI probe : Found a non" "ONFI Compliant device \n"); err = -EIO; break; } } else { for (crc_chk_count = 0; crc_chk_count < ONFI_PARAM_INFO_LENGTH / ONFI_PARAM_PAGE_LENGTH; crc_chk_count++) { onfi_param_page_ptr = (struct onfi_param_page *) (&(onfi_param_info_buf [ONFI_PARAM_PAGE_LENGTH * crc_chk_count])); if (flash_onfi_crc_check( (uint8_t *)onfi_param_page_ptr, ONFI_PARAM_PAGE_LENGTH - 2) == onfi_param_page_ptr->integrity_crc) { break; } } if (crc_chk_count >= ONFI_PARAM_INFO_LENGTH / ONFI_PARAM_PAGE_LENGTH) { pr_info("ONFI probe : CRC Check " "failed on ONFI Parameter " "data \n"); err = -EIO; break; } else { supported_flash[0].flash_id = flash_read_id(chip); supported_flash[0].widebus = onfi_param_page_ptr-> features_supported & 0x01; supported_flash[0].pagesize = onfi_param_page_ptr-> number_of_data_bytes_per_page; supported_flash[0].blksize = onfi_param_page_ptr-> number_of_pages_per_block * supported_flash[0].pagesize; supported_flash[0].oobsize = onfi_param_page_ptr-> number_of_spare_bytes_per_page; supported_flash[0].density = onfi_param_page_ptr-> number_of_blocks_per_logical_unit * supported_flash[0].blksize; pr_info("ONFI probe : Found an ONFI " "compliant device %s\n", onfi_param_page_ptr->device_model); /* Temporary hack for MT29F4G08ABC device. * Since the device is not properly adhering * to ONFi specification it is reporting * as 16 bit device though it is 8 bit device!!! */ if (!strcmp(onfi_param_page_ptr->device_model, "MT29F4G08ABC")) supported_flash[0].widebus = 0; } } } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); msm_nand_release_dma_buffer(chip, onfi_param_info_buf, ONFI_PARAM_INFO_LENGTH); msm_nand_release_dma_buffer(chip, onfi_identifier_buf, ONFI_IDENTIFIER_LENGTH); return err; } static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[8 * 5 + 2]; unsigned cmdptr; struct { uint32_t cmd; uint32_t addr0; uint32_t addr1; uint32_t chipsel; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; struct { uint32_t flash_status; uint32_t buffer_status; } result[8]; } data; } *dma_buffer; dmov_s *cmd; unsigned n; unsigned page = 0; uint32_t oob_len; uint32_t sectordatasize; uint32_t sectoroobsize; int err, pageerr, rawerr; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; uint32_t oob_col = 0; unsigned page_count; unsigned pages_read = 0; unsigned start_sector = 0; uint32_t ecc_errors; uint32_t total_ecc_errors = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = from >> 11; if (mtd->writesize == 4096) page = from >> 12; oob_len = ops->ooblen; cwperpage = (mtd->writesize >> 9); if (from & (mtd->writesize - 1)) { pr_err("%s: unsupported from, 0x%llx\n", __func__, from); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { /* when ops->datbuf is NULL, ops->len can be ooblen */ pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if (ops->datbuf != NULL && (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len," " %d for MTD_OOB_RAW\n", __func__, ops->len); return -EINVAL; } } if (ops->mode != MTD_OOB_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } if (ops->oobbuf && !ops->datbuf && ops->mode == MTD_OOB_AUTO) start_sector = cwperpage - 1; if (ops->oobbuf && !ops->datbuf) { page_count = ops->ooblen / ((ops->mode == MTD_OOB_AUTO) ? mtd->oobavail : mtd->oobsize); if ((page_count == 0) && (ops->ooblen)) page_count = 1; } else if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); #if 0 /* yaffs reads more oob data than it needs */ if (ops->ooblen >= sectoroobsize * 4) { pr_err("%s: unsupported ops->ooblen, %d\n", __func__, ops->ooblen); return -EINVAL; } #endif #if VERBOSE pr_info("msm_nand_read_oob %llx %p %x %p %x\n", from, ops->datbuf, ops->len, ops->oobbuf, ops->ooblen); #endif if (ops->datbuf) { /* memset(ops->datbuf, 0x55, ops->len); */ data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_FROM_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("msm_nand_read_oob: failed to get dma addr " "for %p\n", ops->datbuf); return -EIO; } } if (ops->oobbuf) { memset(ops->oobbuf, 0xff, ops->ooblen); oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_BIDIRECTIONAL); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("msm_nand_read_oob: failed to get dma addr " "for %p\n", ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); oob_col = start_sector * 0x210; if (chip->CFG1 & CFG1_WIDE_FLASH) oob_col >>= 1; err = 0; while (page_count-- > 0) { cmd = dma_buffer->cmd; /* CMD / ADDR0 / ADDR1 / CHIPSEL program values */ if (ops->mode != MTD_OOB_RAW) { dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ_ECC; dma_buffer->data.cfg0 = (chip->CFG0 & ~(7U << 6)) | (((cwperpage-1) - start_sector) << 6); dma_buffer->data.cfg1 = chip->CFG1; } else { dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; dma_buffer->data.cfg0 = (MSM_NAND_CFG0_RAW & ~(7U << 6)) | ((cwperpage-1) << 6); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); } dma_buffer->data.addr0 = (page << 16) | oob_col; /* qc example is (page >> 16) && 0xff !? */ dma_buffer->data.addr1 = (page >> 16) & 0xff; /* flash0 + undoc bit */ dma_buffer->data.chipsel = 0 | 4; /* GO bit for the EXEC register */ dma_buffer->data.exec = 1; BUILD_BUG_ON(8 != ARRAY_SIZE(dma_buffer->data.result)); for (n = start_sector; n < cwperpage; n++) { /* flash + buffer status return words */ dma_buffer->data.result[n].flash_status = 0xeeeeeeee; dma_buffer->data.result[n].buffer_status = 0xeeeeeeee; /* block on cmd ready, then * write CMD / ADDR0 / ADDR1 / CHIPSEL * regs in a burst */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = MSM_NAND_FLASH_CMD; if (n == start_sector) cmd->len = 16; else cmd->len = 4; cmd++; if (n == start_sector) { cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = MSM_NAND_DEV0_CFG0; cmd->len = 8; cmd++; dma_buffer->data.ecccfg = chip->ecc_buf_cfg; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ecccfg); cmd->dst = MSM_NAND_EBI2_ECC_BUF_CFG; cmd->len = 4; cmd++; } /* kick the execute register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = MSM_NAND_EXEC_CMD; cmd->len = 4; cmd++; /* block on data ready, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_FLASH_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[n]); /* MSM_NAND_FLASH_STATUS + MSM_NAND_BUFFER_STATUS */ cmd->len = 8; cmd++; /* read data block * (only valid if status says success) */ if (ops->datbuf) { if (ops->mode != MTD_OOB_RAW) sectordatasize = (n < (cwperpage - 1)) ? 516 : (512 - ((cwperpage - 1) << 2)); else sectordatasize = 528; cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER; cmd->dst = data_dma_addr_curr; data_dma_addr_curr += sectordatasize; cmd->len = sectordatasize; cmd++; } if (ops->oobbuf && (n == (cwperpage - 1) || ops->mode != MTD_OOB_AUTO)) { cmd->cmd = 0; if (n == (cwperpage - 1)) { cmd->src = MSM_NAND_FLASH_BUFFER + (512 - ((cwperpage - 1) << 2)); sectoroobsize = (cwperpage << 2); if (ops->mode != MTD_OOB_AUTO) sectoroobsize += 10; } else { cmd->src = MSM_NAND_FLASH_BUFFER + 516; sectoroobsize = 10; } cmd->dst = oob_dma_addr_curr; if (sectoroobsize < oob_len) cmd->len = sectoroobsize; else cmd->len = oob_len; oob_dma_addr_curr += cmd->len; oob_len -= cmd->len; if (cmd->len > 0) cmd++; } } BUILD_BUG_ON(8 * 5 + 2 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* if any of the writes failed (0x10), or there * was a protection violation (0x100), we lose */ pageerr = rawerr = 0; for (n = start_sector; n < cwperpage; n++) { if (dma_buffer->data.result[n].flash_status & 0x110) { rawerr = -EIO; break; } } if (rawerr) { if (ops->datbuf && ops->mode != MTD_OOB_RAW) { uint8_t *datbuf = ops->datbuf + pages_read * mtd->writesize; dma_sync_single_for_cpu(chip->dev, data_dma_addr_curr-mtd->writesize, mtd->writesize, DMA_BIDIRECTIONAL); for (n = 0; n < mtd->writesize; n++) { /* empty blocks read 0x54 at * these offsets */ if (n % 516 == 3 && datbuf[n] == 0x54) datbuf[n] = 0xff; if (datbuf[n] != 0xff) { pageerr = rawerr; break; } } dma_sync_single_for_device(chip->dev, data_dma_addr_curr-mtd->writesize, mtd->writesize, DMA_BIDIRECTIONAL); } if (ops->oobbuf) { for (n = 0; n < ops->ooblen; n++) { if (ops->oobbuf[n] != 0xff) { pageerr = rawerr; break; } } } } if (pageerr) { for (n = start_sector; n < cwperpage; n++) { if (dma_buffer->data.result[n].buffer_status & 0x8) { /* not thread safe */ mtd->ecc_stats.failed++; pageerr = -EBADMSG; break; } } } if (!rawerr) { /* check for corretable errors */ for (n = start_sector; n < cwperpage; n++) { ecc_errors = dma_buffer->data. result[n].buffer_status & 0x7; if (ecc_errors) { total_ecc_errors += ecc_errors; /* not thread safe */ mtd->ecc_stats.corrected += ecc_errors; if (ecc_errors > 1) pageerr = -EUCLEAN; } } } if (pageerr && (pageerr != -EUCLEAN || err == 0)) err = pageerr; #if VERBOSE if (rawerr && !pageerr) { pr_err("msm_nand_read_oob %llx %x %x empty page\n", (loff_t)page * mtd->writesize, ops->len, ops->ooblen); } else { pr_info("status: %x %x %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x \n", dma_buffer->data.result[0].flash_status, dma_buffer->data.result[0].buffer_status, dma_buffer->data.result[1].flash_status, dma_buffer->data.result[1].buffer_status, dma_buffer->data.result[2].flash_status, dma_buffer->data.result[2].buffer_status, dma_buffer->data.result[3].flash_status, dma_buffer->data.result[3].buffer_status, dma_buffer->data.result[4].flash_status, dma_buffer->data.result[4].buffer_status, dma_buffer->data.result[5].flash_status, dma_buffer->data.result[5].buffer_status, dma_buffer->data.result[6].flash_status, dma_buffer->data.result[6].buffer_status, dma_buffer->data.result[7].flash_status, dma_buffer->data.result[7].buffer_status); } #endif if (err && err != -EUCLEAN && err != -EBADMSG) break; pages_read++; page++; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (ops->oobbuf) { dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_FROM_DEVICE); } err_dma_map_oobbuf_failed: if (ops->datbuf) { dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_BIDIRECTIONAL); } if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_read; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_read; ops->oobretlen = ops->ooblen - oob_len; if (err) pr_err("msm_nand_read_oob %llx %x %x failed %d, corrected %d\n", from, ops->datbuf ? ops->len : 0, ops->ooblen, err, total_ecc_errors); return err; } static int msm_nand_read_oob_dualnandc(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[16 * 6 + 20]; unsigned cmdptr; struct { uint32_t cmd; uint32_t nandc01_addr0; uint32_t nandc10_addr0; uint32_t nandc11_addr1; uint32_t chipsel_cs0; uint32_t chipsel_cs1; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; uint32_t ebi2_cfg; uint32_t ebi2_chip_select_cfg0; uint32_t adm_mux_data_ack_req_nc01; uint32_t adm_mux_cmd_ack_req_nc01; uint32_t adm_mux_data_ack_req_nc10; uint32_t adm_mux_cmd_ack_req_nc10; uint32_t adm_default_mux; uint32_t default_ebi2_chip_select_cfg0; uint32_t nc10_flash_dev_cmd_vld; uint32_t nc10_flash_dev_cmd1; uint32_t nc10_flash_dev_cmd_vld_default; uint32_t nc10_flash_dev_cmd1_default; uint32_t ebi2_cfg_default; struct { uint32_t flash_status; uint32_t buffer_status; } result[16]; } data; } *dma_buffer; dmov_s *cmd; unsigned n; unsigned page = 0; uint32_t oob_len; uint32_t sectordatasize; uint32_t sectoroobsize; int err, pageerr, rawerr; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; uint32_t oob_col = 0; unsigned page_count; unsigned pages_read = 0; unsigned start_sector = 0; uint32_t ecc_errors; uint32_t total_ecc_errors = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = from >> 11; if (mtd->writesize == 4096) page = from >> 12; if (interleave_enable) page = (from >> 1) >> 12; oob_len = ops->ooblen; cwperpage = (mtd->writesize >> 9); if (from & (mtd->writesize - 1)) { pr_err("%s: unsupported from, 0x%llx\n", __func__, from); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if (ops->datbuf != NULL && (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len," " %d for MTD_OOB_RAW\n", __func__, ops->len); return -EINVAL; } } if (ops->mode != MTD_OOB_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } if (ops->oobbuf && !ops->datbuf && ops->mode == MTD_OOB_AUTO) start_sector = cwperpage - 1; if (ops->oobbuf && !ops->datbuf) { page_count = ops->ooblen / ((ops->mode == MTD_OOB_AUTO) ? mtd->oobavail : mtd->oobsize); if ((page_count == 0) && (ops->ooblen)) page_count = 1; } else if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); #if VERBOSE pr_info("msm_nand_read_oob_dualnandc %llx %p %x %p %x\n", from, ops->datbuf, ops->len, ops->oobbuf, ops->ooblen); #endif if (ops->datbuf) { data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_FROM_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("msm_nand_read_oob_dualnandc: " "failed to get dma addr for %p\n", ops->datbuf); return -EIO; } } if (ops->oobbuf) { memset(ops->oobbuf, 0xff, ops->ooblen); oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_BIDIRECTIONAL); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("msm_nand_read_oob_dualnandc: " "failed to get dma addr for %p\n", ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); oob_col = start_sector * 0x210; if (chip->CFG1 & CFG1_WIDE_FLASH) oob_col >>= 1; err = 0; while (page_count-- > 0) { cmd = dma_buffer->cmd; if (ops->mode != MTD_OOB_RAW) { dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ_ECC; if (start_sector == (cwperpage - 1)) { dma_buffer->data.cfg0 = (chip->CFG0 & ~(7U << 6)); } else { dma_buffer->data.cfg0 = (chip->CFG0 & ~(7U << 6)) | (((cwperpage >> 1)-1) << 6); } dma_buffer->data.cfg1 = chip->CFG1; } else { dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; dma_buffer->data.cfg0 = ((MSM_NAND_CFG0_RAW & ~(7U << 6)) | ((((cwperpage >> 1)-1) << 6))); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); } if (!interleave_enable) { if (start_sector == (cwperpage - 1)) { dma_buffer->data.nandc10_addr0 = (page << 16) | oob_col; dma_buffer->data.nc10_flash_dev_cmd_vld = 0xD; dma_buffer->data.nc10_flash_dev_cmd1 = 0xF00F3000; } else { dma_buffer->data.nandc01_addr0 = (page << 16) | oob_col; dma_buffer->data.nandc10_addr0 = 0x108; dma_buffer->data.nc10_flash_dev_cmd_vld = 0x1D; dma_buffer->data.nc10_flash_dev_cmd1 = 0xF00FE005; } } else { dma_buffer->data.nandc01_addr0 = dma_buffer->data.nandc10_addr0 = (page << 16) | oob_col; } /* ADDR1 */ dma_buffer->data.nandc11_addr1 = (page >> 16) & 0xff; dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; dma_buffer->data.adm_default_mux = 0x00000FC0; dma_buffer->data.nc10_flash_dev_cmd_vld_default = 0x1D; dma_buffer->data.nc10_flash_dev_cmd1_default = 0xF00F3000; /* config ebi2 cfg reg for pingpong ( 0xA000_0004 ) */ dma_buffer->data.ebi2_cfg = 0x4010080; dma_buffer->data.ebi2_cfg_default = 0x4010000; dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; /* flash0 + undoc bit */ dma_buffer->data.chipsel_cs0 = (1<<4) | 4; dma_buffer->data.chipsel_cs1 = (1<<4) | 5; /* GO bit for the EXEC register */ dma_buffer->data.exec = 1; BUILD_BUG_ON(16 != ARRAY_SIZE(dma_buffer->data.result)); for (n = start_sector; n < cwperpage; n++) { /* flash + buffer status return words */ dma_buffer->data.result[n].flash_status = 0xeeeeeeee; dma_buffer->data.result[n].buffer_status = 0xeeeeeeee; if (n == start_sector) { if (!interleave_enable) { /* config ebi2 cfg reg */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_cfg); cmd->dst = EBI2_CFG_REG; cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.nc10_flash_dev_cmd_vld); cmd->dst = NC10(MSM_NAND_DEV_CMD_VLD); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc10_flash_dev_cmd1); cmd->dst = NC10(MSM_NAND_DEV_CMD1); cmd->len = 4; cmd++; /* NC01, NC10 --> ADDR1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc11_addr1); cmd->dst = NC11(MSM_NAND_ADDR1); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC11(MSM_NAND_DEV0_CFG0); cmd->len = 8; cmd++; } else { /* enable CS0 & CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; /* NC01, NC10 --> ADDR1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc11_addr1); cmd->dst = NC11(MSM_NAND_ADDR1); cmd->len = 4; cmd++; /* Enable CS0 for NC01 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs0); cmd->dst = NC01(MSM_NAND_FLASH_CHIP_SELECT); cmd->len = 4; cmd++; /* Enable CS1 for NC10 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs1); cmd->dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); cmd->len = 4; cmd++; /* config DEV0_CFG0 & CFG1 for CS0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC01(MSM_NAND_DEV0_CFG0); cmd->len = 8; cmd++; /* config DEV1_CFG0 & CFG1 for CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC10(MSM_NAND_DEV1_CFG0); cmd->len = 8; cmd++; } dma_buffer->data.ecccfg = chip->ecc_buf_cfg; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ecccfg); cmd->dst = NC11(MSM_NAND_EBI2_ECC_BUF_CFG); cmd->len = 4; cmd++; /* if 'only' the last code word */ if (n == cwperpage - 1) { /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_cmd_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC10(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; /* NC10 --> ADDR0 ( 0x0 ) */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc10_addr0); cmd->dst = NC10(MSM_NAND_ADDR0); cmd->len = 4; cmd++; /* kick the execute reg for NC10 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC10(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC10, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[n]); /* MSM_NAND_FLASH_STATUS + * MSM_NAND_BUFFER_STATUS */ cmd->len = 8; cmd++; } else { if (!interleave_enable) { cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.nc10_flash_dev_cmd1); cmd->dst = NC10(MSM_NAND_DEV_CMD1); cmd->len = 4; cmd++; } /* NC01 --> ADDR0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc01_addr0); cmd->dst = NC01(MSM_NAND_ADDR0); cmd->len = 4; cmd++; /* NC10 --> ADDR1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc10_addr0); cmd->dst = NC10(MSM_NAND_ADDR0); cmd->len = 4; cmd++; /* MASK CMD ACK/REQ --> NC10 (0xF14)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_cmd_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC01(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; /* kick the execute register for NC01*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC01(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; } } /* read data block * (only valid if status says success) */ if (ops->datbuf) { if (ops->mode != MTD_OOB_RAW) sectordatasize = (n < (cwperpage - 1)) ? 516 : (512 - ((cwperpage - 1) << 2)); else sectordatasize = 528; if (n % 2 == 0) { /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_cmd_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC10(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; /* kick the execute register for NC10 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC10(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* MASK DATA ACK/REQ --> NC10 (0xF28)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_data_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC01, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC01(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[n]); /* MSM_NAND_FLASH_STATUS + * MSM_NAND_BUFFER_STATUS */ cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = NC01(MSM_NAND_FLASH_BUFFER); cmd->dst = data_dma_addr_curr; data_dma_addr_curr += sectordatasize; cmd->len = sectordatasize; cmd++; } else { if (n != cwperpage - 1) { /* MASK CMD ACK/REQ --> * NC10 (0xF14) */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_cmd_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC01(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; /* EXEC */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC01(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* MASK DATA ACK/REQ --> * NC01 (0xA3C) */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC10 * then read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[n]); /* MSM_NAND_FLASH_STATUS + * MSM_NAND_BUFFER_STATUS */ cmd->len = 8; cmd++; } else { /* MASK DATA ACK/REQ -> * NC01 (0xA3C) */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC10 * then read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[n]); /* MSM_NAND_FLASH_STATUS + * MSM_NAND_BUFFER_STATUS */ cmd->len = 8; cmd++; } cmd->cmd = 0; cmd->src = NC10(MSM_NAND_FLASH_BUFFER); cmd->dst = data_dma_addr_curr; data_dma_addr_curr += sectordatasize; cmd->len = sectordatasize; cmd++; } } if (ops->oobbuf && (n == (cwperpage - 1) || ops->mode != MTD_OOB_AUTO)) { cmd->cmd = 0; if (n == (cwperpage - 1)) { /* Use NC10 for reading the * last codeword!!! */ cmd->src = NC10(MSM_NAND_FLASH_BUFFER) + (512 - ((cwperpage - 1) << 2)); sectoroobsize = (cwperpage << 2); if (ops->mode != MTD_OOB_AUTO) sectoroobsize += 10; } else { if (n % 2 == 0) { cmd->src = NC01(MSM_NAND_FLASH_BUFFER) + 516; sectoroobsize = 10; } else { cmd->src = NC10(MSM_NAND_FLASH_BUFFER) + 516; sectoroobsize = 10; } } cmd->dst = oob_dma_addr_curr; if (sectoroobsize < oob_len) cmd->len = sectoroobsize; else cmd->len = oob_len; oob_dma_addr_curr += cmd->len; oob_len -= cmd->len; if (cmd->len > 0) cmd++; } } /* ADM --> Default mux state (0xFC0) */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_default_mux); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; if (!interleave_enable) { cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc10_flash_dev_cmd_vld_default); cmd->dst = NC10(MSM_NAND_DEV_CMD_VLD); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc10_flash_dev_cmd1_default); cmd->dst = NC10(MSM_NAND_DEV_CMD1); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_cfg_default); cmd->dst = EBI2_CFG_REG; cmd->len = 4; cmd++; } else { /* disable CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.default_ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; } BUILD_BUG_ON(16 * 6 + 20 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* if any of the writes failed (0x10), or there * was a protection violation (0x100), we lose */ pageerr = rawerr = 0; for (n = start_sector; n < cwperpage; n++) { if (dma_buffer->data.result[n].flash_status & 0x110) { rawerr = -EIO; break; } } if (rawerr) { if (ops->datbuf && ops->mode != MTD_OOB_RAW) { uint8_t *datbuf = ops->datbuf + pages_read * mtd->writesize; dma_sync_single_for_cpu(chip->dev, data_dma_addr_curr-mtd->writesize, mtd->writesize, DMA_BIDIRECTIONAL); for (n = 0; n < mtd->writesize; n++) { /* empty blocks read 0x54 at * these offsets */ if (n % 516 == 3 && datbuf[n] == 0x54) datbuf[n] = 0xff; if (datbuf[n] != 0xff) { pageerr = rawerr; break; } } dma_sync_single_for_device(chip->dev, data_dma_addr_curr-mtd->writesize, mtd->writesize, DMA_BIDIRECTIONAL); } if (ops->oobbuf) { for (n = 0; n < ops->ooblen; n++) { if (ops->oobbuf[n] != 0xff) { pageerr = rawerr; break; } } } } if (pageerr) { for (n = start_sector; n < cwperpage; n++) { if (dma_buffer->data.result[n].buffer_status & 0x8) { /* not thread safe */ mtd->ecc_stats.failed++; pageerr = -EBADMSG; break; } } } if (!rawerr) { /* check for corretable errors */ for (n = start_sector; n < cwperpage; n++) { ecc_errors = dma_buffer->data. result[n].buffer_status & 0x7; if (ecc_errors) { total_ecc_errors += ecc_errors; /* not thread safe */ mtd->ecc_stats.corrected += ecc_errors; if (ecc_errors > 1) pageerr = -EUCLEAN; } } } if (pageerr && (pageerr != -EUCLEAN || err == 0)) err = pageerr; #if VERBOSE if (rawerr && !pageerr) { pr_err("msm_nand_read_oob_dualnandc " "%llx %x %x empty page\n", (loff_t)page * mtd->writesize, ops->len, ops->ooblen); } else if (!interleave_enable) { pr_info("status: %x %x %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x \n", dma_buffer->data.result[0].flash_status, dma_buffer->data.result[0].buffer_status, dma_buffer->data.result[1].flash_status, dma_buffer->data.result[1].buffer_status, dma_buffer->data.result[2].flash_status, dma_buffer->data.result[2].buffer_status, dma_buffer->data.result[3].flash_status, dma_buffer->data.result[3].buffer_status, dma_buffer->data.result[4].flash_status, dma_buffer->data.result[4].buffer_status, dma_buffer->data.result[5].flash_status, dma_buffer->data.result[5].buffer_status, dma_buffer->data.result[6].flash_status, dma_buffer->data.result[6].buffer_status, dma_buffer->data.result[7].flash_status, dma_buffer->data.result[7].buffer_status); } else { pr_info("status: %x %x %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x \n", dma_buffer->data.result[0].flash_status, dma_buffer->data.result[0].buffer_status, dma_buffer->data.result[1].flash_status, dma_buffer->data.result[1].buffer_status, dma_buffer->data.result[2].flash_status, dma_buffer->data.result[2].buffer_status, dma_buffer->data.result[3].flash_status, dma_buffer->data.result[3].buffer_status, dma_buffer->data.result[4].flash_status, dma_buffer->data.result[4].buffer_status, dma_buffer->data.result[5].flash_status, dma_buffer->data.result[5].buffer_status, dma_buffer->data.result[6].flash_status, dma_buffer->data.result[6].buffer_status, dma_buffer->data.result[7].flash_status, dma_buffer->data.result[7].buffer_status, dma_buffer->data.result[8].flash_status, dma_buffer->data.result[8].buffer_status, dma_buffer->data.result[9].flash_status, dma_buffer->data.result[9].buffer_status, dma_buffer->data.result[10].flash_status, dma_buffer->data.result[10].buffer_status, dma_buffer->data.result[11].flash_status, dma_buffer->data.result[11].buffer_status, dma_buffer->data.result[12].flash_status, dma_buffer->data.result[12].buffer_status, dma_buffer->data.result[13].flash_status, dma_buffer->data.result[13].buffer_status, dma_buffer->data.result[14].flash_status, dma_buffer->data.result[14].buffer_status, dma_buffer->data.result[15].flash_status, dma_buffer->data.result[15].buffer_status); } #endif if (err && err != -EUCLEAN && err != -EBADMSG) break; pages_read++; page++; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (ops->oobbuf) { dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_FROM_DEVICE); } err_dma_map_oobbuf_failed: if (ops->datbuf) { dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_BIDIRECTIONAL); } if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_read; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_read; ops->oobretlen = ops->ooblen - oob_len; if (err) pr_err("msm_nand_read_oob_dualnandc " "%llx %x %x failed %d, corrected %d\n", from, ops->datbuf ? ops->len : 0, ops->ooblen, err, total_ecc_errors); return err; } static int msm_nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { int ret; struct mtd_oob_ops ops; /* printk("msm_nand_read %llx %x\n", from, len); */ ops.mode = MTD_OOB_PLACE; ops.len = len; ops.retlen = 0; ops.ooblen = 0; ops.datbuf = buf; ops.oobbuf = NULL; if (!dual_nand_ctlr_present) ret = msm_nand_read_oob(mtd, from, &ops); else ret = msm_nand_read_oob_dualnandc(mtd, from, &ops); *retlen = ops.retlen; return ret; } static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[8 * 7 + 2]; unsigned cmdptr; struct { uint32_t cmd; uint32_t addr0; uint32_t addr1; uint32_t chipsel; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; uint32_t clrfstatus; uint32_t clrrstatus; uint32_t flash_status[8]; } data; } *dma_buffer; dmov_s *cmd; unsigned n; unsigned page = 0; uint32_t oob_len; uint32_t sectordatawritesize; int err; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; unsigned page_count; unsigned pages_written = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = to >> 11; if (mtd->writesize == 4096) page = to >> 12; oob_len = ops->ooblen; cwperpage = (mtd->writesize >> 9); if (to & (mtd->writesize - 1)) { pr_err("%s: unsupported to, 0x%llx\n", __func__, to); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->ooblen != 0 && ops->mode != MTD_OOB_AUTO) { pr_err("%s: unsupported ops->mode,%d\n", __func__, ops->mode); return -EINVAL; } if ((ops->len % mtd->writesize) != 0) { pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if ((ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len, " "%d for MTD_OOB_RAW mode\n", __func__, ops->len); return -EINVAL; } } if (ops->datbuf == NULL) { pr_err("%s: unsupported ops->datbuf == NULL\n", __func__); return -EINVAL; } #if 0 /* yaffs writes more oob data than it needs */ if (ops->ooblen >= sectoroobsize * 4) { pr_err("%s: unsupported ops->ooblen, %d\n", __func__, ops->ooblen); return -EINVAL; } #endif if (ops->mode != MTD_OOB_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } if (ops->datbuf) { data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("msm_nand_write_oob: failed to get dma addr " "for %p\n", ops->datbuf); return -EIO; } } if (ops->oobbuf) { oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("msm_nand_write_oob: failed to get dma addr " "for %p\n", ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer(chip, sizeof(*dma_buffer)))); while (page_count-- > 0) { cmd = dma_buffer->cmd; /* CMD / ADDR0 / ADDR1 / CHIPSEL program values */ if (ops->mode != MTD_OOB_RAW) { dma_buffer->data.cfg0 = chip->CFG0; dma_buffer->data.cfg1 = chip->CFG1; } else { dma_buffer->data.cfg0 = (MSM_NAND_CFG0_RAW & ~(7U << 6)) | ((cwperpage-1) << 6); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); } dma_buffer->data.cmd = MSM_NAND_CMD_PRG_PAGE; dma_buffer->data.addr0 = page << 16; dma_buffer->data.addr1 = (page >> 16) & 0xff; dma_buffer->data.chipsel = 0 | 4; /* flash0 + undoc bit */ /* GO bit for the EXEC register */ dma_buffer->data.exec = 1; dma_buffer->data.clrfstatus = 0x00000020; dma_buffer->data.clrrstatus = 0x000000C0; BUILD_BUG_ON(8 != ARRAY_SIZE(dma_buffer->data.flash_status)); for (n = 0; n < cwperpage ; n++) { /* status return words */ dma_buffer->data.flash_status[n] = 0xeeeeeeee; /* block on cmd ready, then * write CMD / ADDR0 / ADDR1 / CHIPSEL regs in a burst */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = MSM_NAND_FLASH_CMD; if (n == 0) cmd->len = 16; else cmd->len = 4; cmd++; if (n == 0) { cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = MSM_NAND_DEV0_CFG0; cmd->len = 8; cmd++; dma_buffer->data.ecccfg = chip->ecc_buf_cfg; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ecccfg); cmd->dst = MSM_NAND_EBI2_ECC_BUF_CFG; cmd->len = 4; cmd++; } /* write data block */ if (ops->mode != MTD_OOB_RAW) sectordatawritesize = (n < (cwperpage - 1)) ? 516 : (512 - ((cwperpage - 1) << 2)); else sectordatawritesize = 528; cmd->cmd = 0; cmd->src = data_dma_addr_curr; data_dma_addr_curr += sectordatawritesize; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = sectordatawritesize; cmd++; if (ops->oobbuf) { if (n == (cwperpage - 1)) { cmd->cmd = 0; cmd->src = oob_dma_addr_curr; cmd->dst = MSM_NAND_FLASH_BUFFER + (512 - ((cwperpage - 1) << 2)); if ((cwperpage << 2) < oob_len) cmd->len = (cwperpage << 2); else cmd->len = oob_len; oob_dma_addr_curr += cmd->len; oob_len -= cmd->len; if (cmd->len > 0) cmd++; } if (ops->mode != MTD_OOB_AUTO) { /* skip ecc bytes in oobbuf */ if (oob_len < 10) { oob_dma_addr_curr += 10; oob_len -= 10; } else { oob_dma_addr_curr += oob_len; oob_len = 0; } } } /* kick the execute register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = MSM_NAND_EXEC_CMD; cmd->len = 4; cmd++; /* block on data ready, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_FLASH_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[n]); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrfstatus); cmd->dst = MSM_NAND_FLASH_STATUS; cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrrstatus); cmd->dst = MSM_NAND_READ_STATUS; cmd->len = 4; cmd++; } dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; BUILD_BUG_ON(8 * 7 + 2 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR( msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* if any of the writes failed (0x10), or there was a * protection violation (0x100), or the program success * bit (0x80) is unset, we lose */ err = 0; for (n = 0; n < cwperpage; n++) { if (dma_buffer->data.flash_status[n] & 0x110) { err = -EIO; break; } if (!(dma_buffer->data.flash_status[n] & 0x80)) { err = -EIO; break; } } #if VERBOSE pr_info("write pg %d: status: %x %x %x %x %x %x %x %x\n", page, dma_buffer->data.flash_status[0], dma_buffer->data.flash_status[1], dma_buffer->data.flash_status[2], dma_buffer->data.flash_status[3], dma_buffer->data.flash_status[4], dma_buffer->data.flash_status[5], dma_buffer->data.flash_status[6], dma_buffer->data.flash_status[7]); #endif if (err) break; pages_written++; page++; } if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_written; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_written; ops->oobretlen = ops->ooblen - oob_len; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (ops->oobbuf) dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_TO_DEVICE); err_dma_map_oobbuf_failed: if (ops->datbuf) dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_TO_DEVICE); if (err) pr_err("msm_nand_write_oob %llx %x %x failed %d\n", to, ops->len, ops->ooblen, err); return err; } static int msm_nand_write_oob_dualnandc(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[16 * 6 + 18]; unsigned cmdptr; struct { uint32_t cmd; uint32_t nandc01_addr0; uint32_t nandc10_addr0; uint32_t nandc11_addr1; uint32_t chipsel_cs0; uint32_t chipsel_cs1; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; uint32_t ebi2_cfg; uint32_t ebi2_chip_select_cfg0; uint32_t adm_mux_data_ack_req_nc01; uint32_t adm_mux_cmd_ack_req_nc01; uint32_t adm_mux_data_ack_req_nc10; uint32_t adm_mux_cmd_ack_req_nc10; uint32_t adm_default_mux; uint32_t default_ebi2_chip_select_cfg0; uint32_t nc01_flash_dev_cmd_vld; uint32_t nc10_flash_dev_cmd0; uint32_t nc01_flash_dev_cmd_vld_default; uint32_t nc10_flash_dev_cmd0_default; uint32_t ebi2_cfg_default; uint32_t flash_status[16]; uint32_t clrfstatus; uint32_t clrrstatus; } data; } *dma_buffer; dmov_s *cmd; unsigned n; unsigned page = 0; uint32_t oob_len; uint32_t sectordatawritesize; int err; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; unsigned page_count; unsigned pages_written = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = to >> 11; if (mtd->writesize == 4096) page = to >> 12; if (interleave_enable) page = (to >> 1) >> 12; oob_len = ops->ooblen; cwperpage = (mtd->writesize >> 9); if (to & (mtd->writesize - 1)) { pr_err("%s: unsupported to, 0x%llx\n", __func__, to); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->ooblen != 0 && ops->mode != MTD_OOB_AUTO) { pr_err("%s: unsupported ops->mode,%d\n", __func__, ops->mode); return -EINVAL; } if ((ops->len % mtd->writesize) != 0) { pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if ((ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len, " "%d for MTD_OOB_RAW mode\n", __func__, ops->len); return -EINVAL; } } if (ops->datbuf == NULL) { pr_err("%s: unsupported ops->datbuf == NULL\n", __func__); return -EINVAL; } if (ops->mode != MTD_OOB_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } #if VERBOSE pr_info("msm_nand_write_oob_dualnandc %llx %p %x %p %x\n", to, ops->datbuf, ops->len, ops->oobbuf, ops->ooblen); #endif if (ops->datbuf) { data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("msm_nand_write_oob_dualnandc:" "failed to get dma addr " "for %p\n", ops->datbuf); return -EIO; } } if (ops->oobbuf) { oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("msm_nand_write_oob_dualnandc:" "failed to get dma addr " "for %p\n", ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer(chip, sizeof(*dma_buffer)))); dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; dma_buffer->data.adm_default_mux = 0x00000FC0; dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; dma_buffer->data.nc01_flash_dev_cmd_vld = 0x9; dma_buffer->data.nc10_flash_dev_cmd0 = 0x1085D060; dma_buffer->data.nc01_flash_dev_cmd_vld_default = 0x1D; dma_buffer->data.nc10_flash_dev_cmd0_default = 0x1080D060; dma_buffer->data.clrfstatus = 0x00000020; dma_buffer->data.clrrstatus = 0x000000C0; while (page_count-- > 0) { cmd = dma_buffer->cmd; if (ops->mode != MTD_OOB_RAW) { dma_buffer->data.cfg0 = ((chip->CFG0 & ~(7U << 6)) | (1 << 4)) | ((((cwperpage >> 1)-1)) << 6); dma_buffer->data.cfg1 = chip->CFG1; } else { dma_buffer->data.cfg0 = ((MSM_NAND_CFG0_RAW & ~(7U << 6)) | (1<<4)) | (((cwperpage >> 1)-1) << 6); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); } dma_buffer->data.cmd = MSM_NAND_CMD_PRG_PAGE; dma_buffer->data.chipsel_cs0 = (1<<4) | 4; dma_buffer->data.chipsel_cs1 = (1<<4) | 5; /* GO bit for the EXEC register */ dma_buffer->data.exec = 1; /* config ebi2 cfg reg ( 0xA000_0004 ) */ dma_buffer->data.ebi2_cfg = 0x4010080; dma_buffer->data.ebi2_cfg_default = 0x4010000; if (!interleave_enable) { dma_buffer->data.nandc01_addr0 = (page << 16) | 0x0; dma_buffer->data.nandc10_addr0 = (page << 16) | 0x108; } else { dma_buffer->data.nandc01_addr0 = dma_buffer->data.nandc10_addr0 = (page << 16) | 0x0; } /* ADDR1 */ dma_buffer->data.nandc11_addr1 = (page >> 16) & 0xff; BUILD_BUG_ON(16 != ARRAY_SIZE(dma_buffer->data.flash_status)); for (n = 0; n < cwperpage; n++) { /* status return words */ dma_buffer->data.flash_status[n] = 0xeeeeeeee; if (n == 0) { if (!interleave_enable) { /* config ebi2 cfg reg */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_cfg); cmd->dst = EBI2_CFG_REG; cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.nc01_flash_dev_cmd_vld); cmd->dst = NC01(MSM_NAND_DEV_CMD_VLD); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc10_flash_dev_cmd0); cmd->dst = NC10(MSM_NAND_DEV_CMD0); cmd->len = 4; cmd++; /* common settings for both NC01 & NC10 * NC01, NC10 --> ADDR1 / CHIPSEL */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc11_addr1); cmd->dst = NC11(MSM_NAND_ADDR1); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC11(MSM_NAND_DEV0_CFG0); cmd->len = 8; cmd++; } else { /* enable CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; /* NC11 --> ADDR1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc11_addr1); cmd->dst = NC11(MSM_NAND_ADDR1); cmd->len = 4; cmd++; /* Enable CS0 for NC01 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs0); cmd->dst = NC01(MSM_NAND_FLASH_CHIP_SELECT); cmd->len = 4; cmd++; /* Enable CS1 for NC10 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs1); cmd->dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); cmd->len = 4; cmd++; /* config DEV0_CFG0 & CFG1 for CS0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC01(MSM_NAND_DEV0_CFG0); cmd->len = 8; cmd++; /* config DEV1_CFG0 & CFG1 for CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC10(MSM_NAND_DEV1_CFG0); cmd->len = 8; cmd++; } dma_buffer->data.ecccfg = chip->ecc_buf_cfg; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ecccfg); cmd->dst = NC11(MSM_NAND_EBI2_ECC_BUF_CFG); cmd->len = 4; cmd++; /* NC01 --> ADDR0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc01_addr0); cmd->dst = NC01(MSM_NAND_ADDR0); cmd->len = 4; cmd++; /* NC10 --> ADDR0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nandc10_addr0); cmd->dst = NC10(MSM_NAND_ADDR0); cmd->len = 4; cmd++; } if (n % 2 == 0) { /* MASK CMD ACK/REQ --> NC10 (0xF14)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_cmd_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC01(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; } else { /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_cmd_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* CMD */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC10(MSM_NAND_FLASH_CMD); cmd->len = 4; cmd++; } if (ops->mode != MTD_OOB_RAW) sectordatawritesize = (n < (cwperpage - 1)) ? 516 : (512 - ((cwperpage - 1) << 2)); else sectordatawritesize = 528; cmd->cmd = 0; cmd->src = data_dma_addr_curr; data_dma_addr_curr += sectordatawritesize; if (n % 2 == 0) cmd->dst = NC01(MSM_NAND_FLASH_BUFFER); else cmd->dst = NC10(MSM_NAND_FLASH_BUFFER); cmd->len = sectordatawritesize; cmd++; if (ops->oobbuf) { if (n == (cwperpage - 1)) { cmd->cmd = 0; cmd->src = oob_dma_addr_curr; cmd->dst = NC10(MSM_NAND_FLASH_BUFFER) + (512 - ((cwperpage - 1) << 2)); if ((cwperpage << 2) < oob_len) cmd->len = (cwperpage << 2); else cmd->len = oob_len; oob_dma_addr_curr += cmd->len; oob_len -= cmd->len; if (cmd->len > 0) cmd++; } if (ops->mode != MTD_OOB_AUTO) { /* skip ecc bytes in oobbuf */ if (oob_len < 10) { oob_dma_addr_curr += 10; oob_len -= 10; } else { oob_dma_addr_curr += oob_len; oob_len = 0; } } } if (n % 2 == 0) { /* kick the NC01 execute register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC01(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; if (n != 0) { /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer-> data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC10, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[n-1]); cmd->len = 4; cmd++; } } else { /* kick the execute register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC10(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* MASK DATA ACK/REQ --> NC10 (0xF28)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_data_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* block on data ready from NC01, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC01(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[n-1]); cmd->len = 4; cmd++; } } /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* we should process outstanding request */ /* block on data ready, then * read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[n-1]); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrfstatus); cmd->dst = NC11(MSM_NAND_FLASH_STATUS); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrrstatus); cmd->dst = NC11(MSM_NAND_READ_STATUS); cmd->len = 4; cmd++; /* MASK DATA ACK/REQ --> NC01 (0xFC0)*/ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_default_mux); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; if (!interleave_enable) { /* setting to defalut values back */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc01_flash_dev_cmd_vld_default); cmd->dst = NC01(MSM_NAND_DEV_CMD_VLD); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.nc10_flash_dev_cmd0_default); cmd->dst = NC10(MSM_NAND_DEV_CMD0); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_cfg_default); cmd->dst = EBI2_CFG_REG; cmd->len = 4; cmd++; } else { /* disable CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.default_ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; } dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; BUILD_BUG_ON(16 * 6 + 18 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmdptr = ((msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP); dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR( msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* if any of the writes failed (0x10), or there was a * protection violation (0x100), or the program success * bit (0x80) is unset, we lose */ err = 0; for (n = 0; n < cwperpage; n++) { if (dma_buffer->data.flash_status[n] & 0x110) { err = -EIO; break; } if (!(dma_buffer->data.flash_status[n] & 0x80)) { err = -EIO; break; } } #if VERBOSE if (!interleave_enable) { pr_info("write pg %d: status: %x %x %x %x %x %x %x %x\n", page, dma_buffer->data.flash_status[0], dma_buffer->data.flash_status[1], dma_buffer->data.flash_status[2], dma_buffer->data.flash_status[3], dma_buffer->data.flash_status[4], dma_buffer->data.flash_status[5], dma_buffer->data.flash_status[6], dma_buffer->data.flash_status[7]); } else { pr_info("write pg %d: status: %x %x %x %x %x %x %x %x \ %x %x %x %x %x %x %x %x \n", page, dma_buffer->data.flash_status[0], dma_buffer->data.flash_status[1], dma_buffer->data.flash_status[2], dma_buffer->data.flash_status[3], dma_buffer->data.flash_status[4], dma_buffer->data.flash_status[5], dma_buffer->data.flash_status[6], dma_buffer->data.flash_status[7], dma_buffer->data.flash_status[8], dma_buffer->data.flash_status[9], dma_buffer->data.flash_status[10], dma_buffer->data.flash_status[11], dma_buffer->data.flash_status[12], dma_buffer->data.flash_status[13], dma_buffer->data.flash_status[14], dma_buffer->data.flash_status[15]); } #endif if (err) break; pages_written++; page++; } if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_written; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_written; ops->oobretlen = ops->ooblen - oob_len; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (ops->oobbuf) dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_TO_DEVICE); err_dma_map_oobbuf_failed: if (ops->datbuf) dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_TO_DEVICE); if (err) pr_err("msm_nand_write_oob_dualnandc %llx %x %x failed %d\n", to, ops->len, ops->ooblen, err); return err; } static int msm_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { int ret; struct mtd_oob_ops ops; ops.mode = MTD_OOB_PLACE; ops.len = len; ops.retlen = 0; ops.ooblen = 0; ops.datbuf = (uint8_t *)buf; ops.oobbuf = NULL; if (!dual_nand_ctlr_present) ret = msm_nand_write_oob(mtd, to, &ops); else ret = msm_nand_write_oob_dualnandc(mtd, to, &ops); *retlen = ops.retlen; return ret; } static int msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) { int err; struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[6]; unsigned cmdptr; unsigned data[10]; } *dma_buffer; unsigned page = 0; if (mtd->writesize == 2048) page = instr->addr >> 11; if (mtd->writesize == 4096) page = instr->addr >> 12; if (instr->addr & (mtd->erasesize - 1)) { pr_err("%s: unsupported erase address, 0x%llx\n", __func__, instr->addr); return -EINVAL; } if (instr->len != mtd->erasesize) { pr_err("%s: unsupported erase len, %lld\n", __func__, instr->len); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); dma_buffer->data[0] = MSM_NAND_CMD_BLOCK_ERASE; dma_buffer->data[1] = page; dma_buffer->data[2] = 0; dma_buffer->data[3] = 0 | 4; dma_buffer->data[4] = 1; dma_buffer->data[5] = 0xeeeeeeee; dma_buffer->data[6] = chip->CFG0 & (~(7 << 6)); /* CW_PER_PAGE = 0 */ dma_buffer->data[7] = chip->CFG1; dma_buffer->data[8] = 0x00000020; dma_buffer->data[9] = 0x000000C0; BUILD_BUG_ON(9 != ARRAY_SIZE(dma_buffer->data) - 1); dma_buffer->cmd[0].cmd = DST_CRCI_NAND_CMD | CMD_OCB; dma_buffer->cmd[0].src = msm_virt_to_dma(chip, &dma_buffer->data[0]); dma_buffer->cmd[0].dst = MSM_NAND_FLASH_CMD; dma_buffer->cmd[0].len = 16; dma_buffer->cmd[1].cmd = 0; dma_buffer->cmd[1].src = msm_virt_to_dma(chip, &dma_buffer->data[6]); dma_buffer->cmd[1].dst = MSM_NAND_DEV0_CFG0; dma_buffer->cmd[1].len = 8; dma_buffer->cmd[2].cmd = 0; dma_buffer->cmd[2].src = msm_virt_to_dma(chip, &dma_buffer->data[4]); dma_buffer->cmd[2].dst = MSM_NAND_EXEC_CMD; dma_buffer->cmd[2].len = 4; dma_buffer->cmd[3].cmd = SRC_CRCI_NAND_DATA; dma_buffer->cmd[3].src = MSM_NAND_FLASH_STATUS; dma_buffer->cmd[3].dst = msm_virt_to_dma(chip, &dma_buffer->data[5]); dma_buffer->cmd[3].len = 4; dma_buffer->cmd[4].cmd = 0; dma_buffer->cmd[4].src = msm_virt_to_dma(chip, &dma_buffer->data[8]); dma_buffer->cmd[4].dst = MSM_NAND_FLASH_STATUS; dma_buffer->cmd[4].len = 4; dma_buffer->cmd[5].cmd = CMD_OCU | CMD_LC; dma_buffer->cmd[5].src = msm_virt_to_dma(chip, &dma_buffer->data[9]); dma_buffer->cmd[5].dst = MSM_NAND_READ_STATUS; dma_buffer->cmd[5].len = 4; BUILD_BUG_ON(5 != ARRAY_SIZE(dma_buffer->cmd) - 1); dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd( chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* we fail if there was an operation error, a mpu error, or the * erase success bit was not set. */ if (dma_buffer->data[5] & 0x110 || !(dma_buffer->data[5] & 0x80)) err = -EIO; else err = 0; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (err) { pr_err("%s: erase failed, 0x%llx\n", __func__, instr->addr); instr->fail_addr = instr->addr; instr->state = MTD_ERASE_FAILED; } else { instr->state = MTD_ERASE_DONE; instr->fail_addr = 0xffffffff; mtd_erase_callback(instr); } return err; } static int msm_nand_erase_dualnandc(struct mtd_info *mtd, struct erase_info *instr) { int err; struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[18]; unsigned cmdptr; uint32_t ebi2_chip_select_cfg0; uint32_t adm_mux_data_ack_req_nc01; uint32_t adm_mux_cmd_ack_req_nc01; uint32_t adm_mux_data_ack_req_nc10; uint32_t adm_mux_cmd_ack_req_nc10; uint32_t adm_default_mux; uint32_t default_ebi2_chip_select_cfg0; unsigned data[12]; } *dma_buffer; unsigned page = 0; if (mtd->writesize == 2048) page = instr->addr >> 11; if (mtd->writesize == 4096) page = instr->addr >> 12; if (mtd->writesize == 8192) page = (instr->addr >> 1) >> 12; if (instr->addr & (mtd->erasesize - 1)) { pr_err("%s: unsupported erase address, 0x%llx\n", __func__, instr->addr); return -EINVAL; } if (instr->len != mtd->erasesize) { pr_err("%s: unsupported erase len, %lld\n", __func__, instr->len); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); dma_buffer->data[0] = MSM_NAND_CMD_BLOCK_ERASE; dma_buffer->data[1] = page; dma_buffer->data[2] = 0; dma_buffer->data[3] = (1<<4) | 4; dma_buffer->data[4] = (1<<4) | 5; dma_buffer->data[5] = 1; dma_buffer->data[6] = 0xeeeeeeee; dma_buffer->data[7] = 0xeeeeeeee; dma_buffer->data[8] = chip->CFG0 & (~(7 << 6)); /* CW_PER_PAGE = 0 */ dma_buffer->data[9] = chip->CFG1; dma_buffer->data[10] = 0x00000020; dma_buffer->data[11] = 0x000000C0; dma_buffer->ebi2_chip_select_cfg0 = 0x00000805; dma_buffer->adm_mux_data_ack_req_nc01 = 0x00000A3C; dma_buffer->adm_mux_cmd_ack_req_nc01 = 0x0000053C; dma_buffer->adm_mux_data_ack_req_nc10 = 0x00000F28; dma_buffer->adm_mux_cmd_ack_req_nc10 = 0x00000F14; dma_buffer->adm_default_mux = 0x00000FC0; dma_buffer->default_ebi2_chip_select_cfg0 = 0x00000801; BUILD_BUG_ON(11 != ARRAY_SIZE(dma_buffer->data) - 1); /* enable CS1 */ dma_buffer->cmd[0].cmd = 0 | CMD_OCB; dma_buffer->cmd[0].src = msm_virt_to_dma(chip, &dma_buffer->ebi2_chip_select_cfg0); dma_buffer->cmd[0].dst = EBI2_CHIP_SELECT_CFG0; dma_buffer->cmd[0].len = 4; /* erase CS0 block now !!! */ /* 0xF14 */ dma_buffer->cmd[1].cmd = 0; dma_buffer->cmd[1].src = msm_virt_to_dma(chip, &dma_buffer->adm_mux_cmd_ack_req_nc10); dma_buffer->cmd[1].dst = EBI2_NAND_ADM_MUX; dma_buffer->cmd[1].len = 4; dma_buffer->cmd[2].cmd = DST_CRCI_NAND_CMD; dma_buffer->cmd[2].src = msm_virt_to_dma(chip, &dma_buffer->data[0]); dma_buffer->cmd[2].dst = NC01(MSM_NAND_FLASH_CMD); dma_buffer->cmd[2].len = 16; dma_buffer->cmd[3].cmd = 0; dma_buffer->cmd[3].src = msm_virt_to_dma(chip, &dma_buffer->data[8]); dma_buffer->cmd[3].dst = NC01(MSM_NAND_DEV0_CFG0); dma_buffer->cmd[3].len = 8; dma_buffer->cmd[4].cmd = 0; dma_buffer->cmd[4].src = msm_virt_to_dma(chip, &dma_buffer->data[5]); dma_buffer->cmd[4].dst = NC01(MSM_NAND_EXEC_CMD); dma_buffer->cmd[4].len = 4; /* 0xF28 */ dma_buffer->cmd[5].cmd = 0; dma_buffer->cmd[5].src = msm_virt_to_dma(chip, &dma_buffer->adm_mux_data_ack_req_nc10); dma_buffer->cmd[5].dst = EBI2_NAND_ADM_MUX; dma_buffer->cmd[5].len = 4; dma_buffer->cmd[6].cmd = SRC_CRCI_NAND_DATA; dma_buffer->cmd[6].src = NC01(MSM_NAND_FLASH_STATUS); dma_buffer->cmd[6].dst = msm_virt_to_dma(chip, &dma_buffer->data[6]); dma_buffer->cmd[6].len = 4; /* erase CS1 block now !!! */ /* 0x53C */ dma_buffer->cmd[7].cmd = 0; dma_buffer->cmd[7].src = msm_virt_to_dma(chip, &dma_buffer->adm_mux_cmd_ack_req_nc01); dma_buffer->cmd[7].dst = EBI2_NAND_ADM_MUX; dma_buffer->cmd[7].len = 4; dma_buffer->cmd[8].cmd = DST_CRCI_NAND_CMD; dma_buffer->cmd[8].src = msm_virt_to_dma(chip, &dma_buffer->data[0]); dma_buffer->cmd[8].dst = NC10(MSM_NAND_FLASH_CMD); dma_buffer->cmd[8].len = 12; dma_buffer->cmd[9].cmd = 0; dma_buffer->cmd[9].src = msm_virt_to_dma(chip, &dma_buffer->data[4]); dma_buffer->cmd[9].dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); dma_buffer->cmd[9].len = 4; dma_buffer->cmd[10].cmd = 0; dma_buffer->cmd[10].src = msm_virt_to_dma(chip, &dma_buffer->data[8]); dma_buffer->cmd[10].dst = NC10(MSM_NAND_DEV1_CFG0); dma_buffer->cmd[10].len = 8; dma_buffer->cmd[11].cmd = 0; dma_buffer->cmd[11].src = msm_virt_to_dma(chip, &dma_buffer->data[5]); dma_buffer->cmd[11].dst = NC10(MSM_NAND_EXEC_CMD); dma_buffer->cmd[11].len = 4; /* 0xA3C */ dma_buffer->cmd[12].cmd = 0; dma_buffer->cmd[12].src = msm_virt_to_dma(chip, &dma_buffer->adm_mux_data_ack_req_nc01); dma_buffer->cmd[12].dst = EBI2_NAND_ADM_MUX; dma_buffer->cmd[12].len = 4; dma_buffer->cmd[13].cmd = SRC_CRCI_NAND_DATA; dma_buffer->cmd[13].src = NC10(MSM_NAND_FLASH_STATUS); dma_buffer->cmd[13].dst = msm_virt_to_dma(chip, &dma_buffer->data[7]); dma_buffer->cmd[13].len = 4; dma_buffer->cmd[14].cmd = 0; dma_buffer->cmd[14].src = msm_virt_to_dma(chip, &dma_buffer->data[8]); dma_buffer->cmd[14].dst = NC11(MSM_NAND_FLASH_STATUS); dma_buffer->cmd[14].len = 4; dma_buffer->cmd[15].cmd = 0; dma_buffer->cmd[15].src = msm_virt_to_dma(chip, &dma_buffer->data[9]); dma_buffer->cmd[15].dst = NC11(MSM_NAND_READ_STATUS); dma_buffer->cmd[15].len = 4; dma_buffer->cmd[16].cmd = 0; dma_buffer->cmd[16].src = msm_virt_to_dma(chip, &dma_buffer->adm_default_mux); dma_buffer->cmd[16].dst = EBI2_NAND_ADM_MUX; dma_buffer->cmd[16].len = 4; /* disable CS1 */ dma_buffer->cmd[17].cmd = CMD_OCU | CMD_LC; dma_buffer->cmd[17].src = msm_virt_to_dma(chip, &dma_buffer->default_ebi2_chip_select_cfg0); dma_buffer->cmd[17].dst = EBI2_CHIP_SELECT_CFG0; dma_buffer->cmd[17].len = 4; BUILD_BUG_ON(17 != ARRAY_SIZE(dma_buffer->cmd) - 1); dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd( chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* we fail if there was an operation error, a mpu error, or the * erase success bit was not set. */ if (dma_buffer->data[6] & 0x110 || !(dma_buffer->data[6] & 0x80) || dma_buffer->data[6] & 0x110 || !(dma_buffer->data[6] & 0x80)) err = -EIO; else err = 0; msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (err) { pr_err("%s: erase failed, 0x%llx\n", __func__, instr->addr); instr->fail_addr = instr->addr; instr->state = MTD_ERASE_FAILED; } else { instr->state = MTD_ERASE_DONE; instr->fail_addr = 0xffffffff; mtd_erase_callback(instr); } return err; } static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) { struct msm_nand_chip *chip = mtd->priv; int ret; struct { dmov_s cmd[5]; unsigned cmdptr; struct { uint32_t cmd; uint32_t addr0; uint32_t addr1; uint32_t chipsel; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; struct { uint32_t flash_status; uint32_t buffer_status; } result; } data; } *dma_buffer; dmov_s *cmd; uint8_t *buf; unsigned page = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = ofs >> 11; if (mtd->writesize == 4096) page = ofs >> 12; cwperpage = (mtd->writesize >> 9); /* Check for invalid offset */ if (ofs > mtd->size) return -EINVAL; if (ofs & (mtd->erasesize - 1)) { pr_err("%s: unsupported block address, 0x%x\n", __func__, (uint32_t)ofs); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer(chip , sizeof(*dma_buffer) + 4))); buf = (uint8_t *)dma_buffer + sizeof(*dma_buffer); /* Read 4 bytes starting from the bad block marker location * in the last code word of the page */ cmd = dma_buffer->cmd; dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; dma_buffer->data.cfg0 = MSM_NAND_CFG0_RAW & ~(7U << 6); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); if (chip->CFG1 & CFG1_WIDE_FLASH) dma_buffer->data.addr0 = (page << 16) | ((528*(cwperpage-1)) >> 1); else dma_buffer->data.addr0 = (page << 16) | (528*(cwperpage-1)); dma_buffer->data.addr1 = (page >> 16) & 0xff; dma_buffer->data.chipsel = 0 | 4; dma_buffer->data.exec = 1; dma_buffer->data.result.flash_status = 0xeeeeeeee; dma_buffer->data.result.buffer_status = 0xeeeeeeee; cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = MSM_NAND_FLASH_CMD; cmd->len = 16; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = MSM_NAND_DEV0_CFG0; cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = MSM_NAND_EXEC_CMD; cmd->len = 4; cmd++; cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_FLASH_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER + (mtd->writesize - (528*(cwperpage-1))); cmd->dst = msm_virt_to_dma(chip, buf); cmd->len = 4; cmd++; BUILD_BUG_ON(5 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); ret = 0; if (dma_buffer->data.result.flash_status & 0x110) ret = -EIO; if (!ret) { /* Check for bad block marker byte */ if (chip->CFG1 & CFG1_WIDE_FLASH) { if (buf[0] != 0xFF || buf[1] != 0xFF) ret = 1; } else { if (buf[0] != 0xFF) ret = 1; } } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 4); return ret; } static int msm_nand_block_isbad_dualnandc(struct mtd_info *mtd, loff_t ofs) { struct msm_nand_chip *chip = mtd->priv; int ret; struct { dmov_s cmd[18]; unsigned cmdptr; struct { uint32_t cmd; uint32_t addr0; uint32_t addr1; uint32_t chipsel_cs0; uint32_t chipsel_cs1; uint32_t cfg0; uint32_t cfg1; uint32_t exec; uint32_t ecccfg; uint32_t ebi2_chip_select_cfg0; uint32_t adm_mux_data_ack_req_nc01; uint32_t adm_mux_cmd_ack_req_nc01; uint32_t adm_mux_data_ack_req_nc10; uint32_t adm_mux_cmd_ack_req_nc10; uint32_t adm_default_mux; uint32_t default_ebi2_chip_select_cfg0; struct { uint32_t flash_status; uint32_t buffer_status; } result[2]; } data; } *dma_buffer; dmov_s *cmd; uint8_t *buf01; uint8_t *buf10; unsigned page = 0; unsigned cwperpage; if (mtd->writesize == 2048) page = ofs >> 11; if (mtd->writesize == 4096) page = ofs >> 12; if (mtd->writesize == 8192) page = (ofs >> 1) >> 12; cwperpage = ((mtd->writesize >> 1) >> 9); /* Check for invalid offset */ if (ofs > mtd->size) return -EINVAL; if (ofs & (mtd->erasesize - 1)) { pr_err("%s: unsupported block address, 0x%x\n", __func__, (uint32_t)ofs); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer(chip , sizeof(*dma_buffer) + 8))); buf01 = (uint8_t *)dma_buffer + sizeof(*dma_buffer); buf10 = buf01 + 4; /* Read 4 bytes starting from the bad block marker location * in the last code word of the page */ cmd = dma_buffer->cmd; dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; dma_buffer->data.cfg0 = MSM_NAND_CFG0_RAW & ~(7U << 6); dma_buffer->data.cfg1 = MSM_NAND_CFG1_RAW | (chip->CFG1 & CFG1_WIDE_FLASH); if (chip->CFG1 & CFG1_WIDE_FLASH) dma_buffer->data.addr0 = (page << 16) | ((528*(cwperpage-1)) >> 1); else dma_buffer->data.addr0 = (page << 16) | (528*(cwperpage-1)); dma_buffer->data.addr1 = (page >> 16) & 0xff; dma_buffer->data.chipsel_cs0 = (1<<4) | 4; dma_buffer->data.chipsel_cs1 = (1<<4) | 5; dma_buffer->data.exec = 1; dma_buffer->data.result[0].flash_status = 0xeeeeeeee; dma_buffer->data.result[0].buffer_status = 0xeeeeeeee; dma_buffer->data.result[1].flash_status = 0xeeeeeeee; dma_buffer->data.result[1].buffer_status = 0xeeeeeeee; dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; dma_buffer->data.adm_default_mux = 0x00000FC0; dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; /* Reading last code word from NC01 */ /* enable CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; /* 0xF14 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_cmd_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC01(MSM_NAND_FLASH_CMD); cmd->len = 16; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC01(MSM_NAND_DEV0_CFG0); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC01(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* 0xF28 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_data_ack_req_nc10); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC01(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[0]); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = NC01(MSM_NAND_FLASH_BUFFER) + ((mtd->writesize >> 1) - (528*(cwperpage-1))); cmd->dst = msm_virt_to_dma(chip, buf01); cmd->len = 4; cmd++; /* Reading last code word from NC10 */ /* 0x53C */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_cmd_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = NC10(MSM_NAND_FLASH_CMD); cmd->len = 12; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs1); cmd->dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); cmd->len = 4; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); cmd->dst = NC10(MSM_NAND_DEV1_CFG0); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = NC10(MSM_NAND_EXEC_CMD); cmd->len = 4; cmd++; /* A3C */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_mux_data_ack_req_nc01); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = NC10(MSM_NAND_FLASH_STATUS); cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[1]); cmd->len = 8; cmd++; cmd->cmd = 0; cmd->src = NC10(MSM_NAND_FLASH_BUFFER) + ((mtd->writesize >> 1) - (528*(cwperpage-1))); cmd->dst = msm_virt_to_dma(chip, buf10); cmd->len = 4; cmd++; /* FC0 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.adm_default_mux); cmd->dst = EBI2_NAND_ADM_MUX; cmd->len = 4; cmd++; /* disble CS1 */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.ebi2_chip_select_cfg0); cmd->dst = EBI2_CHIP_SELECT_CFG0; cmd->len = 4; cmd++; BUILD_BUG_ON(18 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); ret = 0; if ((dma_buffer->data.result[0].flash_status & 0x110) || (dma_buffer->data.result[1].flash_status & 0x110)) ret = -EIO; if (!ret) { /* Check for bad block marker byte for NC01 & NC10 */ if (chip->CFG1 & CFG1_WIDE_FLASH) { if ((buf01[0] != 0xFF || buf01[1] != 0xFF) || (buf10[0] != 0xFF || buf10[1] != 0xFF)) ret = 1; } else { if (buf01[0] != 0xFF || buf10[0] != 0xFF) ret = 1; } } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 8); return ret; } static int msm_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) { struct mtd_oob_ops ops; int ret; uint8_t *buf; /* Check for invalid offset */ if (ofs > mtd->size) return -EINVAL; if (ofs & (mtd->erasesize - 1)) { pr_err("%s: unsupported block address, 0x%x\n", __func__, (uint32_t)ofs); return -EINVAL; } /* Write all 0s to the first page This will set the BB marker to 0 */ buf = page_address(ZERO_PAGE()); ops.mode = MTD_OOB_RAW; ops.len = mtd->writesize + mtd->oobsize; ops.retlen = 0; ops.ooblen = 0; ops.datbuf = buf; ops.oobbuf = NULL; if (!interleave_enable) ret = msm_nand_write_oob(mtd, ofs, &ops); else ret = msm_nand_write_oob_dualnandc(mtd, ofs, &ops); return ret; } /** * msm_nand_suspend - [MTD Interface] Suspend the msm_nand flash * @param mtd MTD device structure */ static int msm_nand_suspend(struct mtd_info *mtd) { return 0; } /** * msm_nand_resume - [MTD Interface] Resume the msm_nand flash * @param mtd MTD device structure */ static void msm_nand_resume(struct mtd_info *mtd) { } struct onenand_information { uint16_t manufacturer_id; uint16_t device_id; uint16_t version_id; uint16_t data_buf_size; uint16_t boot_buf_size; uint16_t num_of_buffers; uint16_t technology; }; static struct onenand_information onenand_info; static uint32_t nand_sfcmd_mode; uint32_t flash_onenand_probe(struct msm_nand_chip *chip) { struct { dmov_s cmd[7]; unsigned cmdptr; struct { uint32_t bcfg; uint32_t cmd; uint32_t exec; uint32_t status; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; } data; } *dma_buffer; dmov_s *cmd; int err = 0; uint32_t initialsflashcmd = 0; initialsflashcmd = flash_rd_reg(chip, MSM_NAND_SFLASHC_CMD); if ((initialsflashcmd & 0x10) == 0x10) nand_sfcmd_mode = MSM_NAND_SFCMD_ASYNC; else nand_sfcmd_mode = MSM_NAND_SFCMD_BURST; printk(KERN_INFO "SFLASHC Async Mode bit: %x \n", nand_sfcmd_mode); wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); cmd = dma_buffer->cmd; dma_buffer->data.bcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.cmd = SFLASH_PREPCMD(7, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.exec = 1; dma_buffer->data.status = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_DEVICE_ID << 16) | (ONENAND_MANUFACTURER_ID); dma_buffer->data.addr1 = (ONENAND_DATA_BUFFER_SIZE << 16) | (ONENAND_VERSION_ID); dma_buffer->data.addr2 = (ONENAND_AMOUNT_OF_BUFFERS << 16) | (ONENAND_BOOT_BUFFER_SIZE); dma_buffer->data.addr3 = (CLEAN_DATA_16 << 16) | (ONENAND_TECHNOLOGY << 0); dma_buffer->data.data0 = CLEAN_DATA_32; dma_buffer->data.data1 = CLEAN_DATA_32; dma_buffer->data.data2 = CLEAN_DATA_32; dma_buffer->data.data3 = CLEAN_DATA_32; /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.bcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Configure the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Configure the ADDR2 and ADDR3 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 8; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the two status registers */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.status); cmd->len = 4; cmd++; /* Read data registers - valid only if status says success */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG0; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->len = 16; cmd++; BUILD_BUG_ON(7 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); /* Check for errors, protection violations etc */ if (dma_buffer->data.status & 0x110) { pr_info("%s: MPU/OP error" "(0x%x) during Onenand probe\n", __func__, dma_buffer->data.status); err = -EIO; } else { onenand_info.manufacturer_id = (dma_buffer->data.data0 >> 0) & 0x0000FFFF; onenand_info.device_id = (dma_buffer->data.data0 >> 16) & 0x0000FFFF; onenand_info.version_id = (dma_buffer->data.data1 >> 0) & 0x0000FFFF; onenand_info.data_buf_size = (dma_buffer->data.data1 >> 16) & 0x0000FFFF; onenand_info.boot_buf_size = (dma_buffer->data.data2 >> 0) & 0x0000FFFF; onenand_info.num_of_buffers = (dma_buffer->data.data2 >> 16) & 0x0000FFFF; onenand_info.technology = (dma_buffer->data.data3 >> 0) & 0x0000FFFF; pr_info("=======================================" "==========================\n"); pr_info("%s: manufacturer_id = 0x%x\n" , __func__, onenand_info.manufacturer_id); pr_info("%s: device_id = 0x%x\n" , __func__, onenand_info.device_id); pr_info("%s: version_id = 0x%x\n" , __func__, onenand_info.version_id); pr_info("%s: data_buf_size = 0x%x\n" , __func__, onenand_info.data_buf_size); pr_info("%s: boot_buf_size = 0x%x\n" , __func__, onenand_info.boot_buf_size); pr_info("%s: num_of_buffers = 0x%x\n" , __func__, onenand_info.num_of_buffers); pr_info("%s: technology = 0x%x\n" , __func__, onenand_info.technology); pr_info("=======================================" "==========================\n"); if ((onenand_info.manufacturer_id != 0x00EC) || ((onenand_info.device_id & 0x0040) != 0x0040) || (onenand_info.data_buf_size != 0x0800) || (onenand_info.boot_buf_size != 0x0200) || (onenand_info.num_of_buffers != 0x0201) || (onenand_info.technology != 0)) { pr_info("%s: Detected an unsupported device\n" , __func__); err = -EIO; } } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); return err; } int msm_onenand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[53]; unsigned cmdptr; struct { uint32_t sfbcfg; uint32_t sfcmd[9]; uint32_t sfexec; uint32_t sfstat[9]; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; uint32_t macro[5]; } data; } *dma_buffer; dmov_s *cmd; int err = 0; int i; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; loff_t from_curr = 0; unsigned page_count; unsigned pages_read = 0; uint16_t onenand_startaddr1; uint16_t onenand_startaddr8; uint16_t onenand_startaddr2; uint16_t onenand_startbuffer; uint16_t onenand_sysconfig1; uint16_t controller_status; uint16_t interrupt_status; uint16_t ecc_status; #if VERBOSE pr_info("=================================================" "================\n"); pr_info("%s: from 0x%llx mode %d \ndatbuf 0x%p datlen 0x%x" "\noobbuf 0x%p ooblen 0x%x\n", __func__, from, ops->mode, ops->datbuf, ops->len, ops->oobbuf, ops->ooblen); #endif if (!mtd) { pr_err("%s: invalid mtd pointer, 0x%x\n", __func__, (uint32_t)mtd); return -EINVAL; } if (from & (mtd->writesize - 1)) { pr_err("%s: unsupported from, 0x%llx\n", __func__, from); return -EINVAL; } if ((ops->mode != MTD_OOB_PLACE) && (ops->mode != MTD_OOB_AUTO) && (ops->mode != MTD_OOB_RAW)) { pr_err("%s: unsupported ops->mode, %d\n", __func__, ops->mode); return -EINVAL; } if (((ops->datbuf == NULL) || (ops->len == 0)) && ((ops->oobbuf == NULL) || (ops->ooblen == 0))) { pr_err("%s: incorrect ops fields - nothing to do\n", __func__); return -EINVAL; } if ((ops->datbuf != NULL) && (ops->len == 0)) { pr_err("%s: data buffer passed but length 0\n", __func__); return -EINVAL; } if ((ops->oobbuf != NULL) && (ops->ooblen == 0)) { pr_err("%s: oob buffer passed but length 0\n", __func__); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { /* when ops->datbuf is NULL, ops->len can be ooblen */ pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if (ops->datbuf != NULL && (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len," " %d for MTD_OOB_RAW\n", __func__, ops->len); return -EINVAL; } } if ((ops->mode == MTD_OOB_RAW) && (ops->oobbuf)) { pr_err("%s: unsupported operation, oobbuf pointer " "passed in for RAW mode, %x\n", __func__, (uint32_t)ops->oobbuf); return -EINVAL; } if (ops->oobbuf && !ops->datbuf) page_count = ops->ooblen / ((ops->mode == MTD_OOB_AUTO) ? mtd->oobavail : mtd->oobsize); else if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); if ((ops->mode == MTD_OOB_AUTO) && (ops->oobbuf != NULL)) { if (page_count * mtd->oobavail > ops->ooblen) { pr_err("%s: unsupported ops->ooblen for " "AUTO, %d\n", __func__, ops->ooblen); return -EINVAL; } } if ((ops->mode == MTD_OOB_PLACE) && (ops->oobbuf != NULL)) { if (page_count * mtd->oobsize > ops->ooblen) { pr_err("%s: unsupported ops->ooblen for " "PLACE, %d\n", __func__, ops->ooblen); return -EINVAL; } } if ((ops->mode == MTD_OOB_PLACE) && (ops->ooblen != 0) && (ops->ooboffs != 0)) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } if (ops->datbuf) { memset(ops->datbuf, 0x55, ops->len); data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_FROM_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("%s: failed to get dma addr for %p\n", __func__, ops->datbuf); return -EIO; } } if (ops->oobbuf) { memset(ops->oobbuf, 0x55, ops->ooblen); oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_FROM_DEVICE); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("%s: failed to get dma addr for %p\n", __func__, ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); from_curr = from; while (page_count-- > 0) { cmd = dma_buffer->cmd; if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) && (from_curr >= (mtd->size>>1))) { /* DDP Device */ onenand_startaddr1 = DEVICE_FLASHCORE_1 | (((uint32_t)(from_curr-(mtd->size>>1)) / mtd->erasesize)); onenand_startaddr2 = DEVICE_BUFFERRAM_1; } else { onenand_startaddr1 = DEVICE_FLASHCORE_0 | ((uint32_t)from_curr / mtd->erasesize) ; onenand_startaddr2 = DEVICE_BUFFERRAM_0; } onenand_startaddr8 = (((uint32_t)from_curr & (mtd->erasesize - 1)) / mtd->writesize) << 2; onenand_startbuffer = DATARAM0_0 << 8; onenand_sysconfig1 = (ops->mode == MTD_OOB_RAW) ? ONENAND_SYSCFG1_ECCDIS(nand_sfcmd_mode) : ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode); dma_buffer->data.sfbcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_INTHI); dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATRD); dma_buffer->data.sfcmd[4] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATRD); dma_buffer->data.sfcmd[5] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATRD); dma_buffer->data.sfcmd[6] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATRD); dma_buffer->data.sfcmd[7] = SFLASH_PREPCMD(32, 0, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATRD); dma_buffer->data.sfcmd[8] = SFLASH_PREPCMD(4, 10, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfexec = 1; dma_buffer->data.sfstat[0] = CLEAN_DATA_32; dma_buffer->data.sfstat[1] = CLEAN_DATA_32; dma_buffer->data.sfstat[2] = CLEAN_DATA_32; dma_buffer->data.sfstat[3] = CLEAN_DATA_32; dma_buffer->data.sfstat[4] = CLEAN_DATA_32; dma_buffer->data.sfstat[5] = CLEAN_DATA_32; dma_buffer->data.sfstat[6] = CLEAN_DATA_32; dma_buffer->data.sfstat[7] = CLEAN_DATA_32; dma_buffer->data.sfstat[8] = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | (ONENAND_START_ADDRESS_2); dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | (ONENAND_COMMAND); dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | (ONENAND_INTERRUPT_STATUS); dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | (onenand_sysconfig1); dma_buffer->data.data1 = (onenand_startaddr8 << 16) | (onenand_startaddr1); dma_buffer->data.data2 = (onenand_startbuffer << 16) | (onenand_startaddr2); dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMDLOADSPARE); dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | (CLEAN_DATA_16); dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | (ONENAND_STARTADDR1_RES); dma_buffer->data.macro[0] = 0x0200; dma_buffer->data.macro[1] = 0x0300; dma_buffer->data.macro[2] = 0x0400; dma_buffer->data.macro[3] = 0x0500; dma_buffer->data.macro[4] = 0x8010; /*************************************************************/ /* Write necessary address registers in the onenand device */ /*************************************************************/ /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 16; cmd++; /* Write the ADDR6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); cmd->dst = MSM_NAND_ADDR6; cmd->len = 4; cmd++; /* Write the GENP0, GENP1, GENP2, GENP3 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->dst = MSM_NAND_GENP_REG0; cmd->len = 16; cmd++; /* Write the FLASH_DEV_CMD4,5,6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->dst = MSM_NAND_DEV_CMD4; cmd->len = 12; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); cmd->len = 4; cmd++; /*************************************************************/ /* Wait for the interrupt from the Onenand device controller */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); cmd->len = 4; cmd++; /*************************************************************/ /* Read necessary status registers from the onenand device */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); cmd->len = 4; cmd++; /* Read the GENP3 register */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG3; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); cmd->len = 4; cmd++; /* Read the DEVCMD4 register */ cmd->cmd = 0; cmd->src = MSM_NAND_DEV_CMD4; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->len = 4; cmd++; /*************************************************************/ /* Read the data ram area from the onenand buffer ram */ /*************************************************************/ if (ops->datbuf) { dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMDLOAD); for (i = 0; i < 4; i++) { /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3+i]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the MACRO1 register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.macro[i]); cmd->dst = MSM_NAND_MACRO1_REG; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data rdy, & read status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3+i]); cmd->len = 4; cmd++; /* Transfer nand ctlr buf contents to usr buf */ cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER; cmd->dst = data_dma_addr_curr; cmd->len = 512; data_dma_addr_curr += 512; cmd++; } } if ((ops->oobbuf) || (ops->mode == MTD_OOB_RAW)) { /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[7]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the MACRO1 register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.macro[4]); cmd->dst = MSM_NAND_MACRO1_REG; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[7]); cmd->len = 4; cmd++; /* Transfer nand ctlr buffer contents into usr buf */ if (ops->mode == MTD_OOB_AUTO) { for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) { cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER + mtd->ecclayout->oobfree[i].offset; cmd->dst = oob_dma_addr_curr; cmd->len = mtd->ecclayout->oobfree[i].length; oob_dma_addr_curr += mtd->ecclayout->oobfree[i].length; cmd++; } } if (ops->mode == MTD_OOB_PLACE) { cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER; cmd->dst = oob_dma_addr_curr; cmd->len = mtd->oobsize; oob_dma_addr_curr += mtd->oobsize; cmd++; } if (ops->mode == MTD_OOB_RAW) { cmd->cmd = 0; cmd->src = MSM_NAND_FLASH_BUFFER; cmd->dst = data_dma_addr_curr; cmd->len = mtd->oobsize; data_dma_addr_curr += mtd->oobsize; cmd++; } } /*************************************************************/ /* Restore the necessary registers to proper values */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[8]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[8]); cmd->len = 4; cmd++; BUILD_BUG_ON(53 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); ecc_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; #if VERBOSE pr_info("\n%s: sflash status %x %x %x %x %x %x %x" "%x %x\n", __func__, dma_buffer->data.sfstat[0], dma_buffer->data.sfstat[1], dma_buffer->data.sfstat[2], dma_buffer->data.sfstat[3], dma_buffer->data.sfstat[4], dma_buffer->data.sfstat[5], dma_buffer->data.sfstat[6], dma_buffer->data.sfstat[7], dma_buffer->data.sfstat[8]); pr_info("%s: controller_status = %x\n", __func__, controller_status); pr_info("%s: interrupt_status = %x\n", __func__, interrupt_status); pr_info("%s: ecc_status = %x\n", __func__, ecc_status); #endif /* Check for errors, protection violations etc */ if ((controller_status != 0) || (dma_buffer->data.sfstat[0] & 0x110) || (dma_buffer->data.sfstat[1] & 0x110) || (dma_buffer->data.sfstat[2] & 0x110) || (dma_buffer->data.sfstat[8] & 0x110) || ((dma_buffer->data.sfstat[3] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[4] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[5] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[6] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[7] & 0x110) && ((ops->oobbuf) || (ops->mode == MTD_OOB_RAW)))) { pr_info("%s: ECC/MPU/OP error\n", __func__); err = -EIO; } if (err) break; pages_read++; from_curr += mtd->writesize; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (ops->oobbuf) { dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_FROM_DEVICE); } err_dma_map_oobbuf_failed: if (ops->datbuf) { dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_FROM_DEVICE); } if (err) { pr_err("%s: %llx %x %x failed\n", __func__, from_curr, ops->datbuf ? ops->len : 0, ops->ooblen); } else { ops->retlen = ops->oobretlen = 0; if (ops->datbuf != NULL) { if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_read; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_read; } if (ops->oobbuf != NULL) { if (ops->mode == MTD_OOB_AUTO) ops->oobretlen = mtd->oobavail * pages_read; else ops->oobretlen = mtd->oobsize * pages_read; } } #if VERBOSE pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", __func__, err, ops->retlen, ops->oobretlen); pr_info("===================================================" "==============\n"); #endif return err; } int msm_onenand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { int ret; struct mtd_oob_ops ops; ops.mode = MTD_OOB_PLACE; ops.datbuf = buf; ops.len = len; ops.retlen = 0; ops.oobbuf = NULL; ops.ooblen = 0; ops.oobretlen = 0; ret = msm_onenand_read_oob(mtd, from, &ops); *retlen = ops.retlen; return ret; } static int msm_onenand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[53]; unsigned cmdptr; struct { uint32_t sfbcfg; uint32_t sfcmd[10]; uint32_t sfexec; uint32_t sfstat[10]; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; uint32_t macro[5]; } data; } *dma_buffer; dmov_s *cmd; int err = 0; int i, j, k; dma_addr_t data_dma_addr = 0; dma_addr_t oob_dma_addr = 0; dma_addr_t init_dma_addr = 0; dma_addr_t data_dma_addr_curr = 0; dma_addr_t oob_dma_addr_curr = 0; uint8_t *init_spare_bytes; loff_t to_curr = 0; unsigned page_count; unsigned pages_written = 0; uint16_t onenand_startaddr1; uint16_t onenand_startaddr8; uint16_t onenand_startaddr2; uint16_t onenand_startbuffer; uint16_t onenand_sysconfig1; uint16_t controller_status; uint16_t interrupt_status; uint16_t ecc_status; #if VERBOSE pr_info("=================================================" "================\n"); pr_info("%s: to 0x%llx mode %d \ndatbuf 0x%p datlen 0x%x" "\noobbuf 0x%p ooblen 0x%x\n", __func__, to, ops->mode, ops->datbuf, ops->len, ops->oobbuf, ops->ooblen); #endif if (!mtd) { pr_err("%s: invalid mtd pointer, 0x%x\n", __func__, (uint32_t)mtd); return -EINVAL; } if (to & (mtd->writesize - 1)) { pr_err("%s: unsupported to, 0x%llx\n", __func__, to); return -EINVAL; } if ((ops->mode != MTD_OOB_PLACE) && (ops->mode != MTD_OOB_AUTO) && (ops->mode != MTD_OOB_RAW)) { pr_err("%s: unsupported ops->mode, %d\n", __func__, ops->mode); return -EINVAL; } if (((ops->datbuf == NULL) || (ops->len == 0)) && ((ops->oobbuf == NULL) || (ops->ooblen == 0))) { pr_err("%s: incorrect ops fields - nothing to do\n", __func__); return -EINVAL; } if ((ops->datbuf != NULL) && (ops->len == 0)) { pr_err("%s: data buffer passed but length 0\n", __func__); return -EINVAL; } if ((ops->oobbuf != NULL) && (ops->ooblen == 0)) { pr_err("%s: oob buffer passed but length 0\n", __func__); return -EINVAL; } if (ops->mode != MTD_OOB_RAW) { if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { /* when ops->datbuf is NULL, ops->len can be ooblen */ pr_err("%s: unsupported ops->len, %d\n", __func__, ops->len); return -EINVAL; } } else { if (ops->datbuf != NULL && (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { pr_err("%s: unsupported ops->len," " %d for MTD_OOB_RAW\n", __func__, ops->len); return -EINVAL; } } if ((ops->mode == MTD_OOB_RAW) && (ops->oobbuf)) { pr_err("%s: unsupported operation, oobbuf pointer " "passed in for RAW mode, %x\n", __func__, (uint32_t)ops->oobbuf); return -EINVAL; } if (ops->oobbuf && !ops->datbuf) page_count = ops->ooblen / ((ops->mode == MTD_OOB_AUTO) ? mtd->oobavail : mtd->oobsize); else if (ops->mode != MTD_OOB_RAW) page_count = ops->len / mtd->writesize; else page_count = ops->len / (mtd->writesize + mtd->oobsize); if ((ops->mode == MTD_OOB_AUTO) && (ops->oobbuf != NULL)) { if (page_count > 1) { pr_err("%s: unsupported ops->ooblen for" "AUTO, %d\n", __func__, ops->ooblen); return -EINVAL; } } if ((ops->mode == MTD_OOB_PLACE) && (ops->oobbuf != NULL)) { if (page_count * mtd->oobsize > ops->ooblen) { pr_err("%s: unsupported ops->ooblen for" "PLACE, %d\n", __func__, ops->ooblen); return -EINVAL; } } if ((ops->mode == MTD_OOB_PLACE) && (ops->ooblen != 0) && (ops->ooboffs != 0)) { pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, ops->ooboffs); return -EINVAL; } init_spare_bytes = kmalloc(64, GFP_KERNEL); if (!init_spare_bytes) { pr_err("%s: failed to alloc init_spare_bytes buffer\n", __func__); return -ENOMEM; } for (i = 0; i < 64; i++) init_spare_bytes[i] = 0xFF; if ((ops->oobbuf) && (ops->mode == MTD_OOB_AUTO)) { for (i = 0, k = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) for (j = 0; j < mtd->ecclayout->oobfree[i].length; j++) { init_spare_bytes[j + mtd->ecclayout->oobfree[i].offset] = (ops->oobbuf)[k]; k++; } } if (ops->datbuf) { data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, data_dma_addr)) { pr_err("%s: failed to get dma addr for %p\n", __func__, ops->datbuf); return -EIO; } } if (ops->oobbuf) { oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, ops->oobbuf, ops->ooblen, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, oob_dma_addr)) { pr_err("%s: failed to get dma addr for %p\n", __func__, ops->oobbuf); err = -EIO; goto err_dma_map_oobbuf_failed; } } init_dma_addr = msm_nand_dma_map(chip->dev, init_spare_bytes, 64, DMA_TO_DEVICE); if (dma_mapping_error(chip->dev, init_dma_addr)) { pr_err("%s: failed to get dma addr for %p\n", __func__, init_spare_bytes); err = -EIO; goto err_dma_map_initbuf_failed; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); to_curr = to; while (page_count-- > 0) { cmd = dma_buffer->cmd; if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) && (to_curr >= (mtd->size>>1))) { /* DDP Device */ onenand_startaddr1 = DEVICE_FLASHCORE_1 | (((uint32_t)(to_curr-(mtd->size>>1)) / mtd->erasesize)); onenand_startaddr2 = DEVICE_BUFFERRAM_1; } else { onenand_startaddr1 = DEVICE_FLASHCORE_0 | ((uint32_t)to_curr / mtd->erasesize) ; onenand_startaddr2 = DEVICE_BUFFERRAM_0; } onenand_startaddr8 = (((uint32_t)to_curr & (mtd->erasesize - 1)) / mtd->writesize) << 2; onenand_startbuffer = DATARAM0_0 << 8; onenand_sysconfig1 = (ops->mode == MTD_OOB_RAW) ? ONENAND_SYSCFG1_ECCDIS(nand_sfcmd_mode) : ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode); dma_buffer->data.sfbcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(6, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATWR); dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATWR); dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATWR); dma_buffer->data.sfcmd[4] = SFLASH_PREPCMD(256, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATWR); dma_buffer->data.sfcmd[5] = SFLASH_PREPCMD(32, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_DATWR); dma_buffer->data.sfcmd[6] = SFLASH_PREPCMD(1, 6, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[7] = SFLASH_PREPCMD(0, 0, 32, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_INTHI); dma_buffer->data.sfcmd[8] = SFLASH_PREPCMD(3, 7, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.sfcmd[9] = SFLASH_PREPCMD(4, 10, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfexec = 1; dma_buffer->data.sfstat[0] = CLEAN_DATA_32; dma_buffer->data.sfstat[1] = CLEAN_DATA_32; dma_buffer->data.sfstat[2] = CLEAN_DATA_32; dma_buffer->data.sfstat[3] = CLEAN_DATA_32; dma_buffer->data.sfstat[4] = CLEAN_DATA_32; dma_buffer->data.sfstat[5] = CLEAN_DATA_32; dma_buffer->data.sfstat[6] = CLEAN_DATA_32; dma_buffer->data.sfstat[7] = CLEAN_DATA_32; dma_buffer->data.sfstat[8] = CLEAN_DATA_32; dma_buffer->data.sfstat[9] = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | (ONENAND_START_ADDRESS_2); dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | (ONENAND_COMMAND); dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | (ONENAND_INTERRUPT_STATUS); dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | (onenand_sysconfig1); dma_buffer->data.data1 = (onenand_startaddr8 << 16) | (onenand_startaddr1); dma_buffer->data.data2 = (onenand_startbuffer << 16) | (onenand_startaddr2); dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMDPROGSPARE); dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | (CLEAN_DATA_16); dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | (ONENAND_STARTADDR1_RES); dma_buffer->data.macro[0] = 0x0200; dma_buffer->data.macro[1] = 0x0300; dma_buffer->data.macro[2] = 0x0400; dma_buffer->data.macro[3] = 0x0500; dma_buffer->data.macro[4] = 0x8010; /*************************************************************/ /* Write necessary address registers in the onenand device */ /*************************************************************/ /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 16; cmd++; /* Write the ADDR6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); cmd->dst = MSM_NAND_ADDR6; cmd->len = 4; cmd++; /* Write the GENP0, GENP1, GENP2, GENP3 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->dst = MSM_NAND_GENP_REG0; cmd->len = 16; cmd++; /* Write the FLASH_DEV_CMD4,5,6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->dst = MSM_NAND_DEV_CMD4; cmd->len = 12; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); cmd->len = 4; cmd++; /*************************************************************/ /* Write the data ram area in the onenand buffer ram */ /*************************************************************/ if (ops->datbuf) { dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMDPROG); for (i = 0; i < 4; i++) { /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1+i]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Trnsfr usr buf contents to nand ctlr buf */ cmd->cmd = 0; cmd->src = data_dma_addr_curr; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = 512; data_dma_addr_curr += 512; cmd++; /* Write the MACRO1 register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.macro[i]); cmd->dst = MSM_NAND_MACRO1_REG; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data rdy, & read status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1+i]); cmd->len = 4; cmd++; } } /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[5]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; if ((ops->oobbuf) || (ops->mode == MTD_OOB_RAW)) { /* Transfer user buf contents into nand ctlr buffer */ if (ops->mode == MTD_OOB_AUTO) { cmd->cmd = 0; cmd->src = init_dma_addr; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = mtd->oobsize; cmd++; } if (ops->mode == MTD_OOB_PLACE) { cmd->cmd = 0; cmd->src = oob_dma_addr_curr; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = mtd->oobsize; oob_dma_addr_curr += mtd->oobsize; cmd++; } if (ops->mode == MTD_OOB_RAW) { cmd->cmd = 0; cmd->src = data_dma_addr_curr; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = mtd->oobsize; data_dma_addr_curr += mtd->oobsize; cmd++; } } else { cmd->cmd = 0; cmd->src = init_dma_addr; cmd->dst = MSM_NAND_FLASH_BUFFER; cmd->len = mtd->oobsize; cmd++; } /* Write the MACRO1 register */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.macro[4]); cmd->dst = MSM_NAND_MACRO1_REG; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[5]); cmd->len = 4; cmd++; /*********************************************************/ /* Issuing write command */ /*********************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[6]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[6]); cmd->len = 4; cmd++; /*************************************************************/ /* Wait for the interrupt from the Onenand device controller */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[7]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[7]); cmd->len = 4; cmd++; /*************************************************************/ /* Read necessary status registers from the onenand device */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[8]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[8]); cmd->len = 4; cmd++; /* Read the GENP3 register */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG3; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); cmd->len = 4; cmd++; /* Read the DEVCMD4 register */ cmd->cmd = 0; cmd->src = MSM_NAND_DEV_CMD4; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->len = 4; cmd++; /*************************************************************/ /* Restore the necessary registers to proper values */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[9]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[9]); cmd->len = 4; cmd++; BUILD_BUG_ON(53 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); ecc_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; interrupt_status = (dma_buffer->data.data4 >> 0)&0x0000FFFF; controller_status = (dma_buffer->data.data4 >> 16)&0x0000FFFF; #if VERBOSE pr_info("\n%s: sflash status %x %x %x %x %x %x %x" " %x %x %x\n", __func__, dma_buffer->data.sfstat[0], dma_buffer->data.sfstat[1], dma_buffer->data.sfstat[2], dma_buffer->data.sfstat[3], dma_buffer->data.sfstat[4], dma_buffer->data.sfstat[5], dma_buffer->data.sfstat[6], dma_buffer->data.sfstat[7], dma_buffer->data.sfstat[8], dma_buffer->data.sfstat[9]); pr_info("%s: controller_status = %x\n", __func__, controller_status); pr_info("%s: interrupt_status = %x\n", __func__, interrupt_status); pr_info("%s: ecc_status = %x\n", __func__, ecc_status); #endif /* Check for errors, protection violations etc */ if ((controller_status != 0) || (dma_buffer->data.sfstat[0] & 0x110) || (dma_buffer->data.sfstat[6] & 0x110) || (dma_buffer->data.sfstat[7] & 0x110) || (dma_buffer->data.sfstat[8] & 0x110) || (dma_buffer->data.sfstat[9] & 0x110) || ((dma_buffer->data.sfstat[1] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[2] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[3] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[4] & 0x110) && (ops->datbuf)) || ((dma_buffer->data.sfstat[5] & 0x110) && ((ops->oobbuf) || (ops->mode == MTD_OOB_RAW)))) { pr_info("%s: ECC/MPU/OP error\n", __func__); err = -EIO; } if (err) break; pages_written++; to_curr += mtd->writesize; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); dma_unmap_page(chip->dev, init_dma_addr, 64, DMA_TO_DEVICE); err_dma_map_initbuf_failed: if (ops->oobbuf) { dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, DMA_TO_DEVICE); } err_dma_map_oobbuf_failed: if (ops->datbuf) { dma_unmap_page(chip->dev, data_dma_addr, ops->len, DMA_TO_DEVICE); } if (err) { pr_err("%s: %llx %x %x failed\n", __func__, to_curr, ops->datbuf ? ops->len : 0, ops->ooblen); } else { ops->retlen = ops->oobretlen = 0; if (ops->datbuf != NULL) { if (ops->mode != MTD_OOB_RAW) ops->retlen = mtd->writesize * pages_written; else ops->retlen = (mtd->writesize + mtd->oobsize) * pages_written; } if (ops->oobbuf != NULL) { if (ops->mode == MTD_OOB_AUTO) ops->oobretlen = mtd->oobavail * pages_written; else ops->oobretlen = mtd->oobsize * pages_written; } } #if VERBOSE pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", __func__, err, ops->retlen, ops->oobretlen); pr_info("=================================================" "================\n"); #endif kfree(init_spare_bytes); return err; } static int msm_onenand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { int ret; struct mtd_oob_ops ops; ops.mode = MTD_OOB_PLACE; ops.datbuf = (uint8_t *)buf; ops.len = len; ops.retlen = 0; ops.oobbuf = NULL; ops.ooblen = 0; ops.oobretlen = 0; ret = msm_onenand_write_oob(mtd, to, &ops); *retlen = ops.retlen; return ret; } static int msm_onenand_erase(struct mtd_info *mtd, struct erase_info *instr) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[20]; unsigned cmdptr; struct { uint32_t sfbcfg; uint32_t sfcmd[4]; uint32_t sfexec; uint32_t sfstat[4]; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; } data; } *dma_buffer; dmov_s *cmd; int err = 0; uint16_t onenand_startaddr1; uint16_t onenand_startaddr8; uint16_t onenand_startaddr2; uint16_t onenand_startbuffer; uint16_t controller_status; uint16_t interrupt_status; uint16_t ecc_status; uint64_t temp; #if VERBOSE pr_info("=================================================" "================\n"); pr_info("%s: addr 0x%llx len 0x%llx\n", __func__, instr->addr, instr->len); #endif if (instr->addr & (mtd->erasesize - 1)) { pr_err("%s: Unsupported erase address, 0x%llx\n", __func__, instr->addr); return -EINVAL; } if (instr->len != mtd->erasesize) { pr_err("%s: Unsupported erase len, %lld\n", __func__, instr->len); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); cmd = dma_buffer->cmd; temp = instr->addr; if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) && (temp >= (mtd->size>>1))) { /* DDP Device */ onenand_startaddr1 = DEVICE_FLASHCORE_1 | (((uint32_t)(temp-(mtd->size>>1)) / mtd->erasesize)); onenand_startaddr2 = DEVICE_BUFFERRAM_1; } else { onenand_startaddr1 = DEVICE_FLASHCORE_0 | ((uint32_t)temp / mtd->erasesize) ; onenand_startaddr2 = DEVICE_BUFFERRAM_0; } onenand_startaddr8 = 0x0000; onenand_startbuffer = DATARAM0_0 << 8; dma_buffer->data.sfbcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_INTHI); dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfexec = 1; dma_buffer->data.sfstat[0] = CLEAN_DATA_32; dma_buffer->data.sfstat[1] = CLEAN_DATA_32; dma_buffer->data.sfstat[2] = CLEAN_DATA_32; dma_buffer->data.sfstat[3] = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | (ONENAND_START_ADDRESS_2); dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | (ONENAND_COMMAND); dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | (ONENAND_INTERRUPT_STATUS); dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data1 = (onenand_startaddr8 << 16) | (onenand_startaddr1); dma_buffer->data.data2 = (onenand_startbuffer << 16) | (onenand_startaddr2); dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMDERAS); dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | (CLEAN_DATA_16); dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | (ONENAND_STARTADDR1_RES); /***************************************************************/ /* Write the necessary address registers in the onenand device */ /***************************************************************/ /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 16; cmd++; /* Write the ADDR6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); cmd->dst = MSM_NAND_ADDR6; cmd->len = 4; cmd++; /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->dst = MSM_NAND_GENP_REG0; cmd->len = 16; cmd++; /* Write the FLASH_DEV_CMD4,5,6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->dst = MSM_NAND_DEV_CMD4; cmd->len = 12; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); cmd->len = 4; cmd++; /***************************************************************/ /* Wait for the interrupt from the Onenand device controller */ /***************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); cmd->len = 4; cmd++; /***************************************************************/ /* Read the necessary status registers from the onenand device */ /***************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); cmd->len = 4; cmd++; /* Read the GENP3 register */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG3; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); cmd->len = 4; cmd++; /* Read the DEVCMD4 register */ cmd->cmd = 0; cmd->src = MSM_NAND_DEV_CMD4; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->len = 4; cmd++; /***************************************************************/ /* Restore the necessary registers to proper values */ /***************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); cmd->len = 4; cmd++; BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); ecc_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; #if VERBOSE pr_info("\n%s: sflash status %x %x %x %x\n", __func__, dma_buffer->data.sfstat[0], dma_buffer->data.sfstat[1], dma_buffer->data.sfstat[2], dma_buffer->data.sfstat[3]); pr_info("%s: controller_status = %x\n", __func__, controller_status); pr_info("%s: interrupt_status = %x\n", __func__, interrupt_status); pr_info("%s: ecc_status = %x\n", __func__, ecc_status); #endif /* Check for errors, protection violations etc */ if ((controller_status != 0) || (dma_buffer->data.sfstat[0] & 0x110) || (dma_buffer->data.sfstat[1] & 0x110) || (dma_buffer->data.sfstat[2] & 0x110) || (dma_buffer->data.sfstat[3] & 0x110)) { pr_err("%s: ECC/MPU/OP error\n", __func__); err = -EIO; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); if (err) { pr_err("%s: Erase failed, 0x%llx\n", __func__, instr->addr); instr->fail_addr = instr->addr; instr->state = MTD_ERASE_FAILED; } else { instr->state = MTD_ERASE_DONE; instr->fail_addr = 0xffffffff; mtd_erase_callback(instr); } #if VERBOSE pr_info("\n%s: ret %d\n", __func__, err); pr_info("====================================================" "=============\n"); #endif return err; } static int msm_onenand_block_isbad(struct mtd_info *mtd, loff_t ofs) { struct mtd_oob_ops ops; int rval, i; int ret = 0; uint8_t *buffer; uint8_t *oobptr; if ((ofs > mtd->size) || (ofs & (mtd->erasesize - 1))) { pr_err("%s: unsupported block address, 0x%x\n", __func__, (uint32_t)ofs); return -EINVAL; } buffer = kmalloc(2112, GFP_KERNEL|GFP_DMA); if (buffer == 0) { pr_err("%s: Could not kmalloc for buffer\n", __func__); return -ENOMEM; } memset(buffer, 0x00, 2112); oobptr = &(buffer[2048]); ops.mode = MTD_OOB_RAW; ops.len = 2112; ops.retlen = 0; ops.ooblen = 0; ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = buffer; ops.oobbuf = NULL; for (i = 0; i < 2; i++) { ofs = ofs + i*mtd->writesize; rval = msm_onenand_read_oob(mtd, ofs, &ops); if (rval) { pr_err("%s: Error in reading bad blk info\n", __func__); ret = rval; break; } if ((oobptr[0] != 0xFF) || (oobptr[1] != 0xFF) || (oobptr[16] != 0xFF) || (oobptr[17] != 0xFF) || (oobptr[32] != 0xFF) || (oobptr[33] != 0xFF) || (oobptr[48] != 0xFF) || (oobptr[49] != 0xFF) ) { ret = 1; break; } } kfree(buffer); #if VERBOSE if (ret == 1) pr_info("%s : Block containing 0x%x is bad\n", __func__, (unsigned int)ofs); #endif return ret; } static int msm_onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) { struct mtd_oob_ops ops; int rval, i; int ret = 0; uint8_t *buffer; if ((ofs > mtd->size) || (ofs & (mtd->erasesize - 1))) { pr_err("%s: unsupported block address, 0x%x\n", __func__, (uint32_t)ofs); return -EINVAL; } buffer = page_address(ZERO_PAGE()); ops.mode = MTD_OOB_RAW; ops.len = 2112; ops.retlen = 0; ops.ooblen = 0; ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = buffer; ops.oobbuf = NULL; for (i = 0; i < 2; i++) { ofs = ofs + i*mtd->writesize; rval = msm_onenand_write_oob(mtd, ofs, &ops); if (rval) { pr_err("%s: Error in writing bad blk info\n", __func__); ret = rval; break; } } return ret; } static int msm_onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[20]; unsigned cmdptr; struct { uint32_t sfbcfg; uint32_t sfcmd[4]; uint32_t sfexec; uint32_t sfstat[4]; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; } data; } *dma_buffer; dmov_s *cmd; int err = 0; uint16_t onenand_startaddr1; uint16_t onenand_startaddr8; uint16_t onenand_startaddr2; uint16_t onenand_startblock; uint16_t controller_status; uint16_t interrupt_status; uint16_t write_prot_status; uint64_t start_ofs; #if VERBOSE pr_info("====================================================" "=============\n"); pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); #endif /* 'ofs' & 'len' should align to block size */ if (ofs&(mtd->erasesize - 1)) { pr_err("%s: Unsupported ofs address, 0x%llx\n", __func__, ofs); return -EINVAL; } if (len&(mtd->erasesize - 1)) { pr_err("%s: Unsupported len, %lld\n", __func__, len); return -EINVAL; } if (ofs+len > mtd->size) { pr_err("%s: Maximum chip size exceeded\n", __func__); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); for (start_ofs = ofs; ofs < start_ofs+len; ofs = ofs+mtd->erasesize) { #if VERBOSE pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); #endif cmd = dma_buffer->cmd; if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) && (ofs >= (mtd->size>>1))) { /* DDP Device */ onenand_startaddr1 = DEVICE_FLASHCORE_1 | (((uint32_t)(ofs - (mtd->size>>1)) / mtd->erasesize)); onenand_startaddr2 = DEVICE_BUFFERRAM_1; onenand_startblock = ((uint32_t)(ofs - (mtd->size>>1)) / mtd->erasesize); } else { onenand_startaddr1 = DEVICE_FLASHCORE_0 | ((uint32_t)ofs / mtd->erasesize) ; onenand_startaddr2 = DEVICE_BUFFERRAM_0; onenand_startblock = ((uint32_t)ofs / mtd->erasesize); } onenand_startaddr8 = 0x0000; dma_buffer->data.sfbcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_INTHI); dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfexec = 1; dma_buffer->data.sfstat[0] = CLEAN_DATA_32; dma_buffer->data.sfstat[1] = CLEAN_DATA_32; dma_buffer->data.sfstat[2] = CLEAN_DATA_32; dma_buffer->data.sfstat[3] = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.addr2 = (ONENAND_START_BLOCK_ADDRESS << 16) | (ONENAND_START_ADDRESS_2); dma_buffer->data.addr3 = (ONENAND_WRITE_PROT_STATUS << 16) | (ONENAND_COMMAND); dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | (ONENAND_INTERRUPT_STATUS); dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data1 = (onenand_startaddr8 << 16) | (onenand_startaddr1); dma_buffer->data.data2 = (onenand_startblock << 16) | (onenand_startaddr2); dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMD_UNLOCK); dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | (CLEAN_DATA_16); dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | (ONENAND_STARTADDR1_RES); /*************************************************************/ /* Write the necessary address reg in the onenand device */ /*************************************************************/ /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 16; cmd++; /* Write the ADDR6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); cmd->dst = MSM_NAND_ADDR6; cmd->len = 4; cmd++; /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->dst = MSM_NAND_GENP_REG0; cmd->len = 16; cmd++; /* Write the FLASH_DEV_CMD4,5,6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->dst = MSM_NAND_DEV_CMD4; cmd->len = 12; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); cmd->len = 4; cmd++; /*************************************************************/ /* Wait for the interrupt from the Onenand device controller */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); cmd->len = 4; cmd++; /*********************************************************/ /* Read the necessary status reg from the onenand device */ /*********************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); cmd->len = 4; cmd++; /* Read the GENP3 register */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG3; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); cmd->len = 4; cmd++; /* Read the DEVCMD4 register */ cmd->cmd = 0; cmd->src = MSM_NAND_DEV_CMD4; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->len = 4; cmd++; /************************************************************/ /* Restore the necessary registers to proper values */ /************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); cmd->len = 4; cmd++; BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); write_prot_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; #if VERBOSE pr_info("\n%s: sflash status %x %x %x %x\n", __func__, dma_buffer->data.sfstat[0], dma_buffer->data.sfstat[1], dma_buffer->data.sfstat[2], dma_buffer->data.sfstat[3]); pr_info("%s: controller_status = %x\n", __func__, controller_status); pr_info("%s: interrupt_status = %x\n", __func__, interrupt_status); pr_info("%s: write_prot_status = %x\n", __func__, write_prot_status); #endif /* Check for errors, protection violations etc */ if ((controller_status != 0) || (dma_buffer->data.sfstat[0] & 0x110) || (dma_buffer->data.sfstat[1] & 0x110) || (dma_buffer->data.sfstat[2] & 0x110) || (dma_buffer->data.sfstat[3] & 0x110)) { pr_err("%s: ECC/MPU/OP error\n", __func__); err = -EIO; } if (!(write_prot_status & ONENAND_WP_US)) { pr_err("%s: Unexpected status ofs = 0x%llx," "wp_status = %x\n", __func__, ofs, write_prot_status); err = -EIO; } if (err) break; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); #if VERBOSE pr_info("\n%s: ret %d\n", __func__, err); pr_info("====================================================" "=============\n"); #endif return err; } static int msm_onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[20]; unsigned cmdptr; struct { uint32_t sfbcfg; uint32_t sfcmd[4]; uint32_t sfexec; uint32_t sfstat[4]; uint32_t addr0; uint32_t addr1; uint32_t addr2; uint32_t addr3; uint32_t addr4; uint32_t addr5; uint32_t addr6; uint32_t data0; uint32_t data1; uint32_t data2; uint32_t data3; uint32_t data4; uint32_t data5; uint32_t data6; } data; } *dma_buffer; dmov_s *cmd; int err = 0; uint16_t onenand_startaddr1; uint16_t onenand_startaddr8; uint16_t onenand_startaddr2; uint16_t onenand_startblock; uint16_t controller_status; uint16_t interrupt_status; uint16_t write_prot_status; uint64_t start_ofs; #if VERBOSE pr_info("====================================================" "=============\n"); pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); #endif /* 'ofs' & 'len' should align to block size */ if (ofs&(mtd->erasesize - 1)) { pr_err("%s: Unsupported ofs address, 0x%llx\n", __func__, ofs); return -EINVAL; } if (len&(mtd->erasesize - 1)) { pr_err("%s: Unsupported len, %lld\n", __func__, len); return -EINVAL; } if (ofs+len > mtd->size) { pr_err("%s: Maximum chip size exceeded\n", __func__); return -EINVAL; } wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer (chip, sizeof(*dma_buffer)))); for (start_ofs = ofs; ofs < start_ofs+len; ofs = ofs+mtd->erasesize) { #if VERBOSE pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); #endif cmd = dma_buffer->cmd; if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) && (ofs >= (mtd->size>>1))) { /* DDP Device */ onenand_startaddr1 = DEVICE_FLASHCORE_1 | (((uint32_t)(ofs - (mtd->size>>1)) / mtd->erasesize)); onenand_startaddr2 = DEVICE_BUFFERRAM_1; onenand_startblock = ((uint32_t)(ofs - (mtd->size>>1)) / mtd->erasesize); } else { onenand_startaddr1 = DEVICE_FLASHCORE_0 | ((uint32_t)ofs / mtd->erasesize) ; onenand_startaddr2 = DEVICE_BUFFERRAM_0; onenand_startblock = ((uint32_t)ofs / mtd->erasesize); } onenand_startaddr8 = 0x0000; dma_buffer->data.sfbcfg = SFLASH_BCFG | (nand_sfcmd_mode ? 0 : (1 << 24)); dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_INTHI); dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, MSM_NAND_SFCMD_DATXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGRD); dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, MSM_NAND_SFCMD_CMDXS, nand_sfcmd_mode, MSM_NAND_SFCMD_REGWR); dma_buffer->data.sfexec = 1; dma_buffer->data.sfstat[0] = CLEAN_DATA_32; dma_buffer->data.sfstat[1] = CLEAN_DATA_32; dma_buffer->data.sfstat[2] = CLEAN_DATA_32; dma_buffer->data.sfstat[3] = CLEAN_DATA_32; dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.addr2 = (ONENAND_START_BLOCK_ADDRESS << 16) | (ONENAND_START_ADDRESS_2); dma_buffer->data.addr3 = (ONENAND_WRITE_PROT_STATUS << 16) | (ONENAND_COMMAND); dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | (ONENAND_INTERRUPT_STATUS); dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | (ONENAND_SYSTEM_CONFIG_1); dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | (ONENAND_START_ADDRESS_1); dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data1 = (onenand_startaddr8 << 16) | (onenand_startaddr1); dma_buffer->data.data2 = (onenand_startblock << 16) | (onenand_startaddr2); dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | (ONENAND_CMD_LOCK); dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | (CLEAN_DATA_16); dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | (ONENAND_STARTADDR1_RES); /*************************************************************/ /* Write the necessary address reg in the onenand device */ /*************************************************************/ /* Enable and configure the SFlash controller */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; cmd->len = 4; cmd++; /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Write the ADDR0 and ADDR1 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); cmd->dst = MSM_NAND_ADDR0; cmd->len = 8; cmd++; /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); cmd->dst = MSM_NAND_ADDR2; cmd->len = 16; cmd++; /* Write the ADDR6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); cmd->dst = MSM_NAND_ADDR6; cmd->len = 4; cmd++; /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); cmd->dst = MSM_NAND_GENP_REG0; cmd->len = 16; cmd++; /* Write the FLASH_DEV_CMD4,5,6 registers */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->dst = MSM_NAND_DEV_CMD4; cmd->len = 12; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); cmd->len = 4; cmd++; /*************************************************************/ /* Wait for the interrupt from the Onenand device controller */ /*************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); cmd->len = 4; cmd++; /*********************************************************/ /* Read the necessary status reg from the onenand device */ /*********************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); cmd->len = 4; cmd++; /* Read the GENP3 register */ cmd->cmd = 0; cmd->src = MSM_NAND_GENP_REG3; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); cmd->len = 4; cmd++; /* Read the DEVCMD4 register */ cmd->cmd = 0; cmd->src = MSM_NAND_DEV_CMD4; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); cmd->len = 4; cmd++; /************************************************************/ /* Restore the necessary registers to proper values */ /************************************************************/ /* Block on cmd ready and write CMD register */ cmd->cmd = DST_CRCI_NAND_CMD; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); cmd->dst = MSM_NAND_SFLASHC_CMD; cmd->len = 4; cmd++; /* Kick the execute command */ cmd->cmd = 0; cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; cmd->len = 4; cmd++; /* Block on data ready, and read the status register */ cmd->cmd = SRC_CRCI_NAND_DATA; cmd->src = MSM_NAND_SFLASHC_STATUS; cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); cmd->len = 4; cmd++; BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); write_prot_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; #if VERBOSE pr_info("\n%s: sflash status %x %x %x %x\n", __func__, dma_buffer->data.sfstat[0], dma_buffer->data.sfstat[1], dma_buffer->data.sfstat[2], dma_buffer->data.sfstat[3]); pr_info("%s: controller_status = %x\n", __func__, controller_status); pr_info("%s: interrupt_status = %x\n", __func__, interrupt_status); pr_info("%s: write_prot_status = %x\n", __func__, write_prot_status); #endif /* Check for errors, protection violations etc */ if ((controller_status != 0) || (dma_buffer->data.sfstat[0] & 0x110) || (dma_buffer->data.sfstat[1] & 0x110) || (dma_buffer->data.sfstat[2] & 0x110) || (dma_buffer->data.sfstat[3] & 0x110)) { pr_err("%s: ECC/MPU/OP error\n", __func__); err = -EIO; } if (!(write_prot_status & ONENAND_WP_LS)) { pr_err("%s: Unexpected status ofs = 0x%llx," "wp_status = %x\n", __func__, ofs, write_prot_status); err = -EIO; } if (err) break; } msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); #if VERBOSE pr_info("\n%s: ret %d\n", __func__, err); pr_info("====================================================" "=============\n"); #endif return err; } static int msm_onenand_suspend(struct mtd_info *mtd) { return 0; } static void msm_onenand_resume(struct mtd_info *mtd) { } int msm_onenand_scan(struct mtd_info *mtd, int maxchips) { struct msm_nand_chip *chip = mtd->priv; /* Probe and check whether onenand device is present */ if (flash_onenand_probe(chip)) return -ENODEV; mtd->size = 0x1000000 << ((onenand_info.device_id & 0xF0) >> 4); mtd->writesize = onenand_info.data_buf_size; mtd->oobsize = mtd->writesize >> 5; mtd->erasesize = mtd->writesize << 6; mtd->oobavail = msm_onenand_oob_64.oobavail; mtd->ecclayout = &msm_onenand_oob_64; mtd->type = MTD_NANDFLASH; mtd->flags = MTD_CAP_NANDFLASH; mtd->erase = msm_onenand_erase; mtd->point = NULL; mtd->unpoint = NULL; mtd->read = msm_onenand_read; mtd->write = msm_onenand_write; mtd->read_oob = msm_onenand_read_oob; mtd->write_oob = msm_onenand_write_oob; mtd->lock = msm_onenand_lock; mtd->unlock = msm_onenand_unlock; mtd->suspend = msm_onenand_suspend; mtd->resume = msm_onenand_resume; mtd->block_isbad = msm_onenand_block_isbad; mtd->block_markbad = msm_onenand_block_markbad; mtd->owner = THIS_MODULE; pr_info("Found a supported onenand device\n"); return 0; } /** * msm_nand_scan - [msm_nand Interface] Scan for the msm_nand device * @param mtd MTD device structure * @param maxchips Number of chips to scan for * * This fills out all the not initialized function pointers * with the defaults. * The flash ID is read and the mtd/chip structures are * filled with the appropriate values. */ int msm_nand_scan(struct mtd_info *mtd, int maxchips) { struct msm_nand_chip *chip = mtd->priv; uint32_t flash_id = 0, i = 1, mtd_writesize; uint8_t dev_found = 0; uint8_t wide_bus; uint8_t index; /* Probe the Flash device for ONFI compliance */ if (!flash_onfi_probe(chip)) { index = 0; dev_found = 1; } else { /* Read the Flash ID from the Nand Flash Device */ flash_id = flash_read_id(chip); for (index = 1; index < ARRAY_SIZE(supported_flash); index++) if ((flash_id & supported_flash[index].mask) == (supported_flash[index].flash_id & (supported_flash[index].mask))) { dev_found = 1; break; } } if (dev_found) { (!interleave_enable) ? (i = 1) : (i = 2); wide_bus = supported_flash[index].widebus; mtd->size = supported_flash[index].density * i; mtd->writesize = supported_flash[index].pagesize * i; mtd->oobsize = supported_flash[index].oobsize * i; mtd->erasesize = supported_flash[index].blksize * i; if (!interleave_enable) mtd_writesize = mtd->writesize; else mtd_writesize = mtd->writesize >> 1; pr_info("Found a supported NAND device\n"); pr_info("NAND Id : 0x%x\n", supported_flash[index]. flash_id); pr_info("Buswidth : %d Bits \n", (wide_bus) ? 16 : 8); pr_info("Density : %lld MByte\n", (mtd->size>>20)); pr_info("Pagesize : %d Bytes\n", mtd->writesize); pr_info("Erasesize: %d Bytes\n", mtd->erasesize); pr_info("Oobsize : %d Bytes\n", mtd->oobsize); } else { pr_err("Unsupported Nand,Id: 0x%x \n", flash_id); return -ENODEV; } chip->CFG0 = (((mtd_writesize >> 9)-1) << 6) /* 4/8 cw/pg for 2/4k */ | (516 << 9) /* 516 user data bytes */ | (10 << 19) /* 10 parity bytes */ | (5 << 27) /* 5 address cycles */ | (0 << 30) /* Do not read status before data */ | (1 << 31) /* Send read cmd */ /* 0 spare bytes for 16 bit nand or 1 spare bytes for 8 bit */ | ((wide_bus) ? (0 << 23) : (1 << 23)); chip->CFG1 = (0 << 0) /* Enable ecc */ | (7 << 2) /* 8 recovery cycles */ | (0 << 5) /* Allow CS deassertion */ | ((mtd_writesize - (528 * ((mtd_writesize >> 9) - 1)) + 1) << 6) /* Bad block marker location */ | (0 << 16) /* Bad block in user data area */ | (2 << 17) /* 6 cycle tWB/tRB */ | (wide_bus << 1); /* Wide flash bit */ chip->ecc_buf_cfg = 0x203; pr_info("CFG0 Init : 0x%08x \n", chip->CFG0); pr_info("CFG1 Init : 0x%08x \n", chip->CFG1); pr_info("ECCBUFCFG : 0x%08x \n", chip->ecc_buf_cfg); if (mtd->oobsize == 64) { mtd->oobavail = msm_nand_oob_64.oobavail; mtd->ecclayout = &msm_nand_oob_64; } else if (mtd->oobsize == 128) { mtd->oobavail = msm_nand_oob_128.oobavail; mtd->ecclayout = &msm_nand_oob_128; } else if (mtd->oobsize == 256) { mtd->oobavail = msm_nand_oob_256.oobavail; mtd->ecclayout = &msm_nand_oob_256; } else { pr_err("Unsupported Nand, oobsize: 0x%x \n", mtd->oobsize); return -ENODEV; } /* Fill in remaining MTD driver data */ mtd->type = MTD_NANDFLASH; mtd->flags = MTD_CAP_NANDFLASH; /* mtd->ecctype = MTD_ECC_SW; */ mtd->erase = msm_nand_erase; mtd->block_isbad = msm_nand_block_isbad; mtd->block_markbad = msm_nand_block_markbad; mtd->point = NULL; mtd->unpoint = NULL; mtd->read = msm_nand_read; mtd->write = msm_nand_write; mtd->read_oob = msm_nand_read_oob; mtd->write_oob = msm_nand_write_oob; if (dual_nand_ctlr_present) { mtd->read_oob = msm_nand_read_oob_dualnandc; mtd->write_oob = msm_nand_write_oob_dualnandc; if (interleave_enable) { mtd->erase = msm_nand_erase_dualnandc; mtd->block_isbad = msm_nand_block_isbad_dualnandc; } } /* mtd->sync = msm_nand_sync; */ mtd->lock = NULL; /* mtd->unlock = msm_nand_unlock; */ mtd->suspend = msm_nand_suspend; mtd->resume = msm_nand_resume; mtd->owner = THIS_MODULE; /* Unlock whole block */ /* msm_nand_unlock_all(mtd); */ /* return this->scan_bbt(mtd); */ return 0; } EXPORT_SYMBOL_GPL(msm_nand_scan); /** * msm_nand_release - [msm_nand Interface] Free resources held by the msm_nand device * @param mtd MTD device structure */ void msm_nand_release(struct mtd_info *mtd) { /* struct msm_nand_chip *this = mtd->priv; */ #ifdef CONFIG_MTD_PARTITIONS /* Deregister partitions */ del_mtd_partitions(mtd); #endif /* Deregister the device */ del_mtd_device(mtd); } EXPORT_SYMBOL_GPL(msm_nand_release); #ifdef CONFIG_MTD_PARTITIONS static const char *part_probes[] = { "cmdlinepart", NULL, }; #endif struct msm_nand_info { struct mtd_info mtd; struct mtd_partition *parts; struct msm_nand_chip msm_nand; }; /* duplicating the NC01 XFR contents to NC10 */ static int msm_nand_nc10_xfr_settings(struct mtd_info *mtd) { struct msm_nand_chip *chip = mtd->priv; struct { dmov_s cmd[2]; unsigned cmdptr; } *dma_buffer; dmov_s *cmd; wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer( chip, sizeof(*dma_buffer)))); cmd = dma_buffer->cmd; /* Copying XFR register contents from NC01 --> NC10 */ cmd->cmd = 0; cmd->src = NC01(MSM_NAND_XFR_STEP1); cmd->dst = NC10(MSM_NAND_XFR_STEP1); cmd->len = 28; cmd++; BUILD_BUG_ON(2 != ARRAY_SIZE(dma_buffer->cmd)); BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); dma_buffer->cmd[0].cmd |= CMD_OCB; cmd[-1].cmd |= CMD_OCU | CMD_LC; dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; dsb(); msm_dmov_exec_cmd(chip->dma_channel, crci_mask, DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); dsb(); msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); return 0; } #ifdef CONFIG_MTD_PARTITIONS static void setup_mtd_device(struct platform_device *pdev, struct msm_nand_info *info) { int i, nr_parts; struct flash_platform_data *pdata = pdev->dev.platform_data; for (i = 0; i < pdata->nr_parts; i++) { pdata->parts[i].offset = pdata->parts[i].offset * info->mtd.erasesize; pdata->parts[i].size = pdata->parts[i].size * info->mtd.erasesize; } nr_parts = parse_mtd_partitions(&info->mtd, part_probes, &info->parts, 0); if (nr_parts > 0) add_mtd_partitions(&info->mtd, info->parts, nr_parts); else if (nr_parts <= 0 && pdata && pdata->parts) add_mtd_partitions(&info->mtd, pdata->parts, pdata->nr_parts); else add_mtd_device(&info->mtd); } #else static void setup_mtd_device(struct platform_device *pdev, struct msm_nand_info *info) { add_mtd_device(&info->mtd); } #endif static int __devinit msm_nand_probe(struct platform_device *pdev) { struct msm_nand_info *info; struct resource *res; int err; struct flash_platform_data *plat_data; plat_data = pdev->dev.platform_data; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msm_nand_phys"); if (!res || !res->start) { pr_err("%s: msm_nand_phys resource invalid/absent\n", __func__); return -ENODEV; } msm_nand_phys = res->start; pr_info("%s: phys addr 0x%lx \n", __func__, msm_nand_phys); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msm_nandc01_phys"); if (!res || !res->start) goto no_dual_nand_ctlr_support; msm_nandc01_phys = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msm_nandc10_phys"); if (!res || !res->start) goto no_dual_nand_ctlr_support; msm_nandc10_phys = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msm_nandc11_phys"); if (!res || !res->start) goto no_dual_nand_ctlr_support; msm_nandc11_phys = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ebi2_reg_base"); if (!res || !res->start) goto no_dual_nand_ctlr_support; ebi2_register_base = res->start; dual_nand_ctlr_present = 1; if (plat_data != NULL) interleave_enable = plat_data->interleave; else interleave_enable = 0; if (!interleave_enable) pr_info("%s: Dual Nand Ctrl in ping-pong mode\n", __func__); else pr_info("%s: Dual Nand Ctrl in interleave mode\n", __func__); no_dual_nand_ctlr_support: res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "msm_nand_dmac"); if (!res || !res->start) { pr_err("%s: invalid msm_nand_dmac resource\n", __func__); return -ENODEV; } info = kzalloc(sizeof(struct msm_nand_info), GFP_KERNEL); if (!info) { pr_err("%s: No memory for msm_nand_info\n", __func__); return -ENOMEM; } info->msm_nand.dev = &pdev->dev; init_waitqueue_head(&info->msm_nand.wait_queue); info->msm_nand.dma_channel = res->start; pr_info("%s: dmac 0x%x\n", __func__, info->msm_nand.dma_channel); /* this currently fails if dev is passed in */ info->msm_nand.dma_buffer = dma_alloc_coherent(/*dev*/ NULL, MSM_NAND_DMA_BUFFER_SIZE, &info->msm_nand.dma_addr, GFP_KERNEL); if (info->msm_nand.dma_buffer == NULL) { pr_err("%s: No memory for msm_nand.dma_buffer\n", __func__); err = -ENOMEM; goto out_free_info; } pr_info("%s: allocated dma buffer at %p, dma_addr %x\n", __func__, info->msm_nand.dma_buffer, info->msm_nand.dma_addr); crci_mask = msm_dmov_build_crci_mask(2, DMOV_NAND_CRCI_DATA, DMOV_NAND_CRCI_CMD); info->mtd.name = dev_name(&pdev->dev); info->mtd.priv = &info->msm_nand; info->mtd.owner = THIS_MODULE; if (dual_nand_ctlr_present) msm_nand_nc10_xfr_settings(&info->mtd); if (msm_nand_scan(&info->mtd, 1)) if (msm_onenand_scan(&info->mtd, 1)) { pr_err("%s: No nand device found\n", __func__); err = -ENXIO; goto out_free_dma_buffer; } setup_mtd_device(pdev, info); dev_set_drvdata(&pdev->dev, info); return 0; out_free_dma_buffer: dma_free_coherent(NULL, MSM_NAND_DMA_BUFFER_SIZE, info->msm_nand.dma_buffer, info->msm_nand.dma_addr); out_free_info: kfree(info); return err; } static int __devexit msm_nand_remove(struct platform_device *pdev) { struct msm_nand_info *info = dev_get_drvdata(&pdev->dev); dev_set_drvdata(&pdev->dev, NULL); if (info) { #ifdef CONFIG_MTD_PARTITIONS if (info->parts) del_mtd_partitions(&info->mtd); else #endif del_mtd_device(&info->mtd); msm_nand_release(&info->mtd); dma_free_coherent(NULL, MSM_NAND_DMA_BUFFER_SIZE, info->msm_nand.dma_buffer, info->msm_nand.dma_addr); kfree(info); } return 0; } #define DRIVER_NAME "msm_nand" static struct platform_driver msm_nand_driver = { .probe = msm_nand_probe, .remove = __devexit_p(msm_nand_remove), .driver = { .name = DRIVER_NAME, } }; MODULE_ALIAS(DRIVER_NAME); static int __init msm_nand_init(void) { return platform_driver_register(&msm_nand_driver); } static void __exit msm_nand_exit(void) { platform_driver_unregister(&msm_nand_driver); } module_init(msm_nand_init); module_exit(msm_nand_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("msm_nand flash driver code");
Shkerzy/AlcatelOT990_Froyo_kernel
drivers/mtd/devices/msm_nand.c
C
gpl-2.0
194,529
&lt;u&gt;This line of text will render as underlined&lt;/u&gt;
jjohnsonbit/jj-bitsource-patternlab
patternlab/public/patterns/00-atoms-02-text-15-underlined-text/00-atoms-02-text-15-underlined-text.escaped.html
HTML
gpl-2.0
62
/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: system libraries * PURPOSE: System setup * FILE: dll/win32/syssetup/security.c * PROGRAMER: Eric Kohl */ /* INCLUDES *****************************************************************/ #include "precomp.h" #include <ntlsa.h> #include <ntsecapi.h> #include <ntsam.h> #include <sddl.h> #define NDEBUG #include <debug.h> /* FUNCTIONS ****************************************************************/ NTSTATUS WINAPI SetAccountsDomainSid( PSID DomainSid, LPCWSTR DomainName) { PPOLICY_ACCOUNT_DOMAIN_INFO OrigInfo = NULL; POLICY_ACCOUNT_DOMAIN_INFO Info; LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_HANDLE PolicyHandle; SAM_HANDLE ServerHandle = NULL; SAM_HANDLE DomainHandle = NULL; DOMAIN_NAME_INFORMATION DomainNameInfo; NTSTATUS Status; DPRINT("SYSSETUP: SetAccountsDomainSid\n"); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); Status = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_VIEW_LOCAL_INFORMATION | POLICY_TRUST_ADMIN, &PolicyHandle); if (Status != STATUS_SUCCESS) { DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status); return Status; } Status = LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation, (PVOID *)&OrigInfo); if (Status == STATUS_SUCCESS && OrigInfo != NULL) { if (DomainName == NULL) { Info.DomainName.Buffer = OrigInfo->DomainName.Buffer; Info.DomainName.Length = OrigInfo->DomainName.Length; Info.DomainName.MaximumLength = OrigInfo->DomainName.MaximumLength; } else { Info.DomainName.Buffer = (LPWSTR)DomainName; Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR); } if (DomainSid == NULL) Info.DomainSid = OrigInfo->DomainSid; else Info.DomainSid = DomainSid; } else { Info.DomainName.Buffer = (LPWSTR)DomainName; Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR); Info.DomainSid = DomainSid; } Status = LsaSetInformationPolicy(PolicyHandle, PolicyAccountDomainInformation, (PVOID)&Info); if (Status != STATUS_SUCCESS) { DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status); } if (OrigInfo != NULL) LsaFreeMemory(OrigInfo); LsaClose(PolicyHandle); DomainNameInfo.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); DomainNameInfo.DomainName.MaximumLength = (wcslen(DomainName) + 1) * sizeof(WCHAR); DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName; Status = SamConnect(NULL, &ServerHandle, SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN, NULL); if (NT_SUCCESS(Status)) { Status = SamOpenDomain(ServerHandle, DOMAIN_WRITE_OTHER_PARAMETERS, Info.DomainSid, &DomainHandle); if (NT_SUCCESS(Status)) { Status = SamSetInformationDomain(DomainHandle, DomainNameInformation, (PVOID)&DomainNameInfo); if (!NT_SUCCESS(Status)) { DPRINT1("SamSetInformationDomain failed (Status: 0x%08lx)\n", Status); } SamCloseHandle(DomainHandle); } else { DPRINT1("SamOpenDomain failed (Status: 0x%08lx)\n", Status); } SamCloseHandle(ServerHandle); } return Status; } /* Hack */ static NTSTATUS SetPrimaryDomain(LPCWSTR DomainName, PSID DomainSid) { PPOLICY_PRIMARY_DOMAIN_INFO OrigInfo = NULL; POLICY_PRIMARY_DOMAIN_INFO Info; LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_HANDLE PolicyHandle; NTSTATUS Status; DPRINT1("SYSSETUP: SetPrimaryDomain()\n"); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); Status = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_VIEW_LOCAL_INFORMATION | POLICY_TRUST_ADMIN, &PolicyHandle); if (Status != STATUS_SUCCESS) { DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status); return Status; } Status = LsaQueryInformationPolicy(PolicyHandle, PolicyPrimaryDomainInformation, (PVOID *)&OrigInfo); if (Status == STATUS_SUCCESS && OrigInfo != NULL) { if (DomainName == NULL) { Info.Name.Buffer = OrigInfo->Name.Buffer; Info.Name.Length = OrigInfo->Name.Length; Info.Name.MaximumLength = OrigInfo->Name.MaximumLength; } else { Info.Name.Buffer = (LPWSTR)DomainName; Info.Name.Length = wcslen(DomainName) * sizeof(WCHAR); Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR); } if (DomainSid == NULL) Info.Sid = OrigInfo->Sid; else Info.Sid = DomainSid; } else { Info.Name.Buffer = (LPWSTR)DomainName; Info.Name.Length = wcslen(DomainName) * sizeof(WCHAR); Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR); Info.Sid = DomainSid; } Status = LsaSetInformationPolicy(PolicyHandle, PolicyPrimaryDomainInformation, (PVOID)&Info); if (Status != STATUS_SUCCESS) { DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status); } if (OrigInfo != NULL) LsaFreeMemory(OrigInfo); LsaClose(PolicyHandle); return Status; } static VOID InstallBuiltinAccounts(VOID) { LPWSTR BuiltinAccounts[] = { L"S-1-1-0", /* Everyone */ L"S-1-5-4", /* Interactive */ L"S-1-5-6", /* Service */ L"S-1-5-19", /* Local Service */ L"S-1-5-20", /* Network Service */ L"S-1-5-32-544", /* Administrators */ L"S-1-5-32-545", /* Users */ L"S-1-5-32-547", /* Power Users */ L"S-1-5-32-551", /* Backup Operators */ L"S-1-5-32-555"}; /* Remote Desktop Users */ LSA_OBJECT_ATTRIBUTES ObjectAttributes; NTSTATUS Status; LSA_HANDLE PolicyHandle = NULL; LSA_HANDLE AccountHandle = NULL; PSID AccountSid; ULONG i; DPRINT("InstallBuiltinAccounts()\n"); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); Status = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_CREATE_ACCOUNT, &PolicyHandle); if (!NT_SUCCESS(Status)) { DPRINT1("LsaOpenPolicy failed (Status %08lx)\n", Status); return; } for (i = 0; i < 10; i++) { if (!ConvertStringSidToSid(BuiltinAccounts[i], &AccountSid)) { DPRINT1("ConvertStringSidToSid(%S) failed: %lu\n", BuiltinAccounts[i], GetLastError()); continue; } Status = LsaCreateAccount(PolicyHandle, AccountSid, 0, &AccountHandle); if (NT_SUCCESS(Status)) { LsaClose(AccountHandle); } LocalFree(AccountSid); } LsaClose(PolicyHandle); } static VOID InstallPrivileges(VOID) { HINF hSecurityInf = INVALID_HANDLE_VALUE; LSA_OBJECT_ATTRIBUTES ObjectAttributes; WCHAR szPrivilegeString[256]; WCHAR szSidString[256]; INFCONTEXT InfContext; DWORD i; PRIVILEGE_SET PrivilegeSet; PSID AccountSid; NTSTATUS Status; LSA_HANDLE PolicyHandle = NULL; LSA_HANDLE AccountHandle; DPRINT("InstallPrivileges()\n"); hSecurityInf = SetupOpenInfFileW(L"defltws.inf", //szNameBuffer, NULL, INF_STYLE_WIN4, NULL); if (hSecurityInf == INVALID_HANDLE_VALUE) { DPRINT1("SetupOpenInfFileW failed\n"); return; } memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); Status = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_CREATE_ACCOUNT, &PolicyHandle); if (!NT_SUCCESS(Status)) { DPRINT1("LsaOpenPolicy failed (Status %08lx)\n", Status); goto done; } if (!SetupFindFirstLineW(hSecurityInf, L"Privilege Rights", NULL, &InfContext)) { DPRINT1("SetupFindfirstLineW failed\n"); goto done; } PrivilegeSet.PrivilegeCount = 1; PrivilegeSet.Control = 0; do { /* Retrieve the privilege name */ if (!SetupGetStringFieldW(&InfContext, 0, szPrivilegeString, 256, NULL)) { DPRINT1("SetupGetStringFieldW() failed\n"); goto done; } DPRINT("Privilege: %S\n", szPrivilegeString); if (!LookupPrivilegeValueW(NULL, szPrivilegeString, &(PrivilegeSet.Privilege[0].Luid))) { DPRINT1("LookupPrivilegeNameW() failed\n"); goto done; } PrivilegeSet.Privilege[0].Attributes = 0; for (i = 0; i < SetupGetFieldCount(&InfContext); i++) { if (!SetupGetStringFieldW(&InfContext, i + 1, szSidString, 256, NULL)) { DPRINT1("SetupGetStringFieldW() failed\n"); goto done; } DPRINT("SID: %S\n", szSidString); if (!ConvertStringSidToSid(szSidString, &AccountSid)) { DPRINT1("ConvertStringSidToSid(%S) failed: %lu\n", szSidString, GetLastError()); continue; } Status = LsaOpenAccount(PolicyHandle, AccountSid, ACCOUNT_VIEW | ACCOUNT_ADJUST_PRIVILEGES, &AccountHandle); if (NT_SUCCESS(Status)) { Status = LsaAddPrivilegesToAccount(AccountHandle, &PrivilegeSet); if (!NT_SUCCESS(Status)) { DPRINT1("LsaAddPrivilegesToAccount() failed (Status %08lx)\n", Status); } LsaClose(AccountHandle); } LocalFree(AccountSid); } } while (SetupFindNextLine(&InfContext, &InfContext)); done: if (PolicyHandle != NULL) LsaClose(PolicyHandle); if (hSecurityInf != INVALID_HANDLE_VALUE) SetupCloseInfFile(hSecurityInf); } VOID InstallSecurity(VOID) { InstallBuiltinAccounts(); InstallPrivileges(); /* Hack */ SetPrimaryDomain(L"WORKGROUP", NULL); } NTSTATUS SetAdministratorPassword(LPCWSTR Password) { PPOLICY_ACCOUNT_DOMAIN_INFO OrigInfo = NULL; PUSER_ACCOUNT_NAME_INFORMATION AccountNameInfo = NULL; USER_SET_PASSWORD_INFORMATION PasswordInfo; LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_HANDLE PolicyHandle = NULL; SAM_HANDLE ServerHandle = NULL; SAM_HANDLE DomainHandle = NULL; SAM_HANDLE UserHandle = NULL; NTSTATUS Status; DPRINT("SYSSETUP: SetAdministratorPassword(%p)\n", Password); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); Status = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_VIEW_LOCAL_INFORMATION | POLICY_TRUST_ADMIN, &PolicyHandle); if (Status != STATUS_SUCCESS) { DPRINT1("LsaOpenPolicy() failed (Status: 0x%08lx)\n", Status); return Status; } Status = LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation, (PVOID *)&OrigInfo); if (!NT_SUCCESS(Status)) { DPRINT1("LsaQueryInformationPolicy() failed (Status: 0x%08lx)\n", Status); goto done; } Status = SamConnect(NULL, &ServerHandle, SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("SamConnect() failed (Status: 0x%08lx)\n", Status); goto done; } Status = SamOpenDomain(ServerHandle, DOMAIN_LOOKUP, OrigInfo->DomainSid, &DomainHandle); if (!NT_SUCCESS(Status)) { DPRINT1("SamOpenDomain() failed (Status: 0x%08lx)\n", Status); goto done; } Status = SamOpenUser(DomainHandle, USER_FORCE_PASSWORD_CHANGE | USER_READ_GENERAL, DOMAIN_USER_RID_ADMIN, &UserHandle); if (!NT_SUCCESS(Status)) { DPRINT1("SamOpenUser() failed (Status %08lx)\n", Status); goto done; } RtlInitUnicodeString(&PasswordInfo.Password, Password); PasswordInfo.PasswordExpired = FALSE; Status = SamSetInformationUser(UserHandle, UserSetPasswordInformation, (PVOID)&PasswordInfo); if (!NT_SUCCESS(Status)) { DPRINT1("SamSetInformationUser() failed (Status %08lx)\n", Status); goto done; } Status = SamQueryInformationUser(UserHandle, UserAccountNameInformation, (PVOID*)&AccountNameInfo); if (!NT_SUCCESS(Status)) { DPRINT1("SamSetInformationUser() failed (Status %08lx)\n", Status); goto done; } AdminInfo.Name = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, AccountNameInfo->UserName.Length + sizeof(WCHAR)); if (AdminInfo.Name != NULL) RtlCopyMemory(AdminInfo.Name, AccountNameInfo->UserName.Buffer, AccountNameInfo->UserName.Length); AdminInfo.Domain = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, OrigInfo->DomainName.Length + sizeof(WCHAR)); if (AdminInfo.Domain != NULL) RtlCopyMemory(AdminInfo.Domain, OrigInfo->DomainName.Buffer, OrigInfo->DomainName.Length); AdminInfo.Password = RtlAllocateHeap(RtlGetProcessHeap(), 0, (wcslen(Password) + 1) * sizeof(WCHAR)); if (AdminInfo.Password != NULL) wcscpy(AdminInfo.Password, Password); DPRINT("Administrator Name: %S\n", AdminInfo.Name); DPRINT("Administrator Domain: %S\n", AdminInfo.Domain); DPRINT("Administrator Password: %S\n", AdminInfo.Password); done: if (AccountNameInfo != NULL) SamFreeMemory(AccountNameInfo); if (OrigInfo != NULL) LsaFreeMemory(OrigInfo); if (PolicyHandle != NULL) LsaClose(PolicyHandle); if (UserHandle != NULL) SamCloseHandle(UserHandle); if (DomainHandle != NULL) SamCloseHandle(DomainHandle); if (ServerHandle != NULL) SamCloseHandle(ServerHandle); DPRINT1("SYSSETUP: SetAdministratorPassword() done (Status %08lx)\n", Status); return Status; } VOID SetAutoAdminLogon(VOID) { WCHAR szAutoAdminLogon[2]; HKEY hKey = NULL; DWORD dwType; DWORD dwSize; LONG lError; lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", 0, KEY_READ | KEY_WRITE, &hKey); if (lError != ERROR_SUCCESS) return; dwSize = 2 * sizeof(WCHAR); lError = RegQueryValueExW(hKey, L"AutoAdminLogon", NULL, &dwType, (LPBYTE)szAutoAdminLogon, &dwSize); if (lError != ERROR_SUCCESS) goto done; if (wcscmp(szAutoAdminLogon, L"1") == 0) { RegSetValueExW(hKey, L"DefaultDomain", 0, REG_SZ, (LPBYTE)AdminInfo.Domain, (wcslen(AdminInfo.Domain) + 1) * sizeof(WCHAR)); RegSetValueExW(hKey, L"DefaultUserName", 0, REG_SZ, (LPBYTE)AdminInfo.Name, (wcslen(AdminInfo.Name) + 1) * sizeof(WCHAR)); RegSetValueExW(hKey, L"DefaultPassword", 0, REG_SZ, (LPBYTE)AdminInfo.Password, (wcslen(AdminInfo.Password) + 1) * sizeof(WCHAR)); } done: if (hKey != NULL) RegCloseKey(hKey); } /* EOF */
GreenteaOS/Kernel
third-party/reactos/dll/win32/syssetup/security.c
C
gpl-2.0
18,408
<?php $contents="<html> <head> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript' charset='utf-8'></script> <script src='js/jquery.uniform.min.js' type='text/javascript' charset='utf-8'></script> <script type='text/javascript' charset='utf-8'> $(function(){ $('input, textarea, select, button').uniform(); }); </script> <link rel='stylesheet' href='css/uniform.default.css' type='text/css' media='screen'> <style type='text/css' media='screen'> body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #666; padding: 40px; } h1 { margin-top: 0; } ul { list-style: none; padding: 0; margin: 0; } li { margin-bottom: 20px; clear: both; } label { font-size: 10px; font-weight: bold; text-transform: uppercase; display: block; margin-bottom: 3px; clear: both; } </style> </head> "; include('../openinviter.php'); $inviter=new OpenInviter(); $oi_services=$inviter->getPlugins(); $pluginContent=""; if (isset($_POST['provider_box'])) { if (isset($oi_services['email'][$_POST['provider_box']])) $plugType='email'; elseif (isset($oi_services['social'][$_POST['provider_box']])) $plugType='social'; else $plugType=''; if ($plugType) $pluginContent=createPluginContent($_POST['provider_box']); } elseif(!empty($_GET['provider_box'])) { if (isset($oi_services['email'][$_GET['provider_box']])) $plugType='email'; elseif (isset($oi_services['social'][$_GET['provider_box']])) $plugType='social'; else $plugType=''; if($plugType) { $_POST['provider_box']=$_GET['provider_box']; $pluginContent=createPluginContent($_GET['provider_box']); } } else { $plugType = ''; $_POST['provider_box']=''; } function ers($ers) { if (!empty($ers)) { $contents="<table cellspacing='0' cellpadding='0' style='border:1px solid red;' align='center'><tr><td valign='middle' style='padding:3px' valign='middle'><img src='imgs/ers.gif'></td><td valign='middle' style='color:red;padding:5px;'>"; foreach ($ers as $key=>$error) $contents.="{$error}<br >"; $contents.="</td></tr></table><br >"; return $contents; } } function oks($oks) { if (!empty($oks)) { $contents="<table border='0' cellspacing='0' cellpadding='10' style='border:1px solid #5897FE;' align='center'><tr><td valign='middle' valign='middle'><img src='imgs/oks.gif' ></td><td valign='middle' style='color:#5897FE;padding:5px;'> "; foreach ($oks as $key=>$msg) $contents.="{$msg}<br >"; $contents.="</td></tr></table><br >"; return $contents; } } if (!empty($_POST['step'])) $step=$_POST['step']; else $step='get_contacts'; $ers=array();$oks=array();$import_ok=false;$done=false; if ($_SERVER['REQUEST_METHOD']=='POST') { if ($step=='get_contacts') { if (empty($_POST['email_box'])) $ers['email']="Email missing !"; if (empty($_POST['password_box'])) $ers['password']="Password missing !"; if (empty($_POST['provider_box'])) $ers['provide']='Provider missing!'; if (count($ers)==0) { $inviter->startPlugin($_POST['provider_box']); $internal=$inviter->getInternalError(); if ($internal) $ers['inviter']=$internal; elseif (!$inviter->login($_POST['email_box'],$_POST['password_box'])) { $internal=$inviter->getInternalError(); $ers['login']=($internal?$internal:"Login failed. Please check the email and password you have provided and try again later !"); } elseif (false===$contacts=$inviter->getMyContacts()) $ers['contacts']="Unable to get contacts !"; else { $import_ok=true; $step='send_invites'; $_POST['oi_session_id']=$inviter->plugin->getSessionID(); $_POST['message_box']=''; } } } elseif ($step=='send_invites') { if (empty($_POST['provider_box'])) $ers['provider']='Provider missing !'; else { $inviter->startPlugin($_POST['provider_box']); $internal=$inviter->getInternalError(); if ($internal) $ers['internal']=$internal; else { if (empty($_POST['email_box'])) $ers['inviter']='Inviter information missing !'; if (empty($_POST['oi_session_id'])) $ers['session_id']='No active session !'; if (empty($_POST['message_box'])) $ers['message_body']='Message missing !'; else $_POST['message_box']=strip_tags($_POST['message_box']); $selected_contacts=array();$contacts=array(); $message=array('subject'=>$inviter->settings['message_subject'],'body'=>$inviter->settings['message_body'],'attachment'=>"\n\rAttached message: \n\r".$_POST['message_box']); if ($inviter->showContacts()) { foreach ($_POST as $key=>$val) if (strpos($key,'check_')!==false) $selected_contacts[$_POST['email_'.$val]]=$_POST['name_'.$val]; elseif (strpos($key,'email_')!==false) { $temp=explode('_',$key);$counter=$temp[1]; if (is_numeric($temp[1])) $contacts[$val]=$_POST['name_'.$temp[1]]; } if (count($selected_contacts)==0) $ers['contacts']="You haven't selected any contacts to invite !"; } } } if (count($ers)==0) { $sendMessage=$inviter->sendMessage($_POST['oi_session_id'],$message,$selected_contacts); $inviter->logout(); if ($sendMessage===-1) { $message_footer="\r\n\r\nThis invite was sent using OpenInviter technology."; $message_subject=$_POST['email_box'].$message['subject']; $message_body=$message['body'].$message['attachment'].$message_footer; $headers="From: {$_POST['email_box']}"; foreach ($selected_contacts as $email=>$name) mail($email,$message_subject,$message_body,$headers); $oks['mails']="Mails sent successfully"; } elseif ($sendMessage===false) { $internal=$inviter->getInternalError(); $ers['internal']=($internal?$internal:"There were errors while sending your invites.<br>Please try again later!"); } else $oks['internal']="Invites sent successfully!"; $done=true; } } } else { $_POST['email_box']=''; $_POST['password_box']=''; } $contents.="<script type='text/javascript'> function toggleAll(element) { var form = document.forms.openinviter, z = 0; for(z=0; z<form.length;z++) { if(form[z].type == 'checkbox') form[z].checked = element.checked; } } </script>"; $contents.="<form action='' method='POST' name='openinviter'>".ers($ers).oks($oks); if (!$done) { if ($step=='get_contacts') { $contents.="<table align='center' class='thTable' cellspacing='2' cellpadding='0' style='border:none;'> <tr><td align='right'><label for='email_box'>Email</label></td><td><input type='text' name='email_box' value='{$_POST['email_box']}'></td></tr> <tr><td align='right'><label for='password_box'>Password</label></td><td><input type='password' name='password_box' value='{$_POST['password_box']}'></td></tr> <tr><td colspan='2' align='center'><input type='submit' name='import' value='Import Contacts'></td></tr> </table><input type='hidden' name='provider_box' value='{$_POST['provider_box']}'><input type='hidden' name='step' value='get_contacts'>"; } else $contents.="<table class='thTable' cellspacing='0' cellpadding='0' style='border:none;'> <tr><td align='center' valign='top'><label for='message_box'>Message</label></td><td><textarea rows='5' cols='50' name='message_box' style='width:300px;'>{$_POST['message_box']}</textarea></td></tr> <tr><td align='center' colspan='2'><input type='submit' name='send' value='Send Invites' ></td></tr> </table>"; } $contents.="<center>{$pluginContent}</center>"; if (!$done) { if ($step=='send_invites') { if ($inviter->showContacts()) { $contents.="<table align='center' cellspacing='0' cellpadding='0'><tr><td colspan='".($plugType=='email'? "3":"2")."'>Your contacts</td></tr>"; if (count($contacts)==0) $contents.="<tr><td align='center' style='padding:20px;' colspan='".($plugType=='email'? "3":"2")."'>You do not have any contacts in your address book.</td></tr>"; else { $contents.="<tr><td><input type='checkbox' onChange='toggleAll(this)' name='toggle_all' title='Select/Deselect all' checked>Invite?</td><td>Name</td>".($plugType == 'email' ?"<td>E-mail</td>":"")."</tr>"; $counter=0; foreach ($contacts as $email=>$name) { $counter++; $contents.="<tr><td><input name='check_{$counter}' value='{$counter}' type='checkbox' checked><input type='hidden' name='email_{$counter}' value='{$email}'><input type='hidden' name='name_{$counter}' value='{$name}'></td><td>{$name}</td>".($plugType == 'email' ?"<td>{$email}</td>":"")."</tr>"; } $contents.="<tr><td colspan='".($plugType=='email'? "3":"2")."' style='padding:3px;'><input type='submit' name='send' value='Send invites'></td></tr>"; } $contents.="</table>"; } $contents.="<input type='hidden' name='step' value='send_invites'> <input type='hidden' name='provider_box' value='{$_POST['provider_box']}'> <input type='hidden' name='email_box' value='{$_POST['email_box']}'> <input type='hidden' name='oi_session_id' value='{$_POST['oi_session_id']}'>"; $contents.="<script>self.parent.$.fancybox.resize();</script>"; } } $contents.="</form>"; echo $contents; function createPluginContent($pr) { global $oi_services,$plugType; $a=array_keys($oi_services[$plugType]); foreach($a as $r=>$sv) if ($sv==$pr) break; return $contentPlugin="<div style='border:none; display:block; height:60px; margin:0; padding:0; width:130px; background-position: 0px ".(-60*$r)."px; background-image:url(\"imgs/{$plugType}_services.png\");'></div>"; } ?>
berryjace/www
crm/library/ThirdParty/OpenInviter/more_examples/get_contacts.php
PHP
gpl-2.0
9,479
#ifndef _UMLCLASSMEMBER_H #define _UMLCLASSMEMBER_H #include <qcstring.h> #include "UmlBaseClassMember.h" // This class globaly manages class's relations, attributes, operations // and sub-classes // // You can modify it as you want (except the constructor) class UmlClassMember : public UmlBaseClassMember { public: UmlClassMember(void * id, const QCString & n) : UmlBaseClassMember(id, n) {}; void annotation_constraint(); }; #endif
gregsmirnov/bouml
genplugouts/html/cpp/UmlClassMember.h
C
gpl-2.0
452
import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem, NavItem, NavLink } from 'reactstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCog, faExternalLinkAlt, faSignOutAlt } from '@fortawesome/free-solid-svg-icons'; import { useTranslation } from 'react-i18next'; import Avatar from 'components/Avatar'; import { openSettingsModal } from 'store/actions/settingsActions'; import { logOut } from 'store/actions/userActions'; import './UserDropdown.scss'; export default function UserDropdow() { const { t } = useTranslation(); const dispatch = useDispatch(); const user = useSelector((state) => state.user); return ( <React.Fragment> <UncontrolledDropdown data-cy="UserDropdown" nav inNavbar> <DropdownToggle nav caret className="ows-dropdown-user"> <Avatar user={user} alt={user.name} size="sm" /> <span className="ows-username" data-cy="UserDropdown-username"> {user.name} </span> </DropdownToggle> <DropdownMenu right> <DropdownItem href={user.url} target="_blank" rel="noopener" data-cy="UserDropdown-profileLink"> {t('viewProfile')} <FontAwesomeIcon className="ml-1" color="var(--gray)" icon={faExternalLinkAlt} /> </DropdownItem> <DropdownItem divider /> <DropdownItem onClick={openSettingsModal(dispatch)}> <FontAwesomeIcon icon={faCog} /> {t('settings')} </DropdownItem> <DropdownItem className="d-none d-md-block" onClick={logOut(dispatch)}> <FontAwesomeIcon icon={faSignOutAlt} /> {t('logOut')} </DropdownItem> </DropdownMenu> </UncontrolledDropdown> <NavItem className="d-block d-md-none"> <NavLink onClick={logOut(dispatch)}> <FontAwesomeIcon icon={faSignOutAlt} /> {t('logOut')} </NavLink> </NavItem> </React.Fragment> ); }
elamperti/OpenWebScrobbler
src/components/Navigation/partials/UserDropdown.js
JavaScript
gpl-2.0
2,071
/* * Copyright (C) 2005-2011 MaNGOS <http://getmangos.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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SpellMgr.h" #include "ObjectMgr.h" #include "SpellAuraDefines.h" #include "ProgressBar.h" #include "DBCStores.h" #include "World.h" #include "Chat.h" #include "Spell.h" #include "BattleGroundMgr.h" #include "MapManager.h" #include "Unit.h" SpellMgr::SpellMgr() { } SpellMgr::~SpellMgr() { } SpellMgr& SpellMgr::Instance() { static SpellMgr spellMgr; return spellMgr; } int32 GetSpellDuration(SpellEntry const *spellInfo) { if(!spellInfo) return 0; SpellDurationEntry const *du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); if(!du) return 0; return (du->Duration[0] == -1) ? -1 : abs(du->Duration[0]); } int32 GetSpellMaxDuration(SpellEntry const *spellInfo) { if(!spellInfo) return 0; SpellDurationEntry const *du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); if(!du) return 0; return (du->Duration[2] == -1) ? -1 : abs(du->Duration[2]); } int32 CalculateSpellDuration(SpellEntry const *spellInfo, Unit const* caster) { int32 duration = GetSpellDuration(spellInfo); if (duration != -1 && caster) { int32 maxduration = GetSpellMaxDuration(spellInfo); if (duration != maxduration && caster->GetTypeId() == TYPEID_PLAYER) duration += int32((maxduration - duration) * ((Player*)caster)->GetComboPoints() / 5); if (Player* modOwner = caster->GetSpellModOwner()) { modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration); if (duration < 0) duration = 0; } } return duration; } uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell) { if (spell) { // some triggered spells have data only usable for client if (spell->IsTriggeredSpellWithRedundentData()) return 0; // spell targeted to non-trading trade slot item instant at trade success apply if (spell->GetCaster()->GetTypeId()==TYPEID_PLAYER) if (TradeData* my_trade = ((Player*)(spell->GetCaster()))->GetTradeData()) if (Item* nonTrade = my_trade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED)) if (nonTrade == spell->m_targets.getItemTarget()) return 0; } SpellCastTimesEntry const *spellCastTimeEntry = sSpellCastTimesStore.LookupEntry(spellInfo->CastingTimeIndex); // not all spells have cast time index and this is all is pasiive abilities if (!spellCastTimeEntry) return 0; int32 castTime = spellCastTimeEntry->CastTime; if (spell) { if (Player* modOwner = spell->GetCaster()->GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell); if (!(spellInfo->Attributes & (SPELL_ATTR_UNK4|SPELL_ATTR_TRADESPELL))) castTime = int32(castTime * spell->GetCaster()->GetFloatValue(UNIT_MOD_CAST_SPEED)); else { if (spell->IsRangedSpell() && !spell->IsAutoRepeat()) castTime = int32(castTime * spell->GetCaster()->m_modAttackSpeedPct[RANGED_ATTACK]); } } if (spellInfo->Attributes & SPELL_ATTR_RANGED && (!spell || !spell->IsAutoRepeat())) castTime += 500; return (castTime > 0) ? uint32(castTime) : 0; } uint32 GetSpellCastTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype ) { uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); if (CastingTime > 7000) CastingTime = 7000; if (CastingTime < 1500) CastingTime = 1500; if(damagetype == DOT && !IsChanneledSpell(spellProto)) CastingTime = 3500; int32 overTime = 0; uint8 effects = 0; bool DirectDamage = false; bool AreaEffect = false; for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i]))) AreaEffect = true; for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (spellProto->Effect[i]) { case SPELL_EFFECT_SCHOOL_DAMAGE: case SPELL_EFFECT_POWER_DRAIN: case SPELL_EFFECT_HEALTH_LEECH: case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE: case SPELL_EFFECT_POWER_BURN: case SPELL_EFFECT_HEAL: DirectDamage = true; break; case SPELL_EFFECT_APPLY_AURA: switch (spellProto->EffectApplyAuraName[i]) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_PERIODIC_LEECH: if ( GetSpellDuration(spellProto) ) overTime = GetSpellDuration(spellProto); break; // Penalty for additional effects case SPELL_AURA_DUMMY: ++effects; break; case SPELL_AURA_MOD_DECREASE_SPEED: ++effects; break; case SPELL_AURA_MOD_CONFUSE: case SPELL_AURA_MOD_STUN: case SPELL_AURA_MOD_ROOT: // -10% per effect effects += 2; break; default: break; } break; default: break; } } // Combined Spells with Both Over Time and Direct Damage if (overTime > 0 && CastingTime > 0 && DirectDamage) { // mainly for DoTs which are 3500 here otherwise uint32 OriginalCastTime = GetSpellCastTime(spellProto); if (OriginalCastTime > 7000) OriginalCastTime = 7000; if (OriginalCastTime < 1500) OriginalCastTime = 1500; // Portion to Over Time float PtOT = (overTime / 15000.0f) / ((overTime / 15000.0f) + (OriginalCastTime / 3500.0f)); if (damagetype == DOT) CastingTime = uint32(CastingTime * PtOT); else if (PtOT < 1.0f) CastingTime = uint32(CastingTime * (1 - PtOT)); else CastingTime = 0; } // Area Effect Spells receive only half of bonus if (AreaEffect) CastingTime /= 2; // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || (spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)) { CastingTime /= 2; break; } } // -5% of total per any additional effect (multiplicative) for (int i = 0; i < effects; ++i) CastingTime *= 0.95f; return CastingTime; } uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo) { int32 DotDuration = GetSpellDuration(spellInfo); if(DotDuration == 0) return 1; // 200% limit if(DotDuration > 30000) DotDuration = 30000; for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( spellInfo->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_HEAL || spellInfo->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) { if (spellInfo->EffectAmplitude[j] != 0) return DotDuration / spellInfo->EffectAmplitude[j]; break; } } return 6; } uint16 GetSpellAuraMaxTicks(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) { sLog.outError("GetSpellAuraMaxTicks: Spell %u not exist!", spellId); return 1; } return GetSpellAuraMaxTicks(spellInfo); } float CalculateDefaultCoefficient(SpellEntry const *spellProto, DamageEffectType const damagetype) { // Damage over Time spells bonus calculation float DotFactor = 1.0f; if (damagetype == DOT) { if (!IsChanneledSpell(spellProto)) DotFactor = GetSpellDuration(spellProto) / 15000.0f; if (uint16 DotTicks = GetSpellAuraMaxTicks(spellProto)) DotFactor /= DotTicks; } // Distribute Damage over multiple effects, reduce by AoE float coeff = GetSpellCastTimeForBonus(spellProto, damagetype) / 3500.0f; return coeff * DotFactor; } WeaponAttackType GetWeaponAttackType(SpellEntry const *spellInfo) { if(!spellInfo) return BASE_ATTACK; switch (spellInfo->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: if (spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) return OFF_ATTACK; else return BASE_ATTACK; break; case SPELL_DAMAGE_CLASS_RANGED: return RANGED_ATTACK; break; default: // Wands if (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) return RANGED_ATTACK; else return BASE_ATTACK; break; } } bool IsPassiveSpell(uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) return false; return IsPassiveSpell(spellInfo); } bool IsPassiveSpell(SpellEntry const *spellInfo) { return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; } bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 spellId_2) { SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if(!spellInfo_1 || !spellInfo_2) return false; if(spellInfo_1->Id == spellId_2) return false; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { for (int32 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo_1->Effect[i] == spellInfo_2->Effect[j] && spellInfo_1->EffectApplyAuraName[i] == spellInfo_2->EffectApplyAuraName[j] && spellInfo_1->EffectMiscValue[i] == spellInfo_2->EffectMiscValue[j] && spellInfo_1->EffectItemType[i] == spellInfo_2->EffectItemType[j] && (spellInfo_1->Effect[i] != 0 || spellInfo_1->EffectApplyAuraName[i] != 0 || spellInfo_1->EffectMiscValue[i] != 0 || spellInfo_1->EffectItemType[i] != 0)) return true; } } return false; } int32 CompareAuraRanks(uint32 spellId_1, uint32 spellId_2) { SpellEntry const*spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const*spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if(!spellInfo_1 || !spellInfo_2) return 0; if (spellId_1 == spellId_2) return 0; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->Effect[i] != 0 && spellInfo_2->Effect[i] != 0 && spellInfo_1->Effect[i] == spellInfo_2->Effect[i]) { int32 diff = spellInfo_1->EffectBasePoints[i] - spellInfo_2->EffectBasePoints[i]; if (spellInfo_1->CalculateSimpleValue(SpellEffectIndex(i)) < 0 && spellInfo_2->CalculateSimpleValue(SpellEffectIndex(i)) < 0) return -diff; else return diff; } } return 0; } SpellSpecific GetSpellSpecific(uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) return SPELL_NORMAL; switch(spellInfo->SpellFamilyName) { case SPELLFAMILY_GENERIC: { // Food / Drinks (mostly) if (spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) { bool food = false; bool drink = false; for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(spellInfo->EffectApplyAuraName[i]) { // Food case SPELL_AURA_MOD_REGEN: case SPELL_AURA_OBS_MOD_HEALTH: food = true; break; // Drink case SPELL_AURA_MOD_POWER_REGEN: case SPELL_AURA_OBS_MOD_MANA: drink = true; break; default: break; } } if (food && drink) return SPELL_FOOD_AND_DRINK; else if (food) return SPELL_FOOD; else if (drink) return SPELL_DRINK; } else { // Well Fed buffs (must be exclusive with Food / Drink replenishment effects, or else Well Fed will cause them to be removed) // SpellIcon 2560 is Spell 46687, does not have this flag if ((spellInfo->AttributesEx2 & SPELL_ATTR_EX2_FOOD_BUFF) || spellInfo->SpellIconID == 2560) return SPELL_WELL_FED; else if (spellInfo->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_STAT && spellInfo->Attributes & SPELL_ATTR_NOT_SHAPESHIFT && spellInfo->SchoolMask & SPELL_SCHOOL_MASK_NATURE && spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) return SPELL_SCROLL; } break; } case SPELLFAMILY_MAGE: { // family flags 18(Molten), 25(Frost/Ice), 28(Mage) if (spellInfo->SpellFamilyFlags & UI64LIT(0x12040000)) return SPELL_MAGE_ARMOR; if ((spellInfo->SpellFamilyFlags & UI64LIT(0x1000000)) && spellInfo->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_CONFUSE) return SPELL_MAGE_POLYMORPH; break; } case SPELLFAMILY_WARRIOR: { if (spellInfo->SpellFamilyFlags & UI64LIT(0x00008000010000)) return SPELL_POSITIVE_SHOUT; break; } case SPELLFAMILY_WARLOCK: { // only warlock curses have this if (spellInfo->Dispel == DISPEL_CURSE) return SPELL_CURSE; // Warlock (Demon Armor | Demon Skin | Fel Armor) if (spellInfo->IsFitToFamilyMask(UI64LIT(0x2000002000000000), 0x00000010)) return SPELL_WARLOCK_ARMOR; // Unstable Affliction | Immolate if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000010000000004))) return SPELL_UA_IMMOLATE; break; } case SPELLFAMILY_PRIEST: { // "Well Fed" buff from Blessed Sunfruit, Blessed Sunfruit Juice, Alterac Spring Water if ((spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_SITTING) && (spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK) && (spellInfo->SpellIconID == 52 || spellInfo->SpellIconID == 79)) return SPELL_WELL_FED; break; } case SPELLFAMILY_HUNTER: { // only hunter stings have this if (spellInfo->Dispel == DISPEL_POISON) return SPELL_STING; // only hunter aspects have this if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0044000000380000), 0x00001010)) return SPELL_ASPECT; break; } case SPELLFAMILY_PALADIN: { if (IsSealSpell(spellInfo)) return SPELL_SEAL; if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000011010002))) return SPELL_BLESSING; if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000002190))) return SPELL_HAND; // skip Heart of the Crusader that have also same spell family mask if (spellInfo->IsFitToFamilyMask(UI64LIT(0x00000820180400)) && (spellInfo->AttributesEx3 & 0x200) && (spellInfo->SpellIconID != 237)) return SPELL_JUDGEMENT; // only paladin auras have this (for palaldin class family) if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00000020)) return SPELL_AURA; break; } case SPELLFAMILY_SHAMAN: { if (IsElementalShield(spellInfo)) return SPELL_ELEMENTAL_SHIELD; break; } case SPELLFAMILY_POTION: return sSpellMgr.GetSpellElixirSpecific(spellInfo->Id); case SPELLFAMILY_DEATHKNIGHT: if (spellInfo->Category == 47) return SPELL_PRESENCE; break; } // Tracking spells (exclude Well Fed, some other always allowed cases) if ((IsSpellHaveAura(spellInfo, SPELL_AURA_TRACK_CREATURES) || IsSpellHaveAura(spellInfo, SPELL_AURA_TRACK_RESOURCES) || IsSpellHaveAura(spellInfo, SPELL_AURA_TRACK_STEALTHED)) && ((spellInfo->AttributesEx & SPELL_ATTR_EX_UNK17) || (spellInfo->AttributesEx6 & SPELL_ATTR_EX6_UNK12))) return SPELL_TRACKER; // elixirs can have different families, but potion most ofc. if (SpellSpecific sp = sSpellMgr.GetSpellElixirSpecific(spellInfo->Id)) return sp; return SPELL_NORMAL; } // target not allow have more one spell specific from same caster bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2) { switch(spellSpec1) { case SPELL_BLESSING: case SPELL_AURA: case SPELL_STING: case SPELL_CURSE: case SPELL_ASPECT: case SPELL_POSITIVE_SHOUT: case SPELL_JUDGEMENT: case SPELL_HAND: case SPELL_UA_IMMOLATE: return spellSpec1==spellSpec2; default: return false; } } // target not allow have more one ranks from spell from spell specific per target bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) { switch(spellSpec1) { case SPELL_BLESSING: case SPELL_AURA: case SPELL_CURSE: case SPELL_ASPECT: case SPELL_HAND: return spellSpec1==spellSpec2; default: return false; } } // target not allow have more one spell specific per target from any caster bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) { switch(spellSpec1) { case SPELL_SEAL: case SPELL_TRACKER: case SPELL_WARLOCK_ARMOR: case SPELL_MAGE_ARMOR: case SPELL_ELEMENTAL_SHIELD: case SPELL_MAGE_POLYMORPH: case SPELL_PRESENCE: case SPELL_WELL_FED: return spellSpec1==spellSpec2; case SPELL_BATTLE_ELIXIR: return spellSpec2==SPELL_BATTLE_ELIXIR || spellSpec2==SPELL_FLASK_ELIXIR; case SPELL_GUARDIAN_ELIXIR: return spellSpec2==SPELL_GUARDIAN_ELIXIR || spellSpec2==SPELL_FLASK_ELIXIR; case SPELL_FLASK_ELIXIR: return spellSpec2==SPELL_BATTLE_ELIXIR || spellSpec2==SPELL_GUARDIAN_ELIXIR || spellSpec2==SPELL_FLASK_ELIXIR; case SPELL_FOOD: return spellSpec2==SPELL_FOOD || spellSpec2==SPELL_FOOD_AND_DRINK; case SPELL_DRINK: return spellSpec2==SPELL_DRINK || spellSpec2==SPELL_FOOD_AND_DRINK; case SPELL_FOOD_AND_DRINK: return spellSpec2==SPELL_FOOD || spellSpec2==SPELL_DRINK || spellSpec2==SPELL_FOOD_AND_DRINK; default: return false; } } bool IsPositiveTarget(uint32 targetA, uint32 targetB) { switch(targetA) { // non-positive targets case TARGET_CHAIN_DAMAGE: case TARGET_ALL_ENEMY_IN_AREA: case TARGET_ALL_ENEMY_IN_AREA_INSTANT: case TARGET_IN_FRONT_OF_CASTER: case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: case TARGET_CURRENT_ENEMY_COORDINATES: case TARGET_SINGLE_ENEMY: case TARGET_IN_FRONT_OF_CASTER_30: return false; // positive or dependent case TARGET_CASTER_COORDINATES: return (targetB == TARGET_ALL_PARTY || targetB == TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER); default: break; } if (targetB) return IsPositiveTarget(targetB, 0); return true; } bool IsExplicitPositiveTarget(uint32 targetA) { // positive targets that in target selection code expect target in m_targers, so not that auto-select target by spell data by m_caster and etc switch(targetA) { case TARGET_SINGLE_FRIEND: case TARGET_SINGLE_PARTY: case TARGET_CHAIN_HEAL: case TARGET_SINGLE_FRIEND_2: case TARGET_AREAEFFECT_PARTY_AND_CLASS: return true; default: break; } return false; } bool IsExplicitNegativeTarget(uint32 targetA) { // non-positive targets that in target selection code expect target in m_targers, so not that auto-select target by spell data by m_caster and etc switch(targetA) { case TARGET_CHAIN_DAMAGE: case TARGET_CURRENT_ENEMY_COORDINATES: case TARGET_SINGLE_ENEMY: return true; default: break; } return false; } bool IsPositiveEffect(SpellEntry const *spellproto, SpellEffectIndex effIndex) { // FG: temp fix, that they are not cancelable switch(spellproto->Id) { case 37675: // Chaos Blast case 36810: // rotting puterescence case 36809: // overpowering sickness case 48323: // indisposed return false; } switch(spellproto->Effect[effIndex]) { case SPELL_EFFECT_DUMMY: // some explicitly required dummy effect sets switch(spellproto->Id) { case 28441: // AB Effect 000 return false; case 49634: // Sergeant's Flare case 54530: // Opening case 62105: // To'kini's Blowgun return true; default: break; } break; // always positive effects (check before target checks that provided non-positive result in some case for positive effects) case SPELL_EFFECT_HEAL: case SPELL_EFFECT_LEARN_SPELL: case SPELL_EFFECT_SKILL_STEP: case SPELL_EFFECT_HEAL_PCT: case SPELL_EFFECT_ENERGIZE_PCT: return true; // non-positive aura use case SPELL_EFFECT_APPLY_AURA: case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: { switch(spellproto->EffectApplyAuraName[effIndex]) { case SPELL_AURA_DUMMY: { // dummy aura can be positive or negative dependent from casted spell switch(spellproto->Id) { case 13139: // net-o-matic special effect case 23445: // evil twin case 35679: // Protectorate Demolitionist case 38637: // Nether Exhaustion (red) case 38638: // Nether Exhaustion (green) case 38639: // Nether Exhaustion (blue) case 11196: // Recently Bandaged case 44689: // Relay Race Accept Hidden Debuff - DND case 58600: // Restricted Flight Area return false; // some spells have unclear target modes for selection, so just make effect positive case 27184: case 27190: case 27191: case 27201: case 27202: case 27203: return true; default: break; } } break; case SPELL_AURA_MOD_DAMAGE_DONE: // dependent from base point sign (negative -> negative) case SPELL_AURA_MOD_RESISTANCE: case SPELL_AURA_MOD_STAT: case SPELL_AURA_MOD_SKILL: case SPELL_AURA_MOD_DODGE_PERCENT: case SPELL_AURA_MOD_HEALING_PCT: case SPELL_AURA_MOD_HEALING_DONE: if(spellproto->CalculateSimpleValue(effIndex) < 0) return false; break; case SPELL_AURA_MOD_DAMAGE_TAKEN: // dependent from bas point sign (positive -> negative) if (spellproto->CalculateSimpleValue(effIndex) < 0) return true; // let check by target modes (for Amplify Magic cases/etc) break; case SPELL_AURA_MOD_SPELL_CRIT_CHANCE: case SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT: case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: if(spellproto->CalculateSimpleValue(effIndex) > 0) return true; // some expected positive spells have SPELL_ATTR_EX_NEGATIVE or unclear target modes break; case SPELL_AURA_ADD_TARGET_TRIGGER: return true; case SPELL_AURA_PERIODIC_TRIGGER_SPELL: if (spellproto->Id != spellproto->EffectTriggerSpell[effIndex]) { uint32 spellTriggeredId = spellproto->EffectTriggerSpell[effIndex]; SpellEntry const *spellTriggeredProto = sSpellStore.LookupEntry(spellTriggeredId); if (spellTriggeredProto) { // non-positive targets of main spell return early for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // if non-positive trigger cast targeted to positive target this main cast is non-positive // this will place this spell auras as debuffs if (spellTriggeredProto->Effect[i] && IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[i], spellTriggeredProto->EffectImplicitTargetB[i]) && !IsPositiveEffect(spellTriggeredProto, SpellEffectIndex(i))) return false; } } } break; case SPELL_AURA_PROC_TRIGGER_SPELL: // many positive auras have negative triggered spells at damage for example and this not make it negative (it can be canceled for example) break; case SPELL_AURA_MOD_STUN: //have positive and negative spells, we can't sort its correctly at this moment. if (effIndex == EFFECT_INDEX_0 && spellproto->Effect[EFFECT_INDEX_1] == 0 && spellproto->Effect[EFFECT_INDEX_2] == 0) return false; // but all single stun aura spells is negative // Petrification if(spellproto->Id == 17624) return false; break; case SPELL_AURA_MOD_PACIFY_SILENCE: switch(spellproto->Id) { case 24740: // Wisp Costume case 47585: // Dispersion return true; default: break; } return false; case SPELL_AURA_MOD_ROOT: case SPELL_AURA_MOD_SILENCE: case SPELL_AURA_GHOST: case SPELL_AURA_PERIODIC_LEECH: case SPELL_AURA_MOD_STALKED: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: return false; case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also. // part of negative spell if casted at self (prevent cancel) if (spellproto->EffectImplicitTargetA[effIndex] == TARGET_SELF || spellproto->EffectImplicitTargetA[effIndex] == TARGET_SELF2) return false; break; case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also // part of positive spell if casted at self if ((spellproto->EffectImplicitTargetA[effIndex] == TARGET_SELF || spellproto->EffectImplicitTargetA[effIndex] == TARGET_SELF2) && spellproto->SpellFamilyName == SPELLFAMILY_GENERIC) return false; // but not this if this first effect (don't found better check) if (spellproto->Attributes & 0x4000000 && effIndex == EFFECT_INDEX_0) return false; break; case SPELL_AURA_TRANSFORM: // some spells negative switch(spellproto->Id) { case 36897: // Transporter Malfunction (race mutation to horde) case 36899: // Transporter Malfunction (race mutation to alliance) return false; } break; case SPELL_AURA_MOD_SCALE: // some spells negative switch(spellproto->Id) { case 802: // Mutate Bug, wrongly negative by target modes return true; case 36900: // Soul Split: Evil! case 36901: // Soul Split: Good case 36893: // Transporter Malfunction (decrease size case) case 36895: // Transporter Malfunction (increase size case) return false; } break; case SPELL_AURA_MECHANIC_IMMUNITY: { // non-positive immunities switch(spellproto->EffectMiscValue[effIndex]) { case MECHANIC_BANDAGE: case MECHANIC_SHIELD: case MECHANIC_MOUNT: case MECHANIC_INVULNERABILITY: return false; default: break; } } break; case SPELL_AURA_ADD_FLAT_MODIFIER: // mods case SPELL_AURA_ADD_PCT_MODIFIER: { // non-positive mods switch(spellproto->EffectMiscValue[effIndex]) { case SPELLMOD_COST: // dependent from bas point sign (negative -> positive) if(spellproto->CalculateSimpleValue(effIndex) > 0) return false; break; default: break; } } break; case SPELL_AURA_FORCE_REACTION: { switch (spellproto->Id) { case 42792: // Recently Dropped Flag (prevent cancel) case 46221: // Animal Blood return false; default: break; } break; } default: break; } break; } default: break; } // non-positive targets if(!IsPositiveTarget(spellproto->EffectImplicitTargetA[effIndex],spellproto->EffectImplicitTargetB[effIndex])) return false; // AttributesEx check if(spellproto->AttributesEx & SPELL_ATTR_EX_NEGATIVE) return false; // ok, positive return true; } bool IsPositiveSpell(uint32 spellId) { SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); if (!spellproto) return false; return IsPositiveSpell(spellproto); } bool IsPositiveSpell(SpellEntry const *spellproto) { // spells with at least one negative effect are considered negative // some self-applied spells have negative effects but in self casting case negative check ignored. for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (spellproto->Effect[i] && !IsPositiveEffect(spellproto, SpellEffectIndex(i))) return false; return true; } bool IsSingleTargetSpell(SpellEntry const *spellInfo) { // all other single target spells have if it has AttributesEx5 if ( spellInfo->AttributesEx5 & SPELL_ATTR_EX5_SINGLE_TARGET_SPELL ) return true; // TODO - need found Judgements rule switch(GetSpellSpecific(spellInfo->Id)) { case SPELL_JUDGEMENT: return true; default: break; } // single target triggered spell. // Not real client side single target spell, but it' not triggered until prev. aura expired. // This is allow store it in single target spells list for caster for spell proc checking if(spellInfo->Id==38324) // Regeneration (triggered by 38299 (HoTs on Heals)) return true; return false; } bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellInfo2) { // TODO - need better check // Equal icon and spellfamily if( spellInfo1->SpellFamilyName == spellInfo2->SpellFamilyName && spellInfo1->SpellIconID == spellInfo2->SpellIconID ) return true; // TODO - need found Judgements rule SpellSpecific spec1 = GetSpellSpecific(spellInfo1->Id); // spell with single target specific types switch(spec1) { case SPELL_JUDGEMENT: case SPELL_MAGE_POLYMORPH: if(GetSpellSpecific(spellInfo2->Id) == spec1) return true; break; default: break; } return false; } SpellCastResult GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form) { // talents that learn spells can have stance requirements that need ignore // (this requirement only for client-side stance show in talent description) if( GetTalentSpellCost(spellInfo->Id) > 0 && (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[EFFECT_INDEX_1] == SPELL_EFFECT_LEARN_SPELL || spellInfo->Effect[EFFECT_INDEX_2] == SPELL_EFFECT_LEARN_SPELL) ) return SPELL_CAST_OK; uint32 stanceMask = (form ? 1 << (form - 1) : 0); if (stanceMask & spellInfo->StancesNot) // can explicitly not be casted in this stance return SPELL_FAILED_NOT_SHAPESHIFT; if (stanceMask & spellInfo->Stances) // can explicitly be casted in this stance return SPELL_CAST_OK; bool actAsShifted = false; if (form > 0) { SpellShapeshiftFormEntry const *shapeInfo = sSpellShapeshiftFormStore.LookupEntry(form); if (!shapeInfo) { sLog.outError("GetErrorAtShapeshiftedCast: unknown shapeshift %u", form); return SPELL_CAST_OK; } actAsShifted = !(shapeInfo->flags1 & 1); // shapeshift acts as normal form for spells } if(actAsShifted) { if (spellInfo->Attributes & SPELL_ATTR_NOT_SHAPESHIFT) // not while shapeshifted { //but we must allow cast of Berserk+modifier from any form... where for the hell should we do it? if (!(spellInfo->SpellIconID == 1680 && (spellInfo->AttributesEx & 0x8000))) return SPELL_FAILED_NOT_SHAPESHIFT; } else if (spellInfo->Stances != 0) // needs other shapeshift return SPELL_FAILED_ONLY_SHAPESHIFT; } else { // needs shapeshift if(!(spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && spellInfo->Stances != 0) return SPELL_FAILED_ONLY_SHAPESHIFT; } return SPELL_CAST_OK; } void SpellMgr::LoadSpellTargetPositions() { mSpellTargetPositions.clear(); // need for reload case uint32 count = 0; // 0 1 2 3 4 5 QueryResult *result = WorldDatabase.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u spell target destination coordinates", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 Spell_ID = fields[0].GetUInt32(); SpellTargetPosition st; st.target_mapId = fields[1].GetUInt32(); st.target_X = fields[2].GetFloat(); st.target_Y = fields[3].GetFloat(); st.target_Z = fields[4].GetFloat(); st.target_Orientation = fields[5].GetFloat(); MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId); if (!mapEntry) { sLog.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Spell_ID,st.target_mapId); continue; } if (st.target_X==0 && st.target_Y==0 && st.target_Z==0) { sLog.outErrorDb("Spell (ID:%u) target coordinates not provided.",Spell_ID); continue; } SpellEntry const* spellInfo = sSpellStore.LookupEntry(Spell_ID); if (!spellInfo) { sLog.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.",Spell_ID); continue; } bool found = false; for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo->EffectImplicitTargetA[i]==TARGET_TABLE_X_Y_Z_COORDINATES || spellInfo->EffectImplicitTargetB[i]==TARGET_TABLE_X_Y_Z_COORDINATES) { // additional requirements if (spellInfo->Effect[i]==SPELL_EFFECT_BIND && spellInfo->EffectMiscValue[i]) { uint32 zone_id = sTerrainMgr.GetAreaId(st.target_mapId, st.target_X, st.target_Y, st.target_Z); if (int32(zone_id) != spellInfo->EffectMiscValue[i]) { sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` expected point to zone %u bit point to zone %u.",Spell_ID, spellInfo->EffectMiscValue[i], zone_id); break; } } found = true; break; } } if (!found) { sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).",Spell_ID); continue; } mSpellTargetPositions[Spell_ID] = st; ++count; } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString(">> Loaded %u spell target destination coordinates", count); } template <typename EntryType, typename WorkerType, typename StorageType> struct SpellRankHelper { SpellRankHelper(SpellMgr &_mgr, StorageType &_storage): mgr(_mgr), worker(_storage), customRank(0) {} void RecordRank(EntryType &entry, uint32 spell_id) { const SpellEntry *spell = sSpellStore.LookupEntry(spell_id); if (!spell) { sLog.outErrorDb("Spell %u listed in `%s` does not exist", spell_id, worker.TableName()); return; } uint32 first_id = mgr.GetFirstSpellInChain(spell_id); // most spell ranks expected same data if(first_id) { firstRankSpells.insert(first_id); if (first_id != spell_id) { if (!worker.IsValidCustomRank(entry, spell_id, first_id)) return; // for later check that first rank also added else { firstRankSpellsWithCustomRanks.insert(first_id); ++customRank; } } } worker.AddEntry(entry, spell); } void FillHigherRanks() { // check that first rank added for custom ranks for (std::set<uint32>::const_iterator itr = firstRankSpellsWithCustomRanks.begin(); itr != firstRankSpellsWithCustomRanks.end(); ++itr) if (!worker.HasEntry(*itr)) sLog.outErrorDb("Spell %u must be listed in `%s` as first rank for listed custom ranks of spell but not found!", *itr, worker.TableName()); // fill absent non first ranks data base at first rank data for (std::set<uint32>::const_iterator itr = firstRankSpells.begin(); itr != firstRankSpells.end(); ++itr) { if (worker.SetStateToEntry(*itr)) mgr.doForHighRanks(*itr, worker); } } std::set<uint32> firstRankSpells; std::set<uint32> firstRankSpellsWithCustomRanks; SpellMgr &mgr; WorkerType worker; uint32 customRank; }; struct DoSpellProcEvent { DoSpellProcEvent(SpellProcEventMap& _spe_map) : spe_map(_spe_map), customProc(0), count(0) {} void operator() (uint32 spell_id) { SpellProcEventEntry const& spe = state->second; // add ranks only for not filled data (some ranks have ppm data different for ranks for example) SpellProcEventMap::const_iterator spellItr = spe_map.find(spell_id); if (spellItr == spe_map.end()) spe_map[spell_id] = spe; // if custom rank data added then it must be same except ppm else { SpellProcEventEntry const& r_spe = spellItr->second; if (spe.schoolMask != r_spe.schoolMask) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different schoolMask from first rank in chain", spell_id); if (spe.spellFamilyName != r_spe.spellFamilyName) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different spellFamilyName from first rank in chain", spell_id); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spe.spellFamilyMask[i] != r_spe.spellFamilyMask[i]) { sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different spellFamilyMask/spellFamilyMask2 from first rank in chain", spell_id); break; } } if (spe.procFlags != r_spe.procFlags) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different procFlags from first rank in chain", spell_id); if (spe.procEx != r_spe.procEx) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different procEx from first rank in chain", spell_id); // only ppm allowed has been different from first rank if (spe.customChance != r_spe.customChance) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different customChance from first rank in chain", spell_id); if (spe.cooldown != r_spe.cooldown) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different cooldown from first rank in chain", spell_id); } } const char* TableName() { return "spell_proc_event"; } bool IsValidCustomRank(SpellProcEventEntry const &spe, uint32 entry, uint32 first_id) { // let have independent data in table for spells with ppm rates (exist rank dependent ppm rate spells) if (!spe.ppmRate) { sLog.outErrorDb("Spell %u listed in `spell_proc_event` is not first rank (%u) in chain", entry, first_id); // prevent loading since it won't have an effect anyway return false; } return true; } void AddEntry(SpellProcEventEntry const &spe, SpellEntry const *spell) { spe_map[spell->Id] = spe; bool isCustom = false; if (spe.procFlags == 0) { if (spell->procFlags==0) sLog.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell (no proc flags)", spell->Id); } else { if (spell->procFlags==spe.procFlags) sLog.outErrorDb("Spell %u listed in `spell_proc_event` has exactly same proc flags as in spell.dbc, field value redundant", spell->Id); else isCustom = true; } if (spe.customChance == 0) { /* enable for re-check cases, 0 chance ok for some cases because in some cases it set by another spell/talent spellmod) if (spell->procChance==0 && !spe.ppmRate) sLog.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell (no chance or ppm)", spell->Id); */ } else { if (spell->procChance==spe.customChance) sLog.outErrorDb("Spell %u listed in `spell_proc_event` has exactly same custom chance as in spell.dbc, field value redundant", spell->Id); else isCustom = true; } // totally redundant record if (!spe.schoolMask && !spe.procFlags && !spe.procEx && !spe.ppmRate && !spe.customChance && !spe.cooldown) { bool empty = !spe.spellFamilyName ? true : false; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spe.spellFamilyMask[i]) { empty = false; ClassFamilyMask const& mask = spell->GetEffectSpellClassMask(SpellEffectIndex(i)); if (mask == spe.spellFamilyMask[i]) sLog.outErrorDb("Spell %u listed in `spell_proc_event` has same class mask as in Spell.dbc (EffectIndex %u) and doesn't have any other data", spell->Id, i); } } if (empty) sLog.outErrorDb("Spell %u listed in `spell_proc_event` doesn't have any useful data", spell->Id); } if (isCustom) ++customProc; else ++count; } bool HasEntry(uint32 spellId) { return spe_map.count(spellId) > 0; } bool SetStateToEntry(uint32 spellId) { return (state = spe_map.find(spellId)) != spe_map.end(); } SpellProcEventMap& spe_map; SpellProcEventMap::const_iterator state; uint32 customProc; uint32 count; }; void SpellMgr::LoadSpellProcEvents() { mSpellProcEventMap.clear(); // need for reload case // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMaskA0, SpellFamilyMaskA1, SpellFamilyMaskA2, SpellFamilyMaskB0, SpellFamilyMaskB1, SpellFamilyMaskB2, SpellFamilyMaskC0, SpellFamilyMaskC1, SpellFamilyMaskC2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> No spell proc event conditions loaded"); return; } SpellRankHelper<SpellProcEventEntry, DoSpellProcEvent, SpellProcEventMap> rankHelper(*this, mSpellProcEventMap); BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); SpellProcEventEntry spe; spe.schoolMask = fields[1].GetUInt32(); spe.spellFamilyName = fields[2].GetUInt32(); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { spe.spellFamilyMask[i] = ClassFamilyMask( (uint64)fields[i+3].GetUInt32() | ((uint64)fields[i+6].GetUInt32()<<32), fields[i+9].GetUInt32()); } spe.procFlags = fields[12].GetUInt32(); spe.procEx = fields[13].GetUInt32(); spe.ppmRate = fields[14].GetFloat(); spe.customChance = fields[15].GetFloat(); spe.cooldown = fields[16].GetUInt32(); rankHelper.RecordRank(spe, entry); } while (result->NextRow()); rankHelper.FillHigherRanks(); delete result; sLog.outString(); sLog.outString( ">> Loaded %u extra spell proc event conditions +%u custom proc (inc. +%u custom ranks)", rankHelper.worker.count, rankHelper.worker.customProc, rankHelper.customRank); } struct DoSpellProcItemEnchant { DoSpellProcItemEnchant(SpellProcItemEnchantMap& _procMap, float _ppm) : procMap(_procMap), ppm(_ppm) {} void operator() (uint32 spell_id) { procMap[spell_id] = ppm; } SpellProcItemEnchantMap& procMap; float ppm; }; void SpellMgr::LoadSpellProcItemEnchant() { mSpellProcItemEnchantMap.clear(); // need for reload case uint32 count = 0; // 0 1 QueryResult *result = WorldDatabase.Query("SELECT entry, ppmRate FROM spell_proc_item_enchant"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u proc item enchant definitions", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); float ppmRate = fields[1].GetFloat(); SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry); if (!spellInfo) { sLog.outErrorDb("Spell %u listed in `spell_proc_item_enchant` does not exist", entry); continue; } uint32 first_id = GetFirstSpellInChain(entry); if ( first_id != entry ) { sLog.outErrorDb("Spell %u listed in `spell_proc_item_enchant` is not first rank (%u) in chain", entry, first_id); // prevent loading since it won't have an effect anyway continue; } mSpellProcItemEnchantMap[entry] = ppmRate; // also add to high ranks DoSpellProcItemEnchant worker(mSpellProcItemEnchantMap, ppmRate); doForHighRanks(entry,worker); ++count; } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString( ">> Loaded %u proc item enchant definitions", count ); } struct DoSpellBonuses { DoSpellBonuses(SpellBonusMap& _spellBonusMap, SpellBonusEntry const& _spellBonus) : spellBonusMap(_spellBonusMap), spellBonus(_spellBonus) {} void operator() (uint32 spell_id) { spellBonusMap[spell_id] = spellBonus; } SpellBonusMap& spellBonusMap; SpellBonusEntry const& spellBonus; }; void SpellMgr::LoadSpellBonuses() { mSpellBonusMap.clear(); // need for reload case uint32 count = 0; // 0 1 2 3 QueryResult *result = WorldDatabase.Query("SELECT entry, direct_bonus, dot_bonus, ap_bonus, ap_dot_bonus FROM spell_bonus_data"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u spell bonus data", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); SpellEntry const* spell = sSpellStore.LookupEntry(entry); if (!spell) { sLog.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry); continue; } uint32 first_id = GetFirstSpellInChain(entry); if ( first_id != entry ) { sLog.outErrorDb("Spell %u listed in `spell_bonus_data` is not first rank (%u) in chain", entry, first_id); // prevent loading since it won't have an effect anyway continue; } SpellBonusEntry sbe; sbe.direct_damage = fields[1].GetFloat(); sbe.dot_damage = fields[2].GetFloat(); sbe.ap_bonus = fields[3].GetFloat(); sbe.ap_dot_bonus = fields[4].GetFloat(); bool need_dot = false; bool need_direct = false; uint32 x = 0; // count all, including empty, meaning: not all existing effect is DoTs/HoTs for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!spell->Effect[i]) { ++x; continue; } // DoTs/HoTs switch(spell->EffectApplyAuraName[i]) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: case SPELL_AURA_PERIODIC_LEECH: case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_OBS_MOD_HEALTH: case SPELL_AURA_PERIODIC_MANA_LEECH: case SPELL_AURA_OBS_MOD_MANA: case SPELL_AURA_POWER_BURN_MANA: need_dot = true; ++x; break; default: break; } } //TODO: maybe add explicit list possible direct damage spell effects... if (x < MAX_EFFECT_INDEX) need_direct = true; // Check if direct_bonus is needed in `spell_bonus_data` float direct_calc; float direct_diff = 1000.0f; // for have big diff if no DB field value if (sbe.direct_damage) { bool isHeal = false; for(int i = 0; i < 3; ++i) { // Heals (Also count Mana Shield and Absorb effects as heals) if (spell->Effect[i] == SPELL_EFFECT_HEAL || spell->Effect[i] == SPELL_EFFECT_HEAL_MAX_HEALTH || (spell->Effect[i] == SPELL_EFFECT_APPLY_AURA && (spell->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_ABSORB || spell->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL)) ) { isHeal = true; break; } } direct_calc = CalculateDefaultCoefficient(spell, SPELL_DIRECT_DAMAGE) * (isHeal ? 1.88f : 1.0f); direct_diff = std::abs(sbe.direct_damage - direct_calc); } // Check if dot_bonus is needed in `spell_bonus_data` float dot_calc; float dot_diff = 1000.0f; // for have big diff if no DB field value if (sbe.dot_damage) { bool isHeal = false; for(int i = 0; i < 3; ++i) { // Periodic Heals if (spell->Effect[i] == SPELL_EFFECT_APPLY_AURA && spell->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL) { isHeal = true; break; } } dot_calc = CalculateDefaultCoefficient(spell, DOT) * (isHeal ? 1.88f : 1.0f); dot_diff = std::abs(sbe.dot_damage - dot_calc); } if (direct_diff < 0.02f && !need_dot && !sbe.ap_bonus && !sbe.ap_dot_bonus) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not needed (data from table: %f, calculated %f, difference of %f) and `dot_bonus` also not used", entry, sbe.direct_damage, direct_calc, direct_diff); else if (direct_diff < 0.02f && dot_diff < 0.02f && !sbe.ap_bonus && !sbe.ap_dot_bonus) { sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not needed (data from table: %f, calculated %f, difference of %f) and ", entry, sbe.direct_damage, direct_calc, direct_diff); sLog.outErrorDb(" ... `dot_bonus` not needed (data from table: %f, calculated %f, difference of %f)", sbe.dot_damage, dot_calc, dot_diff); } else if (!need_direct && dot_diff < 0.02f && !sbe.ap_bonus && !sbe.ap_dot_bonus) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `dot_bonus` not needed (data from table: %f, calculated %f, difference of %f) and direct also not used", entry, sbe.dot_damage, dot_calc, dot_diff); else if (!need_direct && sbe.direct_damage) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not used (spell not have non-periodic affects)", entry); else if (!need_dot && sbe.dot_damage) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `dot_bonus` not used (spell not have periodic affects)", entry); if (!need_direct && sbe.ap_bonus) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `ap_bonus` not used (spell not have non-periodic affects)", entry); else if (!need_dot && sbe.ap_dot_bonus) sLog.outErrorDb("`spell_bonus_data` entry for spell %u `ap_dot_bonus` not used (spell not have periodic affects)", entry); mSpellBonusMap[entry] = sbe; // also add to high ranks DoSpellBonuses worker(mSpellBonusMap, sbe); doForHighRanks(entry,worker); ++count; } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString( ">> Loaded %u extra spell bonus data", count); } bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra) { // No extra req need uint32 procEvent_procEx = PROC_EX_NONE; // check prockFlags for condition if((procFlags & EventProcFlag) == 0) return false; // Always trigger for this if (EventProcFlag & (PROC_FLAG_KILLED | PROC_FLAG_KILL | PROC_FLAG_ON_TRAP_ACTIVATION | PROC_FLAG_ON_DEATH)) return true; if (spellProcEvent) // Exist event data { // Store extra req procEvent_procEx = spellProcEvent->procEx; // For melee triggers if (procSpell == NULL) { // Check (if set) for school (melee attack have Normal school) if(spellProcEvent->schoolMask && (spellProcEvent->schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) return false; } else // For spells need check school/spell family/family mask { // Check (if set) for school if(spellProcEvent->schoolMask && (spellProcEvent->schoolMask & procSpell->SchoolMask) == 0) return false; // Check (if set) for spellFamilyName if(spellProcEvent->spellFamilyName && (spellProcEvent->spellFamilyName != procSpell->SpellFamilyName)) return false; } } // Check for extra req (if none) and hit/crit if (procEvent_procEx == PROC_EX_NONE) { // Don't allow proc from periodic heal if no extra requirement is defined if (EventProcFlag & (PROC_FLAG_ON_DO_PERIODIC | PROC_FLAG_ON_TAKE_PERIODIC) && (procExtra & PROC_EX_PERIODIC_POSITIVE)) return false; // No extra req, so can trigger for (damage/healing present) and hit/crit if(procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) return true; } else // all spells hits here only if resist/reflect/immune/evade { // Exist req for PROC_EX_EX_TRIGGER_ALWAYS if (procEvent_procEx & PROC_EX_EX_TRIGGER_ALWAYS) return true; // Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other) if (procEvent_procEx & procExtra) return true; } return false; } void SpellMgr::LoadSpellElixirs() { mSpellElixirs.clear(); // need for reload case uint32 count = 0; // 0 1 QueryResult *result = WorldDatabase.Query("SELECT entry, mask FROM spell_elixir"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u spell elixir definitions", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); uint8 mask = fields[1].GetUInt8(); SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry); if (!spellInfo) { sLog.outErrorDb("Spell %u listed in `spell_elixir` does not exist", entry); continue; } mSpellElixirs[entry] = mask; ++count; } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString( ">> Loaded %u spell elixir definitions", count ); } struct DoSpellThreat { DoSpellThreat(SpellThreatMap& _threatMap) : threatMap(_threatMap), count(0) {} void operator() (uint32 spell_id) { SpellThreatEntry const &ste = state->second; // add ranks only for not filled data (spells adding flat threat are usually different for ranks) SpellThreatMap::const_iterator spellItr = threatMap.find(spell_id); if (spellItr == threatMap.end()) threatMap[spell_id] = ste; // just assert that entry is not redundant else { SpellThreatEntry const& r_ste = spellItr->second; if (ste.threat == r_ste.threat && ste.multiplier == r_ste.multiplier && ste.ap_bonus == r_ste.ap_bonus) sLog.outErrorDb("Spell %u listed in `spell_threat` as custom rank has same data as Rank 1, so redundant", spell_id); } } const char* TableName() { return "spell_threat"; } bool IsValidCustomRank(SpellThreatEntry const &ste, uint32 entry, uint32 first_id) { if (!ste.threat) { sLog.outErrorDb("Spell %u listed in `spell_threat` is not first rank (%u) in chain and has no threat", entry, first_id); // prevent loading unexpected data return false; } return true; } void AddEntry(SpellThreatEntry const &ste, SpellEntry const *spell) { threatMap[spell->Id] = ste; // flat threat bonus and attack power bonus currently only work properly when all // effects have same targets, otherwise, we'd need to seperate it by effect index if (ste.threat || ste.ap_bonus != 0.f) { const uint32 *targetA = spell->EffectImplicitTargetA; const uint32 *targetB = spell->EffectImplicitTargetB; if ((targetA[EFFECT_INDEX_1] && targetA[EFFECT_INDEX_1] != targetA[EFFECT_INDEX_0]) || (targetA[EFFECT_INDEX_2] && targetA[EFFECT_INDEX_2] != targetA[EFFECT_INDEX_0])) sLog.outErrorDb("Spell %u listed in `spell_threat` has effects with different targets, threat may be assigned incorrectly", spell->Id); } ++count; } bool HasEntry(uint32 spellId) { return threatMap.count(spellId) > 0; } bool SetStateToEntry(uint32 spellId) { return (state = threatMap.find(spellId)) != threatMap.end(); } SpellThreatMap& threatMap; SpellThreatMap::const_iterator state; uint32 count; }; void SpellMgr::LoadSpellThreats() { mSpellThreatMap.clear(); // need for reload case // 0 1 2 3 QueryResult *result = WorldDatabase.Query("SELECT entry, Threat, multiplier, ap_bonus FROM spell_threat"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> No spell threat entries loaded."); return; } SpellRankHelper<SpellThreatEntry, DoSpellThreat, SpellThreatMap> rankHelper(*this, mSpellThreatMap); BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); SpellThreatEntry ste; ste.threat = fields[1].GetUInt16(); ste.multiplier = fields[2].GetFloat(); ste.ap_bonus = fields[3].GetFloat(); rankHelper.RecordRank(ste, entry); } while( result->NextRow() ); rankHelper.FillHigherRanks(); delete result; sLog.outString(); sLog.outString( ">> Loaded %u spell threat entries", rankHelper.worker.count ); } bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const { SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if(!spellInfo_1 || !spellInfo_2) return false; if(spellInfo_1->Id == spellId_2) return false; return GetFirstSpellInChain(spellInfo_1->Id)==GetFirstSpellInChain(spellId_2); } bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const *spellInfo) const { if (IsPassiveSpell(spellInfo)) // ranked passive spell return false; if (spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH) return false; if (IsProfessionOrRidingSpell(spellInfo->Id)) return false; if (IsSkillBonusSpell(spellInfo->Id)) return false; // All stance spells. if any better way, change it. for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(spellInfo->SpellFamilyName) { case SPELLFAMILY_PALADIN: // Paladin aura Spell if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AREA_AURA_RAID) return false; // Seal of Righteousness, 2 version of same rank if ((spellInfo->SpellFamilyFlags & UI64LIT(0x0000000008000000)) && spellInfo->SpellIconID == 25) return false; break; case SPELLFAMILY_DRUID: // Druid form Spell if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) return false; break; case SPELLFAMILY_ROGUE: // Rogue Stealth if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) return false; break; } } return true; } bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const { SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if (!spellInfo_1 || !spellInfo_2) return false; if (spellId_1 == spellId_2) return false; // Resurrection sickness if ((spellInfo_1->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS) != (spellInfo_2->Id==SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) return false; // Allow stack passive and not passive spells if ((spellInfo_1->Attributes & SPELL_ATTR_PASSIVE)!=(spellInfo_2->Attributes & SPELL_ATTR_PASSIVE)) return false; // My rules! :D if (spellInfo_1->AttributesEx6 & SPELL_ATTR_EX6_UNK26 && spellInfo_2->AttributesEx6 & SPELL_ATTR_EX6_UNK26) { // Marks and Gifts of the Wild if (spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_2] == SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE && spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_2] == SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE) return true; // Blessings of Kings and Blessing of Forgotten Kings if (spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE && spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE) return true; } // Mangle and Trauma if (spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_1] == SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT && spellInfo_1->EffectMiscValue[EFFECT_INDEX_1] == MECHANIC_BLEED && spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT && spellInfo_2->EffectMiscValue[EFFECT_INDEX_0] == MECHANIC_BLEED || spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_1] == SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT && spellInfo_2->EffectMiscValue[EFFECT_INDEX_1] == MECHANIC_BLEED && spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT && spellInfo_1->EffectMiscValue[EFFECT_INDEX_0] == MECHANIC_BLEED ) return true; // Specific spell family spells switch(spellInfo_1->SpellFamilyName) { case SPELLFAMILY_GENERIC: switch(spellInfo_2->SpellFamilyName) { case SPELLFAMILY_GENERIC: // same family case { // Thunderfury if ((spellInfo_1->Id == 21992 && spellInfo_2->Id == 27648) || (spellInfo_2->Id == 21992 && spellInfo_1->Id == 27648)) return false; // Lightning Speed (Mongoose) and Fury of the Crashing Waves (Tsunami Talisman) if ((spellInfo_1->Id == 28093 && spellInfo_2->Id == 42084) || (spellInfo_2->Id == 28093 && spellInfo_1->Id == 42084)) return false; // Soulstone Resurrection and Twisting Nether (resurrector) if (spellInfo_1->SpellIconID == 92 && spellInfo_2->SpellIconID == 92 && ( (spellInfo_1->SpellVisual[0] == 99 && spellInfo_2->SpellVisual[0] == 0) || (spellInfo_2->SpellVisual[0] == 99 && spellInfo_1->SpellVisual[0] == 0))) return false; // Heart of the Wild, Agility and various Idol Triggers if (spellInfo_1->SpellIconID == 240 && spellInfo_2->SpellIconID == 240) return false; // Personalized Weather (thunder effect should overwrite rainy aura) if (spellInfo_1->SpellIconID == 2606 && spellInfo_2->SpellIconID == 2606) return false; // Brood Affliction: Bronze if ((spellInfo_1->Id == 23170 && spellInfo_2->Id == 23171) || (spellInfo_2->Id == 23170 && spellInfo_1->Id == 23171)) return false; // Male Shadowy Disguise if ((spellInfo_1->Id == 32756 && spellInfo_2->Id == 38080) || (spellInfo_2->Id == 32756 && spellInfo_1->Id == 38080)) return false; // Female Shadowy Disguise if ((spellInfo_1->Id == 32756 && spellInfo_2->Id == 38081) || (spellInfo_2->Id == 32756 && spellInfo_1->Id == 38081)) return false; // Cool Down (See PeriodicAuraTick()) if ((spellInfo_1->Id == 52441 && spellInfo_2->Id == 52443) || (spellInfo_2->Id == 52441 && spellInfo_1->Id == 52443)) return false; // See Chapel Invisibility and See Noth Invisibility if ((spellInfo_1->Id == 52950 && spellInfo_2->Id == 52707) || (spellInfo_2->Id == 52950 && spellInfo_1->Id == 52707)) return false; // Regular and Night Elf Ghost if ((spellInfo_1->Id == 8326 && spellInfo_2->Id == 20584) || (spellInfo_2->Id == 8326 && spellInfo_1->Id == 20584)) return false; // Aura of Despair auras if ((spellInfo_1->Id == 64848 && spellInfo_2->Id == 62692) || (spellInfo_2->Id == 64848 && spellInfo_1->Id == 62692)) return false; // Blood Fury and Rage of the Unraveller if (spellInfo_1->SpellIconID == 1662 && spellInfo_2->SpellIconID == 1662) return false; // Kindred Spirits if (spellInfo_1->SpellIconID == 3559 && spellInfo_2->SpellIconID == 3559) return false; // Vigilance and Damage Reduction (Vigilance triggered spell) if (spellInfo_1->SpellIconID == 2834 && spellInfo_2->SpellIconID == 2834) return false; // Unstable Sphere Timer and Unstable Sphere Passive if ((spellInfo_1->Id == 50758 && spellInfo_2->Id == 50756) || (spellInfo_2->Id == 50758 && spellInfo_1->Id == 50756)) return false; break; } case SPELLFAMILY_MAGE: // Arcane Intellect and Insight if (spellInfo_2->SpellIconID == 125 && spellInfo_1->Id == 18820) return false; break; case SPELLFAMILY_WARRIOR: { // Scroll of Protection and Defensive Stance (multi-family check) if (spellInfo_1->SpellIconID == 276 && spellInfo_1->SpellVisual[0] == 196 && spellInfo_2->Id == 71) return false; // Improved Hamstring -> Hamstring (multi-family check) if ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x2)) && spellInfo_1->Id == 23694) return false; // Death Wish and Heart of a Dragon if (spellInfo_1->Id == 169 && spellInfo_2->SpellIconID == 169) return false; break; } case SPELLFAMILY_PRIEST: { // Berserking/Enrage PvE spells and Mind Trauma if(spellInfo_1->SpellIconID == 95 && spellInfo_2->Id == 48301) return false; break; // Frenzy (Grand Widow Faerlina) and Mind Trauma if( spellInfo_1->SpellIconID == 95 && spellInfo_2->SpellFamilyFlags & UI64LIT(0x84000000)) return false; // Runescroll of Fortitude and Power Word: Fortitude if( spellInfo_1->Id == 72590 && spellInfo_2->SpellFamilyFlags & UI64LIT(0x8)) return true; } case SPELLFAMILY_DRUID: { // Scroll of Stamina and Leader of the Pack (multi-family check) if (spellInfo_1->SpellIconID == 312 && spellInfo_1->SpellVisual[0] == 216 && spellInfo_2->Id == 24932) return false; // Dragonmaw Illusion (multi-family check) if (spellId_1 == 40216 && spellId_2 == 42016) return false; // Drums of the Wild and Gift of the Wild if( spellInfo_1->Id == 72588 && spellInfo_2->SpellFamilyFlags & UI64LIT(0x40000)) return true; // FG: Gift of the Wild (21849 and ranks) and Gift of the Wild (from Item: Drums of the Wild) if (spellInfo_1->Id == 72588 && spellInfo_2->SpellIconID == 2435) return true; // does not stack break; } case SPELLFAMILY_ROGUE: { // Garrote-Silence -> Garrote (multi-family check) if (spellInfo_1->SpellIconID == 498 && spellInfo_1->SpellVisual[0] == 0 && spellInfo_2->SpellIconID == 498) return false; // Honor Among Thieves dummy auras (multi-family check) if (spellId_1 == 51699 && spellId_2 == 52916) return false; break; } case SPELLFAMILY_HUNTER: { // Concussive Shot and Imp. Concussive Shot (multi-family check) if (spellInfo_1->Id == 19410 && spellInfo_2->Id == 5116) return false; // Improved Wing Clip -> Wing Clip (multi-family check) if ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x40)) && spellInfo_1->Id == 19229) return false; break; } case SPELLFAMILY_PALADIN: { // Unstable Currents and other -> *Sanctity Aura (multi-family check) if (spellInfo_2->SpellIconID==502 && spellInfo_1->SpellIconID==502 && spellInfo_1->SpellVisual[0]==969) return false; // *Band of Eternal Champion and Seal of Command(multi-family check) if (spellId_1 == 35081 && spellInfo_2->SpellIconID==561 && spellInfo_2->SpellVisual[0]==7992) return false; // FG: Frostforged Champion and Seal of Command(multi-family check) if( spellId_1 == 72412 && spellInfo_2->SpellIconID==561 && spellInfo_2->SpellVisual[0]==7992) return false; // Blessing of Sanctuary (multi-family check, some from 16 spell icon spells) if (spellInfo_1->Id == 67480 && spellInfo_2->Id == 20911) return false; // Devotion Aura and Essence if Gossamer if (spellInfo_1->SpellIconID == 291 && spellInfo_2->SpellIconID == 291) return false; // FG: Greater Blessing of Kings and Blessing of Forgotten Kings if (spellId_1 == 72586 && spellId_2 == 25898) return true; // does not stack // Drums of Forgotten Kings and Blessing of Kings if( spellInfo_1->Id == 72586 && spellInfo_2->SpellFamilyFlags & UI64LIT(0x10000000)) return true; break; } } // Dragonmaw Illusion, Blood Elf Illusion, Human Illusion, Illidari Agent Illusion, Scarlet Crusade Disguise if(spellInfo_1->SpellIconID == 1691 && spellInfo_2->SpellIconID == 1691) return false; break; case SPELLFAMILY_MAGE: if( spellInfo_2->SpellFamilyName == SPELLFAMILY_MAGE ) { // Blizzard & Chilled (and some other stacked with blizzard spells if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x80)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x100000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x80)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x100000)))) return false; // Blink & Improved Blink if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x0000000000010000)) && (spellInfo_2->SpellVisual[0] == 72 && spellInfo_2->SpellIconID == 1499)) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x0000000000010000)) && (spellInfo_1->SpellVisual[0] == 72 && spellInfo_1->SpellIconID == 1499))) return false; // Fingers of Frost effects if (spellInfo_1->SpellIconID == 2947 && spellInfo_2->SpellIconID == 2947) return false; // Living Bomb & Ignite (Dots) if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x2000000000000)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x8000000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x2000000000000)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x8000000)))) return false; // Fireball & Pyroblast (Dots) if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x1)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x400000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x1)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x400000)))) return false; //Focus magic 30min buff and 10s proc if( (spellInfo_1->SpellIconID == 54648) && (spellInfo_2->SpellIconID == 54646) || (spellInfo_2->SpellIconID == 54648) && (spellInfo_1->SpellIconID == 54646) ) return false; //Improved scorch and Winter's Chill if( (spellInfo_1->Id == 22959) && (spellInfo_2->Id == 12579) || (spellInfo_2->Id == 22959) && (spellInfo_1->Id == 12579) ) return false; // FG: arcane intelligence, arcane brilliance, dalaran intelligence, dalaran brilliance if( spellInfo_1->SpellFamilyFlags.Flags == 1024 && spellInfo_2->SpellFamilyFlags.Flags == 1024) return true; // cant be stacked } // Detect Invisibility and Mana Shield (multi-family check) if (spellInfo_2->Id == 132 && spellInfo_1->SpellIconID == 209 && spellInfo_1->SpellVisual[0] == 968) return false; // Combustion and Fire Protection Aura (multi-family check) if (spellInfo_1->Id == 11129 && spellInfo_2->SpellIconID == 33 && spellInfo_2->SpellVisual[0] == 321) return false; // Arcane Intellect and Insight if (spellInfo_1->SpellIconID == 125 && spellInfo_2->Id == 18820) return false; break; case SPELLFAMILY_WARLOCK: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_WARLOCK) { // Siphon Life and Drain Life if ((spellInfo_1->SpellIconID == 152 && spellInfo_2->SpellIconID == 546) || (spellInfo_2->SpellIconID == 152 && spellInfo_1->SpellIconID == 546)) return false; //Corruption & Seed of corruption if ((spellInfo_1->SpellIconID == 313 && spellInfo_2->SpellIconID == 1932) || (spellInfo_2->SpellIconID == 313 && spellInfo_1->SpellIconID == 1932)) if(spellInfo_1->SpellVisual[0] != 0 && spellInfo_2->SpellVisual[0] != 0) return true; // can't be stacked // Corruption and Unstable Affliction if ((spellInfo_1->SpellIconID == 313 && spellInfo_2->SpellIconID == 2039) || (spellInfo_2->SpellIconID == 313 && spellInfo_1->SpellIconID == 2039)) return false; // (Corruption or Unstable Affliction) and (Curse of Agony or Curse of Doom) if (((spellInfo_1->SpellIconID == 313 || spellInfo_1->SpellIconID == 2039) && (spellInfo_2->SpellIconID == 544 || spellInfo_2->SpellIconID == 91)) || ((spellInfo_2->SpellIconID == 313 || spellInfo_2->SpellIconID == 2039) && (spellInfo_1->SpellIconID == 544 || spellInfo_1->SpellIconID == 91))) return false; // Shadowflame and Curse of Agony if( spellInfo_1->SpellIconID == 544 && spellInfo_2->SpellIconID == 3317 || spellInfo_2->SpellIconID == 544 && spellInfo_1->SpellIconID == 3317 ) return false; // Shadowflame and Curse of Doom if( spellInfo_1->SpellIconID == 91 && spellInfo_2->SpellIconID == 3317 || spellInfo_2->SpellIconID == 91 && spellInfo_1->SpellIconID == 3317 ) return false; // Metamorphosis, diff effects if (spellInfo_1->SpellIconID == 3314 && spellInfo_2->SpellIconID == 3314) return false; // Shadowflame and Corruption if ( ( (spellInfo_1->SpellFamilyFlags.Flags2 & 0x00000002) && spellInfo_2->SpellIconID == 313 ) || ( (spellInfo_2->SpellFamilyFlags.Flags2 & 0x00000002) && spellInfo_1->SpellIconID == 313 ) ) return false; // Shadowflame and Curse of Agony if ( ( (spellInfo_1->SpellFamilyFlags.Flags2 & 0x00000002) && spellInfo_2->SpellIconID == 544 ) || ( (spellInfo_2->SpellFamilyFlags.Flags2 & 0x00000002) && spellInfo_1->SpellIconID == 544 ) ) return false; } // Detect Invisibility and Mana Shield (multi-family check) if (spellInfo_1->Id == 132 && spellInfo_2->SpellIconID == 209 && spellInfo_2->SpellVisual[0] == 968) return false; break; case SPELLFAMILY_WARRIOR: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_WARRIOR) { // Rend and Deep Wound if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x20)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x1000000000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x20)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x1000000000)))) return false; // Battle Shout and Rampage if ((spellInfo_1->SpellIconID == 456 && spellInfo_2->SpellIconID == 2006) || (spellInfo_2->SpellIconID == 456 && spellInfo_1->SpellIconID == 2006)) return false; // Glyph of Revenge (triggered), and Sword and Board (triggered) if ((spellInfo_1->SpellIconID == 856 && spellInfo_2->SpellIconID == 2780) || (spellInfo_2->SpellIconID == 856 && spellInfo_1->SpellIconID == 2780)) return false; // Defensive/Berserker/Battle stance aura can not stack (needed for dummy auras) if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x800000)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x800000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x800000)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x800000)))) return true; // Taste of Blood and Sudden Death if( (spellInfo_1->Id == 52437 && spellInfo_2->Id == 60503) || (spellInfo_2->Id == 52437 && spellInfo_1->Id == 60503) ) return false; } else if (spellInfo_2->SpellFamilyName == SPELLFAMILY_ROGUE) { // Sunder Armor and Expose Armor if (spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_RESISTANCE_PCT && spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_RESISTANCE_PCT) return true; } // Hamstring -> Improved Hamstring (multi-family check) if ((spellInfo_1->SpellFamilyFlags & UI64LIT(0x2)) && spellInfo_2->Id == 23694) return false; // Defensive Stance and Scroll of Protection (multi-family check) if (spellInfo_1->Id == 71 && spellInfo_2->SpellIconID == 276 && spellInfo_2->SpellVisual[0] == 196) return false; // Bloodlust and Bloodthirst (multi-family check) if (spellInfo_2->Id == 2825 && spellInfo_1->SpellIconID == 38 && spellInfo_1->SpellVisual[0] == 0) return false; // Death Wish and Heart of a Dragon if (spellInfo_1->Id == 169 && spellInfo_2->SpellIconID == 169 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC) return false; break; case SPELLFAMILY_PRIEST: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_PRIEST) { //Devouring Plague and Shadow Vulnerability if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x2000000)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x800000000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x2000000)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x800000000)))) return false; //StarShards and Shadow Word: Pain if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x200000)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x8000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x200000)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x8000)))) return false; // Dispersion if ((spellInfo_1->Id == 47585 && spellInfo_2->Id == 60069) || (spellInfo_2->Id == 47585 && spellInfo_1->Id == 60069)) return false; // Power Word: Shield and Divine Aegis if ((spellInfo_1->SpellIconID == 566 && spellInfo_2->SpellIconID == 2820) || (spellInfo_2->SpellIconID == 566 && spellInfo_1->SpellIconID == 2820)) return false; // Inner Fire and Consecration if (spellInfo_1->SpellIconID == 51 && spellInfo_2->SpellIconID == 51 && spellInfo_2->SpellFamilyName == SPELLFAMILY_PALADIN) return false; // Prayer/PW Fortitude && Runescroll of Fortitude if (spellInfo_1->SpellVisual[0] == 278 && spellInfo_2->Id == 72590) return true; } // Power Word: Fortitude and Runescroll of Fortitude if( spellInfo_1->SpellFamilyFlags & UI64LIT(0x8) && spellInfo_2->Id == 72590 ) return true; break; case SPELLFAMILY_DRUID: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_DRUID) { //Omen of Clarity and Blood Frenzy if (((spellInfo_1->SpellFamilyFlags == UI64LIT(0x0) && spellInfo_1->SpellIconID == 108) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x20000000000000))) || ((spellInfo_2->SpellFamilyFlags == UI64LIT(0x0) && spellInfo_2->SpellIconID == 108) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x20000000000000)))) return false; // Tree of Life (Shapeshift) and 34123 Tree of Life (Passive) if ((spellId_1 == 33891 && spellId_2 == 34123) || (spellId_2 == 33891 && spellId_1 == 34123)) return false; // Lifebloom and Wild Growth if ((spellInfo_1->SpellIconID == 2101 && spellInfo_2->SpellIconID == 2864) || (spellInfo_2->SpellIconID == 2101 && spellInfo_1->SpellIconID == 2864)) return false; // Innervate and Glyph of Innervate and some other spells if (spellInfo_1->SpellIconID == 62 && spellInfo_2->SpellIconID == 62) return false; // Wrath of Elune and Nature's Grace if ((spellInfo_1->Id == 16886 && spellInfo_2->Id == 46833) || (spellInfo_2->Id == 16886 && spellInfo_1->Id == 46833)) return false; // Bear Rage (Feral T4 (2)) and Omen of Clarity if ((spellInfo_1->Id == 16864 && spellInfo_2->Id == 37306) || (spellInfo_2->Id == 16864 && spellInfo_1->Id == 37306)) return false; // Cat Energy (Feral T4 (2)) and Omen of Clarity if ((spellInfo_1->Id == 16864 && spellInfo_2->Id == 37311) || (spellInfo_2->Id == 16864 && spellInfo_1->Id == 37311)) return false; // Survival Instincts and Survival Instincts if ((spellInfo_1->Id == 61336 && spellInfo_2->Id == 50322) || (spellInfo_2->Id == 61336 && spellInfo_1->Id == 50322)) return false; // Frenzied Regeneration and Savage Defense if( spellInfo_1->Id == 22842 && spellInfo_2->Id == 62606 || spellInfo_2->Id == 22842 && spellInfo_1->Id == 62606 ) return false; // Savage Roar and Savage Roar (triggered) if (spellInfo_1->SpellIconID == 2865 && spellInfo_2->SpellIconID == 2865) return false; // Frenzied Regeneration and Savage Defense if ((spellInfo_1->Id == 22842 && spellInfo_2->Id == 62606) || (spellInfo_2->Id == 22842 && spellInfo_1->Id == 62606)) return false; // FG: Moonfire and Lacerate if ((spellInfo_1->SpellIconID == 225 && spellInfo_2->SpellIconID == 2246) || (spellInfo_1->SpellIconID == 2246 && spellInfo_2->SpellIconID == 225)) return false; } // FG: Gift of the Wild (21849 and ranks) and Gift of the Wild (from Item: Drums of the Wild) if (spellInfo_1->SpellIconID == 2435 && spellId_2 == 72588) return true; // does not stack // Leader of the Pack and Scroll of Stamina (multi-family check) if (spellInfo_1->Id == 24932 && spellInfo_2->SpellIconID == 312 && spellInfo_2->SpellVisual[0] == 216) return false; // Dragonmaw Illusion (multi-family check) if (spellId_1 == 42016 && spellId_2 == 40216 ) return false; // Gift of the Wild and Drums of the Wild if( spellInfo_1->SpellFamilyFlags & UI64LIT(0x40000) && spellInfo_2->Id == 72588) return true; break; case SPELLFAMILY_ROGUE: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_ROGUE) { // Master of Subtlety if ((spellId_1 == 31665 && spellId_2 == 31666) || (spellId_1 == 31666 && spellId_2 == 31665)) return false; // Sprint & Sprint (waterwalk) if (spellInfo_1->SpellIconID == 516 && spellInfo_2->SpellIconID == 516 && ((spellInfo_1->Category == 44 && spellInfo_2->Category == 0) || (spellInfo_2->Category == 44 && spellInfo_1->Category == 0))) return false; } else if (spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC) { if (spellInfo_1->SpellIconID == 2903 && spellInfo_2->SpellIconID == 2903) return false; // Honor Among Thieves dummy auras (multi-family check) if (spellId_1 == 52916 && spellId_2 == 51699) return false; } else if (spellInfo_2->SpellFamilyName == SPELLFAMILY_WARRIOR) { // Sunder Armor and Expose Armor if (spellInfo_1->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_RESISTANCE_PCT && spellInfo_2->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_MOD_RESISTANCE_PCT) return true; } //Overkill if (spellInfo_1->SpellIconID == 2285 && spellInfo_2->SpellIconID == 2285) return false; // Garrote -> Garrote-Silence (multi-family check) if (spellInfo_1->SpellIconID == 498 && spellInfo_2->SpellIconID == 498 && spellInfo_2->SpellVisual[0] == 0) return false; break; case SPELLFAMILY_HUNTER: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_HUNTER) { // Rapid Fire & Quick Shots if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x20)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x20000000000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x20)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x20000000000))) ) return false; // Serpent Sting & (Immolation/Explosive Trap Effect) if (((spellInfo_1->SpellFamilyFlags & UI64LIT(0x4)) && (spellInfo_2->SpellFamilyFlags & UI64LIT(0x00000004000))) || ((spellInfo_2->SpellFamilyFlags & UI64LIT(0x4)) && (spellInfo_1->SpellFamilyFlags & UI64LIT(0x00000004000)))) return false; // Deterrence if (spellInfo_1->SpellIconID == 83 && spellInfo_2->SpellIconID == 83) return false; // Bestial Wrath if (spellInfo_1->SpellIconID == 1680 && spellInfo_2->SpellIconID == 1680) return false; // Aspect of the Viper & Vicious Viper if (spellInfo_1->SpellIconID == 2227 && spellInfo_2->SpellIconID == 2227) return false; } // Repentance and Track Humanoids if (spellInfo_2->SpellFamilyName == SPELLFAMILY_PALADIN && spellInfo_1->SpellIconID == 316 && spellInfo_2->SpellIconID == 316) return false; // Wing Clip -> Improved Wing Clip (multi-family check) if ((spellInfo_1->SpellFamilyFlags & UI64LIT(0x40)) && spellInfo_2->Id == 19229) return false; // Concussive Shot and Imp. Concussive Shot (multi-family check) if (spellInfo_2->Id == 19410 && spellInfo_1->Id == 5116) return false; break; case SPELLFAMILY_PALADIN: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_PALADIN) { // Paladin Seals if (IsSealSpell(spellInfo_1) && IsSealSpell(spellInfo_2)) return true; //Blood Corruption, Holy Vengeance, Righteous Vengeance if ((spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 3025) || (spellInfo_2->SpellIconID == 2292 && spellInfo_1->SpellIconID == 3025)) return false; // Swift Retribution / Improved Devotion Aura (talents) and Paladin Auras if ((spellInfo_1->IsFitToFamilyMask(UI64LIT(0x0), 0x00000020) && (spellInfo_2->SpellIconID == 291 || spellInfo_2->SpellIconID == 3028)) || (spellInfo_2->IsFitToFamilyMask(UI64LIT(0x0), 0x00000020) && (spellInfo_1->SpellIconID == 291 || spellInfo_1->SpellIconID == 3028))) return false; // Beacon of Light and Light's Beacon if ((spellInfo_1->SpellIconID == 3032) && (spellInfo_2->SpellIconID == 3032)) return false; // Concentration Aura and Improved Concentration Aura and Aura Mastery if ((spellInfo_1->SpellIconID == 1487) && (spellInfo_2->SpellIconID == 1487)) return false; // Seal of Corruption (caster/target parts stacking allow, other stacking checked by spell specs) if (spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 2292) return false; // Divine Sacrifice and Divine Guardian if (spellInfo_1->SpellIconID == 3837 && spellInfo_2->SpellIconID == 3837) return false; // Blood Corruption, Holy Vengeance, Righteous Vengeance if ((spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 3025) || (spellInfo_2->SpellIconID == 2292 && spellInfo_1->SpellIconID == 3025)) return false; // Sacred Shield and Blessing of Sanctuary if ((( spellInfo_1->SpellFamilyFlags & UI64LIT(0x0008000000000000)) && (spellInfo_2->Id == 25899 || spellInfo_2->Id == 20911)) || (( spellInfo_2->SpellFamilyFlags & UI64LIT(0x0008000000000000)) && (spellInfo_1->Id == 25899 || spellInfo_1->Id == 20911))) return false; // Seal of Corruption/Vengeance DoT and Righteouss Fury if ((spellInfo_1->SpellIconID == 3025 && spellInfo_2->SpellIconID == 2292) || (spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 3025)) return false; } // Blessing of Sanctuary (multi-family check, some from 16 spell icon spells) if (spellInfo_2->Id == 67480 && spellInfo_1->Id == 20911) return false; // Combustion and Fire Protection Aura (multi-family check) if (spellInfo_2->Id == 11129 && spellInfo_1->SpellIconID == 33 && spellInfo_1->SpellVisual[0] == 321) return false; // *Sanctity Aura -> Unstable Currents and other (multi-family check) if (spellInfo_1->SpellIconID==502 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC && spellInfo_2->SpellIconID==502 && spellInfo_2->SpellVisual[0]==969) return false; // *Seal of Command and Band of Eternal Champion (multi-family check) if (spellInfo_1->SpellIconID==561 && spellInfo_1->SpellVisual[0]==7992 && spellId_2 == 35081) return false; // Blessing of Kings and Drums of Forgotten Kings if( spellInfo_1->SpellFamilyFlags & UI64LIT(0x10000000) && spellInfo_2->Id == 72586) return true; break; // FG: Seal of Command and Frostforged Champion (multi-family check) if( spellInfo_1->SpellIconID==561 && spellInfo_1->SpellVisual[0]==7992 && spellId_2 == 72412) return false; // Devotion Aura and Essence of Gossamer if (spellInfo_1->SpellIconID == 291 && spellInfo_2->SpellIconID == 291 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC) return false; // Inner Fire and Consecration if (spellInfo_1->SpellIconID == 51 && spellInfo_2->SpellIconID == 51 && spellInfo_2->SpellFamilyName == SPELLFAMILY_PRIEST) return false; // Repentance and Track Humanoids if (spellInfo_2->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo_1->SpellIconID == 316 && spellInfo_2->SpellIconID == 316) return false; // FG: Greater Blessing of Kings and Blessing of Forgotten Kings if (spellId_1 == 25898 && spellId_2 == 72586) return true; // does not stack break; case SPELLFAMILY_SHAMAN: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_SHAMAN) { // Windfury weapon if (spellInfo_1->SpellIconID==220 && spellInfo_2->SpellIconID==220 && !spellInfo_1->IsFitToFamilyMask(spellInfo_2->SpellFamilyFlags)) return false; // Ghost Wolf if (spellInfo_1->SpellIconID == 67 && spellInfo_2->SpellIconID == 67) return false; // Totem of Wrath (positive/negative), ranks checked early if (spellInfo_1->SpellIconID == 2019 && spellInfo_2->SpellIconID == 2019) return false; } // Bloodlust and Bloodthirst (multi-family check) if (spellInfo_1->Id == 2825 && spellInfo_2->SpellIconID == 38 && spellInfo_2->SpellVisual[0] == 0) return false; break; case SPELLFAMILY_DEATHKNIGHT: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT) { // Lichborne and Lichborne (triggered) if (spellInfo_1->SpellIconID == 61 && spellInfo_2->SpellIconID == 61) return false; // Frost Presence and Frost Presence (triggered) if (spellInfo_1->SpellIconID == 2632 && spellInfo_2->SpellIconID == 2632) return false; // Unholy Presence and Unholy Presence (triggered) if (spellInfo_1->SpellIconID == 2633 && spellInfo_2->SpellIconID == 2633) return false; // Blood Presence and Blood Presence (triggered) if (spellInfo_1->SpellIconID == 2636 && spellInfo_2->SpellIconID == 2636) return false; } break; default: break; } // more generic checks if (spellInfo_1->SpellIconID == spellInfo_2->SpellIconID && spellInfo_1->SpellIconID != 0 && spellInfo_2->SpellIconID != 0) { bool isModifier = false; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_FLAT_MODIFIER || spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_PCT_MODIFIER || spellInfo_2->EffectApplyAuraName[i] == SPELL_AURA_ADD_FLAT_MODIFIER || spellInfo_2->EffectApplyAuraName[i] == SPELL_AURA_ADD_PCT_MODIFIER ) isModifier = true; } if (!isModifier) return true; } if (IsRankSpellDueToSpell(spellInfo_1, spellId_2)) return true; if (spellInfo_1->SpellFamilyName == 0 || spellInfo_2->SpellFamilyName == 0) return false; if (spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) return false; bool dummy_only = true; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->Effect[i] != spellInfo_2->Effect[i] || spellInfo_1->EffectItemType[i] != spellInfo_2->EffectItemType[i] || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i] || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) return false; // ignore dummy only spells if (spellInfo_1->Effect[i] && spellInfo_1->Effect[i] != SPELL_EFFECT_DUMMY && spellInfo_1->EffectApplyAuraName[i] != SPELL_AURA_DUMMY) dummy_only = false; } if (dummy_only) return false; return true; } bool SpellMgr::IsProfessionOrRidingSpell(uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) return false; if (spellInfo->Effect[EFFECT_INDEX_1] != SPELL_EFFECT_SKILL) return false; uint32 skill = spellInfo->EffectMiscValue[EFFECT_INDEX_1]; return IsProfessionOrRidingSkill(skill); } bool SpellMgr::IsProfessionSpell(uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) return false; if (spellInfo->Effect[EFFECT_INDEX_1] != SPELL_EFFECT_SKILL) return false; uint32 skill = spellInfo->EffectMiscValue[EFFECT_INDEX_1]; return IsProfessionSkill(skill); } bool SpellMgr::IsPrimaryProfessionSpell(uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) return false; if (spellInfo->Effect[EFFECT_INDEX_1] != SPELL_EFFECT_SKILL) return false; uint32 skill = spellInfo->EffectMiscValue[EFFECT_INDEX_1]; return IsPrimaryProfessionSkill(skill); } uint32 SpellMgr::GetProfessionSpellMinLevel(uint32 spellId) { uint32 s2l[8][3] = { // 0 - gather 1 - non-gather 2 - fish /*0*/ { 0, 5, 5 }, /*1*/ { 0, 5, 5 }, /*2*/ { 0, 10, 10 }, /*3*/ { 10, 20, 10 }, /*4*/ { 25, 35, 10 }, /*5*/ { 40, 50, 10 }, /*6*/ { 55, 65, 10 }, /*7*/ { 75, 75, 10 }, }; uint32 rank = GetSpellRank(spellId); if (rank >= 8) return 0; SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId); if (bounds.first == bounds.second) return 0; switch (bounds.first->second->skillId) { case SKILL_FISHING: return s2l[rank][2]; case SKILL_HERBALISM: case SKILL_MINING: case SKILL_SKINNING: return s2l[rank][0]; default: return s2l[rank][1]; } } bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId) const { return IsPrimaryProfessionSpell(spellId) && GetSpellRank(spellId)==1; } bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const { SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId); for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) { SkillLineAbilityEntry const *pAbility = _spell_idx->second; if (!pAbility || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) continue; if (pAbility->req_skill_value > 0) return true; } return false; } SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, uint32 level) const { // fast case if (level + 10 >= spellInfo->spellLevel) return spellInfo; // ignore selection for passive spells if (IsPassiveSpell(spellInfo)) return spellInfo; bool needRankSelection = false; for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // for simple aura in check apply to any non caster based targets, in rank search mode to any explicit targets if (((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && (IsExplicitPositiveTarget(spellInfo->EffectImplicitTargetA[i]) || IsAreaEffectPossitiveTarget(Targets(spellInfo->EffectImplicitTargetA[i])))) || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID) && IsPositiveEffect(spellInfo, SpellEffectIndex(i))) { needRankSelection = true; break; } } // not required (rank check more slow so check it here) if (!needRankSelection || GetSpellRank(spellInfo->Id) == 0) return spellInfo; for(uint32 nextSpellId = spellInfo->Id; nextSpellId != 0; nextSpellId = GetPrevSpellInChain(nextSpellId)) { SpellEntry const *nextSpellInfo = sSpellStore.LookupEntry(nextSpellId); if (!nextSpellInfo) break; // if found appropriate level if (level + 10 >= spellInfo->spellLevel) return nextSpellInfo; // one rank less then } // not found return NULL; } typedef UNORDERED_MAP<uint32,uint32> AbilitySpellPrevMap; static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellPrevMap const& prevRanks, uint32 spell_id, uint32 prev_id, uint32 deep = 30) { // spell already listed in chains store SpellChainMap::const_iterator chain_itr = chainMap.find(spell_id); if (chain_itr != chainMap.end()) { MANGOS_ASSERT(chain_itr->second.prev == prev_id && "LoadSpellChains_AbilityHelper: Conflicting data in talents or spell abilities dbc"); return; } // prev rank listed in main chain table (can fill correct data directly) SpellChainMap::const_iterator prev_chain_itr = chainMap.find(prev_id); if (prev_chain_itr != chainMap.end()) { SpellChainNode node; node.prev = prev_id; node.first = prev_chain_itr->second.first; node.rank = prev_chain_itr->second.rank+1; node.req = 0; chainMap[spell_id] = node; return; } // prev spell not listed in prev ranks store, so it first rank AbilitySpellPrevMap::const_iterator prev_itr = prevRanks.find(prev_id); if (prev_itr == prevRanks.end()) { SpellChainNode prev_node; prev_node.prev = 0; prev_node.first = prev_id; prev_node.rank = 1; prev_node.req = 0; chainMap[prev_id] = prev_node; SpellChainNode node; node.prev = prev_id; node.first = prev_id; node.rank = 2; node.req = 0; chainMap[spell_id] = node; return; } if (deep == 0) { MANGOS_ASSERT(false && "LoadSpellChains_AbilityHelper: Infinity cycle in spell ability data"); return; } // prev rank listed, so process it first LoadSpellChains_AbilityHelper(chainMap, prevRanks, prev_id, prev_itr->second, deep-1); // prev rank must be listed now prev_chain_itr = chainMap.find(prev_id); if (prev_chain_itr == chainMap.end()) return; SpellChainNode node; node.prev = prev_id; node.first = prev_chain_itr->second.first; node.rank = prev_chain_itr->second.rank+1; node.req = 0; chainMap[spell_id] = node; } void SpellMgr::LoadSpellChains() { mSpellChains.clear(); // need for reload case mSpellChainsNext.clear(); // need for reload case // load known data for talents for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) { TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); if (!talentInfo) continue; // not add ranks for 1 ranks talents (if exist non ranks spells then it will included in table data) if (!talentInfo->RankID[1]) continue; for (int j = 0; j < MAX_TALENT_RANK; j++) { uint32 spell_id = talentInfo->RankID[j]; if (!spell_id) continue; if (!sSpellStore.LookupEntry(spell_id)) { //sLog.outErrorDb("Talent %u not exist as spell",spell_id); continue; } SpellChainNode node; node.prev = (j > 0) ? talentInfo->RankID[j-1] : 0; node.first = talentInfo->RankID[0]; node.rank = j+1; node.req = 0; mSpellChains[spell_id] = node; } } // load known data from spell abilities { // we can calculate ranks only after full data generation AbilitySpellPrevMap prevRanks; for(SkillLineAbilityMap::const_iterator ab_itr = mSkillLineAbilityMap.begin(); ab_itr != mSkillLineAbilityMap.end(); ++ab_itr) { uint32 spell_id = ab_itr->first; // skip GM/test/internal spells.begin Its not have ranks anyway if (ab_itr->second->skillId == SKILL_INTERNAL) continue; // some forward spells not exist and can be ignored (some outdated data) SpellEntry const* spell_entry = sSpellStore.LookupEntry(spell_id); if (!spell_entry) // no cases continue; // ignore spell without forwards (non ranked or missing info in skill abilities) uint32 forward_id = ab_itr->second->forward_spellid; if (!forward_id) continue; // some forward spells not exist and can be ignored (some outdated data) SpellEntry const* forward_entry = sSpellStore.LookupEntry(forward_id); if (!forward_entry) continue; // some forward spells still exist but excluded from real use as ranks and not listed in skill abilities now SkillLineAbilityMapBounds bounds = mSkillLineAbilityMap.equal_range(forward_id); if (bounds.first == bounds.second) continue; // spell already listed in chains store SpellChainMap::const_iterator chain_itr = mSpellChains.find(forward_id); if (chain_itr != mSpellChains.end()) { MANGOS_ASSERT(chain_itr->second.prev == spell_id && "Conflicting data in talents or spell abilities dbc"); continue; } // spell already listed in prev ranks store AbilitySpellPrevMap::const_iterator prev_itr = prevRanks.find(forward_id); if (prev_itr != prevRanks.end()) { MANGOS_ASSERT(prev_itr->second == spell_id && "Conflicting data in talents or spell abilities dbc"); continue; } // prev rank listed in main chain table (can fill correct data directly) SpellChainMap::const_iterator prev_chain_itr = mSpellChains.find(spell_id); if (prev_chain_itr != mSpellChains.end()) { SpellChainNode node; node.prev = spell_id; node.first = prev_chain_itr->second.first; node.rank = prev_chain_itr->second.rank+1; node.req = 0; mSpellChains[forward_id] = node; continue; } // need temporary store for later rank calculation prevRanks[forward_id] = spell_id; } while (!prevRanks.empty()) { uint32 spell_id = prevRanks.begin()->first; uint32 prev_id = prevRanks.begin()->second; prevRanks.erase(prevRanks.begin()); LoadSpellChains_AbilityHelper(mSpellChains, prevRanks, spell_id, prev_id); } } // load custom case QueryResult *result = WorldDatabase.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded 0 spell chain records"); sLog.outErrorDb("`spell_chains` table is empty!"); return; } uint32 dbc_count = mSpellChains.size(); uint32 new_count = 0; uint32 req_count = 0; BarGoLink bar(result->GetRowCount()); do { bar.step(); Field *fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); SpellChainNode node; node.prev = fields[1].GetUInt32(); node.first = fields[2].GetUInt32(); node.rank = fields[3].GetUInt8(); node.req = fields[4].GetUInt32(); if (!sSpellStore.LookupEntry(spell_id)) { sLog.outErrorDb("Spell %u listed in `spell_chain` does not exist",spell_id); continue; } SpellChainMap::iterator chain_itr = mSpellChains.find(spell_id); if (chain_itr != mSpellChains.end()) { if (chain_itr->second.rank != node.rank) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected rank %u by DBC data.", spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.rank); continue; } if (chain_itr->second.prev != node.prev) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected prev %u by DBC data.", spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.prev); continue; } if (chain_itr->second.first != node.first) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected first %u by DBC data.", spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.first); continue; } // update req field by table data if (node.req) { chain_itr->second.req = node.req; ++req_count; continue; } // in other case redundant sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) already added (talent or spell ability with forward) and non need in `spell_chain`", spell_id,node.prev,node.first,node.rank,node.req); continue; } if (node.prev != 0 && !sSpellStore.LookupEntry(node.prev)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has nonexistent previous rank spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; } if(!sSpellStore.LookupEntry(node.first)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing first rank spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; } // check basic spell chain data integrity (note: rank can be equal 0 or 1 for first/single spell) if( (spell_id == node.first) != (node.rank <= 1) || (spell_id == node.first) != (node.prev == 0) || (node.rank <= 1) != (node.prev == 0) ) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not compatible chain data.", spell_id,node.prev,node.first,node.rank,node.req); continue; } if(node.req!=0 && !sSpellStore.LookupEntry(node.req)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing required spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; } // talents not required data in spell chain for work, but must be checked if present for integrity if(TalentSpellPos const* pos = GetTalentSpellPos(spell_id)) { if(node.rank!=pos->rank+1) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong rank.", spell_id,node.prev,node.first,node.rank,node.req); continue; } if(TalentEntry const* talentEntry = sTalentStore.LookupEntry(pos->talent_id)) { if(node.first!=talentEntry->RankID[0]) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong first rank spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; } if(node.rank > 1 && node.prev != talentEntry->RankID[node.rank-1-1]) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong prev rank spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; } /*if(node.req!=talentEntry->DependsOnSpell) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong required spell.", spell_id,node.prev,node.first,node.rank,node.req); continue; }*/ } } // removed ranks often still listed as forward in skill abilities but not listed as spell in it if (node.prev) { bool skip = false; // some forward spells still exist but excluded from real use as ranks and not listed in skill abilities now SkillLineAbilityMapBounds bounds = mSkillLineAbilityMap.equal_range(spell_id); if (bounds.first == bounds.second) { SkillLineAbilityMapBounds prev_bounds = mSkillLineAbilityMap.equal_range(node.prev); for(SkillLineAbilityMap::const_iterator ab_itr = prev_bounds.first; ab_itr != prev_bounds.second; ++ab_itr) { // spell listed as forward and not listed as ability // this is marker for removed ranks if (ab_itr->second->forward_spellid == spell_id) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` is removed rank by DBC data.", spell_id, node.prev, node.first, node.rank, node.req); skip = true; break; } } } if (skip) continue; } mSpellChains[spell_id] = node; ++new_count; } while( result->NextRow() ); delete result; // additional integrity checks for(SpellChainMap::const_iterator i = mSpellChains.begin(); i != mSpellChains.end(); ++i) { if(i->second.prev) { SpellChainMap::const_iterator i_prev = mSpellChains.find(i->second.prev); if(i_prev == mSpellChains.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found previous rank spell in table.", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); } else if( i_prev->second.first != i->second.first ) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different first spell in chain compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); } else if( i_prev->second.rank+1 != i->second.rank ) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different rank compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); } } if(i->second.req) { SpellChainMap::const_iterator i_req = mSpellChains.find(i->second.req); if(i_req == mSpellChains.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found required rank spell in table.", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); } else if( i_req->second.first == i->second.first ) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell from same spell chain (prev: %u, first: %u, rank: %d, req: %u).", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); } else if( i_req->second.req ) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell with required spell (prev: %u, first: %u, rank: %d, req: %u).", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); } } } // fill next rank cache for(SpellChainMap::const_iterator i = mSpellChains.begin(); i != mSpellChains.end(); ++i) { uint32 spell_id = i->first; SpellChainNode const& node = i->second; if(node.prev) mSpellChainsNext.insert(SpellChainMapNext::value_type(node.prev,spell_id)); if(node.req) mSpellChainsNext.insert(SpellChainMapNext::value_type(node.req,spell_id)); } // check single rank redundant cases (single rank talents/spell abilities not added by default so this can be only custom cases) for(SpellChainMap::const_iterator i = mSpellChains.begin(); i != mSpellChains.end(); ++i) { // skip non-first ranks, and spells with additional reqs if (i->second.rank > 1 || i->second.req) continue; if (mSpellChainsNext.find(i->first) == mSpellChainsNext.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has single rank data, so redundant.", i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); } } sLog.outString(); sLog.outString( ">> Loaded %u spell chain records (%u from DBC data with %u req field updates, and %u loaded from table)", dbc_count+new_count, dbc_count, req_count, new_count); } void SpellMgr::LoadSpellLearnSkills() { mSpellLearnSkills.clear(); // need for reload case // search auto-learned skills and add its to map also for use in unlearn spells/talents uint32 dbc_count = 0; BarGoLink bar(sSpellStore.GetNumRows()); for (uint32 spell = 0; spell < sSpellStore.GetNumRows(); ++spell) { bar.step(); SpellEntry const* entry = sSpellStore.LookupEntry(spell); if (!entry) continue; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (entry->Effect[i] == SPELL_EFFECT_SKILL) { SpellLearnSkillNode dbc_node; dbc_node.skill = entry->EffectMiscValue[i]; dbc_node.step = entry->CalculateSimpleValue(SpellEffectIndex(i)); if (dbc_node.skill != SKILL_RIDING) dbc_node.value = 1; else dbc_node.value = dbc_node.step * 75; dbc_node.maxvalue = dbc_node.step * 75; mSpellLearnSkills[spell] = dbc_node; ++dbc_count; break; } } } sLog.outString(); sLog.outString(">> Loaded %u Spell Learn Skills from DBC", dbc_count); } void SpellMgr::LoadSpellLearnSpells() { mSpellLearnSpells.clear(); // need for reload case // 0 1 2 QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded 0 spell learn spells"); sLog.outErrorDb("`spell_learn_spell` table is empty!"); return; } uint32 count = 0; BarGoLink bar(result->GetRowCount()); do { bar.step(); Field *fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); SpellLearnSpellNode node; node.spell = fields[1].GetUInt32(); node.active = fields[2].GetBool(); node.autoLearned= false; if (!sSpellStore.LookupEntry(spell_id)) { sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id); continue; } if (!sSpellStore.LookupEntry(node.spell)) { sLog.outErrorDb("Spell %u listed in `spell_learn_spell` learning nonexistent spell %u",spell_id,node.spell); continue; } if (GetTalentSpellCost(node.spell)) { sLog.outErrorDb("Spell %u listed in `spell_learn_spell` attempt learning talent spell %u, skipped",spell_id,node.spell); continue; } mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell_id,node)); ++count; } while (result->NextRow()); delete result; // search auto-learned spells and add its to map also for use in unlearn spells/talents uint32 dbc_count = 0; for(uint32 spell = 0; spell < sSpellStore.GetNumRows(); ++spell) { SpellEntry const* entry = sSpellStore.LookupEntry(spell); if (!entry) continue; for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if(entry->Effect[i]==SPELL_EFFECT_LEARN_SPELL) { SpellLearnSpellNode dbc_node; dbc_node.spell = entry->EffectTriggerSpell[i]; dbc_node.active = true; // all dbc based learned spells is active (show in spell book or hide by client itself) // ignore learning nonexistent spells (broken/outdated/or generic learning spell 483 if (!sSpellStore.LookupEntry(dbc_node.spell)) continue; // talent or passive spells or skill-step spells auto-casted and not need dependent learning, // pet teaching spells don't must be dependent learning (casted) // other required explicit dependent learning dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(entry) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP); SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds(spell); bool found = false; for(SpellLearnSpellMap::const_iterator itr = db_node_bounds.first; itr != db_node_bounds.second; ++itr) { if (itr->second.spell == dbc_node.spell) { sLog.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.", spell,dbc_node.spell); found = true; break; } } if (!found) // add new spell-spell pair if not found { mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell,dbc_node)); ++dbc_count; } } } } sLog.outString(); sLog.outString( ">> Loaded %u spell learn spells + %u found in DBC", count, dbc_count ); } void SpellMgr::LoadSpellScriptTarget() { mSpellScriptTarget.clear(); // need for reload case uint32 count = 0; QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM spell_script_target"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outErrorDb(">> Loaded 0 SpellScriptTarget. DB table `spell_script_target` is empty."); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 spellId = fields[0].GetUInt32(); uint32 type = fields[1].GetUInt32(); uint32 targetEntry = fields[2].GetUInt32(); SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); if (!spellProto) { sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId,targetEntry); continue; } bool targetfound = false; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if( spellProto->EffectImplicitTargetA[i] == TARGET_SCRIPT || spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT || spellProto->EffectImplicitTargetA[i] == TARGET_SCRIPT_COORDINATES || spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT_COORDINATES || spellProto->EffectImplicitTargetA[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || spellProto->EffectImplicitTargetB[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_INSTANT || spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_INSTANT || spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_CUSTOM || spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_CUSTOM || spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_GO_AROUND_DEST || spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_GO_AROUND_DEST) { targetfound = true; break; } } if (!targetfound) { sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not have any implicit target TARGET_SCRIPT(38) or TARGET_SCRIPT_COORDINATES (46) or TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT (40).", spellId, targetEntry); continue; } if (type >= MAX_SPELL_TARGET_TYPE) { sLog.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type,targetEntry); continue; } // Checks by target type switch (type) { case SPELL_TARGET_TYPE_GAMEOBJECT: { if (!targetEntry) break; if (!sGOStorage.LookupEntry<GameObjectInfo>(targetEntry)) { sLog.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry); continue; } break; } default: if (!targetEntry) { sLog.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type); continue; } if (const CreatureInfo* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(targetEntry)) { if (spellId == 30427 && !cInfo->SkinLootId) { sLog.outErrorDb("Table `spell_script_target` has creature %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!", cInfo->Entry); continue; } } else { sLog.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry); continue; } break; } mSpellScriptTarget.insert(SpellScriptTarget::value_type(spellId,SpellTargetEntry(SpellTargetType(type),targetEntry))); ++count; } while (result->NextRow()); delete result; // Check all spells /* Disabled (lot errors at this moment) for(uint32 i = 1; i < sSpellStore.nCount; ++i) { SpellEntry const * spellInfo = sSpellStore.LookupEntry(i); if(!spellInfo) continue; bool found = false; for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) { SpellScriptTarget::const_iterator lower = GetBeginSpellScriptTarget(spellInfo->Id); SpellScriptTarget::const_iterator upper = GetEndSpellScriptTarget(spellInfo->Id); if(lower==upper) { sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = %u (TARGET_SCRIPT), but does not have record in `spell_script_target`",spellInfo->Id,TARGET_SCRIPT); break; // effects of spell } } } } */ sLog.outString(); sLog.outString(">> Loaded %u Spell Script Targets", count); } void SpellMgr::LoadSpellPetAuras() { mSpellPetAuraMap.clear(); // need for reload case uint32 count = 0; // 0 1 2 3 QueryResult *result = WorldDatabase.Query("SELECT spell, effectId, pet, aura FROM spell_pet_auras"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u spell pet auras", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 spell = fields[0].GetUInt32(); SpellEffectIndex eff = SpellEffectIndex(fields[1].GetUInt32()); uint32 pet = fields[2].GetUInt32(); uint32 aura = fields[3].GetUInt32(); if (eff >= MAX_EFFECT_INDEX) { sLog.outErrorDb("Spell %u listed in `spell_pet_auras` with wrong spell effect index (%u)", spell, eff); continue; } SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find((spell<<8) + eff); if(itr != mSpellPetAuraMap.end()) { itr->second.AddAura(pet, aura); } else { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo) { sLog.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell); continue; } if (spellInfo->Effect[eff] != SPELL_EFFECT_DUMMY && (spellInfo->Effect[eff] != SPELL_EFFECT_APPLY_AURA || spellInfo->EffectApplyAuraName[eff] != SPELL_AURA_DUMMY)) { sLog.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell); continue; } SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(aura); if (!spellInfo2) { sLog.outErrorDb("Aura %u listed in `spell_pet_auras` does not exist", aura); continue; } PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[eff] == TARGET_PET, spellInfo->CalculateSimpleValue(eff)); mSpellPetAuraMap[(spell<<8) + eff] = pa; } ++count; } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString( ">> Loaded %u spell pet auras", count ); } void SpellMgr::LoadPetLevelupSpellMap() { uint32 count = 0; uint32 family_count = 0; for (uint32 i = 0; i < sCreatureFamilyStore.GetNumRows(); ++i) { CreatureFamilyEntry const *creatureFamily = sCreatureFamilyStore.LookupEntry(i); if(!creatureFamily) // not exist continue; for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); if( !skillLine ) continue; if (skillLine->skillId!=creatureFamily->skillLine[0] && (!creatureFamily->skillLine[1] || skillLine->skillId!=creatureFamily->skillLine[1])) continue; if(skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL) continue; SpellEntry const *spell = sSpellStore.LookupEntry(skillLine->spellId); if(!spell) // not exist continue; PetLevelupSpellSet& spellSet = mPetLevelupSpellMap[creatureFamily->ID]; if(spellSet.empty()) ++family_count; spellSet.insert(PetLevelupSpellSet::value_type(spell->spellLevel,spell->Id)); count++; } } sLog.outString(); sLog.outString( ">> Loaded %u pet levelup and default spells for %u families", count, family_count ); } bool SpellMgr::LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells) { // skip empty list; bool have_spell = false; for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j) { if(petDefSpells.spellid[j]) { have_spell = true; break; } } if(!have_spell) return false; // remove duplicates with levelupSpells if any if(PetLevelupSpellSet const *levelupSpells = cInfo->family ? GetPetLevelupSpellList(cInfo->family) : NULL) { for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j) { if(!petDefSpells.spellid[j]) continue; for(PetLevelupSpellSet::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr) { if (itr->second == petDefSpells.spellid[j]) { petDefSpells.spellid[j] = 0; break; } } } } // skip empty list; have_spell = false; for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j) { if(petDefSpells.spellid[j]) { have_spell = true; break; } } return have_spell; } void SpellMgr::LoadPetDefaultSpells() { MANGOS_ASSERT(MAX_CREATURE_SPELL_DATA_SLOT==CREATURE_MAX_SPELLS); mPetDefaultSpellsMap.clear(); uint32 countCreature = 0; uint32 countData = 0; for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i ) { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i); if(!cInfo) continue; if(!cInfo->PetSpellDataId) continue; // for creature with PetSpellDataId get default pet spells from dbc CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId); if(!spellDataEntry) continue; int32 petSpellsId = -(int32)cInfo->PetSpellDataId; PetDefaultSpellsEntry petDefSpells; for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j) petDefSpells.spellid[j] = spellDataEntry->spellId[j]; if(LoadPetDefaultSpells_helper(cInfo, petDefSpells)) { mPetDefaultSpellsMap[petSpellsId] = petDefSpells; ++countData; } } // different summon spells for(uint32 i = 0; i < sSpellStore.GetNumRows(); ++i ) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(i); if(!spellEntry) continue; for(int k = 0; k < MAX_EFFECT_INDEX; ++k) { if(spellEntry->Effect[k]==SPELL_EFFECT_SUMMON || spellEntry->Effect[k]==SPELL_EFFECT_SUMMON_PET) { uint32 creature_id = spellEntry->EffectMiscValue[k]; CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(creature_id); if(!cInfo) continue; // already loaded if(cInfo->PetSpellDataId) continue; // for creature without PetSpellDataId get default pet spells from creature_template int32 petSpellsId = cInfo->Entry; if(mPetDefaultSpellsMap.find(cInfo->Entry) != mPetDefaultSpellsMap.end()) continue; PetDefaultSpellsEntry petDefSpells; for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j) petDefSpells.spellid[j] = cInfo->spells[j]; if(LoadPetDefaultSpells_helper(cInfo, petDefSpells)) { mPetDefaultSpellsMap[petSpellsId] = petDefSpells; ++countCreature; } } } } sLog.outString(); sLog.outString( ">> Loaded addition spells for %u pet spell data entries and %u summonable creature templates", countData, countCreature ); } /// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) { // not exist if(!spellInfo) return false; bool need_check_reagents = false; // check effects for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(spellInfo->Effect[i]) { case 0: continue; // craft spell for crafting nonexistent item (break client recipes list show) case SPELL_EFFECT_CREATE_ITEM: case SPELL_EFFECT_CREATE_ITEM_2: { if (spellInfo->EffectItemType[i] == 0) { // skip auto-loot crafting spells, its not need explicit item info (but have special fake items sometime) if (!IsLootCraftingSpell(spellInfo)) { if(msg) { if(pl) ChatHandler(pl).PSendSysMessage("Craft spell %u not have create item entry.",spellInfo->Id); else sLog.outErrorDb("Craft spell %u not have create item entry.",spellInfo->Id); } return false; } } // also possible IsLootCraftingSpell case but fake item must exist anyway else if (!ObjectMgr::GetItemPrototype( spellInfo->EffectItemType[i] )) { if(msg) { if(pl) ChatHandler(pl).PSendSysMessage("Craft spell %u create item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->EffectItemType[i]); else sLog.outErrorDb("Craft spell %u create item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->EffectItemType[i]); } return false; } need_check_reagents = true; break; } case SPELL_EFFECT_LEARN_SPELL: { SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(spellInfo->EffectTriggerSpell[i]); if( !IsSpellValid(spellInfo2,pl,msg) ) { if(msg) { if(pl) ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]); else sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]); } return false; } break; } } } if(need_check_reagents) { for(int j = 0; j < MAX_SPELL_REAGENTS; ++j) { if(spellInfo->Reagent[j] > 0 && !ObjectMgr::GetItemPrototype( spellInfo->Reagent[j] )) { if(msg) { if(pl) ChatHandler(pl).PSendSysMessage("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->Reagent[j]); else sLog.outErrorDb("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->Reagent[j]); } return false; } } } return true; } void SpellMgr::LoadSpellAreas() { mSpellAreaMap.clear(); // need for reload case mSpellAreaForQuestMap.clear(); mSpellAreaForActiveQuestMap.clear(); mSpellAreaForQuestEndMap.clear(); mSpellAreaForAuraMap.clear(); uint32 count = 0; // 0 1 2 3 4 5 6 7 8 QueryResult *result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outString(">> Loaded %u spell area requirements", count); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 spell = fields[0].GetUInt32(); SpellArea spellArea; spellArea.spellId = spell; spellArea.areaId = fields[1].GetUInt32(); spellArea.questStart = fields[2].GetUInt32(); spellArea.questStartCanActive = fields[3].GetBool(); spellArea.questEnd = fields[4].GetUInt32(); spellArea.auraSpell = fields[5].GetInt32(); spellArea.raceMask = fields[6].GetUInt32(); spellArea.gender = Gender(fields[7].GetUInt8()); spellArea.autocast = fields[8].GetBool(); if (!sSpellStore.LookupEntry(spell)) { sLog.outErrorDb("Spell %u listed in `spell_area` does not exist", spell); continue; } { bool ok = true; SpellAreaMapBounds sa_bounds = GetSpellAreaMapBounds(spellArea.spellId); for (SpellAreaMap::const_iterator itr = sa_bounds.first; itr != sa_bounds.second; ++itr) { if (spellArea.spellId != itr->second.spellId) continue; if (spellArea.areaId != itr->second.areaId) continue; if (spellArea.questStart != itr->second.questStart) continue; if (spellArea.auraSpell != itr->second.auraSpell) continue; if ((spellArea.raceMask & itr->second.raceMask) == 0) continue; if (spellArea.gender != itr->second.gender) continue; // duplicate by requirements ok =false; break; } if (!ok) { sLog.outErrorDb("Spell %u listed in `spell_area` already listed with similar requirements.", spell); continue; } } if (spellArea.areaId && !GetAreaEntryByAreaID(spellArea.areaId)) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong area (%u) requirement", spell,spellArea.areaId); continue; } if (spellArea.questStart && !sObjectMgr.GetQuestTemplate(spellArea.questStart)) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell,spellArea.questStart); continue; } if (spellArea.questEnd) { if (!sObjectMgr.GetQuestTemplate(spellArea.questEnd)) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell,spellArea.questEnd); continue; } if (spellArea.questEnd==spellArea.questStart && !spellArea.questStartCanActive) { sLog.outErrorDb("Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell,spellArea.questEnd); continue; } } if (spellArea.auraSpell) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(spellArea.auraSpell)); if (!spellInfo) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell,abs(spellArea.auraSpell)); continue; } switch (spellInfo->EffectApplyAuraName[EFFECT_INDEX_0]) { case SPELL_AURA_DUMMY: case SPELL_AURA_PHASE: case SPELL_AURA_GHOST: break; default: sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase/ghost aura in effect 0", spell,abs(spellArea.auraSpell)); continue; } if (uint32(abs(spellArea.auraSpell))==spellArea.spellId) { sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell, abs(spellArea.auraSpell)); continue; } // not allow autocast chains by auraSpell field (but allow use as alternative if not present) if (spellArea.autocast && spellArea.auraSpell > 0) { bool chain = false; SpellAreaForAuraMapBounds saBound = GetSpellAreaForAuraMapBounds(spellArea.spellId); for (SpellAreaForAuraMap::const_iterator itr = saBound.first; itr != saBound.second; ++itr) { if (itr->second->autocast && itr->second->auraSpell > 0) { chain = true; break; } } if (chain) { sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell,spellArea.auraSpell); continue; } SpellAreaMapBounds saBound2 = GetSpellAreaMapBounds(spellArea.auraSpell); for (SpellAreaMap::const_iterator itr2 = saBound2.first; itr2 != saBound2.second; ++itr2) { if (itr2->second.autocast && itr2->second.auraSpell > 0) { chain = true; break; } } if (chain) { sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell,spellArea.auraSpell); continue; } } } if (spellArea.raceMask && (spellArea.raceMask & RACEMASK_ALL_PLAYABLE)==0) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell,spellArea.raceMask); continue; } if (spellArea.gender!=GENDER_NONE && spellArea.gender!=GENDER_FEMALE && spellArea.gender!=GENDER_MALE) { sLog.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell,spellArea.gender); continue; } SpellArea const* sa = &mSpellAreaMap.insert(SpellAreaMap::value_type(spell,spellArea))->second; // for search by current zone/subzone at zone/subzone change if (spellArea.areaId) mSpellAreaForAreaMap.insert(SpellAreaForAreaMap::value_type(spellArea.areaId,sa)); // for search at quest start/reward if (spellArea.questStart) { if (spellArea.questStartCanActive) mSpellAreaForActiveQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart,sa)); else mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart,sa)); } // for search at quest start/reward if (spellArea.questEnd) mSpellAreaForQuestEndMap.insert(SpellAreaForQuestMap::value_type(spellArea.questEnd,sa)); // for search at aura apply if (spellArea.auraSpell) mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell),sa)); ++count; } while (result->NextRow()); delete result; sLog.outString(); sLog.outString(">> Loaded %u spell area requirements", count); } SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player) { // normal case int32 areaGroupId = spellInfo->AreaGroupId; if (areaGroupId > 0) { bool found = false; AreaGroupEntry const* groupEntry = sAreaGroupStore.LookupEntry(areaGroupId); while (groupEntry) { for (uint32 i=0; i<6; ++i) if (groupEntry->AreaId[i] == zone_id || groupEntry->AreaId[i] == area_id) found = true; if (found || !groupEntry->nextGroup) break; // Try search in next group groupEntry = sAreaGroupStore.LookupEntry(groupEntry->nextGroup); } if (!found) return SPELL_FAILED_INCORRECT_AREA; } // continent limitation (virtual continent), ignore for GM if ((spellInfo->AttributesEx4 & SPELL_ATTR_EX4_CAST_ONLY_IN_OUTLAND) && !(player && player->isGameMaster())) { uint32 v_map = GetVirtualMapForMapAndZone(map_id, zone_id); MapEntry const* mapEntry = sMapStore.LookupEntry(v_map); if (!mapEntry || mapEntry->addon < 1 || !mapEntry->IsContinent()) return SPELL_FAILED_INCORRECT_AREA; } // raid instance limitation if (spellInfo->AttributesEx6 & SPELL_ATTR_EX6_NOT_IN_RAID_INSTANCE) { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry || mapEntry->IsRaid()) return SPELL_FAILED_NOT_IN_RAID_INSTANCE; } // DB base check (if non empty then must fit at least single for allow) SpellAreaMapBounds saBounds = GetSpellAreaMapBounds(spellInfo->Id); if (saBounds.first != saBounds.second) { for(SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) { if(itr->second.IsFitToRequirements(player,zone_id,area_id)) return SPELL_CAST_OK; } return SPELL_FAILED_INCORRECT_AREA; } // bg spell checks // do not allow spells to be cast in arenas // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag // - with greater than 10 min CD if ((spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || (GetSpellRecoveryTime(spellInfo) > 10 * MINUTE * IN_MILLISECONDS && !(spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA))) if (player && player->InArena()) return SPELL_FAILED_NOT_IN_ARENA; // Spell casted only on battleground if ((spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND)) if (!player || !player->InBattleGround()) return SPELL_FAILED_ONLY_BATTLEGROUNDS; switch(spellInfo->Id) { // a trinket in alterac valley allows to teleport to the boss case 22564: // recall case 22563: // recall { if (!player) return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); return map_id == 30 && bg && bg->GetStatus() != STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; } case 23333: // Warsong Flag case 23335: // Silverwing Flag return map_id == 489 && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; case 34976: // Netherstorm Flag return map_id == 566 && player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; case 2584: // Waiting to Resurrect case 42792: // Recently Dropped Flag case 43681: // Inactive { return player && player->InBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 22011: // Spirit Heal Channel case 22012: // Spirit Heal case 24171: // Resurrection Impact Visual case 44535: // Spirit Heal (mana) { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry) return SPELL_FAILED_INCORRECT_AREA; return mapEntry->IsBattleGround()? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 44521: // Preparation { if (!player) return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 32724: // Gold Team (Alliance) case 32725: // Green Team (Alliance) case 35774: // Gold Team (Horde) case 35775: // Green Team (Horde) { return player && player->InArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; } case 32727: // Arena Preparation { if (!player) return SPELL_FAILED_REQUIRES_AREA; if (!player->InArena()) return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; } case 74410: // Arena - Dampening return player && player->InArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; case 74411: // Battleground - Dampening { if (!player) return SPELL_FAILED_ONLY_BATTLEGROUNDS; BattleGround* bg = player->GetBattleGround(); return bg && !bg->isArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } } return SPELL_CAST_OK; } void SpellMgr::LoadSkillLineAbilityMap() { mSkillLineAbilityMap.clear(); BarGoLink bar(sSkillLineAbilityStore.GetNumRows()); uint32 count = 0; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) { bar.step(); SkillLineAbilityEntry const *SkillInfo = sSkillLineAbilityStore.LookupEntry(i); if(!SkillInfo) continue; mSkillLineAbilityMap.insert(SkillLineAbilityMap::value_type(SkillInfo->spellId,SkillInfo)); ++count; } sLog.outString(); sLog.outString(">> Loaded %u SkillLineAbility MultiMap Data", count); } void SpellMgr::LoadSkillRaceClassInfoMap() { mSkillRaceClassInfoMap.clear(); BarGoLink bar(sSkillRaceClassInfoStore.GetNumRows()); uint32 count = 0; for (uint32 i = 0; i < sSkillRaceClassInfoStore.GetNumRows(); ++i) { bar.step(); SkillRaceClassInfoEntry const *skillRCInfo = sSkillRaceClassInfoStore.LookupEntry(i); if (!skillRCInfo) continue; // not all skills really listed in ability skills list if (!sSkillLineStore.LookupEntry(skillRCInfo->skillId)) continue; mSkillRaceClassInfoMap.insert(SkillRaceClassInfoMap::value_type(skillRCInfo->skillId,skillRCInfo)); ++count; } sLog.outString(); sLog.outString(">> Loaded %u SkillRaceClassInfo MultiMap Data", count); } void SpellMgr::CheckUsedSpells(char const* table) { uint32 countSpells = 0; uint32 countMasks = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 QueryResult *result = WorldDatabase.PQuery("SELECT spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMaskB,SpellIcon,SpellVisual,SpellCategory,EffectType,EffectAura,EffectIdx,Name,Code FROM %s",table); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); sLog.outErrorDb("`%s` table is empty!",table); return; } BarGoLink bar(result->GetRowCount()); do { Field *fields = result->Fetch(); bar.step(); uint32 spell = fields[0].GetUInt32(); int32 family = fields[1].GetInt32(); uint64 familyMaskA = fields[2].GetUInt64(); uint32 familyMaskB = fields[3].GetUInt32(); int32 spellIcon = fields[4].GetInt32(); int32 spellVisual = fields[5].GetInt32(); int32 category = fields[6].GetInt32(); int32 effectType = fields[7].GetInt32(); int32 auraType = fields[8].GetInt32(); int32 effectIdx = fields[9].GetInt32(); std::string name = fields[10].GetCppString(); std::string code = fields[11].GetCppString(); // checks of correctness requirements itself if (family < -1 || family > SPELLFAMILY_PET) { sLog.outError("Table '%s' for spell %u have wrong SpellFamily value(%u), skipped.",table,spell,family); continue; } // TODO: spellIcon check need dbc loading if (spellIcon < -1) { sLog.outError("Table '%s' for spell %u have wrong SpellIcon value(%u), skipped.",table,spell,spellIcon); continue; } // TODO: spellVisual check need dbc loading if (spellVisual < -1) { sLog.outError("Table '%s' for spell %u have wrong SpellVisual value(%u), skipped.",table,spell,spellVisual); continue; } // TODO: for spellCategory better check need dbc loading if (category < -1 || (category >=0 && sSpellCategoryStore.find(category) == sSpellCategoryStore.end())) { sLog.outError("Table '%s' for spell %u have wrong SpellCategory value(%u), skipped.",table,spell,category); continue; } if (effectType < -1 || effectType >= TOTAL_SPELL_EFFECTS) { sLog.outError("Table '%s' for spell %u have wrong SpellEffect type value(%u), skipped.",table,spell,effectType); continue; } if (auraType < -1 || auraType >= TOTAL_AURAS) { sLog.outError("Table '%s' for spell %u have wrong SpellAura type value(%u), skipped.",table,spell,auraType); continue; } if (effectIdx < -1 || effectIdx >= 3) { sLog.outError("Table '%s' for spell %u have wrong EffectIdx value(%u), skipped.",table,spell,effectIdx); continue; } // now checks of requirements if(spell) { ++countSpells; SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell); if(!spellEntry) { sLog.outError("Spell %u '%s' not exist but used in %s.",spell,name.c_str(),code.c_str()); continue; } if (family >= 0 && spellEntry->SpellFamilyName != uint32(family)) { sLog.outError("Spell %u '%s' family(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellFamilyName,family,code.c_str()); continue; } if(familyMaskA != UI64LIT(0xFFFFFFFFFFFFFFFF) || familyMaskB != 0xFFFFFFFF) { if(familyMaskA == UI64LIT(0x0000000000000000) && familyMaskB == 0x00000000) { if (spellEntry->SpellFamilyFlags) { sLog.outError("Spell %u '%s' not fit to (" I64FMT "," I32FMT ") but used in %s.", spell, name.c_str(), familyMaskA, familyMaskB, code.c_str()); continue; } } else { if (!spellEntry->IsFitToFamilyMask(familyMaskA, familyMaskB)) { sLog.outError("Spell %u '%s' not fit to (" I64FMT "," I32FMT ") but used in %s.",spell,name.c_str(),familyMaskA,familyMaskB,code.c_str()); continue; } } } if (spellIcon >= 0 && spellEntry->SpellIconID != uint32(spellIcon)) { sLog.outError("Spell %u '%s' icon(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellIconID,spellIcon,code.c_str()); continue; } if (spellVisual >= 0 && spellEntry->SpellVisual[0] != uint32(spellVisual)) { sLog.outError("Spell %u '%s' visual(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellVisual[0],spellVisual,code.c_str()); continue; } if (category >= 0 && spellEntry->Category != uint32(category)) { sLog.outError("Spell %u '%s' category(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->Category,category,code.c_str()); continue; } if (effectIdx >= EFFECT_INDEX_0) { if (effectType >= 0 && spellEntry->Effect[effectIdx] != uint32(effectType)) { sLog.outError("Spell %u '%s' effect%d <> %u but used in %s.",spell,name.c_str(),effectIdx+1,effectType,code.c_str()); continue; } if (auraType >= 0 && spellEntry->EffectApplyAuraName[effectIdx] != uint32(auraType)) { sLog.outError("Spell %u '%s' aura%d <> %u but used in %s.",spell,name.c_str(),effectIdx+1,auraType,code.c_str()); continue; } } else { if (effectType >= 0 && !IsSpellHaveEffect(spellEntry,SpellEffects(effectType))) { sLog.outError("Spell %u '%s' not have effect %u but used in %s.",spell,name.c_str(),effectType,code.c_str()); continue; } if (auraType >= 0 && !IsSpellHaveAura(spellEntry, AuraType(auraType))) { sLog.outError("Spell %u '%s' not have aura %u but used in %s.",spell,name.c_str(),auraType,code.c_str()); continue; } } } else { ++countMasks; bool found = false; for(uint32 spellId = 1; spellId < sSpellStore.GetNumRows(); ++spellId) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId); if (!spellEntry) continue; if (family >=0 && spellEntry->SpellFamilyName != uint32(family)) continue; if (familyMaskA != UI64LIT(0xFFFFFFFFFFFFFFFF) || familyMaskB != 0xFFFFFFFF) { if(familyMaskA == UI64LIT(0x0000000000000000) && familyMaskB == 0x00000000) { if (spellEntry->SpellFamilyFlags) continue; } else { if (!spellEntry->IsFitToFamilyMask(familyMaskA, familyMaskB)) continue; } } if (spellIcon >= 0 && spellEntry->SpellIconID != uint32(spellIcon)) continue; if (spellVisual >= 0 && spellEntry->SpellVisual[0] != uint32(spellVisual)) continue; if (category >= 0 && spellEntry->Category != uint32(category)) continue; if (effectIdx >= 0) { if (effectType >=0 && spellEntry->Effect[effectIdx] != uint32(effectType)) continue; if (auraType >=0 && spellEntry->EffectApplyAuraName[effectIdx] != uint32(auraType)) continue; } else { if (effectType >=0 && !IsSpellHaveEffect(spellEntry,SpellEffects(effectType))) continue; if (auraType >=0 && !IsSpellHaveAura(spellEntry,AuraType(auraType))) continue; } found = true; break; } if (!found) { if (effectIdx >= 0) sLog.outError("Spells '%s' not found for family %i (" I64FMT "," I32FMT ") icon(%i) visual(%i) category(%i) effect%d(%i) aura%d(%i) but used in %s", name.c_str(),family,familyMaskA,familyMaskB,spellIcon,spellVisual,category,effectIdx+1,effectType,effectIdx+1,auraType,code.c_str()); else sLog.outError("Spells '%s' not found for family %i (" I64FMT "," I32FMT ") icon(%i) visual(%i) category(%i) effect(%i) aura(%i) but used in %s", name.c_str(),family,familyMaskA,familyMaskB,spellIcon,spellVisual,category,effectType,auraType,code.c_str()); continue; } } } while( result->NextRow() ); delete result; sLog.outString(); sLog.outString( ">> Checked %u spells and %u spell masks", countSpells, countMasks ); } DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto, bool triggered) { // Explicit Diminishing Groups switch(spellproto->SpellFamilyName) { case SPELLFAMILY_GENERIC: // some generic arena related spells have by some strange reason MECHANIC_TURN if (spellproto->Mechanic == MECHANIC_TURN) return DIMINISHING_NONE; break; case SPELLFAMILY_MAGE: // Dragon's Breath if (spellproto->SpellIconID == 1548) return DIMINISHING_DISORIENT; break; case SPELLFAMILY_ROGUE: { // Blind if (spellproto->IsFitToFamilyMask(UI64LIT(0x00001000000))) return DIMINISHING_FEAR_CHARM_BLIND; // Cheap Shot else if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000000400))) return DIMINISHING_CHEAPSHOT_POUNCE; // Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags) else if (spellproto->SpellIconID == 163) return DIMINISHING_LIMITONLY; break; } case SPELLFAMILY_HUNTER: { // Freezing Trap & Freezing Arrow & Wyvern Sting if (spellproto->SpellIconID == 180 || spellproto->SpellIconID == 1721) return DIMINISHING_DISORIENT; break; } case SPELLFAMILY_WARLOCK: { // Curses/etc if (spellproto->IsFitToFamilyMask(UI64LIT(0x00080000000))) return DIMINISHING_LIMITONLY; break; } case SPELLFAMILY_PALADIN: { // Judgement of Justice - Limit to 10 seconds in PvP if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000100000))) return DIMINISHING_LIMITONLY; break; } case SPELLFAMILY_DRUID: { // Cyclone if (spellproto->IsFitToFamilyMask(UI64LIT(0x02000000000))) return DIMINISHING_CYCLONE; // Pounce else if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000020000))) return DIMINISHING_CHEAPSHOT_POUNCE; // Faerie Fire else if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000000400))) return DIMINISHING_LIMITONLY; break; } case SPELLFAMILY_WARRIOR: { // Hamstring - limit duration to 10s in PvP if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000000002))) return DIMINISHING_LIMITONLY; break; } case SPELLFAMILY_PRIEST: { // Shackle Undead if (spellproto->SpellIconID == 27) return DIMINISHING_DISORIENT; break; } case SPELLFAMILY_DEATHKNIGHT: { // Hungering Cold (no flags) if (spellproto->SpellIconID == 2797) return DIMINISHING_DISORIENT; break; } default: break; } // Get by mechanic uint32 mechanic = GetAllSpellMechanicMask(spellproto); if (!mechanic) return DIMINISHING_NONE; if (mechanic & ((1<<(MECHANIC_STUN-1))|(1<<(MECHANIC_SHACKLE-1)))) return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN; if (mechanic & ((1<<(MECHANIC_SLEEP-1))|(1<<(MECHANIC_FREEZE-1)))) return DIMINISHING_FREEZE_SLEEP; if (mechanic & ((1<<(MECHANIC_KNOCKOUT-1))|(1<<(MECHANIC_POLYMORPH-1))|(1<<(MECHANIC_SAPPED-1)))) return DIMINISHING_DISORIENT; if (mechanic & (1<<(MECHANIC_ROOT-1))) return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT; if (mechanic & ((1<<(MECHANIC_FEAR-1))|(1<<(MECHANIC_CHARM-1))|(1<<(MECHANIC_TURN-1)))) return DIMINISHING_FEAR_CHARM_BLIND; if (mechanic & ((1<<(MECHANIC_SILENCE-1))|(1<<(MECHANIC_INTERRUPT-1)))) return DIMINISHING_SILENCE; if (mechanic & (1<<(MECHANIC_DISARM-1))) return DIMINISHING_DISARM; if (mechanic & (1<<(MECHANIC_BANISH-1))) return DIMINISHING_BANISH; if (mechanic & (1<<(MECHANIC_HORROR-1))) return DIMINISHING_HORROR; return DIMINISHING_NONE; } int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto) { if(!IsDiminishingReturnsGroupDurationLimited(group)) return 0; // Explicit diminishing duration switch(spellproto->SpellFamilyName) { case SPELLFAMILY_HUNTER: { // Wyvern Sting if (spellproto->SpellFamilyFlags & UI64LIT(0x0000100000000000)) return 6000; break; } case SPELLFAMILY_PALADIN: { // Repentance - limit to 6 seconds in PvP if (spellproto->SpellFamilyFlags & UI64LIT(0x00000000004)) return 6000; break; } case SPELLFAMILY_DRUID: { // Faerie Fire - limit to 40 seconds in PvP (3.1) if (spellproto->SpellFamilyFlags & UI64LIT(0x00000000400)) return 40000; break; } default: break; } return 10000; } bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group) { switch(group) { case DIMINISHING_CONTROL_STUN: case DIMINISHING_TRIGGER_STUN: case DIMINISHING_CONTROL_ROOT: case DIMINISHING_TRIGGER_ROOT: case DIMINISHING_FEAR_CHARM_BLIND: case DIMINISHING_DISORIENT: case DIMINISHING_CHEAPSHOT_POUNCE: case DIMINISHING_FREEZE_SLEEP: case DIMINISHING_CYCLONE: case DIMINISHING_BANISH: case DIMINISHING_LIMITONLY: return true; default: return false; } return false; } DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group) { switch(group) { case DIMINISHING_CYCLONE: case DIMINISHING_TRIGGER_STUN: case DIMINISHING_CONTROL_STUN: return DRTYPE_ALL; case DIMINISHING_CONTROL_ROOT: case DIMINISHING_TRIGGER_ROOT: case DIMINISHING_FEAR_CHARM_BLIND: case DIMINISHING_DISORIENT: case DIMINISHING_SILENCE: case DIMINISHING_DISARM: case DIMINISHING_HORROR: case DIMINISHING_FREEZE_SLEEP: case DIMINISHING_BANISH: case DIMINISHING_CHEAPSHOT_POUNCE: return DRTYPE_PLAYER; default: break; } return DRTYPE_NONE; } bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 newArea) const { if(gender!=GENDER_NONE) { // not in expected gender if(!player || gender != player->getGender()) return false; } if(raceMask) { // not in expected race if(!player || !(raceMask & player->getRaceMask())) return false; } if(areaId) { // not in expected zone if(newZone!=areaId && newArea!=areaId) return false; } if(questStart) { // not in expected required quest state if(!player || (!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart)) return false; } if(questEnd) { // not in expected forbidden quest state if(!player || player->GetQuestRewardStatus(questEnd)) return false; } if(auraSpell) { // not have expected aura if(!player) return false; if(auraSpell > 0) // have expected aura return player->HasAura(auraSpell, EFFECT_INDEX_0); else // not have expected aura return !player->HasAura(-auraSpell, EFFECT_INDEX_0); } return true; } SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty, bool isRaid) { SpellDifficultyEntry const* spellDiff = sSpellDifficultyStore.LookupEntry(id); if (!spellDiff) return NULL; for (Difficulty diff = difficulty; diff >= REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, isRaid)) { if (spellDiff->spellId[diff]) return sSpellStore.LookupEntry(spellDiff->spellId[diff]); } return NULL; }
fgenesis/mangos
src/game/SpellMgr.cpp
C++
gpl-2.0
188,760
package mattparks.mods.space.venus.entities; import mattparks.mods.space.venus.items.GCVenusItems; import micdoodle8.mods.galacticraft.api.entity.IEntityBreathable; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySmallFireball; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class GCVenusEntityEvolvedBlaze extends EntityMob implements IEntityBreathable { private float heightOffset = 0.5F; private int heightOffsetUpdateTime; private int field_70846_g; public GCVenusEntityEvolvedBlaze(World par1World) { super(par1World); this.isImmuneToFire = true; this.experienceValue = 10; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(6.0D); } @Override protected void attackEntity(Entity par1Entity, float par2) { if (this.attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY) { this.attackTime = 20; this.attackEntityAsMob(par1Entity); } else if (par2 < 30.0F) { double d0 = par1Entity.posX - this.posX; double d1 = par1Entity.boundingBox.minY + par1Entity.height / 2.0F - (this.posY + this.height / 2.0F); double d2 = par1Entity.posZ - this.posZ; if (this.attackTime == 0) { ++this.field_70846_g; if (this.field_70846_g == 1) { this.attackTime = 60; this.func_70844_e(true); } else if (this.field_70846_g <= 4) { this.attackTime = 6; } else { this.attackTime = 100; this.field_70846_g = 0; this.func_70844_e(false); } if (this.field_70846_g > 1) { float f1 = MathHelper.sqrt_float(par2) * 0.5F; this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)this.posX, (int)this.posY, (int)this.posZ, 0); for (int i = 0; i < 1; ++i) { EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.worldObj, this, d0 + this.rand.nextGaussian() * f1, d1, d2 + this.rand.nextGaussian() * f1); entitysmallfireball.posY = this.posY + this.height / 2.0F + 0.5D; this.worldObj.spawnEntityInWorld(entitysmallfireball); } } } this.rotationYaw = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; this.hasAttacked = true; } } @Override public boolean canBreath() { return true; } @Override protected void dropFewItems(boolean par1, int par2) { if (par1) { int j = this.rand.nextInt(2 + par2); for (int k = 0; k < j; ++k) { this.dropItem(GCVenusItems.venusRod.itemID, 1); } } } @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, new Byte((byte)0)); } @Override protected void fall(float par1) {} public void func_70844_e(boolean par1) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (par1) { b0 = (byte)(b0 | 1); } else { b0 &= -2; } this.dataWatcher.updateObject(16, Byte.valueOf(b0)); } public boolean func_70845_n() { return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; } @Override public float getBrightness(float par1) { return 1.0F; } @Override @SideOnly(Side.CLIENT) public int getBrightnessForRender(float par1) { return 15728880; } @Override protected String getDeathSound() { return "mob.blaze.death"; } @Override protected int getDropItemId() { return GCVenusItems.venusRod.itemID; } @Override protected String getHurtSound() { return "mob.blaze.hit"; } @Override protected String getLivingSound() { return "mob.blaze.breathe"; } @Override public boolean isBurning() { return this.func_70845_n(); } @Override protected boolean isValidLightLevel() { return true; } @Override public void onLivingUpdate() { if (!this.worldObj.isRemote) { if (this.isWet()) { this.attackEntityFrom(DamageSource.drown, 1.0F); } --this.heightOffsetUpdateTime; if (this.heightOffsetUpdateTime <= 0) { this.heightOffsetUpdateTime = 100; this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F; } if (this.getEntityToAttack() != null && this.getEntityToAttack().posY + this.getEntityToAttack().getEyeHeight() > this.posY + this.getEyeHeight() + this.heightOffset) { this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; } } if (this.rand.nextInt(24) == 0) { this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.fire", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); } if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } for (int i = 0; i < 2; ++i) { this.worldObj.spawnParticle("largesmoke", this.posX + (this.rand.nextDouble() - 0.5D) * this.width, this.posY + this.rand.nextDouble() * this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * this.width, 0.0D, 0.0D, 0.0D); } super.onLivingUpdate(); } }
4Space/4-Space-1.6.4
common/mattparks/mods/space/venus/entities/GCVenusEntityEvolvedBlaze.java
Java
gpl-2.0
6,459
/* * Copyright (C) 2015 MediaTek Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef _KD_FLASHLIGHT_TYPE_H #define _KD_FLASHLIGHT_TYPE_H /* ------------------------*/ /* Basic Type Definitions */ /* -----------------------*/ typedef long LONG; typedef unsigned char UBYTE; typedef short SHORT; typedef signed char kal_int8; typedef signed short kal_int16; typedef signed int kal_int32; typedef long long kal_int64; typedef unsigned char kal_uint8; typedef unsigned short kal_uint16; typedef unsigned int kal_uint32; typedef unsigned long long kal_uint64; typedef char kal_char; typedef unsigned int *UINT32P; typedef volatile unsigned short *UINT16P; typedef volatile unsigned char *UINT8P; typedef unsigned char *U8P; typedef unsigned char U8; typedef signed char S8; typedef unsigned short U16; typedef signed short S16; typedef unsigned int U32; typedef signed int S32; typedef unsigned long long U64; typedef signed long long S64; /* typedef unsigned char bool; */ typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned int UINT32; typedef unsigned short USHORT; typedef signed char INT8; typedef signed short INT16; typedef signed int INT32; typedef unsigned int DWORD; typedef void VOID; typedef unsigned char BYTE; typedef float FLOAT; typedef char *LPCSTR; typedef short *LPWSTR; /* -----------*/ /* Constants */ /* ----------*/ #ifndef FALSE #define FALSE (0) #endif #ifndef TRUE #define TRUE (1) #endif #ifndef NULL #define NULL (0) #endif #ifndef BOOL typedef unsigned char BOOL; #endif typedef enum { KAL_FALSE = 0, KAL_TRUE = 1, } kal_bool; #endif /* _KD_FLASHLIGHT_TYPE_H */
nik124seleznev/ZC500TG
drivers/misc/mediatek/flashlight/inc/kd_flashlight_type.h
C
gpl-2.0
2,048
/** * OWASP Benchmark Project v1.1 * * This file is part of the Open Web Application Security Project (OWASP) * Benchmark Project. For details, please see * <a href="https://www.owasp.org/index.php/Benchmark">https://www.owasp.org/index.php/Benchmark</a>. * * The Benchmark 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. * * The Benchmark 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 * * @author Nick Sanidas <a href="https://www.aspectsecurity.com">Aspect Security</a> * @created 2015 */ package org.owasp.benchmark.testcode; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/BenchmarkTest15221") public class BenchmarkTest15221 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = request.getHeader("foo"); String bar = doSomething(param); try { float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat(); } catch (java.security.NoSuchAlgorithmException e) { System.out.println("Problem executing SecureRandom.nextFloat() - TestCase"); throw new ServletException(e); } response.getWriter().println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed"); } // end doPost private static String doSomething(String param) throws ServletException, IOException { String bar = "safe!"; java.util.HashMap<String,Object> map33682 = new java.util.HashMap<String,Object>(); map33682.put("keyA-33682", "a_Value"); // put some stuff in the collection map33682.put("keyB-33682", param.toString()); // put it in a collection map33682.put("keyC", "another_Value"); // put some stuff in the collection bar = (String)map33682.get("keyB-33682"); // get it back out bar = (String)map33682.get("keyA-33682"); // get safe value back out return bar; } }
iammyr/Benchmark
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest15221.java
Java
gpl-2.0
2,564
############################ -*- Mode: Makefile -*- ########################### ## Makefile --- ## Author : Manoj Srivastava ( srivasta@glaurung.stdc.com ) ## Created On : Sat Sep 15 22:07:31 2001 ## Created On Node : glaurung.stdc.com ## Last Modified By : Manoj Srivastava ## Last Modified On : Tue Oct 16 13:40:53 2001 ## Last Machine Used: ember.stdc.com ## Update Count : 14 ## Status : Unknown, Use with caution! ## HISTORY : ## Description : ## ############################################################################### # Copyright (C) 2001 System/Technology Development Corporation # This file is part of QoS Metrics Services (QMS) # # 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., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA # # You may contact System/Technology Development Corporation at # # System/Technology Development Corporation # Suite 500, Center for Innovative Technology, # 2214 Rock Hill Road, # Herndon, VA 20170 # (703) 476-0687 THIS_DIR:= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) SRCTOP := $(shell cd $(THIS_DIR)/../../../; pwd) PROJECTPRECONF=$(SRCTOP)/Config/qms.preconf #---------------------------------------------------------------------------- # Local macros #---------------------------------------------------------------------------- #CPPFLAGS += -DDEBUG=1L -DQMS_DO_TRACE=1 SRC = Makefile index.css #---------------------------------------------------------------------------- # Include macros and targets #---------------------------------------------------------------------------- include $(SRCTOP)/Config/project.tmpl #---------------------------------------------------------------------------- # Local targets #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # Dependencies #---------------------------------------------------------------------------- # Local Variables: # mode: makefile # comment-start: "#" # End:
srivasta/QMS
Documentation/Output/stylesheets/Makefile
Makefile
gpl-2.0
2,733
/*************************************************************** Copyright (C) 2013 Hewlett-Packard Development Company, L.P. Copyright (C) 2019 Siemens AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***************************************************************/ /** * \file * \brief Miscellaneous utility functions for maintagent */ #include "maintagent.h" /** * @brief Exit function. This does all cleanup and should be used * instead of calling exit() or main() return. * * @param exitVal Exit value * @returns void Calls exit() */ FUNCTION void exitNow(int exitVal) { if (pgConn) PQfinish(pgConn); if (dbManager) fo_dbManager_free(dbManager); if (exitVal) LOG_ERROR("Exiting with status %d", exitVal); fo_scheduler_disconnect(exitVal); exit(exitVal); } /* ExitNow() */
alpianon/fossology
src/maintagent/agent/utils.c
C
gpl-2.0
1,397
<!doctype html> <html> <head> <title>CatOrPillar</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style> canvas { cursor: default; outline: none; } </style> </head> <body> <div align="center" id="embed-com.nathanjent.catorpillar.GwtDefinition"></div> <script type="text/javascript" src="com.nathanjent.catorpillar.GwtDefinition/com.nathanjent.catorpillar.GwtDefinition.nocache.js"></script> </body> <script> function handleMouseDown(evt) { evt.preventDefault(); evt.stopPropagation(); evt.target.style.cursor = 'default'; } function handleMouseUp(evt) { evt.preventDefault(); evt.stopPropagation(); evt.target.style.cursor = ''; } document.getElementById('embed-com.nathanjent.catorpillar.GwtDefinition').addEventListener('mousedown', handleMouseDown, false); document.getElementById('embed-com.nathanjent.catorpillar.GwtDefinition').addEventListener('mouseup', handleMouseUp, false); </script> </html>
nathanjent/catorpillar
CatOrPillar-html/war/index.html
HTML
gpl-2.0
1,044
/* $Id$ */ /* * This file is part of OpenTTD. * OpenTTD 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. * OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file company_manager_face.h Functionality related to the company manager's face */ #ifndef COMPANY_MANAGER_FACE_H #define COMPANY_MANAGER_FACE_H #include "core/random_func.hpp" #include "core/bitmath_func.hpp" #include "table/sprites.h" #include "company_type.h" /** The gender/race combinations that we have faces for */ enum GenderEthnicity { GENDER_FEMALE = 0, ///< This bit set means a female, otherwise male ETHNICITY_BLACK = 1, ///< This bit set means black, otherwise white GE_WM = 0, ///< A male of Caucasian origin (white) GE_WF = 1 << GENDER_FEMALE, ///< A female of Caucasian origin (white) GE_BM = 1 << ETHNICITY_BLACK, ///< A male of African origin (black) GE_BF = 1 << ETHNICITY_BLACK | 1 << GENDER_FEMALE, ///< A female of African origin (black) GE_END, }; DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) ///< See GenderRace as a bitset /** Bitgroups of the CompanyManagerFace variable */ enum CompanyManagerFaceVariable { CMFV_GENDER, CMFV_ETHNICITY, CMFV_GEN_ETHN, CMFV_HAS_MOUSTACHE, CMFV_HAS_TIE_EARRING, CMFV_HAS_GLASSES, CMFV_EYE_COLOUR, CMFV_CHEEKS, CMFV_CHIN, CMFV_EYEBROWS, CMFV_MOUSTACHE, CMFV_LIPS, CMFV_NOSE, CMFV_HAIR, CMFV_JACKET, CMFV_COLLAR, CMFV_TIE_EARRING, CMFV_GLASSES, CMFV_END }; DECLARE_POSTFIX_INCREMENT(CompanyManagerFaceVariable) /** Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw */ struct CompanyManagerFaceBitsInfo { byte offset; ///< Offset in bits into the CompanyManagerFace byte length; ///< Number of bits used in the CompanyManagerFace byte valid_values[GE_END]; ///< The number of valid values per gender/ethnicity SpriteID first_sprite[GE_END]; ///< The first sprite per gender/ethnicity }; /** Lookup table for indices into the CompanyManagerFace, valid ranges and sprites */ static const CompanyManagerFaceBitsInfo _cmf_info[] = { /* Index off len WM WF BM BF WM WF BM BF * CMFV_GENDER */ { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = male, 1 = female /* CMFV_ETHNICITY */ { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = (Western-)Caucasian, 1 = African(-American)/Black /* CMFV_GEN_ETHN */ { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } }, ///< Shortcut to get/set gender _and_ ethnicity /* CMFV_HAS_MOUSTACHE */ { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } }, ///< Females do not have a moustache /* CMFV_HAS_TIE_EARRING */ { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } }, ///< Draw the earring for females or not. For males the tie is always drawn. /* CMFV_HAS_GLASSES */ { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< Whether to draw glasses or not /* CMFV_EYE_COLOUR */ { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } }, ///< Palette modification /* CMFV_CHEEKS */ { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } }, ///< Cheeks are only indexed by their gender/ethnicity /* CMFV_CHIN */ { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } }, /* CMFV_EYEBROWS */ { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } }, /* CMFV_MOUSTACHE */ { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } }, ///< Depends on CMFV_HAS_MOUSTACHE /* CMFV_LIPS */ { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } }, ///< Depends on !CMFV_HAS_MOUSTACHE /* CMFV_NOSE */ { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } }, ///< Depends on !CMFV_HAS_MOUSTACHE /* CMFV_HAIR */ { 20, 4, { 9, 5, 5, 4 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } }, /* CMFV_JACKET */ { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } }, /* CMFV_COLLAR */ { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } }, /* CMFV_TIE_EARRING */ { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } }, ///< Depends on CMFV_HAS_TIE_EARRING /* CMFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on CMFV_HAS_GLASSES }; /** Make sure the table's size is right. */ assert_compile(lengthof(_cmf_info) == CMFV_END); /** * Gets the company manager's face bits for the given company manager's face variable * @param cmf the face to extract the bits from * @param cmfv the face variable to get the data of * @param ge the gender and ethnicity of the face * @pre _cmf_info[cmfv].valid_values[ge] != 0 * @return the requested bits */ static inline uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { assert(_cmf_info[cmfv].valid_values[ge] != 0); return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length); } /** * Sets the company manager's face bits for the given company manager's face variable * @param cmf the face to write the bits to * @param cmfv the face variable to write the data of * @param ge the gender and ethnicity of the face * @param val the new value * @pre val < _cmf_info[cmfv].valid_values[ge] */ static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) { assert(val < _cmf_info[cmfv].valid_values[ge]); SB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length, val); } /** * Increase/Decrease the company manager's face variable by the given amount. * If the new value greater than the max value for this variable it will be set to 0. * Or is it negativ (< 0) it will be set to max value. * * @param cmf the company manager face to write the bits to * @param cmfv the company manager face variable to write the data of * @param ge the gender and ethnicity of the company manager's face * @param amount the amount which change the value * * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge] */ static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount) { int8 val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv /* scales the new value to the correct scope */ if (val >= _cmf_info[cmfv].valid_values[ge]) { val = 0; } else if (val < 0) { val = _cmf_info[cmfv].valid_values[ge] - 1; } SetCompanyManagerFaceBits(cmf, cmfv, ge, val); // save the new value } /** * Checks whether the company manager's face bits have a valid range * @param cmf the face to extract the bits from * @param cmfv the face variable to get the data of * @param ge the gender and ethnicity of the face * @return true if and only if the bits are valid */ static inline bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length) < _cmf_info[cmfv].valid_values[ge]; } /** * Scales a company manager's face bits variable to the correct scope * @param cmfv the face variable to write the data of * @param ge the gender and ethnicity of the face * @param val the to value to scale * @pre val < (1U << _cmf_info[cmfv].length), i.e. val has a value of 0..2^(bits used for this variable)-1 * @return the scaled value */ static inline uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) { assert(val < (1U << _cmf_info[cmfv].length)); return (val * _cmf_info[cmfv].valid_values[ge]) >> _cmf_info[cmfv].length; } /** * Scales all company manager's face bits to the correct scope * * @param cmf the company manager's face to write the bits to */ static inline void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf) { IncreaseCompanyManagerFaceBits(cmf, CMFV_ETHNICITY, GE_WM, 0); // scales the ethnicity GenderEthnicity ge = (GenderEthnicity)GB(cmf, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // gender & ethnicity of the face /* Is a male face with moustache. Need to reduce CPU load in the loop. */ bool is_moust_male = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0; for (CompanyManagerFaceVariable cmfv = CMFV_EYE_COLOUR; cmfv < CMFV_END; cmfv++) { // scales all other variables /* The moustache variable will be scaled only if it is a male face with has a moustache */ if (cmfv != CMFV_MOUSTACHE || is_moust_male) { IncreaseCompanyManagerFaceBits(cmf, cmfv, ge, 0); } } } /** * Make a random new face. * If it is for the advanced company manager's face window then the new face have the same gender * and ethnicity as the old one, else the gender is equal and the ethnicity is random. * * @param cmf the company manager's face to write the bits to * @param ge the gender and ethnicity of the old company manager's face * @param adv if it for the advanced company manager's face window * * @pre scale 'ge' to a valid gender/ethnicity combination */ static inline void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv) { cmf = InteractiveRandom(); // random all company manager's face bits /* scale ge: 0 == GE_WM, 1 == GE_WF, 2 == GE_BM, 3 == GE_BF (and maybe in future: ...) */ ge = (GenderEthnicity)((uint)ge % GE_END); /* set the gender (and ethnicity) for the new company manager's face */ if (adv) { SetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, ge, ge); } else { SetCompanyManagerFaceBits(cmf, CMFV_GENDER, ge, HasBit(ge, GENDER_FEMALE)); } /* scales all company manager's face bits to the correct scope */ ScaleAllCompanyManagerFaceBits(cmf); } /** * Gets the sprite to draw for the given company manager's face variable * @param cmf the face to extract the data from * @param cmfv the face variable to get the sprite of * @param ge the gender and ethnicity of the face * @pre _cmf_info[cmfv].valid_values[ge] != 0 * @return sprite to draw */ static inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { assert(_cmf_info[cmfv].valid_values[ge] != 0); return _cmf_info[cmfv].first_sprite[ge] + GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length); } void DrawCompanyManagerFace(CompanyManagerFace face, int colour, int x, int y); #endif /* COMPANY_MANAGER_FACE_H */
koreapyj/openttd-yacd
src/company_manager_face.h
C
gpl-2.0
11,038
/* gEDA - GPL Electronic Design Automation * libgeda - gEDA's library * Copyright (C) 1998-2010 Ales Hvezda * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details) * * 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 */ /*! \file o_picture.c * \brief functions for the picture object */ #include <config.h> #include <stdio.h> #ifdef HAVE_STRING_H #include <string.h> #endif #include <math.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include <gio/gio.h> #include "libgeda_priv.h" /*! \brief Create picture OBJECT from character string. * \par Function Description * Parses \a first_line and subsequent lines from \a tb, and returns * a newly-created picture #OBJECT. * * \param [in] toplevel The TOPLEVEL object. * \param [in] first_line Character string with picture description. * \param [in] tb Text buffer to load embedded data from. * \param [in] release_ver libgeda release version number. * \param [in] fileformat_ver libgeda file format version number. * \return A pointer to the new picture object. */ OBJECT *o_picture_read (TOPLEVEL *toplevel, const char *first_line, TextBuffer *tb, unsigned int release_ver, unsigned int fileformat_ver) { OBJECT *new_obj; int x1, y1; int width, height, angle; int mirrored, embedded; int num_conv; gchar type; gchar *line = NULL; gchar *filename; gchar *file_content = NULL; guint file_length = 0; num_conv = sscanf(first_line, "%c %d %d %d %d %d %d %d\n", &type, &x1, &y1, &width, &height, &angle, &mirrored, &embedded); if (num_conv != 8) { s_log_message (_("Error reading picture definition line: %s.\n"), first_line); } if (width == 0 || height == 0) { s_log_message(_("Found a zero width/height picture [ %c %d %d %d %d ]\n"), type, x1, y1, width, height); } if ( (mirrored > 1) || (mirrored < 0)) { s_log_message(_("Found a picture with a wrong 'mirrored' parameter: %d.\n"), mirrored); s_log_message(_("Setting mirrored to 0\n")); mirrored = 0; } if ( (embedded > 1) || (embedded < 0)) { s_log_message(_("Found a picture with a wrong 'embedded' parameter: %d.\n"), embedded); s_log_message(_("Setting embedded to 0\n")); embedded = 0; } switch(angle) { case(0): case(90): case(180): case(270): break; default: s_log_message(_("Found an unsupported picture angle [ %d ]\n"), angle); s_log_message(_("Setting angle to 0\n")); angle=0; break; } filename = g_strdup(s_textbuffer_next_line(tb)); filename = remove_last_nl(filename); /* Handle empty filenames */ if (strlen (filename) == 0) { s_log_message (_("Found an image with no filename.")); g_free (filename); } if (embedded == 1) { GString *encoded_picture=g_string_new(""); char finished = 0; /* Read the encoded picture */ do { line = s_textbuffer_next_line(tb); if (line == NULL) break; if (g_strcasecmp(line, ".\n") != 0) { encoded_picture = g_string_append (encoded_picture, line); } else { finished = 1; } } while (finished == 0); /* Decode the picture */ file_content = s_encoding_base64_decode(encoded_picture->str, encoded_picture->len, &file_length); if (encoded_picture != NULL) { g_string_free (encoded_picture, TRUE); } if (file_content == NULL) { s_log_message (_("Failed to load image from embedded data [%s]: %s\n"), filename, _("Base64 decoding failed.")); s_log_message (_("Falling back to file loading. Picture unembedded.\n")); embedded = 0; } } /* create the picture */ /* The picture is described by its upper left and lower right corner */ new_obj = o_picture_new (toplevel, file_content, file_length, filename, type, x1, y1+height, x1+width, y1, angle, mirrored, embedded); g_free (file_content); g_free (filename); return new_obj; } /*! \brief Create a character string representation of a picture OBJECT. * \par Function Description * This function formats a string in the buffer <B>*buff</B> to describe * the picture object <B>*object</B>. * * \param [in] toplevel a TOPLEVEL structure * \param [in] object Picture OBJECT to create string from. * \return A pointer to the picture OBJECT character string. * * \note * Caller must g_free returned character string. * */ char *o_picture_save(TOPLEVEL *toplevel, OBJECT *object) { int width, height, x1, y1; gchar *encoded_picture=NULL; gchar *out=NULL; guint encoded_picture_length; const gchar *filename = NULL; /* calculate the width and height of the box */ width = abs(object->picture->lower_x - object->picture->upper_x); height = abs(object->picture->upper_y - object->picture->lower_y); /* calculate the lower left corner of the box */ x1 = object->picture->upper_x; y1 = object->picture->upper_y - height; /* move the origin to 0, 0*/ #if DEBUG printf("picture: %d %d %d %d\n", x1, y1, width, height); #endif /* Encode the picture if it's embedded */ if (o_picture_is_embedded (toplevel, object)) { encoded_picture = s_encoding_base64_encode( (char *)object->picture->file_content, object->picture->file_length, &encoded_picture_length, TRUE); if (encoded_picture == NULL) { s_log_message(_("ERROR: o_picture_save: unable to encode the picture.\n")); } } /* Cope with null filename */ filename = o_picture_get_filename (toplevel, object); if (filename == NULL) filename = ""; if (o_picture_is_embedded (toplevel, object) && encoded_picture != NULL) { out = g_strdup_printf("%c %d %d %d %d %d %c %c\n%s\n%s\n%s", object->type, x1, y1, width, height, object->picture->angle, /* Convert the (0,1) chars to ASCII */ (object->picture->mirrored)+0x30, '1', filename, encoded_picture, "."); } else { out = g_strdup_printf("%c %d %d %d %d %d %c %c\n%s", object->type, x1, y1, width, height, object->picture->angle, /* Convert the (0,1) chars to ASCII */ (object->picture->mirrored)+0x30, '0', filename); } g_free(encoded_picture); return(out); } /*! \brief Create a picture object. * \par Function Description * This function creates a new object representing a picture. * * The picture is described by its upper left corner (\a x1, \a y1) * and its lower right corner (\a x2, \ay2). The \a type parameter * must be equal to #OBJ_PICTURE. * * If \a file_content is non-NULL, it must be a pointer to a buffer * containing raw image data. If loading data from \a file_content * is unsuccessful, and \a filename is non-NULL, an image will * attempt to be loaded from \a filename. Otherwise, the picture * object will be initially empty. * * \param [in] toplevel The TOPLEVEL object. * \param [in] file_content Raw data of the image file, or NULL. * \param [in] file_length Length of raw data buffer * \param [in] filename File name backing this picture, or NULL. * \param [in] type Must be OBJ_PICTURE. * \param [in] x1 Upper x coordinate. * \param [in] y1 Upper y coordinate. * \param [in] x2 Lower x coordinate. * \param [in] y2 Lower y coordinate. * \param [in] angle Picture rotation angle. * \param [in] mirrored Whether the image should be mirrored or not. * \param [in] embedded Whether the embedded flag should be set or not. * \return A pointer to a new picture #OBJECT. */ OBJECT *o_picture_new (TOPLEVEL *toplevel, const gchar *file_content, gsize file_length, const gchar *filename, char type, int x1, int y1, int x2, int y2, int angle, int mirrored, int embedded) { OBJECT *new_node; PICTURE *picture; /* create the object */ new_node = s_basic_new_object(type, "picture"); picture = (PICTURE *) g_malloc0 (sizeof(PICTURE)); new_node->picture = picture; /* describe the picture with its upper left and lower right corner */ picture->upper_x = (x1 > x2) ? x2 : x1; picture->upper_y = (y1 > y2) ? y1 : y2; picture->lower_x = (x1 > x2) ? x1 : x2; picture->lower_y = (y1 > y2) ? y2 : y1; picture->pixbuf = NULL; picture->file_content = NULL; picture->file_length = 0; picture->ratio = abs ((double) (x1 - x2) / (y1 - y2)); picture->filename = g_strdup (filename); picture->angle = angle; picture->mirrored = mirrored; picture->embedded = embedded; if (file_content != NULL) { GError *error = NULL; if (!o_picture_set_from_buffer (toplevel, new_node, filename, file_content, file_length, &error)) { s_log_message (_("Failed to load buffer image [%s]: %s\n"), filename, error->message); g_error_free (error); /* Force the data into the object anyway, so as to prevent data * loss of embedded images. */ picture->file_content = g_memdup (file_content, file_length); picture->file_length = file_length; } } if (picture->pixbuf == NULL && filename != NULL) { GError *error = NULL; if (!o_picture_set_from_file (toplevel, new_node, filename, &error)) { s_log_message (_("Failed to load image from [%s]: %s\n"), filename, error->message); g_error_free (error); } } /* compute the bounding picture */ o_picture_recalc(toplevel, new_node); return new_node; } /*! \brief Recalculate picture bounding box. * \par Function Description * This function recalculates the bounding box of the <B>o_current</B> * parameter picture object. * * \param [in] toplevel The TOPLEVEL object. * \param [in,out] o_current Picture OBJECT to be recalculated. */ void o_picture_recalc(TOPLEVEL *toplevel, OBJECT *o_current) { int left, top, right, bottom; if (o_current->picture == NULL) { return; } /* update the bounding picture - world units */ world_get_picture_bounds(toplevel, o_current, &left, &top, &right, &bottom); o_current->w_left = left; o_current->w_top = top; o_current->w_right = right; o_current->w_bottom = bottom; o_current->w_bounds_valid = TRUE; } /*! \brief Get picture bounding rectangle in WORLD coordinates. * \par Function Description * This function sets the <B>left</B>, <B>top</B>, <B>right</B> and * <B>bottom</B> parameters to the boundings of the picture object * described in <B>*picture</B> in WORLD units. * * \param [in] toplevel The TOPLEVEL object. * \param [in] object Picture OBJECT to read coordinates from. * \param [out] left Left picture coordinate in WORLD units. * \param [out] top Top picture coordinate in WORLD units. * \param [out] right Right picture coordinate in WORLD units. * \param [out] bottom Bottom picture coordinate in WORLD units. */ void world_get_picture_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom) { *left = min(object->picture->upper_x, object->picture->lower_x); *top = min(object->picture->upper_y, object->picture->lower_y); *right = max(object->picture->upper_x, object->picture->lower_x); *bottom = max(object->picture->upper_y, object->picture->lower_y); } /*! \brief get the position of the left bottom point * \par Function Description * This function gets the position of the bottom left point of a picture object. * * \param [in] toplevel The toplevel environment. * \param [out] x pointer to the x-position * \param [out] y pointer to the y-position * \param [in] object The object to get the position. * \return TRUE if successfully determined the position, FALSE otherwise */ gboolean o_picture_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object) { *x = min(object->picture->lower_x, object->picture->upper_x); *y = min(object->picture->lower_y, object->picture->upper_y); return TRUE; } /*! \brief Get the width/height ratio of an image. * \par Function Description * Returns the width/height ratio of picture \a object, taking the * image rotation into account. * * \param toplevel The current #TOPLEVEL. * \param object Picture #OBJECT to inspect. * \return width/height ratio for \a object. */ double o_picture_get_ratio (TOPLEVEL *toplevel, OBJECT *object) { g_return_val_if_fail (object != NULL, 1); g_return_val_if_fail (object->picture != NULL, 1); /* The effective ratio varies depending on the rotation of the * image. */ switch (object->picture->angle) { case 0: case 180: return object->picture->ratio; case 90: case 270: return 1.0 / object->picture->ratio; default: g_critical (_("Picture %p has invalid angle %i\n"), object, object->picture->angle); } return 0; } /*! \brief Modify the description of a picture OBJECT. * \par Function Description * This function modifies the coordinates of one of the four corner of * the picture. The new coordinates of the corner identified by * <B>whichone</B> are given by <B>x</B> and <B>y</B> in world unit. * * The coordinates of the corner is modified in the world coordinate system. * Screen coordinates and boundings are then updated. * * \param [in] toplevel The TOPLEVEL object. * \param [in,out] object Picture OBJECT to modify. * \param [in] x New x coordinate. * \param [in] y New y coordinate. * \param [in] whichone Which picture parameter to modify. * * <B>whichone</B> can have the following values: * <DL> * <DT>*</DT><DD>PICTURE_UPPER_LEFT * <DT>*</DT><DD>PICTURE_LOWER_LEFT * <DT>*</DT><DD>PICTURE_UPPER_RIGHT * <DT>*</DT><DD>PICTURE_LOWER_RIGHT * </DL> */ void o_picture_modify(TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone) { int tmp; double ratio = o_picture_get_ratio (toplevel, object); o_emit_pre_change_notify (toplevel, object); /* change the position of the selected corner */ switch(whichone) { case PICTURE_UPPER_LEFT: object->picture->upper_x = x; tmp = abs(object->picture->upper_x - object->picture->lower_x) / ratio; if (y < object->picture->lower_y) { tmp = -tmp; } object->picture->upper_y = object->picture->lower_y + tmp; break; case PICTURE_LOWER_LEFT: object->picture->upper_x = x; tmp = abs(object->picture->upper_x - object->picture->lower_x) / ratio; if (y > object->picture->upper_y) { tmp = -tmp; } object->picture->lower_y = object->picture->upper_y - tmp; break; case PICTURE_UPPER_RIGHT: object->picture->lower_x = x; tmp = abs(object->picture->upper_x - object->picture->lower_x) / ratio; if (y < object->picture->lower_y) { tmp = -tmp; } object->picture->upper_y = object->picture->lower_y + tmp; break; case PICTURE_LOWER_RIGHT: object->picture->lower_x = x; tmp = abs(object->picture->upper_x - object->picture->lower_x) / ratio; if (y > object->picture->upper_y) { tmp = -tmp; } object->picture->lower_y = object->picture->upper_y - tmp; break; default: return; } /* need to update the upper left and lower right corners */ if(object->picture->upper_x > object->picture->lower_x) { tmp = object->picture->upper_x; object->picture->upper_x = object->picture->lower_x; object->picture->lower_x = tmp; } if(object->picture->upper_y < object->picture->lower_y) { tmp = object->picture->upper_y; object->picture->upper_y = object->picture->lower_y; object->picture->lower_y = tmp; } /* recalculate the screen coords and the boundings */ o_picture_recalc(toplevel, object); o_emit_change_notify (toplevel, object); } /*! \brief Modify a picture object's coordinates. * \par Function Description * Modifies the coordinates of all four corners of a picture \a * object. The picture is adjusted to fit the rectangle enclosed by * the points (\a x1, \a y1) and (\a x2, \a y2), and scaled as large * as possible to still fit within that rectangle. * * \param [in] toplevel current #TOPLEVEL. * \param [in,out] object picture #OBJECT to be modified. * \param [in] x1 x coordinate of first corner of box. * \param [in] y1 y coordinate of first corner of box. * \param [in] x2 x coordinate of second corner of box. * \param [in] y2 y coordinate of second corner of box. */ void o_picture_modify_all (TOPLEVEL *toplevel, OBJECT *object, int x1, int y1, int x2, int y2) { o_emit_pre_change_notify (toplevel, object); /* Normalise the requested rectangle. */ object->picture->lower_x = (x1 > x2) ? x1 : x2; object->picture->lower_y = (y1 > y2) ? y2 : y1; object->picture->upper_x = (x1 > x2) ? x2 : x1; object->picture->upper_y = (y1 > y2) ? y1 : y2; /* recalculate the world coords and bounds */ o_box_recalc(toplevel, object); o_emit_change_notify (toplevel, object); } /*! \brief Rotate picture OBJECT using WORLD coordinates. * \par Function Description * This function rotates the picture described by <B>*object</B> around * the (<B>world_centerx</B>, <B>world_centery</B>) point by <B>angle</B> * degrees. * The center of rotation is in world units. * * \param [in] toplevel The TOPLEVEL object. * \param [in] world_centerx Rotation center x coordinate in * WORLD units. * \param [in] world_centery Rotation center y coordinate in * WORLD units. * \param [in] angle Rotation angle in degrees (See note below). * \param [in,out] object Picture OBJECT to rotate. */ void o_picture_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) { int newx1, newy1; int newx2, newy2; /* Only 90 degree multiple and positive angles are allowed. */ /* angle must be positive */ if(angle < 0) angle = -angle; /* angle must be a 90 multiple or no rotation performed */ if((angle % 90) != 0) return; object->picture->angle = ( object->picture->angle + angle ) % 360; /* The center of rotation (<B>world_centerx</B>, <B>world_centery</B>) is * translated to the origin. The rotation of the upper left and lower * right corner are then performed. Finally, the rotated picture is * translated back to its previous location. */ /* translate object to origin */ object->picture->upper_x -= world_centerx; object->picture->upper_y -= world_centery; object->picture->lower_x -= world_centerx; object->picture->lower_y -= world_centery; /* rotate the upper left corner of the picture */ rotate_point_90(object->picture->upper_x, object->picture->upper_y, angle, &newx1, &newy1); /* rotate the lower left corner of the picture */ rotate_point_90(object->picture->lower_x, object->picture->lower_y, angle, &newx2, &newy2); /* reorder the corners after rotation */ object->picture->upper_x = min(newx1,newx2); object->picture->upper_y = max(newy1,newy2); object->picture->lower_x = max(newx1,newx2); object->picture->lower_y = min(newy1,newy2); /* translate object back to normal position */ object->picture->upper_x += world_centerx; object->picture->upper_y += world_centery; object->picture->lower_x += world_centerx; object->picture->lower_y += world_centery; /* recalc boundings and screen coords */ o_picture_recalc(toplevel, object); } /*! \brief Mirror a picture using WORLD coordinates. * \par Function Description * This function mirrors the picture from the point * (<B>world_centerx</B>,<B>world_centery</B>) in world unit. * * The picture is first translated to the origin, then mirrored and * finally translated back at its previous position. * * \param [in] toplevel The TOPLEVEL object. * \param [in] world_centerx Origin x coordinate in WORLD units. * \param [in] world_centery Origin y coordinate in WORLD units. * \param [in,out] object Picture OBJECT to mirror. */ void o_picture_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) { int newx1, newy1; int newx2, newy2; /* Set info in object. Sometimes it's necessary to change the * rotation angle as well as the mirror flag. */ object->picture->mirrored = !object->picture->mirrored; switch (object->picture->angle) { case 90: object->picture->angle = 270; break; case 270: object->picture->angle = 90; break; } /* translate object to origin */ object->picture->upper_x -= world_centerx; object->picture->upper_y -= world_centery; object->picture->lower_x -= world_centerx; object->picture->lower_y -= world_centery; /* mirror the corners */ newx1 = -object->picture->upper_x; newy1 = object->picture->upper_y; newx2 = -object->picture->lower_x; newy2 = object->picture->lower_y; /* reorder the corners */ object->picture->upper_x = min(newx1,newx2); object->picture->upper_y = max(newy1,newy2); object->picture->lower_x = max(newx1,newx2); object->picture->lower_y = min(newy1,newy2); /* translate back in position */ object->picture->upper_x += world_centerx; object->picture->upper_y += world_centery; object->picture->lower_x += world_centerx; object->picture->lower_y += world_centery; /* recalc boundings and screen coords */ o_picture_recalc(toplevel, object); } /*! \brief Translate a picture position in WORLD coordinates by a delta. * \par Function Description * This function applies a translation of (<B>x1</B>,<B>y1</B>) to the picture * described by <B>*object</B>. <B>x1</B> and <B>y1</B> are in world units. * * \param [in] toplevel The TOPLEVEL object. * \param [in] dx x distance to move. * \param [in] dy y distance to move. * \param [in,out] object Picture OBJECT to translate. */ void o_picture_translate_world(TOPLEVEL *toplevel, int dx, int dy, OBJECT *object) { if (object == NULL) printf("btw NO!\n"); /* Do world coords */ object->picture->upper_x = object->picture->upper_x + dx; object->picture->upper_y = object->picture->upper_y + dy; object->picture->lower_x = object->picture->lower_x + dx; object->picture->lower_y = object->picture->lower_y + dy; /* recalc the screen coords and the bounding picture */ o_picture_recalc(toplevel, object); } /*! \brief Create a copy of a picture. * \par Function Description * This function creates a verbatim copy of the object pointed by * <B>o_current</B> describing a picture. * * \param [in] toplevel The TOPLEVEL object. * \param [in] object Picture OBJECT to copy. * \return The new OBJECT */ OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *object) { OBJECT *new_node; PICTURE *picture; /* create the object */ new_node = s_basic_new_object(object->type, "picture"); picture = g_malloc(sizeof(PICTURE)); new_node->picture = picture; new_node->color = object->color; new_node->selectable = object->selectable; /* describe the picture with its upper left and lower right corner */ picture->upper_x = object->picture->upper_x; picture->upper_y = object->picture->upper_y; picture->lower_x = object->picture->lower_x; picture->lower_y = object->picture->lower_y; if (object->picture->file_content != NULL) { picture->file_content = g_memdup (object->picture->file_content, object->picture->file_length); } else { picture->file_content = NULL; } picture->file_length = object->picture->file_length; picture->filename = g_strdup (object->picture->filename); picture->ratio = object->picture->ratio; picture->angle = object->picture->angle; picture->mirrored = object->picture->mirrored; picture->embedded = object->picture->embedded; /* Get the picture data */ picture->pixbuf = o_picture_get_pixbuf (toplevel, object); /* compute the bounding picture */ o_picture_recalc(toplevel, new_node); return new_node; } /*! \brief Get RGB data from image. * \par Function Description * This function returns the RGB data of the given image. * Function taken from the DIA source code (http://www.gnome.org/projects/dia) * and licensed under the GNU GPL version 2. * * \param [in] image GdkPixbuf image to read RGB data from. * \return Array of rgb data from image. * * \note * Caller must g_free returned guint8 array. */ static guint8 * o_picture_rgb_data(GdkPixbuf *image) { int width = gdk_pixbuf_get_width(image); int height = gdk_pixbuf_get_height(image); int rowstride = gdk_pixbuf_get_rowstride(image); int size = height*rowstride; guint8 *rgb_pixels = g_malloc(size); if (gdk_pixbuf_get_has_alpha(image)) { guint8 *pixels = gdk_pixbuf_get_pixels(image); int i, j; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { rgb_pixels[i*rowstride+j*3] = pixels[i*rowstride+j*4]; rgb_pixels[i*rowstride+j*3+1] = pixels[i*rowstride+j*4+1]; rgb_pixels[i*rowstride+j*3+2] = pixels[i*rowstride+j*4+2]; } } return rgb_pixels; } else { guint8 *pixels = gdk_pixbuf_get_pixels(image); g_memmove(rgb_pixels, pixels, height*rowstride); return rgb_pixels; } } /*! \brief Get mask data from image. * \par Function Description * This function returns the mask data of the given image. * Function taken from the DIA source code (http://www.gnome.org/projects/dia) * and licensed under the GNU GPL version 2. * * \param [in] image GdkPixbuf image to get mask data from. * \return Array of mask data from image. * * \note * Caller must g_free returned guint8 array. */ static guint8 * o_picture_mask_data(GdkPixbuf *image) { guint8 *pixels; guint8 *mask; int i, size; if (!gdk_pixbuf_get_has_alpha(image)) { return NULL; } pixels = gdk_pixbuf_get_pixels(image); size = gdk_pixbuf_get_width(image)* gdk_pixbuf_get_height(image); mask = g_malloc(size); /* Pick every fourth byte (the alpha channel) into mask */ for (i = 0; i < size; i++) mask[i] = pixels[i*4+3]; return mask; } /*! \brief Print picture to Postscript document. * \par Function Description * This function prints a picture object. The picture is defined by the * coordinates of its upper left corner in (<B>x</B>,<B>y</B>) and its width * and height given by the <B>width</B> and <B>height</B> parameters. * * If the picture object was unable to be loaded, prints a crossed * box of the same dimensions. * * The Postscript document is defined by the file pointer <B>fp</B>. * Function based on the DIA source code (http://www.gnome.org/projects/dia) * and licensed under the GNU GPL version 2. * * All dimensions are in mils. * * \param [in] toplevel The TOPLEVEL object. * \param [in] fp FILE pointer to Postscript document. * \param [in] o_current Picture OBJECT to write to document. * \param [in] origin_x Page x coordinate to place picture OBJECT. * \param [in] origin_y Page y coordinate to place picture OBJECT. */ void o_picture_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y) { int x1, y1, x, y; int height, width; GdkPixbuf* image = o_picture_get_pixbuf (toplevel, o_current); int img_width, img_height, img_rowstride; guint8 *rgb_data; guint8 *mask_data; /* calculate the width and height of the box */ width = abs(o_current->picture->lower_x - o_current->picture->upper_x); height = abs(o_current->picture->upper_y - o_current->picture->lower_y); /* calculate the origin of the box */ x1 = o_current->picture->upper_x; y1 = o_current->picture->upper_y; /* If the image failed to load, try to get hold of the fallback * pixbuf. */ if (image == NULL) image = o_picture_get_fallback_pixbuf (toplevel); /* If the image failed to load, draw a box in the default color with a * cross in it. */ if (image == NULL) { int line_width = (toplevel->line_style == THICK) ? LINE_WIDTH : 2; o_box_print_solid (toplevel, fp, x1, y1, width, height, DEFAULT_COLOR, line_width, -1, -1, -1, -1); o_line_print_solid (toplevel, fp, x1, y1, x1+width, y1+height, DEFAULT_COLOR, line_width, -1, -1, -1, -1); o_line_print_solid (toplevel, fp, x1+width, y1, x1, y1+height, DEFAULT_COLOR, line_width, -1, -1, -1, -1); return; } img_width = gdk_pixbuf_get_width(image); img_rowstride = gdk_pixbuf_get_rowstride(image); img_height = gdk_pixbuf_get_height(image); rgb_data = o_picture_rgb_data(image); mask_data = o_picture_mask_data(image); fprintf(fp, "gsave\n"); /* color output only */ fprintf(fp, "/pix %i string def\n", img_width * 3); fprintf(fp, "%i %i 8\n", img_width, img_height); fprintf(fp, "%i %i translate\n", x1, y1); fprintf(fp, "%i %i scale\n", width, height); fprintf(fp, "[%i 0 0 -%i 0 0]\n", img_width, img_height); fprintf(fp, "{currentfile pix readhexstring pop}\n"); fprintf(fp, "false 3 colorimage\n"); fprintf(fp, "\n"); if (mask_data) { for (y = 0; y < img_height; y++) { for (x = 0; x < img_width; x++) { int i = y*img_rowstride+x*3; int m = y*img_width+x; fprintf(fp, "%02x", 255-(mask_data[m]*(255-rgb_data[i])/255)); fprintf(fp, "%02x", 255-(mask_data[m]*(255-rgb_data[i+1])/255)); fprintf(fp, "%02x", 255-(mask_data[m]*(255-rgb_data[i+2])/255)); } fprintf(fp, "\n"); } } else { for (y = 0; y < img_height; y++) { for (x = 0; x < img_width; x++) { int i = y*img_rowstride+x*3; fprintf(fp, "%02x", (int)(rgb_data[i])); fprintf(fp, "%02x", (int)(rgb_data[i+1])); fprintf(fp, "%02x", (int)(rgb_data[i+2])); } fprintf(fp, "\n"); } } fprintf(fp, "grestore\n"); fprintf(fp, "\n"); g_object_unref (image); g_free(rgb_data); g_free(mask_data); } /*! \brief Embed the image file associated with a picture * \par Function Description * Verify that a picture has valid data associated with it, and if so, * mark it to be embedded. * * \param [in] toplevel The TOPLEVEL object. * \param [in] object The picture OBJECT to embed */ void o_picture_embed (TOPLEVEL *toplevel, OBJECT *object) { const gchar *filename = o_picture_get_filename (toplevel, object); gchar *basename; if (o_picture_is_embedded (toplevel, object)) return; if (object->picture->file_content == NULL) { s_log_message (_("Picture [%s] has no image data.\n"), filename); s_log_message (_("Falling back to file loading. Picture is still unembedded.\n")); object->picture->embedded = 0; return; } object->picture->embedded = 1; basename = g_path_get_basename (filename); s_log_message (_("Picture [%s] has been embedded\n"), basename); g_free (basename); } /*! \brief Unembed a picture, reloading the image from disk * \par Function Description * Verify that the file associated with \a object exists on disk and * is usable, and if so, reload the picture and mark it as unembedded. * * \param [in] toplevel The TOPLEVEL object. * \param [in] object The picture OBJECT to unembed */ void o_picture_unembed (TOPLEVEL *toplevel, OBJECT *object) { GError *err = NULL; const gchar *filename = o_picture_get_filename (toplevel, object); gchar *basename; if (!o_picture_is_embedded (toplevel, object)) return; o_picture_set_from_file (toplevel, object, filename, &err); if (err != NULL) { s_log_message (_("Failed to load image from file [%s]: %s\n"), filename, err->message); s_log_message (_("Picture is still embedded.\n")); g_error_free (err); return; } object->picture->embedded = 0; basename = g_path_get_basename(filename); s_log_message (_("Picture [%s] has been unembedded\n"), basename); g_free(basename); } /*! \brief Calculates the distance between the given point and the closest * point in the picture. * * Interrior points within the picture return a distance of zero. * * \param [in] object The picture OBJECT. * \param [in] x The x coordinate of the given point. * \param [in] y The y coordinate of the given point. * \param [in] force_solid If true, force treating the object as solid. * \return The shortest distance from the object to the point. With an * invalid parameter, this function returns G_MAXDOUBLE. */ double o_picture_shortest_distance (OBJECT *object, int x, int y, int force_solid) { double dx, dy; double x1, y1, x2, y2; g_return_val_if_fail (object->picture != NULL, G_MAXDOUBLE); x1 = (double)min (object->picture->upper_x, object->picture->lower_x); y1 = (double)min (object->picture->upper_y, object->picture->lower_y); x2 = (double)max (object->picture->upper_x, object->picture->lower_x); y2 = (double)max (object->picture->upper_y, object->picture->lower_y); dx = min (((double)x) - x1, x2 - ((double)x)); dy = min (((double)y) - y1, y2 - ((double)y)); dx = min (dx, 0); dy = min (dy, 0); return sqrt ((dx * dx) + (dy * dy)); } /*! \brief Test whether a picture object is embedded. * \par Function Description * Returns TRUE if the picture \a object will have its data embedded * in a schematic or symbol file; returns FALSE if its data will be * obtained from a separate file. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to inspect. * \return TRUE if \a object is embedded. */ gboolean o_picture_is_embedded (TOPLEVEL *toplevel, OBJECT *object) { g_return_val_if_fail (object != NULL, FALSE); g_return_val_if_fail (object->picture != NULL, FALSE); return object->picture->embedded; } /*! \brief Get a pixel buffer for a picture object. * \par Function Description * Returns a #GdkPixbuf for the picture object \a object, or NULL if * the picture could not be loaded. * * The returned value should have its reference count decremented with * g_object_unref() when no longer needed. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to inspect. * \return A #GdkPixbuf for the picture. */ GdkPixbuf * o_picture_get_pixbuf (TOPLEVEL *toplevel, OBJECT *object) { g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object->picture != NULL, NULL); if (object->picture->pixbuf != NULL) { return g_object_ref (object->picture->pixbuf); } else { return NULL; } } /*! \brief Get the raw image data from a picture object. * \par Function Description * Returns the raw image file data underlying the picture \a object, * or NULL if the picture could not be loaded. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to inspect. * \param len Location to store buffer length. * \return A read-only buffer of raw image data. */ const char * o_picture_get_data (TOPLEVEL *toplevel, OBJECT *object, size_t *len) { g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object->picture != NULL, NULL); *len = object->picture->file_length; return object->picture->file_content; } /*! \brief Set a picture object's contents from a buffer. * \par Function Description * Sets the contents of the picture \a object by reading image data * from a buffer. The buffer should be in on-disk format. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to modify. * \param filename The new filename for the picture. * \param data The new image data buffer. * \param len The size of the data buffer. * \param error Location to return error information. * \return TRUE on success, FALSE on failure. */ gboolean o_picture_set_from_buffer (TOPLEVEL *toplevel, OBJECT *object, const gchar *filename, const gchar *data, size_t len, GError **error) { GdkPixbuf *pixbuf; GInputStream *stream; gchar *tmp; g_return_val_if_fail (toplevel != NULL, FALSE); g_return_val_if_fail (object != NULL, FALSE); g_return_val_if_fail (object->picture != NULL, FALSE); g_return_val_if_fail (data != NULL, FALSE); /* Check that we can actually load the data before making any * changes to the object. */ stream = G_INPUT_STREAM (g_memory_input_stream_new_from_data (data, len, NULL)); pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error); g_object_unref (stream); if (pixbuf == NULL) return FALSE; o_emit_pre_change_notify (toplevel, object); if (object->picture->pixbuf != NULL) { g_object_unref (object->picture->pixbuf); } object->picture->pixbuf = pixbuf; object->picture->ratio = ((double) gdk_pixbuf_get_width(pixbuf) / gdk_pixbuf_get_height(pixbuf)); tmp = g_strdup (filename); g_free (object->picture->filename); object->picture->filename = tmp; gchar *buf = g_realloc (object->picture->file_content, len); /* It's possible that these buffers might overlap, because the * library user hates us. */ memmove (buf, data, len); object->picture->file_content = buf; object->picture->file_length = len; o_emit_change_notify (toplevel, object); return TRUE; } /*! \brief Set a picture object's contents from a file. * \par Function Description * Sets the contents of the picture \a object by reading image data * from a file. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to modify. * \param filename The filename to load image data from. * \param error Location to return error information. * \return TRUE on success, FALSE on failure. */ gboolean o_picture_set_from_file (TOPLEVEL *toplevel, OBJECT *object, const gchar *filename, GError **error) { gchar *buf; size_t len; gboolean status; g_return_val_if_fail (filename != NULL, FALSE); if (!g_file_get_contents (filename, &buf, &len, error)) { return FALSE; } status = o_picture_set_from_buffer (toplevel, object, filename, buf, len, error); g_free (buf); return status; } /*! \brief Get a picture's corresponding filename. * \par Function Description * Returns the filename associated with the picture \a object. * * \param toplevel The current #TOPLEVEL. * \param object The picture #OBJECT to inspect. * \return the filename associated with \a object. */ const gchar * o_picture_get_filename (TOPLEVEL *toplevel, OBJECT *object) { g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object->picture != NULL, NULL); return object->picture->filename; } /*! \brief Get fallback pixbuf for displaying pictures. * \par Function Description * Returns a pixbuf containing the fallback image to be used if a * picture object fails to load. The returned pixbuf should be freed * with g_object_unref() when no longer needed. * * \return a #GdkPixbuf containing a warning image. */ GdkPixbuf * o_picture_get_fallback_pixbuf (TOPLEVEL *toplevel) { static GdkPixbuf *pixbuf = NULL; static gboolean failed = FALSE; if (pixbuf == NULL && !failed) { gchar *filename; GError *error = NULL; filename = g_build_filename (toplevel->bitmap_directory, "gschem-warning.png", NULL); pixbuf = gdk_pixbuf_new_from_file (filename, &error); if (pixbuf == NULL) { g_warning ( _("Failed to load fallback image %s: %s.\n"), filename, error->message); g_error_free (error); failed = TRUE; } g_free (filename); } if (failed) return NULL; g_assert (GDK_IS_PIXBUF (pixbuf)); return g_object_ref (pixbuf); }
eivindkv/geda-gaf
libgeda/src/o_picture.c
C
gpl-2.0
41,404
<?php require_once dirname(__FILE__) . '/Reviews.php'; class Sabai_Addon_Directory_Controller_UserReviews extends Sabai_Addon_Directory_Controller_Reviews { protected function _createQuery(Sabai_Context $context, $sort, Sabai_Addon_Entity_Model_Bundle $bundle = null) { return parent::_createQuery($context, $sort, $bundle) ->propertyIs('post_user_id', $context->identity->id); } }
ssxenon01/mm
resources/plugins/sabai-directory/lib/Directory/Controller/UserReviews.php
PHP
gpl-2.0
418
/* * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * ServerMessenger.java * * Created on December 11, 2001, 7:43 PM */ package games.strategy.net; import games.strategy.engine.chat.ChatController; import games.strategy.engine.chat.IChatChannel; import games.strategy.engine.lobby.server.login.LobbyLoginValidator; import games.strategy.engine.lobby.server.userDB.MutedIpController; import games.strategy.engine.lobby.server.userDB.MutedMacController; import games.strategy.engine.lobby.server.userDB.MutedUsernameController; import games.strategy.engine.message.HubInvoke; import games.strategy.engine.message.RemoteMethodCall; import games.strategy.engine.message.RemoteName; import games.strategy.engine.message.SpokeInvoke; import games.strategy.net.nio.NIOSocket; import games.strategy.net.nio.NIOSocketListener; import games.strategy.net.nio.QuarantineConversation; import games.strategy.net.nio.ServerQuarantineConversation; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; import java.util.logging.Logger; /** * A Messenger that can have many clients connected to it. * * @author Sean Bridges * @version 1.0 */ public class ServerMessenger implements IServerMessenger, NIOSocketListener { private static Logger s_logger = Logger.getLogger(ServerMessenger.class.getName()); private final Selector m_acceptorSelector; private final ServerSocketChannel m_socketChannel; private final Node m_node; private boolean m_shutdown = false; private final NIOSocket m_nioSocket; private final CopyOnWriteArrayList<IMessageListener> m_listeners = new CopyOnWriteArrayList<IMessageListener>(); private final CopyOnWriteArrayList<IMessengerErrorListener> m_errorListeners = new CopyOnWriteArrayList<IMessengerErrorListener>(); private final CopyOnWriteArrayList<IConnectionChangeListener> m_connectionListeners = new CopyOnWriteArrayList<IConnectionChangeListener>(); private boolean m_acceptNewConnection = false; private ILoginValidator m_loginValidator; // all our nodes private final ConcurrentHashMap<INode, SocketChannel> m_nodeToChannel = new ConcurrentHashMap<INode, SocketChannel>(); private final ConcurrentHashMap<SocketChannel, INode> m_channelToNode = new ConcurrentHashMap<SocketChannel, INode>(); // A hack, till I think of something better public ServerMessenger(final String name, final int portNumber, final IObjectStreamFactory streamFactory) throws IOException { m_socketChannel = ServerSocketChannel.open(); m_socketChannel.configureBlocking(false); m_socketChannel.socket().setReuseAddress(true); m_socketChannel.socket().bind(new InetSocketAddress(portNumber), 10); m_nioSocket = new NIOSocket(streamFactory, this, "Server"); m_acceptorSelector = Selector.open(); if (IPFinder.findInetAddress() != null) m_node = new Node(name, IPFinder.findInetAddress(), portNumber); else m_node = new Node(name, InetAddress.getLocalHost(), portNumber); final Thread t = new Thread(new ConnectionHandler(), "Server Messenger Connection Handler"); t.start(); } public void setLoginValidator(final ILoginValidator loginValidator) { m_loginValidator = loginValidator; } public ILoginValidator getLoginValidator() { return m_loginValidator; } /** Creates new ServerMessenger */ public ServerMessenger(final String name, final int portNumber) throws IOException { this(name, portNumber, new DefaultObjectStreamFactory()); } /* * @see IMessenger#addMessageListener(Class, IMessageListener) */ public void addMessageListener(final IMessageListener listener) { m_listeners.add(listener); } /* * @see IMessenger#removeMessageListener(Class, IMessageListener) */ public void removeMessageListener(final IMessageListener listener) { m_listeners.remove(listener); } /** * Get a list of nodes. */ public Set<INode> getNodes() { final Set<INode> rVal = new HashSet<INode>(m_nodeToChannel.keySet()); rVal.add(m_node); return rVal; } public synchronized void shutDown() { if (!m_shutdown) { m_shutdown = true; m_nioSocket.shutDown(); try { m_socketChannel.close(); } catch (final Exception e) { // ignore } if (m_acceptorSelector != null) m_acceptorSelector.wakeup(); } } public synchronized boolean isShutDown() { return m_shutdown; } public boolean isConnected() { return !m_shutdown; } /** * Send a message to the given node. */ public void send(final Serializable msg, final INode to) { if (m_shutdown) return; if (s_logger.isLoggable(Level.FINEST)) { s_logger.log(Level.FINEST, "Sending" + msg + " to:" + to); } final MessageHeader header = new MessageHeader(to, m_node, msg); final SocketChannel socketChannel = m_nodeToChannel.get(to); // the socket was removed if (socketChannel == null) { if (s_logger.isLoggable(Level.FINER)) { s_logger.log(Level.FINER, "no channel for node:" + to + " dropping message:" + msg); } // the socket has not been added yet return; } m_nioSocket.send(socketChannel, header); } /** * Send a message to all nodes. */ public void broadcast(final Serializable msg) { final MessageHeader header = new MessageHeader(m_node, msg); forwardBroadcast(header); } private boolean isLobby() { return m_loginValidator instanceof LobbyLoginValidator; } private boolean isGame() { return !isLobby(); } private final Object m_cachedListLock = new Object(); private final HashMap<String, String> m_cachedMacAddresses = new HashMap<String, String>(); public String GetPlayerMac(final String name) { synchronized (m_cachedListLock) { String mac = m_cachedMacAddresses.get(name); if (mac == null) mac = m_playersThatLeftMacs_Last10.get(name); return mac; } } // We need to cache whether players are muted, because otherwise the database would have to be accessed each time a message was sent, which can be very slow private final List<String> m_liveMutedUsernames = new ArrayList<String>(); public boolean IsUsernameMuted(final String username) { synchronized (m_cachedListLock) { return m_liveMutedUsernames.contains(username); } } public void NotifyUsernameMutingOfPlayer(final String username, final Date muteExpires) { synchronized (m_cachedListLock) { if (!m_liveMutedUsernames.contains(username)) m_liveMutedUsernames.add(username); if (muteExpires != null) ScheduleUsernameUnmuteAt(username, muteExpires.getTime()); } } private final List<String> m_liveMutedIpAddresses = new ArrayList<String>(); public boolean IsIpMuted(final String ip) { synchronized (m_cachedListLock) { return m_liveMutedIpAddresses.contains(ip); } } public void NotifyIPMutingOfPlayer(final String ip, final Date muteExpires) { synchronized (m_cachedListLock) { if (!m_liveMutedIpAddresses.contains(ip)) m_liveMutedIpAddresses.add(ip); if (muteExpires != null) ScheduleIpUnmuteAt(ip, muteExpires.getTime()); } } private final List<String> m_liveMutedMacAddresses = new ArrayList<String>(); public boolean IsMacMuted(final String mac) { synchronized (m_cachedListLock) { return m_liveMutedMacAddresses.contains(mac); } } public void NotifyMacMutingOfPlayer(final String mac, final Date muteExpires) { synchronized (m_cachedListLock) { if (!m_liveMutedMacAddresses.contains(mac)) m_liveMutedMacAddresses.add(mac); if (muteExpires != null) ScheduleMacUnmuteAt(mac, muteExpires.getTime()); } } private void ScheduleUsernameUnmuteAt(final String username, final long checkTime) { final Timer unmuteUsernameTimer = new Timer("Username unmute timer"); unmuteUsernameTimer.schedule(GetUsernameUnmuteTask(username), new Date(checkTime)); } private void ScheduleIpUnmuteAt(final String ip, final long checkTime) { final Timer unmuteIpTimer = new Timer("IP unmute timer"); unmuteIpTimer.schedule(GetIpUnmuteTask(ip), new Date(checkTime)); } private void ScheduleMacUnmuteAt(final String mac, final long checkTime) { final Timer unmuteMacTimer = new Timer("Mac unmute timer"); unmuteMacTimer.schedule(GetMacUnmuteTask(mac), new Date(checkTime)); } public void NotifyPlayerLogin(final String uniquePlayerName, final String ip, final String mac) { synchronized (m_cachedListLock) { m_cachedMacAddresses.put(uniquePlayerName, mac); if (isLobby()) { final String realName = uniquePlayerName.split(" ")[0]; if (!m_liveMutedUsernames.contains(realName)) { final long muteTill = new MutedUsernameController().getUsernameUnmuteTime(realName); if (muteTill != -1 && muteTill <= System.currentTimeMillis()) { m_liveMutedUsernames.add(realName); // Signal the player as muted ScheduleUsernameUnmuteAt(realName, muteTill); } } if (!m_liveMutedIpAddresses.contains(ip)) { final long muteTill = new MutedIpController().getIpUnmuteTime(ip); if (muteTill != -1 && muteTill <= System.currentTimeMillis()) { m_liveMutedIpAddresses.add(ip); // Signal the player as muted ScheduleIpUnmuteAt(ip, muteTill); } } if (!m_liveMutedMacAddresses.contains(mac)) { final long muteTill = new MutedMacController().getMacUnmuteTime(mac); if (muteTill != -1 && muteTill <= System.currentTimeMillis()) { m_liveMutedMacAddresses.add(mac); // Signal the player as muted ScheduleMacUnmuteAt(mac, muteTill); } } } } } private final HashMap<String, String> m_playersThatLeftMacs_Last10 = new HashMap<String, String>(); public HashMap<String, String> GetPlayersThatLeftMacs_Last10() { return m_playersThatLeftMacs_Last10; } private void NotifyPlayerRemoval(final INode node) { synchronized (m_cachedListLock) { m_playersThatLeftMacs_Last10.put(node.getName(), m_cachedMacAddresses.get(node.getName())); if (m_playersThatLeftMacs_Last10.size() > 10) m_playersThatLeftMacs_Last10.remove(m_playersThatLeftMacs_Last10.entrySet().iterator().next().toString()); m_cachedMacAddresses.remove(node.getName()); } } public static final String YOU_HAVE_BEEN_MUTED_LOBBY = "?YOUR LOBBY CHATTING HAS BEEN TEMPORARILY 'MUTED' BY THE ADMINS, TRY AGAIN LATER"; // Special character to stop spoofing by server public static final String YOU_HAVE_BEEN_MUTED_GAME = "?YOUR CHATTING IN THIS GAME HAS BEEN 'MUTED' BY THE HOST"; // Special character to stop spoofing by host public void messageReceived(final MessageHeader msg, final SocketChannel channel) { final INode expectedReceive = m_channelToNode.get(channel); if (!expectedReceive.equals(msg.getFrom())) { throw new IllegalStateException("Expected: " + expectedReceive + " not: " + msg.getFrom()); } if (msg.getMessage() instanceof HubInvoke) // Chat messages are always HubInvoke's { if (isLobby() && ((HubInvoke) msg.getMessage()).call.getRemoteName().equals("_ChatCtrl_LOBBY_CHAT")) { final String realName = msg.getFrom().getName().split(" ")[0]; if (IsUsernameMuted(realName)) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_LOBBY, msg.getFrom()); return; } else if (IsIpMuted(msg.getFrom().getAddress().getHostAddress())) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_LOBBY, msg.getFrom()); return; } else if (IsMacMuted(GetPlayerMac(msg.getFrom().getName()))) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_LOBBY, msg.getFrom()); return; } } else if (isGame() && ((HubInvoke) msg.getMessage()).call.getRemoteName().equals("_ChatCtrlgames.strategy.engine.framework.ui.ServerStartup.CHAT_NAME")) { final String realName = msg.getFrom().getName().split(" ")[0]; if (IsUsernameMuted(realName)) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_GAME, msg.getFrom()); return; } else if (IsIpMuted(msg.getFrom().getAddress().getHostAddress())) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_GAME, msg.getFrom()); return; } if (IsMacMuted(GetPlayerMac(msg.getFrom().getName()))) { bareBonesSendChatMessage(YOU_HAVE_BEEN_MUTED_GAME, msg.getFrom()); return; } } } if (msg.getFor() == null) { forwardBroadcast(msg); notifyListeners(msg); } else if (msg.getFor().equals(m_node)) { notifyListeners(msg); } else { forward(msg); } } private void bareBonesSendChatMessage(final String message, final INode to) { final List<Object> args = new ArrayList<Object>(); final Class[] argTypes = new Class[1]; args.add(message); argTypes[0] = args.get(0).getClass(); RemoteName rn; if (isLobby()) rn = new RemoteName(ChatController.getChatChannelName("_LOBBY_CHAT"), IChatChannel.class); else rn = new RemoteName(ChatController.getChatChannelName("games.strategy.engine.framework.ui.ServerStartup.CHAT_NAME"), IChatChannel.class); final RemoteMethodCall call = new RemoteMethodCall(rn.getName(), "chatOccured", args.toArray(), argTypes, rn.getClazz()); final SpokeInvoke spokeInvoke = new SpokeInvoke(null, false, call, getServerNode()); send(spokeInvoke, to); } // The following code is used in hosted lobby games by the host for player mini-banning and mini-muting private final List<String> m_miniBannedUsernames = new ArrayList<String>(); public boolean IsUsernameMiniBanned(final String username) { synchronized (m_cachedListLock) { return m_miniBannedUsernames.contains(username); } } public void NotifyUsernameMiniBanningOfPlayer(final String username, final Date expires) { synchronized (m_cachedListLock) { if (!m_miniBannedUsernames.contains(username)) m_miniBannedUsernames.add(username); if (expires != null) { final Timer unbanUsernameTimer = new Timer("Username unban timer"); unbanUsernameTimer.schedule(new TimerTask() { @Override public void run() { synchronized (m_cachedListLock) { m_miniBannedUsernames.remove(username); } } }, new Date(expires.getTime())); } } } private final List<String> m_miniBannedIpAddresses = new ArrayList<String>(); public boolean IsIpMiniBanned(final String ip) { synchronized (m_cachedListLock) { return m_miniBannedIpAddresses.contains(ip); } } public void NotifyIPMiniBanningOfPlayer(final String ip, final Date expires) { synchronized (m_cachedListLock) { if (!m_miniBannedIpAddresses.contains(ip)) m_miniBannedIpAddresses.add(ip); if (expires != null) { final Timer unbanIpTimer = new Timer("IP unban timer"); unbanIpTimer.schedule(new TimerTask() { @Override public void run() { synchronized (m_cachedListLock) { m_miniBannedIpAddresses.remove(ip); } } }, new Date(expires.getTime())); } } } private final List<String> m_miniBannedMacAddresses = new ArrayList<String>(); public boolean IsMacMiniBanned(final String mac) { synchronized (m_cachedListLock) { return m_miniBannedMacAddresses.contains(mac); } } public void NotifyMacMiniBanningOfPlayer(final String mac, final Date expires) { synchronized (m_cachedListLock) { if (!m_miniBannedMacAddresses.contains(mac)) m_miniBannedMacAddresses.add(mac); if (expires != null) { final Timer unbanMacTimer = new Timer("Mac unban timer"); unbanMacTimer.schedule(new TimerTask() { @Override public void run() { synchronized (m_cachedListLock) { m_miniBannedMacAddresses.remove(mac); } } }, new Date(expires.getTime())); } } } private void forward(final MessageHeader msg) { if (m_shutdown) return; final SocketChannel socketChannel = m_nodeToChannel.get(msg.getFor()); if (socketChannel == null) throw new IllegalStateException("No channel for:" + msg.getFor() + " all channels:" + socketChannel); m_nioSocket.send(socketChannel, msg); } private void forwardBroadcast(final MessageHeader msg) { if (m_shutdown) return; final SocketChannel fromChannel = m_nodeToChannel.get(msg.getFrom()); final List<SocketChannel> nodes = new ArrayList<SocketChannel>(m_nodeToChannel.values()); if (s_logger.isLoggable(Level.FINEST)) { s_logger.log(Level.FINEST, "broadcasting to" + nodes); } for (final SocketChannel channel : nodes) { if (channel != fromChannel) m_nioSocket.send(channel, msg); } } private boolean isNameTaken(final String nodeName) { for (final INode node : getNodes()) { if (node.getName().equalsIgnoreCase(nodeName)) return true; } return false; } public String getUniqueName(String currentName) { if (currentName.length() > 50) { currentName = currentName.substring(0, 50); } if (currentName.length() < 2) { currentName = "aa" + currentName; } synchronized (m_node) { if (isNameTaken(currentName)) { int i = 1; while (true) { final String newName = currentName + " (" + i + ")"; if (!isNameTaken(newName)) { currentName = newName; break; } i++; } } } return currentName; } private void notifyListeners(final MessageHeader msg) { final Iterator<IMessageListener> iter = m_listeners.iterator(); while (iter.hasNext()) { final IMessageListener listener = iter.next(); listener.messageReceived(msg.getMessage(), msg.getFrom()); } } public void addErrorListener(final IMessengerErrorListener listener) { m_errorListeners.add(listener); } public void removeErrorListener(final IMessengerErrorListener listener) { m_errorListeners.remove(listener); } public void addConnectionChangeListener(final IConnectionChangeListener listener) { m_connectionListeners.add(listener); } public void removeConnectionChangeListener(final IConnectionChangeListener listener) { m_connectionListeners.remove(listener); } private void notifyConnectionsChanged(final boolean added, final INode node) { final Iterator<IConnectionChangeListener> iter = m_connectionListeners.iterator(); while (iter.hasNext()) { if (added) { iter.next().connectionAdded(node); } else { iter.next().connectionRemoved(node); } } } public void setAcceptNewConnections(final boolean accept) { m_acceptNewConnection = accept; } public boolean isAcceptNewConnections() { return m_acceptNewConnection; } /** * Get the local node */ public INode getLocalNode() { return m_node; } private class ConnectionHandler implements Runnable { public void run() { try { m_socketChannel.register(m_acceptorSelector, SelectionKey.OP_ACCEPT); } catch (final ClosedChannelException e) { s_logger.log(Level.SEVERE, "socket closed", e); shutDown(); } while (!m_shutdown) { try { m_acceptorSelector.select(); } catch (final IOException e) { s_logger.log(Level.SEVERE, "Could not accept on server", e); shutDown(); } if (m_shutdown) continue; final Set<SelectionKey> keys = m_acceptorSelector.selectedKeys(); final Iterator<SelectionKey> iter = keys.iterator(); while (iter.hasNext()) { final SelectionKey key = iter.next(); iter.remove(); if (key.isAcceptable() && key.isValid()) { final ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel(); // Accept the connection and make it non-blocking SocketChannel socketChannel = null; try { socketChannel = serverSocketChannel.accept(); if (socketChannel == null) { continue; } socketChannel.configureBlocking(false); socketChannel.socket().setKeepAlive(true); } catch (final IOException e) { s_logger.log(Level.FINE, "Could not accept channel", e); try { if (socketChannel != null) socketChannel.close(); } catch (final IOException e2) { s_logger.log(Level.FINE, "Could not close channel", e2); } continue; } // we are not accepting connections if (!m_acceptNewConnection) { try { socketChannel.close(); } catch (final IOException e) { s_logger.log(Level.FINE, "Could not close channel", e); } continue; } final ServerQuarantineConversation conversation = new ServerQuarantineConversation(m_loginValidator, socketChannel, m_nioSocket, ServerMessenger.this); m_nioSocket.add(socketChannel, conversation); } else if (!key.isValid()) { key.cancel(); } } } } } private TimerTask GetUsernameUnmuteTask(final String username) { return new TimerTask() { @Override public void run() { // lobby has a database we need to check, normal hosted games do not if ((isLobby() && new MutedUsernameController().getUsernameUnmuteTime(username) == -1) || (isGame())) // If the mute has expired { synchronized (m_cachedListLock) { m_liveMutedUsernames.remove(username); // Remove the username from the list of live username's muted } } } }; } private TimerTask GetIpUnmuteTask(final String ip) { return new TimerTask() { @Override public void run() { // lobby has a database we need to check, normal hosted games do not if ((isLobby() && new MutedIpController().getIpUnmuteTime(ip) == -1) || (isGame())) // If the mute has expired { synchronized (m_cachedListLock) { m_liveMutedIpAddresses.remove(ip); // Remove the ip from the list of live ip's muted } } } }; } private TimerTask GetMacUnmuteTask(final String mac) { return new TimerTask() { @Override public void run() { // lobby has a database we need to check, normal hosted games do not if ((isLobby() && new MutedMacController().getMacUnmuteTime(mac) == -1) || (isGame())) // If the mute has expired { synchronized (m_cachedListLock) { m_liveMutedMacAddresses.remove(mac); // Remove the mac from the list of live mac's muted } } } }; } public boolean isServer() { return true; } public void removeConnection(final INode node) { if (node.equals(m_node)) throw new IllegalArgumentException("Cant remove ourself!"); NotifyPlayerRemoval(node); SocketChannel channel = m_nodeToChannel.remove(node); if (channel == null) { channel = m_nodeToChannel.remove(node); } if (channel == null) { s_logger.info("Could not remove connection to node:" + node); return; } m_channelToNode.remove(channel); m_nioSocket.close(channel); notifyConnectionsChanged(false, node); s_logger.info("Connection removed:" + node); } public INode getServerNode() { return m_node; } public void socketError(final SocketChannel channel, final Exception error) { if (channel == null) throw new IllegalArgumentException("Null channel"); // already closed, dont report it again final INode node = m_channelToNode.get(channel); if (node != null) removeConnection(node); } public void socketUnqaurantined(final SocketChannel channel, final QuarantineConversation conversation) { final ServerQuarantineConversation con = (ServerQuarantineConversation) conversation; final INode remote = new Node(con.getRemoteName(), (InetSocketAddress) channel.socket().getRemoteSocketAddress()); if (s_logger.isLoggable(Level.FINER)) { s_logger.log(Level.FINER, "Unquarntined node:" + remote); } m_nodeToChannel.put(remote, channel); m_channelToNode.put(channel, remote); notifyConnectionsChanged(true, remote); s_logger.info("Connection added to:" + remote); } public INode getRemoteNode(final SocketChannel channel) { return m_channelToNode.get(channel); } public InetSocketAddress getRemoteServerSocketAddress() { return m_node.getSocketAddress(); } @Override public String toString() { return "ServerMessenger LocalNode:" + m_node + " ClientNodes:" + m_nodeToChannel.keySet(); } }
tea-dragon/triplea
src/main/java/games/strategy/net/ServerMessenger.java
Java
gpl-2.0
25,312
// This file is part of Agros2D. // // Agros2D 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. // // Agros2D 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 Agros2D. If not, see <http://www.gnu.org/licenses/>. // // hp-FEM group (http://hpfem.org/) // University of Nevada, Reno (UNR) and University of West Bohemia, Pilsen // Email: agros2d@googlegroups.com, home page: http://hpfem.org/agros2d/ #include "localvalueview.h" #include "scene.h" LocalPointValue::LocalPointValue(Point &point) { this->point = point; PointValue val = pointValue(Util::scene()->sceneSolution()->sln(), point); value = val.value; derivative = val.derivative; labelMarker = val.marker; } PointValue LocalPointValue::pointValue(Solution *sln, Point &point) { double tmpValue; Point tmpDerivative; SceneLabelMarker *tmpLabelMarker = NULL; if (sln) { int index = Util::scene()->sceneSolution()->findTriangleInMesh(Util::scene()->sceneSolution()->meshInitial(), point); if (index != -1) { if ((Util::scene()->problemInfo()->analysisType == AnalysisType_Transient) && Util::scene()->sceneSolution()->timeStep() == 0) // const solution at first time step tmpValue = Util::scene()->problemInfo()->initialCondition.number; else tmpValue = sln->get_pt_value(point.x, point.y, H2D_FN_VAL_0); if (Util::scene()->problemInfo()->physicField() != PhysicField_Elasticity) { tmpDerivative.x = sln->get_pt_value(point.x, point.y, H2D_FN_DX_0); tmpDerivative.y = sln->get_pt_value(point.x, point.y, H2D_FN_DY_0); } // find marker Element *element = Util::scene()->sceneSolution()->meshInitial()->get_element_fast(index); tmpLabelMarker = Util::scene()->labels[element->marker]->marker; } } return PointValue(tmpValue, tmpDerivative, tmpLabelMarker); } // ************************************************************************************************************************************* LocalPointValueView::LocalPointValueView(QWidget *parent): QDockWidget(tr("Local Values"), parent) { QSettings settings; setMinimumWidth(280); setObjectName("LocalPointValueView"); createActions(); createMenu(); trvWidget = new QTreeWidget(); trvWidget->setHeaderHidden(false); trvWidget->setContextMenuPolicy(Qt::CustomContextMenu); trvWidget->setMouseTracking(true); trvWidget->setColumnCount(3); trvWidget->setColumnWidth(0, settings.value("LocalPointValueView/TreeViewColumn0", 150).value<int>()); trvWidget->setColumnWidth(1, settings.value("LocalPointValueView/TreeViewColumn1", 80).value<int>()); trvWidget->setIndentation(12); QStringList labels; labels << tr("Label") << tr("Value") << tr("Unit"); trvWidget->setHeaderLabels(labels); connect(trvWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(doContextMenu(const QPoint &))); QPushButton *btnPoint = new QPushButton(); btnPoint->setText(actPoint->text()); btnPoint->setIcon(actPoint->icon()); btnPoint->setMaximumSize(btnPoint->sizeHint()); connect(btnPoint, SIGNAL(clicked()), this, SLOT(doPoint())); // main widget QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(trvWidget); layout->addWidget(btnPoint); layout->setContentsMargins(0, 0, 0, 7); QWidget *widget = new QWidget(this); widget->setLayout(layout); setWidget(widget); } LocalPointValueView::~LocalPointValueView() { QSettings settings; settings.setValue("LocalPointValueView/TreeViewColumn0", trvWidget->columnWidth(0)); settings.setValue("LocalPointValueView/TreeViewColumn1", trvWidget->columnWidth(1)); } void LocalPointValueView::createActions() { // point actPoint = new QAction(icon("scene-node"), tr("Local point value"), this); connect(actPoint, SIGNAL(triggered()), this, SLOT(doPoint())); // copy value actCopy = new QAction(icon(""), tr("Copy value"), this); connect(actCopy, SIGNAL(triggered()), this, SLOT(doCopyValue())); } void LocalPointValueView::createMenu() { mnuInfo = new QMenu(this); mnuInfo->addAction(actPoint); mnuInfo->addAction(actCopy); } void LocalPointValueView::doPoint() { LocalPointValueDialog localPointValueDialog(point); if (localPointValueDialog.exec() == QDialog::Accepted) { doShowPoint(localPointValueDialog.point()); } } void LocalPointValueView::doContextMenu(const QPoint &pos) { actCopy->setEnabled(false); QTreeWidgetItem *item = trvWidget->itemAt(pos); if (item) if (!item->text(1).isEmpty()) { trvWidget->setCurrentItem(item); actCopy->setEnabled(true); } mnuInfo->exec(QCursor::pos()); } void LocalPointValueView::doShowPoint(const Point &point) { // store point this->point = point; doShowPoint(); } void LocalPointValueView::doCopyValue() { QTreeWidgetItem *item = trvWidget->currentItem(); if (item) if (!item->text(1).isEmpty()) QApplication::clipboard()->setText(item->text(1)); } void LocalPointValueView::doShowPoint() { trvWidget->clear(); // point QTreeWidgetItem *pointNode = new QTreeWidgetItem(trvWidget); pointNode->setText(0, tr("Point")); pointNode->setExpanded(true); addTreeWidgetItemValue(pointNode, Util::scene()->problemInfo()->labelX() + ":", QString("%1").arg(point.x, 0, 'f', 5), tr("m")); addTreeWidgetItemValue(pointNode, Util::scene()->problemInfo()->labelY() + ":", QString("%1").arg(point.y, 0, 'f', 5), tr("m")); trvWidget->insertTopLevelItem(0, pointNode); if (Util::scene()->sceneSolution()->isSolved()) Util::scene()->problemInfo()->hermes()->showLocalValue(trvWidget, Util::scene()->problemInfo()->hermes()->localPointValue(point)); trvWidget->resizeColumnToContents(2); } LocalPointValueDialog::LocalPointValueDialog(Point point, QWidget *parent) : QDialog(parent) { setWindowIcon(icon("scene-node")); setWindowTitle(tr("Local point value")); setModal(true); txtPointX = new SLineEditValue(); txtPointX->setNumber(point.x); txtPointY = new SLineEditValue(); txtPointY->setNumber(point.y); connect(txtPointX, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); connect(txtPointY, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); QFormLayout *layoutPoint = new QFormLayout(); layoutPoint->addRow(Util::scene()->problemInfo()->labelX() + " (m):", txtPointX); layoutPoint->addRow(Util::scene()->problemInfo()->labelY() + " (m):", txtPointY); // dialog buttons buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QVBoxLayout *layout = new QVBoxLayout(); layout->addLayout(layoutPoint); layout->addStretch(); layout->addWidget(buttonBox); setLayout(layout); setMinimumSize(sizeHint()); setMaximumSize(sizeHint()); } LocalPointValueDialog::~LocalPointValueDialog() { delete txtPointX; delete txtPointY; } Point LocalPointValueDialog::point() { return Point(txtPointX->value().number, txtPointY->value().number); } void LocalPointValueDialog::evaluated(bool isError) { buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!isError); }
panek50/agros2d
src/localvalueview.cpp
C++
gpl-2.0
8,032